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