]> git.sur5r.net Git - kconfig-frontends/blob - configure.ac
configure: introduce mconf-specific ncurses CPPFLAGS
[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      AC_SEARCH_LIBS(
274         [initscr],
275         [ncursesw ncurses curses],
276         [ac_ct_curses_lib_found=yes; break])
277      AS_IF(
278         [test -z "$ac_ct_curses_lib_found"],
279         [AS_IF(
280             [test "$need_curses" = "yes"],
281             [AC_MSG_ERROR([could not find curses library (frontends: mconf/nconf)])],
282             [has_curses=no])])
283      ncurses_LIBS="$LIBS"
284      LIBS=$LIBS_old])
285
286 AS_IF(
287     [test "$has_curses" = "no" ],
288     [enable_mconf=no; enable_nconf=no])
289
290 #----------------------------------------
291 # Check for libpanel and libmenu, for the nconf frontend
292 AS_IF(
293     [test "$need_panel_menu" = "yes" -o "$need_panel_menu" = "auto"],
294     [AC_SUBST([ncurses_nconf_CPPFLAGS])
295      AC_SUBST([ncurses_panel_menu_LIBS])
296      AS_CASE(
297         [$CURSES_LOC],
298         [ncursesw/*],[ncurses_nconf_CPPFLAGS="-I/usr/include/ncursesw"],
299         [ncurses/*],[ncurses_nconf_CPPFLAGS="-I/usr/include/ncurses"])
300      LIBS_old="$LIBS"
301      LIBS=
302      AC_SEARCH_LIBS(
303         [new_panel],
304         [panelw panel],
305         [ac_ct_panel_lib_found=yes; break],,
306         [$ncurses_LIBS])
307      AS_IF(
308         [test -z "$ac_ct_panel_lib_found"],
309         [AS_IF(
310             [test "$need_panel_menu" = "yes"],
311             [AC_MSG_ERROR([could not find libpanel library (frontend: nconf)])],
312             [has_panel_menu=no])])
313      AC_SEARCH_LIBS(
314         [menu_init],
315         [menuw menu],
316         [ac_ct_menu_lib_found=yes; break],,
317         [$ncurses_LIBS])
318      AS_IF(
319         [test -z "$ac_ct_panel_lib_found"],
320         [AS_IF(
321             [test "$need_panel_menu" = "yes"],
322             [AC_MSG_ERROR([could not find libmenu library (frontend: nconf)])],
323             [has_panel_menu=no])])
324      ncurses_panel_menu_LIBS="$LIBS"
325      LIBS=$LIBS_old])
326
327 AS_IF(
328     [test "$has_panel_menu" = "no" ],
329     [enable_nconf=no])
330
331 #----------------------------------------
332 # Check headers and libs for gconf
333 AS_IF(
334     [test "$need_gtk" = "yes" -o "$need_gtk" = "auto"],
335     [PKG_CHECK_MODULES(
336         [gtk],
337         [gtk+-2.0 gmodule-2.0 libglade-2.0],
338         [has_gtk=yes],
339         [AS_IF(
340             [test "$need_gtk" = "yes"],
341             [AC_MSG_ERROR([could not find GTK+ headers and/or libraries (frontend: gconf)])],
342             [has_gtk=no])])])
343
344 AS_IF(
345     [test "$has_gtk" = "no" ],
346     [enable_gconf=no])
347
348 #----------------------------------------
349 # Check headers and libs for qconf
350 AS_IF(
351     [test "$need_qt" = "yes" -o "$need_qt" = "auto"],
352     [PKG_CHECK_MODULES(
353         [qt4],
354         [QtCore QtGui Qt3Support],
355         [has_qt=yes; need_moc="$need_qt"],
356         [AS_IF(
357             [test "$need_qt" = "yes"],
358             [AC_MSG_ERROR([could not find QT4 headers and/or libraries (frontend: qconf)])],
359             [has_qt=no; need_moc=no])])])
360
361 AC_ARG_VAR([MOC], [Qt meta object compiler (moc) command])
362 AS_IF(
363     [test "$need_moc" = "yes" -o "$need_moc" = "auto"],
364     [QT4_BINDIR=`$PKG_CONFIG Qt --variable bindir`
365      AC_PATH_PROGS(
366         [MOC],
367         [moc-qt4 moc],,
368         [$QT4_BINDIR:$PATH])
369      AS_IF(
370         [test -n "$MOC"],
371         [has_moc=yes],
372         [AS_IF(
373             [test "$need_moc" = "yes"],
374             [AC_MSG_ERROR([could not find moc (frontend: qconf)])],
375             [has_moc=no])])])
376
377 AS_IF(
378     [test "$has_qt" = "no" -o "$has_moc" = "no"],
379     [enable_qconf=no])
380
381 #----------------------------------------
382 # Per-frontends extra libraries
383 AC_ARG_VAR([conf_EXTRA_LIBS],  [Extra libraries to build the conf frontend] )
384 AC_ARG_VAR([gconf_EXTRA_LIBS], [Extra libraries to build the gconf frontend])
385 AC_ARG_VAR([mconf_EXTRA_LIBS], [Extra libraries to build the mconf frontend])
386 AC_ARG_VAR([nconf_EXTRA_LIBS], [Extra libraries to build the nconf frontend])
387 AC_ARG_VAR([qconf_EXTRA_LIBS], [Extra libraries to build the qconf frontend])
388
389 #---------------------------------------------------------------------------
390 # Now, we know what frontends to enable
391 AS_IF([test "$enable_conf"  = "auto"], [enable_conf=yes ])
392 AS_IF([test "$enable_gconf" = "auto"], [enable_gconf=yes])
393 AS_IF([test "$enable_mconf" = "auto"], [enable_mconf=yes])
394 AS_IF([test "$enable_nconf" = "auto"], [enable_nconf=yes])
395 AS_IF([test "$enable_qconf" = "auto"], [enable_qconf=yes])
396
397 #----------------------------------------
398 # Check if the lxdialog library should be built
399 AS_IF(
400     [test "$enable_mconf" = "yes"],
401     [need_lxdialog=yes],
402     [need_lxdialog=no])
403
404 #----------------------------------------
405 # Check if the images library should be built
406 AS_IF(
407     [test "$enable_gconf" = "yes" -o "$enable_qconf" = "yes"],
408     [need_images=yes],
409     [need_images=no])
410
411 #----------------------------------------
412 # Setup automake conditional build
413 AM_CONDITIONAL(
414     [COND_conf],
415     [test "$enable_conf" = "yes"])
416 AM_CONDITIONAL(
417     [COND_mconf],
418     [test "$enable_mconf" = "yes"])
419 AM_CONDITIONAL(
420     [COND_nconf],
421     [test "$enable_nconf" = "yes"])
422 AM_CONDITIONAL(
423     [COND_gconf],
424     [test "$enable_gconf" = "yes"])
425 AM_CONDITIONAL(
426     [COND_qconf],
427     [test "$enable_qconf" = "yes"])
428 AM_CONDITIONAL(
429     [COND_lxdialog],
430     [test "$need_lxdialog" = "yes"])
431 AM_CONDITIONAL(
432     [COND_images],
433     [test "$need_images" = "yes"])
434 AM_CONDITIONAL(
435     [COND_utils],
436     [test "$enable_utils" = "yes"])
437 AM_CONDITIONAL(
438     [COND_utils_gettext],
439     [test "$has_gettext" = "yes"])
440
441 #----------------------------------------
442 # Get the version to apply to the parser shared library
443 AC_SUBST(
444     [KCONFIGPARSER_LIB_VERSION],
445     [m4_esyscmd_s([./scripts/version.sh --plain])])
446
447 #----------------------------------------
448 # Finalise
449 AC_CONFIG_FILES([
450     Makefile
451     docs/Makefile
452     libs/Makefile
453     libs/images/Makefile
454     libs/lxdialog/Makefile
455     libs/parser/Makefile
456     frontends/Makefile
457     frontends/conf/Makefile
458     frontends/mconf/Makefile
459     frontends/nconf/Makefile
460     frontends/gconf/Makefile
461     frontends/qconf/Makefile
462     utils/Makefile
463     scripts/Makefile
464 ])
465 AC_OUTPUT
466
467 #----------------------------------------
468 # Pretty-print the configuration settings
469 [fe_list=]
470 AS_IF([test "$enable_conf"  = "yes"], [fe_list="$fe_list conf" ])
471 AS_IF([test "$enable_gconf" = "yes"], [fe_list="$fe_list gconf"])
472 AS_IF([test "$enable_mconf" = "yes"], [fe_list="$fe_list mconf"])
473 AS_IF([test "$enable_nconf" = "yes"], [fe_list="$fe_list nconf"])
474 AS_IF([test "$enable_qconf" = "yes"], [fe_list="$fe_list qconf"])
475
476 [lib_list=]
477 AS_IF(
478     [test "$enable_shared" = "yes"],
479     [lib_list="$lib_list shared (version: $KCONFIGPARSER_LIB_VERSION)"])
480 AS_IF(
481     [test "$enable_static" = "yes"],
482     [lib_list="$lib_list${lib_list:+,} static"])
483
484 AC_MSG_NOTICE()
485 AC_MSG_NOTICE([Configured with:])
486 AC_MSG_NOTICE([- parser library     :$lib_list])
487 AC_MSG_NOTICE([  - root-menu prompt : $root_menu])
488 AC_MSG_NOTICE([  - config prefix    : $config_prefix])
489 AC_MSG_NOTICE([- frontends          :$fe_list])
490 AC_MSG_NOTICE([  - transform name   : $program_transform_name])
491 AC_MSG_NOTICE([  - localised        : $has_gettext])
492 AC_MSG_NOTICE([- install utilities  : $enable_utils])
493 AC_MSG_NOTICE([- CFLAGS CXXFLAGS    : $wall_CFLAGS $werror_CFLAGS])