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