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