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