xref: /nrf52832-nimble/rt-thread/tools/kconfig-frontends/configure.ac (revision 104654410c56c573564690304ae786df310c91fc)
1#                                               -*- Autoconf -*-
2# Process this file with autoconf to produce a configure script.
3
4#---------------------------------------------------------------------------
5# Global initialisation
6
7#----------------------------------------
8# Prepare autoconf
9AC_PREREQ([2.67])
10AC_INIT(
11    [kconfig-frontends],
12    [m4_esyscmd_s([./scripts/version.sh])],
13    [[email protected]])
14AC_CONFIG_SRCDIR([frontends/conf/conf.c])
15# Use a config.h to avoid brazilions -DHAVE_FOO on compile lines
16AC_CONFIG_HEADERS([scripts/.autostuff/config.h])
17AC_CONFIG_AUX_DIR([scripts/.autostuff/scripts])
18AC_CONFIG_MACRO_DIR([scripts/.autostuff/m4])
19
20#----------------------------------------
21# Prepare automake
22
23AM_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
29AS_IF(
30    [test "$(${srcdir}/scripts/version.sh --internal)" = "git"],
31    [AM_SILENT_RULES],
32    [AM_SILENT_RULES([yes])])
33
34#----------------------------------------
35# Prepare libtool
36m4_ifdef([AM_PROG_AR], [AM_PROG_AR]) dnl Automake, we have a problem...
37LT_PREREQ([2.2.6])
38LT_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]
45AC_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=""])])
54AC_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
60AS_IF(
61    [test "$(${srcdir}/scripts/version.sh --internal)" = "git"],
62    [werror_CFLAGS=-Werror])
63AC_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=""])])
72AC_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
76AC_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;' )"])])
87AC_SUBST([root_menu], [${root_menu=Configuration}])
88
89AC_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])])
100AC_SUBST([config_prefix], [${config_prefix-CONFIG_}])
101
102AC_ARG_ENABLE(
103    [utils],
104    [AS_HELP_STRING(
105        [--disable-utils],
106        [install utilities to manage .config files (default=yes)])])
107AC_SUBST([enable_utils], [${enable_utils:-yes}])
108
109AC_ARG_ENABLE(
110    [L10n],
111    [AS_HELP_STRING(
112        [--disable-L10n],
113        [enable localisation (L10n) (default=auto)])])
114AC_SUBST([enable_L10n], [${enable_L10n:-yes}])
115
116#----------------------------------------
117# Options to selectively enable/disable frontends
118# All are selected by default
119AC_ARG_ENABLE(
120    [kconfig],
121    [AS_HELP_STRING(
122        [--disable-kconfig],
123        [kconfig, the meta-frontend to all kconfig tools (default=yes)])])
124AC_SUBST([enable_kconfig], [${enable_kconfig:-yes}])
125
126AC_ARG_ENABLE(
127    [conf],
128    [AS_HELP_STRING(
129        [--disable-conf],
130        [conf, the stdin-based frontend (default=auto)])])
131AC_SUBST([enable_conf], [${enable_conf:-auto}])
132AC_ARG_ENABLE(
133    [mconf],
134    [AS_HELP_STRING(
135        [--disable-mconf],
136        [mconf, the traditional ncurses-based frontend (default=auto)])])
137AC_SUBST([enable_mconf], [${enable_mconf:-auto}])
138AC_ARG_ENABLE(
139    [nconf],
140    [AS_HELP_STRING(
141        [--disable-nconf],
142        [nconf, the modern ncurses-based frontend (default=auto)])])
143AC_SUBST([enable_nconf], [${enable_nconf:-auto}])
144AC_ARG_ENABLE(
145    [gconf],
146    [AS_HELP_STRING(
147        [--disable-gconf],
148        [gconf, the GTK-based frontend (default=auto)])])
149AC_SUBST([enable_gconf], [${enable_gconf:-auto}])
150AC_ARG_ENABLE(
151    [qconf],
152    [AS_HELP_STRING(
153        [--disable-qconf],
154        [qconf, the QT-based frontend (default=auto)])])
155AC_SUBST([enable_qconf], [${enable_qconf:-auto}])
156
157AC_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])
174AC_SUBST([enable_frontends])
175
176#----------------------------------------
177# What extra CFLAGS we will be using
178AC_SUBST([kf_CFLAGS], ["$wall_CFLAGS $werror_CFLAGS"])
179
180#----------------------------------------
181# Dependencies that will be needed, depending on the frontends
182AS_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"]
188AS_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
201AC_PROG_CC
202AM_PROG_CC_C_O
203AC_PROG_CXX
204AC_C_INLINE
205AC_PROG_MAKE_SET
206AS_IF(
207    [test "$need_pkgconfig" = "yes"],
208    [PKG_PROG_PKG_CONFIG()])
209# Look for `lex'. If it cannot be found, autoconf sets $LEX to ':'.
210AC_PROG_LEX
211AS_IF(
212    [test "$LEX" = ":"],
213    [AC_MSG_ERROR([can not find a lexer generator (such as lex or flex)])])
214AC_SUBST([AM_LFLAGS], ["-L -P zconf"])
215# Look for `yacc'. If it cannot be found, autoconf sets $YACC to 'yacc'.
216AC_PROG_YACC
217AS_IF(
218    [test "$YACC" = "yacc"],
219    [AC_CHECK_PROGS(
220        [YACC_IN_PATH],
221        [yacc])]
222     AS_IF(
223        [test -z "$YACC_IN_PATH"],
224        [AC_MSG_ERROR([can not find a parser generator (such as yacc or bison)])]))
225AC_SUBST([AM_YFLAGS], ["-t -l -p zconf"])
226
227#----------------------------------------
228# Special section to check for gperf.
229AC_CHECK_PROGS(
230    [GPERF],
231    [gperf])
232AS_IF(
233    [test -z "$GPERF"],
234    [AC_MSG_ERROR([can not find gperf])])
235
236# gperf 3.1 generates functions with 'size_t' instead of 'unsigned int'
237AC_MSG_CHECKING([for the type used in gperf declarations])
238GPERF_LEN_TYPE=
239AS_VAR_SET(
240    [GPERF_PROLOG],
241    [`echo foo,bar | ${GPERF} -L ANSI-C`])
242AC_COMPILE_IFELSE(
243    [AC_LANG_PROGRAM(
244        [[
245        #include <string.h>
246        ${GPERF_PROLOG}
247        const char * in_word_set(const char *, size_t);
248        ]])
249    ],
250    [GPERF_LEN_TYPE='size_t'],
251    [
252    AC_COMPILE_IFELSE(
253        [AC_LANG_PROGRAM(
254            [[
255            #include <string.h>
256            ${GPERF_PROLOG}
257            const char * in_word_set(const char *, unsigned int);
258            ]])
259        ],
260        [GPERF_LEN_TYPE='unsigned int'],
261        [AC_MSG_RESULT([not size_t, not unsigned int. What else?])
262         AC_MSG_FAILURE([unable to detect the type used in gperf declarations])
263        ])])
264AC_MSG_RESULT([${GPERF_LEN_TYPE}])
265AC_SUBST([GPERF_LEN_TYPE])
266
267#----------------------------------------
268# Check for gettext, for the kconfig frontends
269[has_gettext="$enable_L10n"]
270AS_IF(
271    [test "$has_gettext" = "yes"],
272    [AC_CHECK_HEADERS(
273        [libintl.h],
274        [ac_ct_gettext_hdr=$ac_header; break],
275        [has_gettext=no])])
276AS_IF(
277    [test "$has_gettext" = "yes"],
278    [AC_CHECK_DECL(
279        [gettext],,
280        [has_gettext=no],
281        [#include <$ac_ct_gettext_hdr>])])
282AS_IF(
283    [test "$has_gettext" = "yes"],
284    [LIBS_old="$LIBS"
285     LIBS=
286     AC_SEARCH_LIBS(
287        [gettext],
288        [intl],,
289        [has_gettext=no])
290    intl_LIBS="$LIBS"
291    LIBS="$LIBS_old"])
292AS_IF(
293    [test "$has_gettext" = "no"],
294    [intl_CPPFLAGS=-DKBUILD_NO_NLS])
295AC_SUBST([intl_CPPFLAGS])
296AC_SUBST([intl_LIBS])
297
298#----------------------------------------
299# Check for ncurses, for the mconf & nconf frontends
300AS_IF(
301    [test "$need_curses" = "yes" -o "$need_curses" = "auto"],
302    [AC_SUBST([ncurses_mconf_CPPFLAGS])
303     AC_SUBST([ncurses_LIBS])
304     LIBS_old="$LIBS"
305     LIBS=
306     AC_CHECK_HEADERS(
307        [ncursesw/curses.h ncurses/ncurses.h ncurses/curses.h ncurses.h curses.h],
308        [CURSES_LOC=$ac_header
309         ncurses_mconf_CPPFLAGS=-DCURSES_LOC=\\\"$ac_header\\\"
310         break # Stupid syntax-coloring in vim: "])
311     AS_IF(
312        [test -z "$CURSES_LOC"],
313        [AS_IF(
314            [test "$need_curses" = "yes"],
315            [AC_MSG_ERROR([could not find curses headers (frontends: mconf/nconf)])],
316            [has_curses=no])])
317     AS_CASE(
318        [$CURSES_LOC],
319        [ncursesw/*],[ncurses_mconf_CPPFLAGS="$ncurses_mconf_CPPFLAGS -DNCURSES_WIDECHAR=1"])
320     AC_SEARCH_LIBS(
321        [setupterm],
322        [tinfo],
323        [break])
324     AC_SEARCH_LIBS(
325        [initscr],
326        [ncursesw ncurses curses],
327        [ac_ct_curses_lib_found=yes; break])
328     AS_IF(
329        [test -z "$ac_ct_curses_lib_found"],
330        [AS_IF(
331            [test "$need_curses" = "yes"],
332            [AC_MSG_ERROR([could not find curses library (frontends: mconf/nconf)])],
333            [has_curses=no])])
334     ncurses_LIBS="$LIBS"
335     LIBS=$LIBS_old])
336
337AS_IF(
338    [test "$has_curses" = "no" ],
339    [enable_mconf=no; enable_nconf=no])
340
341#----------------------------------------
342# Check for libpanel and libmenu, for the nconf frontend
343AS_IF(
344    [test "$need_panel_menu" = "yes" -o "$need_panel_menu" = "auto"],
345    [AC_SUBST([ncurses_nconf_CPPFLAGS])
346     AC_SUBST([ncurses_panel_menu_LIBS])
347     AS_CASE(
348        [$CURSES_LOC],
349        [ncursesw/*],[ncurses_nconf_CPPFLAGS="-I/usr/include/ncursesw"],
350        [ncurses/*],[ncurses_nconf_CPPFLAGS="-I/usr/include/ncurses"])
351     LIBS_old="$LIBS"
352     LIBS=
353     AC_SEARCH_LIBS(
354        [new_panel],
355        [panelw panel],
356        [ac_ct_panel_lib_found=yes; break],,
357        [$ncurses_LIBS])
358     AS_IF(
359        [test -z "$ac_ct_panel_lib_found"],
360        [AS_IF(
361            [test "$need_panel_menu" = "yes"],
362            [AC_MSG_ERROR([could not find libpanel library (frontend: nconf)])],
363            [has_panel_menu=no])])
364     AC_SEARCH_LIBS(
365        [menu_init],
366        [menuw menu],
367        [ac_ct_menu_lib_found=yes; break],,
368        [$ncurses_LIBS])
369     AS_IF(
370        [test -z "$ac_ct_panel_lib_found"],
371        [AS_IF(
372            [test "$need_panel_menu" = "yes"],
373            [AC_MSG_ERROR([could not find libmenu library (frontend: nconf)])],
374            [has_panel_menu=no])])
375     ncurses_panel_menu_LIBS="$LIBS"
376     LIBS=$LIBS_old])
377
378AS_IF(
379    [test "$has_panel_menu" = "no" ],
380    [enable_nconf=no])
381
382#----------------------------------------
383# Check headers and libs for gconf
384AS_IF(
385    [test "$need_gtk" = "yes" -o "$need_gtk" = "auto"],
386    [PKG_CHECK_MODULES(
387        [gtk],
388        [gtk+-2.0 gmodule-2.0 libglade-2.0],
389        [has_gtk=yes],
390        [AS_IF(
391            [test "$need_gtk" = "yes"],
392            [AC_MSG_ERROR([could not find GTK+ headers and/or libraries (frontend: gconf)])],
393            [has_gtk=no])])])
394
395AS_IF(
396    [test "$has_gtk" = "no" ],
397    [enable_gconf=no])
398
399#----------------------------------------
400# Check headers and libs for qconf
401AS_IF(
402    [test "$need_qt" = "yes" -o "$need_qt" = "auto"],
403    [PKG_CHECK_MODULES(
404        [Qt5],
405        [Qt5Core Qt5Gui Qt5Widgets],
406        [has_qt=yes; need_moc="$need_qt"],
407        [AS_IF(
408            [test "$need_qt" = "yes"],
409            [AC_MSG_ERROR([could not find Qt5 headers and/or libraries (frontend: qconf)])],
410            [has_qt=no; need_moc=no])])])
411
412AC_ARG_VAR([MOC], [Qt5 meta object compiler (moc) command])
413AS_IF(
414    [test "$need_moc" = "yes" -o "$need_moc" = "auto"],
415    [QT5_BINDIR=`$PKG_CONFIG Qt5Core --variable host_bins`
416     AC_PATH_PROGS(
417        [MOC],
418        [moc-qt5 moc],,
419        [$QT5_BINDIR:$PATH])
420     AS_IF(
421        [test -n "$MOC"],
422        [has_moc=yes],
423        [AS_IF(
424            [test "$need_moc" = "yes"],
425            [AC_MSG_ERROR([could not find moc (frontend: qconf)])],
426            [has_moc=no])])])
427
428AS_IF(
429    [test "$has_qt" = "no" -o "$has_moc" = "no"],
430    [enable_qconf=no])
431
432#----------------------------------------
433# Per-frontends extra libraries
434AC_ARG_VAR([conf_EXTRA_LIBS],  [Extra libraries to build the conf frontend] )
435AC_ARG_VAR([gconf_EXTRA_LIBS], [Extra libraries to build the gconf frontend])
436AC_ARG_VAR([mconf_EXTRA_LIBS], [Extra libraries to build the mconf frontend])
437AC_ARG_VAR([nconf_EXTRA_LIBS], [Extra libraries to build the nconf frontend])
438AC_ARG_VAR([qconf_EXTRA_LIBS], [Extra libraries to build the qconf frontend])
439
440#---------------------------------------------------------------------------
441# Now, we know what frontends to enable
442AS_IF([test "$enable_conf"  = "auto"], [enable_conf=yes ])
443AS_IF([test "$enable_gconf" = "auto"], [enable_gconf=yes])
444AS_IF([test "$enable_mconf" = "auto"], [enable_mconf=yes])
445AS_IF([test "$enable_nconf" = "auto"], [enable_nconf=yes])
446AS_IF([test "$enable_qconf" = "auto"], [enable_qconf=yes])
447
448#----------------------------------------
449# Check if the lxdialog library should be built
450AS_IF(
451    [test "$enable_mconf" = "yes"],
452    [need_lxdialog=yes],
453    [need_lxdialog=no])
454
455#----------------------------------------
456# Check if the images library should be built
457AS_IF(
458    [test "$enable_gconf" = "yes" -o "$enable_qconf" = "yes"],
459    [need_images=yes],
460    [need_images=no])
461
462#----------------------------------------
463# Setup automake conditional build
464AM_CONDITIONAL(
465    [COND_kconfig],
466    [test "$enable_kconfig" = "yes"])
467AM_CONDITIONAL(
468    [COND_conf],
469    [test "$enable_conf" = "yes"])
470AM_CONDITIONAL(
471    [COND_mconf],
472    [test "$enable_mconf" = "yes"])
473AM_CONDITIONAL(
474    [COND_nconf],
475    [test "$enable_nconf" = "yes"])
476AM_CONDITIONAL(
477    [COND_gconf],
478    [test "$enable_gconf" = "yes"])
479AM_CONDITIONAL(
480    [COND_qconf],
481    [test "$enable_qconf" = "yes"])
482AM_CONDITIONAL(
483    [COND_lxdialog],
484    [test "$need_lxdialog" = "yes"])
485AM_CONDITIONAL(
486    [COND_images],
487    [test "$need_images" = "yes"])
488AM_CONDITIONAL(
489    [COND_utils],
490    [test "$enable_utils" = "yes"])
491AM_CONDITIONAL(
492    [COND_utils_gettext],
493    [test "$has_gettext" = "yes"])
494
495#----------------------------------------
496# Get the version to apply to the parser shared library
497AC_SUBST(
498    [KCONFIGPARSER_LIB_VERSION],
499    [m4_esyscmd_s([./scripts/version.sh --plain])])
500
501#----------------------------------------
502# Pretty-print the configuration settings
503[fe_list=]
504AS_IF([test "$enable_conf"  = "yes"], [fe_list="$fe_list conf" ])
505AS_IF([test "$enable_gconf" = "yes"], [fe_list="$fe_list gconf"])
506AS_IF([test "$enable_mconf" = "yes"], [fe_list="$fe_list mconf"])
507AS_IF([test "$enable_nconf" = "yes"], [fe_list="$fe_list nconf"])
508AS_IF([test "$enable_qconf" = "yes"], [fe_list="$fe_list qconf"])
509# The meta frontend is handled separatly, below, because we do not
510# want it in the list of tools, kcfg_list.
511
512[kcfg_list="$fe_list"]
513AS_IF([test "$enable_utils" = "yes"], [kcfg_list="$kcfg_list diff merge tweak"])
514AS_IF([test "$has_gettext" = "yes"],  [kcfg_list="$kcfg_list gettext"])
515AC_SUBST([kcfg_list], [${kcfg_list}])
516
517AS_IF([test "$enable_kconfig" = "yes"], [fe_list=" kconfig$fe_list"])
518
519[lib_list=]
520AS_IF(
521    [test "$enable_shared" = "yes"],
522    [lib_list="$lib_list shared (version: $KCONFIGPARSER_LIB_VERSION)"])
523AS_IF(
524    [test "$enable_static" = "yes"],
525    [lib_list="$lib_list${lib_list:+,} static"])
526
527#----------------------------------------
528# Finalise
529# All generated files are generated by a Makefile rule, except Makefile
530# itself of course.
531# There is no generic solution in automake to generate a file from its
532# .in source, so we'd have to provide custom, hand-made rules, which is
533# not nice. So, we handle libs/parser/kconfig-parser.pc here.
534AC_CONFIG_FILES([
535    Makefile
536    libs/parser/kconfig-parser.pc
537])
538AC_OUTPUT
539
540AC_MSG_NOTICE()
541AC_MSG_NOTICE([Configured with:])
542AC_MSG_NOTICE([- parser library     :$lib_list])
543AC_MSG_NOTICE([  - root-menu prompt : $root_menu])
544AC_MSG_NOTICE([  - config prefix    : $config_prefix])
545AC_MSG_NOTICE([- frontends          :$fe_list])
546AC_MSG_NOTICE([  - localised        : $has_gettext])
547AC_MSG_NOTICE([- install utilities  : $enable_utils])
548AC_MSG_NOTICE([- CFLAGS CXXFLAGS    : $wall_CFLAGS $werror_CFLAGS])
549