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