]> git.sur5r.net Git - kconfig-frontends/blob - configure.ac
configure: also search for libtinfo if needed
[kconfig-frontends] / configure.ac
1 #                                               -*- Autoconf -*-
2 # Process this file with autoconf to produce a configure script.
3
4 #---------------------------------------------------------------------------
5 # Global initialisation
6
7 #----------------------------------------
8 # Prepare autoconf
9 AC_PREREQ([2.67])
10 AC_INIT(
11     [kconfig-frontends],
12     [m4_esyscmd_s([./scripts/version.sh])],
13     [yann.morin.1998@free.fr])
14 AC_CONFIG_SRCDIR([frontends/conf/conf.c])
15 # Use a config.h to avoid brazilions -DHAVE_FOO on compile lines
16 AC_CONFIG_HEADERS([scripts/.autostuff/config.h])
17 AC_CONFIG_AUX_DIR([scripts/.autostuff/scripts])
18 AC_CONFIG_MACRO_DIR([scripts/.autostuff/m4])
19
20 #----------------------------------------
21 # Prepare automake
22
23 # We want to allow the user to override our default program-prefix,
24 # so we must set-it now, before automake has a chance to interpret
25 # it, but after the options are parsed, so as not to overwrite the
26 # value (if any) set by the user
27 AS_IF(
28     [test "$program_prefix" = NONE],
29     [program_prefix=kconfig-])
30
31 AM_INIT_AUTOMAKE([foreign])
32
33 AS_IF(
34     [test "$(${srcdir}/scripts/version.sh --internal)" = "hg"],
35     [AM_SILENT_RULES],
36     [AM_SILENT_RULES([yes])])
37
38 AS_IF(
39     [test $AM_DEFAULT_VERBOSITY -eq 0],
40     [SILENT_MAKEFLAGS="--no-print-directory -s"],
41     [SILENT_MAKEFLAGS=""])
42 AC_SUBST([SILENT_MAKEFLAGS])
43
44 #----------------------------------------
45 # Prepare libtool
46 m4_ifdef([AM_PROG_AR], [AM_PROG_AR]) dnl Automake, we have a problem...
47 LT_PREREQ([2.2.6])
48 LT_INIT([disable-static])
49
50 #---------------------------------------------------------------------------
51 # Set misc options
52
53 # By default, do build with -Wall, unless the user asks not to
54 [wall_CFLAGS=-Wall]
55 AC_ARG_ENABLE(
56     [wall],
57     [AS_HELP_STRING(
58         [--disable-wall],
59         [build with -Wall (default=yes)])],
60     [AS_CASE(
61         ["$enableval"],
62         [yes], [wall_CFLAGS=-Wall],
63         [*],   [wall_CFLAGS=""])])
64 AC_SUBST([wall_CFLAGS],[${wall_CFLAGS}])
65
66 # For releases, do not build with -Werror, unless the user explcitly
67 # requests to build with -Werror.
68 # For the devel tree, do build with -Werror by default, unless user
69 # explicitly disables -Werror
70 AS_IF(
71     [test "$(${srcdir}/scripts/version.sh --internal)" = "hg"],
72     [werror_CFLAGS=-Werror])
73 AC_ARG_ENABLE(
74     [werror],
75     [AS_HELP_STRING(
76         [--enable-werror],
77         [build with -Werror (default=no)])],
78     [AS_CASE(
79         ["$enableval"],
80         [yes], [werror_CFLAGS=-Werror],
81         [*],   [werror_CFLAGS=""])])
82 AC_SUBST([werror_CFLAGS],[${werror_CFLAGS}])
83
84 # Although there is a default (="linux") in the code, we do provide
85 # a default here, to get a consistent autostuff behavior
86 AC_ARG_ENABLE(
87     [root-menu-prompt],
88     [AS_HELP_STRING(
89         [--enable-root-menu-prompt=PROMPT],
90         [set the root-menu prompt (default=Configuration)])],
91     [AS_CASE(
92         ["$enableval"],
93         [yes], [root_menu=Configuration],
94         [no],  [root_menu=],
95                [# Escape the $ signs, otherwise they would get munged by make
96                 # Also, append a space at the end, to separate the package
97                 # name from the literal 'Configuration'
98                 root_menu="$( echo "$enableval" |sed -r -e 's/\$/\\$$/g;' )"])])
99 AC_SUBST([root_menu], [${root_menu=Configuration}])
100
101 AC_ARG_ENABLE(
102     [config-prefix],
103     [AS_HELP_STRING(
104         [--enable-config-prefix=PREFIX],
105         [the prefix to the config option (default=CONFIG_)])],
106     [AS_CASE(
107         ["$enableval"],
108         [*" "*],[AC_MSG_ERROR([config prefix can not contain spaces: '$enableval'])],
109         [yes],  [config_prefix=CONFIG_],
110         [no],   [config_prefix=],
111                 [config_prefix=$enableval])])
112 AC_SUBST([config_prefix], [${config_prefix-CONFIG_}])
113
114 AC_ARG_ENABLE(
115     [utils],
116     [AS_HELP_STRING(
117         [--disable-utils],
118         [install utilities to manage .config files (default=yes)])])
119 AC_SUBST([enable_utils], [${enable_utils:-yes}])
120
121 AC_ARG_ENABLE(
122     [L10n],
123     [AS_HELP_STRING(
124         [--disable-L10n],
125         [enable localisation (L10n) (default=auto)])])
126 AC_SUBST([enable_L10n], [${enable_L10n:-yes}])
127
128 #----------------------------------------
129 # Options to selectively enable/disable frontends
130 # All are selected by default
131 AC_ARG_ENABLE(
132     [conf],
133     [AS_HELP_STRING(
134         [--disable-conf],
135         [conf, the stdin-based frontend (default=auto)])])
136 AC_SUBST([enable_conf], [${enable_conf:-auto}])
137 AC_ARG_ENABLE(
138     [mconf],
139     [AS_HELP_STRING(
140         [--disable-mconf],
141         [mconf, the traditional ncurses-based frontend (default=auto)])])
142 AC_SUBST([enable_mconf], [${enable_mconf:-auto}])
143 AC_ARG_ENABLE(
144     [nconf],
145     [AS_HELP_STRING(
146         [--disable-nconf],
147         [nconf, the modern ncurses-based frontend (default=auto)])])
148 AC_SUBST([enable_nconf], [${enable_nconf:-auto}])
149 AC_ARG_ENABLE(
150     [gconf],
151     [AS_HELP_STRING(
152         [--disable-gconf],
153         [gconf, the GTK-based frontend (default=auto)])])
154 AC_SUBST([enable_gconf], [${enable_gconf:-auto}])
155 AC_ARG_ENABLE(
156     [qconf],
157     [AS_HELP_STRING(
158         [--disable-qconf],
159         [qconf, the QT-based frontend (default=auto)])])
160 AC_SUBST([enable_qconf], [${enable_qconf:-auto}])
161
162 AC_ARG_ENABLE(
163     [frontends],
164     [AS_HELP_STRING(
165         [--enable-frontends=list],
166         [enables only the set of frontends in comma-separated 'list'
167          (default: auto selection), takes precedence over all
168          --enable-*conf, above])],
169     [for f in conf mconf nconf gconf qconf; do
170         AS_CASE(
171             ["$enableval"],
172             [yes],      [eval enable_$f=yes],
173             ["$f"],     [eval enable_$f=yes],
174             ["$f",*],   [eval enable_$f=yes],
175             [*,"$f"],   [eval enable_$f=yes],
176             [*,"$f",*], [eval enable_$f=yes],
177                         [eval enable_$f=no])
178      done])
179 AC_SUBST([enable_frontends])
180
181 #----------------------------------------
182 # What extra CFLAGS we will be using
183 AC_SUBST([kf_CFLAGS], ["$wall_CFLAGS $werror_CFLAGS"])
184
185 #----------------------------------------
186 # Dependencies that will be needed, depending on the frontends
187 AS_CASE(
188     ["$enable_mconf":"$enable_nconf"],
189     [*yes*],  [need_curses=yes],
190     [*auto*], [need_curses=auto],
191               [need_curses=no])
192 [need_panel_menu="$enable_nconf"]
193 AS_CASE(
194     ["$enable_gconf":"$enable_qconf"],
195     [*yes*],  [need_pkgconfig=yes],
196     [*auto*], [need_pkgconfig=yes],
197               [need_pkgconfig=no ])
198 [need_gtk="$enable_gconf"]
199 [need_qt="$enable_qconf"]
200
201 #---------------------------------------------------------------------------
202 # Now check we have the required stuff
203
204 #----------------------------------------
205 # Some program checks
206 AC_PROG_CC
207 AM_PROG_CC_C_O
208 AC_PROG_CXX
209 AC_C_INLINE
210 AC_PROG_MAKE_SET
211 AC_CHECK_PROGS(
212     [GPERF],
213     [gperf])
214 AS_IF(
215     [test -z "$GPERF"],
216     [AC_MSG_ERROR([can not find gperf])])
217 AS_IF(
218     [test "$need_pkgconfig" = "yes"],
219     [PKG_PROG_PKG_CONFIG()])
220 AC_PROG_LEX
221 AC_SUBST([AM_LFLAGS], ["-L -P zconf"])
222 AC_PROG_YACC
223 AC_SUBST([AM_YFLAGS], ["-t -l -p zconf"])
224
225 #----------------------------------------
226 # Check for gettext, for the kconfig frontends
227 [has_gettext="$enable_L10n"]
228 AS_IF(
229     [test "$has_gettext" = "yes"],
230     [AC_CHECK_HEADERS(
231         [libintl.h],
232         [ac_ct_gettext_hdr=$ac_header; break],
233         [has_gettext=no])])
234 AS_IF(
235     [test "$has_gettext" = "yes"],
236     [AC_CHECK_DECL(
237         [gettext],,
238         [has_gettext=no],
239         [#include <$ac_ct_gettext_hdr>])])
240 AS_IF(
241     [test "$has_gettext" = "yes"],
242     [LIBS_old="$LIBS"
243      LIBS=
244      AC_SEARCH_LIBS(
245         [gettext],
246         [intl],,
247         [has_gettext=no])
248     intl_LIBS="$LIBS"
249     LIBS="$LIBS_old"])
250 AS_IF(
251     [test "$has_gettext" = "no"],
252     [intl_CPPFLAGS=-DKBUILD_NO_NLS])
253 AC_SUBST([intl_CPPFLAGS])
254 AC_SUBST([intl_LIBS])
255
256 #----------------------------------------
257 # Check for ncurses, for the mconf & nconf frontends
258 AS_IF(
259     [test "$need_curses" = "yes" -o "$need_curses" = "auto"],
260     [AC_SUBST([ncurses_mconf_CPPFLAGS])
261      AC_SUBST([ncurses_LIBS])
262      LIBS_old="$LIBS"
263      LIBS=
264      AC_CHECK_HEADERS(
265         [ncursesw/curses.h ncurses/ncurses.h ncurses/curses.h ncurses.h curses.h],
266         [CURSES_LOC=$ac_header; ncurses_mconf_CPPFLAGS=-DCURSES_LOC=\\\"$ac_header\\\"; break])
267      AS_IF(
268         [test -z "$CURSES_LOC"],
269         [AS_IF(
270             [test "$need_curses" = "yes"],
271             [AC_MSG_ERROR([could not find curses headers (frontends: mconf/nconf)])],
272             [has_curses=no])])
273      AS_CASE(
274         [$CURSES_LOC],
275         [ncursesw/*],[ncurses_mconf_CPPFLAGS="$ncurses_mconf_CPPFLAGS -DNCURSES_WIDECHAR=1"])
276      AC_SEARCH_LIBS(
277         [initscr],
278         [ncursesw ncurses curses],
279         [ac_ct_curses_lib_found=yes; break])
280      AS_IF(
281         [test -z "$ac_ct_curses_lib_found"],
282         [AS_IF(
283             [test "$need_curses" = "yes"],
284             [AC_MSG_ERROR([could not find curses library (frontends: mconf/nconf)])],
285             [has_curses=no])])
286      AC_SEARCH_LIBS(
287         [setupterm],
288         [tinfo],
289         [break])
290      ncurses_LIBS="$LIBS"
291      LIBS=$LIBS_old])
292
293 AS_IF(
294     [test "$has_curses" = "no" ],
295     [enable_mconf=no; enable_nconf=no])
296
297 #----------------------------------------
298 # Check for libpanel and libmenu, for the nconf frontend
299 AS_IF(
300     [test "$need_panel_menu" = "yes" -o "$need_panel_menu" = "auto"],
301     [AC_SUBST([ncurses_nconf_CPPFLAGS])
302      AC_SUBST([ncurses_panel_menu_LIBS])
303      AS_CASE(
304         [$CURSES_LOC],
305         [ncursesw/*],[ncurses_nconf_CPPFLAGS="-I/usr/include/ncursesw"],
306         [ncurses/*],[ncurses_nconf_CPPFLAGS="-I/usr/include/ncurses"])
307      LIBS_old="$LIBS"
308      LIBS=
309      AC_SEARCH_LIBS(
310         [new_panel],
311         [panelw panel],
312         [ac_ct_panel_lib_found=yes; break],,
313         [$ncurses_LIBS])
314      AS_IF(
315         [test -z "$ac_ct_panel_lib_found"],
316         [AS_IF(
317             [test "$need_panel_menu" = "yes"],
318             [AC_MSG_ERROR([could not find libpanel library (frontend: nconf)])],
319             [has_panel_menu=no])])
320      AC_SEARCH_LIBS(
321         [menu_init],
322         [menuw menu],
323         [ac_ct_menu_lib_found=yes; break],,
324         [$ncurses_LIBS])
325      AS_IF(
326         [test -z "$ac_ct_panel_lib_found"],
327         [AS_IF(
328             [test "$need_panel_menu" = "yes"],
329             [AC_MSG_ERROR([could not find libmenu library (frontend: nconf)])],
330             [has_panel_menu=no])])
331      ncurses_panel_menu_LIBS="$LIBS"
332      LIBS=$LIBS_old])
333
334 AS_IF(
335     [test "$has_panel_menu" = "no" ],
336     [enable_nconf=no])
337
338 #----------------------------------------
339 # Check headers and libs for gconf
340 AS_IF(
341     [test "$need_gtk" = "yes" -o "$need_gtk" = "auto"],
342     [PKG_CHECK_MODULES(
343         [gtk],
344         [gtk+-2.0 gmodule-2.0 libglade-2.0],
345         [has_gtk=yes],
346         [AS_IF(
347             [test "$need_gtk" = "yes"],
348             [AC_MSG_ERROR([could not find GTK+ headers and/or libraries (frontend: gconf)])],
349             [has_gtk=no])])])
350
351 AS_IF(
352     [test "$has_gtk" = "no" ],
353     [enable_gconf=no])
354
355 #----------------------------------------
356 # Check headers and libs for qconf
357 AS_IF(
358     [test "$need_qt" = "yes" -o "$need_qt" = "auto"],
359     [PKG_CHECK_MODULES(
360         [qt4],
361         [QtCore QtGui Qt3Support],
362         [has_qt=yes; need_moc="$need_qt"],
363         [AS_IF(
364             [test "$need_qt" = "yes"],
365             [AC_MSG_ERROR([could not find QT4 headers and/or libraries (frontend: qconf)])],
366             [has_qt=no; need_moc=no])])])
367
368 AC_ARG_VAR([MOC], [Qt meta object compiler (moc) command])
369 AS_IF(
370     [test "$need_moc" = "yes" -o "$need_moc" = "auto"],
371     [QT4_BINDIR=`$PKG_CONFIG Qt --variable bindir`
372      AC_PATH_PROGS(
373         [MOC],
374         [moc-qt4 moc],,
375         [$QT4_BINDIR:$PATH])
376      AS_IF(
377         [test -n "$MOC"],
378         [has_moc=yes],
379         [AS_IF(
380             [test "$need_moc" = "yes"],
381             [AC_MSG_ERROR([could not find moc (frontend: qconf)])],
382             [has_moc=no])])])
383
384 AS_IF(
385     [test "$has_qt" = "no" -o "$has_moc" = "no"],
386     [enable_qconf=no])
387
388 #----------------------------------------
389 # Per-frontends extra libraries
390 AC_ARG_VAR([conf_EXTRA_LIBS],  [Extra libraries to build the conf frontend] )
391 AC_ARG_VAR([gconf_EXTRA_LIBS], [Extra libraries to build the gconf frontend])
392 AC_ARG_VAR([mconf_EXTRA_LIBS], [Extra libraries to build the mconf frontend])
393 AC_ARG_VAR([nconf_EXTRA_LIBS], [Extra libraries to build the nconf frontend])
394 AC_ARG_VAR([qconf_EXTRA_LIBS], [Extra libraries to build the qconf frontend])
395
396 #---------------------------------------------------------------------------
397 # Now, we know what frontends to enable
398 AS_IF([test "$enable_conf"  = "auto"], [enable_conf=yes ])
399 AS_IF([test "$enable_gconf" = "auto"], [enable_gconf=yes])
400 AS_IF([test "$enable_mconf" = "auto"], [enable_mconf=yes])
401 AS_IF([test "$enable_nconf" = "auto"], [enable_nconf=yes])
402 AS_IF([test "$enable_qconf" = "auto"], [enable_qconf=yes])
403
404 #----------------------------------------
405 # Check if the lxdialog library should be built
406 AS_IF(
407     [test "$enable_mconf" = "yes"],
408     [need_lxdialog=yes],
409     [need_lxdialog=no])
410
411 #----------------------------------------
412 # Check if the images library should be built
413 AS_IF(
414     [test "$enable_gconf" = "yes" -o "$enable_qconf" = "yes"],
415     [need_images=yes],
416     [need_images=no])
417
418 #----------------------------------------
419 # Setup automake conditional build
420 AM_CONDITIONAL(
421     [COND_conf],
422     [test "$enable_conf" = "yes"])
423 AM_CONDITIONAL(
424     [COND_mconf],
425     [test "$enable_mconf" = "yes"])
426 AM_CONDITIONAL(
427     [COND_nconf],
428     [test "$enable_nconf" = "yes"])
429 AM_CONDITIONAL(
430     [COND_gconf],
431     [test "$enable_gconf" = "yes"])
432 AM_CONDITIONAL(
433     [COND_qconf],
434     [test "$enable_qconf" = "yes"])
435 AM_CONDITIONAL(
436     [COND_lxdialog],
437     [test "$need_lxdialog" = "yes"])
438 AM_CONDITIONAL(
439     [COND_images],
440     [test "$need_images" = "yes"])
441 AM_CONDITIONAL(
442     [COND_utils],
443     [test "$enable_utils" = "yes"])
444 AM_CONDITIONAL(
445     [COND_utils_gettext],
446     [test "$has_gettext" = "yes"])
447
448 #----------------------------------------
449 # Get the version to apply to the parser shared library
450 AC_SUBST(
451     [KCONFIGPARSER_LIB_VERSION],
452     [m4_esyscmd_s([./scripts/version.sh --plain])])
453
454 #----------------------------------------
455 # Finalise
456 AC_CONFIG_FILES([
457     Makefile
458     docs/Makefile
459     libs/Makefile
460     libs/images/Makefile
461     libs/lxdialog/Makefile
462     libs/parser/Makefile
463     frontends/Makefile
464     frontends/conf/Makefile
465     frontends/mconf/Makefile
466     frontends/nconf/Makefile
467     frontends/gconf/Makefile
468     frontends/qconf/Makefile
469     utils/Makefile
470     scripts/Makefile
471 ])
472 AC_OUTPUT
473
474 #----------------------------------------
475 # Pretty-print the configuration settings
476 [fe_list=]
477 AS_IF([test "$enable_conf"  = "yes"], [fe_list="$fe_list conf" ])
478 AS_IF([test "$enable_gconf" = "yes"], [fe_list="$fe_list gconf"])
479 AS_IF([test "$enable_mconf" = "yes"], [fe_list="$fe_list mconf"])
480 AS_IF([test "$enable_nconf" = "yes"], [fe_list="$fe_list nconf"])
481 AS_IF([test "$enable_qconf" = "yes"], [fe_list="$fe_list qconf"])
482
483 [lib_list=]
484 AS_IF(
485     [test "$enable_shared" = "yes"],
486     [lib_list="$lib_list shared (version: $KCONFIGPARSER_LIB_VERSION)"])
487 AS_IF(
488     [test "$enable_static" = "yes"],
489     [lib_list="$lib_list${lib_list:+,} static"])
490
491 AC_MSG_NOTICE()
492 AC_MSG_NOTICE([Configured with:])
493 AC_MSG_NOTICE([- parser library     :$lib_list])
494 AC_MSG_NOTICE([  - root-menu prompt : $root_menu])
495 AC_MSG_NOTICE([  - config prefix    : $config_prefix])
496 AC_MSG_NOTICE([- frontends          :$fe_list])
497 AC_MSG_NOTICE([  - transform name   : $program_transform_name])
498 AC_MSG_NOTICE([  - localised        : $has_gettext])
499 AC_MSG_NOTICE([- install utilities  : $enable_utils])
500 AC_MSG_NOTICE([- CFLAGS CXXFLAGS    : $wall_CFLAGS $werror_CFLAGS])