]> git.sur5r.net Git - kconfig-frontends/blob - configure.ac
buildsystem: do not use program-prefix to set the kconfig- prefix
[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])
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     [conf],
127     [AS_HELP_STRING(
128         [--disable-conf],
129         [conf, the stdin-based frontend (default=auto)])])
130 AC_SUBST([enable_conf], [${enable_conf:-auto}])
131 AC_ARG_ENABLE(
132     [mconf],
133     [AS_HELP_STRING(
134         [--disable-mconf],
135         [mconf, the traditional ncurses-based frontend (default=auto)])])
136 AC_SUBST([enable_mconf], [${enable_mconf:-auto}])
137 AC_ARG_ENABLE(
138     [nconf],
139     [AS_HELP_STRING(
140         [--disable-nconf],
141         [nconf, the modern ncurses-based frontend (default=auto)])])
142 AC_SUBST([enable_nconf], [${enable_nconf:-auto}])
143 AC_ARG_ENABLE(
144     [gconf],
145     [AS_HELP_STRING(
146         [--disable-gconf],
147         [gconf, the GTK-based frontend (default=auto)])])
148 AC_SUBST([enable_gconf], [${enable_gconf:-auto}])
149 AC_ARG_ENABLE(
150     [qconf],
151     [AS_HELP_STRING(
152         [--disable-qconf],
153         [qconf, the QT-based frontend (default=auto)])])
154 AC_SUBST([enable_qconf], [${enable_qconf:-auto}])
155
156 AC_ARG_ENABLE(
157     [frontends],
158     [AS_HELP_STRING(
159         [--enable-frontends=list],
160         [enables only the set of frontends in comma-separated 'list'
161          (default: auto selection), takes precedence over all
162          --enable-*conf, above])],
163     [for f in conf mconf nconf gconf qconf; do
164         AS_CASE(
165             ["$enableval"],
166             [yes],      [eval enable_$f=yes],
167             ["$f"],     [eval enable_$f=yes],
168             ["$f",*],   [eval enable_$f=yes],
169             [*,"$f"],   [eval enable_$f=yes],
170             [*,"$f",*], [eval enable_$f=yes],
171                         [eval enable_$f=no])
172      done])
173 AC_SUBST([enable_frontends])
174
175 #----------------------------------------
176 # What extra CFLAGS we will be using
177 AC_SUBST([kf_CFLAGS], ["$wall_CFLAGS $werror_CFLAGS"])
178
179 #----------------------------------------
180 # Dependencies that will be needed, depending on the frontends
181 AS_CASE(
182     ["$enable_mconf":"$enable_nconf"],
183     [*yes*],  [need_curses=yes],
184     [*auto*], [need_curses=auto],
185               [need_curses=no])
186 [need_panel_menu="$enable_nconf"]
187 AS_CASE(
188     ["$enable_gconf":"$enable_qconf"],
189     [*yes*],  [need_pkgconfig=yes],
190     [*auto*], [need_pkgconfig=yes],
191               [need_pkgconfig=no ])
192 [need_gtk="$enable_gconf"]
193 [need_qt="$enable_qconf"]
194
195 #---------------------------------------------------------------------------
196 # Now check we have the required stuff
197
198 #----------------------------------------
199 # Some program checks
200 AC_PROG_CC
201 AM_PROG_CC_C_O
202 AC_PROG_CXX
203 AC_C_INLINE
204 AC_PROG_MAKE_SET
205 AC_CHECK_PROGS(
206     [GPERF],
207     [gperf])
208 AS_IF(
209     [test -z "$GPERF"],
210     [AC_MSG_ERROR([can not find gperf])])
211 AS_IF(
212     [test "$need_pkgconfig" = "yes"],
213     [PKG_PROG_PKG_CONFIG()])
214 # Look for `lex'. If it cannot be found, autoconf sets $LEX to ':'.
215 AC_PROG_LEX
216 AS_IF(
217     [test "$LEX" = ":"],
218     [AC_MSG_ERROR([can not find a lexer generator (such as lex or flex)])])
219 AC_SUBST([AM_LFLAGS], ["-L -P zconf"])
220 # Look for `yacc'. If it cannot be found, autoconf sets $YACC to 'yacc'.
221 AC_PROG_YACC
222 AS_IF(
223     [test "$YACC" = "yacc"],
224     [AC_CHECK_PROGS(
225         [YACC_IN_PATH],
226         [yacc])]
227      AS_IF(
228         [test -z "$YACC_IN_PATH"],
229         [AC_MSG_ERROR([can not find a parser generator (such as yacc or bison)])]))
230 AC_SUBST([AM_YFLAGS], ["-t -l -p zconf"])
231
232 #----------------------------------------
233 # Check for gettext, for the kconfig frontends
234 [has_gettext="$enable_L10n"]
235 AS_IF(
236     [test "$has_gettext" = "yes"],
237     [AC_CHECK_HEADERS(
238         [libintl.h],
239         [ac_ct_gettext_hdr=$ac_header; break],
240         [has_gettext=no])])
241 AS_IF(
242     [test "$has_gettext" = "yes"],
243     [AC_CHECK_DECL(
244         [gettext],,
245         [has_gettext=no],
246         [#include <$ac_ct_gettext_hdr>])])
247 AS_IF(
248     [test "$has_gettext" = "yes"],
249     [LIBS_old="$LIBS"
250      LIBS=
251      AC_SEARCH_LIBS(
252         [gettext],
253         [intl],,
254         [has_gettext=no])
255     intl_LIBS="$LIBS"
256     LIBS="$LIBS_old"])
257 AS_IF(
258     [test "$has_gettext" = "no"],
259     [intl_CPPFLAGS=-DKBUILD_NO_NLS])
260 AC_SUBST([intl_CPPFLAGS])
261 AC_SUBST([intl_LIBS])
262
263 #----------------------------------------
264 # Check for ncurses, for the mconf & nconf frontends
265 AS_IF(
266     [test "$need_curses" = "yes" -o "$need_curses" = "auto"],
267     [AC_SUBST([ncurses_mconf_CPPFLAGS])
268      AC_SUBST([ncurses_LIBS])
269      LIBS_old="$LIBS"
270      LIBS=
271      AC_CHECK_HEADERS(
272         [ncursesw/curses.h ncurses/ncurses.h ncurses/curses.h ncurses.h curses.h],
273         [CURSES_LOC=$ac_header
274          ncurses_mconf_CPPFLAGS=-DCURSES_LOC=\\\"$ac_header\\\"
275          break # Stupid syntax-coloring in vim: "])
276      AS_IF(
277         [test -z "$CURSES_LOC"],
278         [AS_IF(
279             [test "$need_curses" = "yes"],
280             [AC_MSG_ERROR([could not find curses headers (frontends: mconf/nconf)])],
281             [has_curses=no])])
282      AS_CASE(
283         [$CURSES_LOC],
284         [ncursesw/*],[ncurses_mconf_CPPFLAGS="$ncurses_mconf_CPPFLAGS -DNCURSES_WIDECHAR=1"])
285      AC_SEARCH_LIBS(
286         [setupterm],
287         [tinfo],
288         [break])
289      AC_SEARCH_LIBS(
290         [initscr],
291         [ncursesw ncurses curses],
292         [ac_ct_curses_lib_found=yes; break])
293      AS_IF(
294         [test -z "$ac_ct_curses_lib_found"],
295         [AS_IF(
296             [test "$need_curses" = "yes"],
297             [AC_MSG_ERROR([could not find curses library (frontends: mconf/nconf)])],
298             [has_curses=no])])
299      ncurses_LIBS="$LIBS"
300      LIBS=$LIBS_old])
301
302 AS_IF(
303     [test "$has_curses" = "no" ],
304     [enable_mconf=no; enable_nconf=no])
305
306 #----------------------------------------
307 # Check for libpanel and libmenu, for the nconf frontend
308 AS_IF(
309     [test "$need_panel_menu" = "yes" -o "$need_panel_menu" = "auto"],
310     [AC_SUBST([ncurses_nconf_CPPFLAGS])
311      AC_SUBST([ncurses_panel_menu_LIBS])
312      AS_CASE(
313         [$CURSES_LOC],
314         [ncursesw/*],[ncurses_nconf_CPPFLAGS="-I/usr/include/ncursesw"],
315         [ncurses/*],[ncurses_nconf_CPPFLAGS="-I/usr/include/ncurses"])
316      LIBS_old="$LIBS"
317      LIBS=
318      AC_SEARCH_LIBS(
319         [new_panel],
320         [panelw panel],
321         [ac_ct_panel_lib_found=yes; break],,
322         [$ncurses_LIBS])
323      AS_IF(
324         [test -z "$ac_ct_panel_lib_found"],
325         [AS_IF(
326             [test "$need_panel_menu" = "yes"],
327             [AC_MSG_ERROR([could not find libpanel library (frontend: nconf)])],
328             [has_panel_menu=no])])
329      AC_SEARCH_LIBS(
330         [menu_init],
331         [menuw menu],
332         [ac_ct_menu_lib_found=yes; break],,
333         [$ncurses_LIBS])
334      AS_IF(
335         [test -z "$ac_ct_panel_lib_found"],
336         [AS_IF(
337             [test "$need_panel_menu" = "yes"],
338             [AC_MSG_ERROR([could not find libmenu library (frontend: nconf)])],
339             [has_panel_menu=no])])
340      ncurses_panel_menu_LIBS="$LIBS"
341      LIBS=$LIBS_old])
342
343 AS_IF(
344     [test "$has_panel_menu" = "no" ],
345     [enable_nconf=no])
346
347 #----------------------------------------
348 # Check headers and libs for gconf
349 AS_IF(
350     [test "$need_gtk" = "yes" -o "$need_gtk" = "auto"],
351     [PKG_CHECK_MODULES(
352         [gtk],
353         [gtk+-2.0 gmodule-2.0 libglade-2.0],
354         [has_gtk=yes],
355         [AS_IF(
356             [test "$need_gtk" = "yes"],
357             [AC_MSG_ERROR([could not find GTK+ headers and/or libraries (frontend: gconf)])],
358             [has_gtk=no])])])
359
360 AS_IF(
361     [test "$has_gtk" = "no" ],
362     [enable_gconf=no])
363
364 #----------------------------------------
365 # Check headers and libs for qconf
366 AS_IF(
367     [test "$need_qt" = "yes" -o "$need_qt" = "auto"],
368     [PKG_CHECK_MODULES(
369         [Qt5],
370         [Qt5Core Qt5Gui Qt5Widgets],
371         [has_qt=yes; need_moc="$need_qt"],
372         [AS_IF(
373             [test "$need_qt" = "yes"],
374             [AC_MSG_ERROR([could not find Qt5 headers and/or libraries (frontend: qconf)])],
375             [has_qt=no; need_moc=no])])])
376
377 AC_ARG_VAR([MOC], [Qt5 meta object compiler (moc) command])
378 AS_IF(
379     [test "$need_moc" = "yes" -o "$need_moc" = "auto"],
380     [QT5_BINDIR=`$PKG_CONFIG Qt5Core --variable host_bins`
381      AC_PATH_PROGS(
382         [MOC],
383         [moc-qt5 moc],,
384         [$QT5_BINDIR:$PATH])
385      AS_IF(
386         [test -n "$MOC"],
387         [has_moc=yes],
388         [AS_IF(
389             [test "$need_moc" = "yes"],
390             [AC_MSG_ERROR([could not find moc (frontend: qconf)])],
391             [has_moc=no])])])
392
393 AS_IF(
394     [test "$has_qt" = "no" -o "$has_moc" = "no"],
395     [enable_qconf=no])
396
397 #----------------------------------------
398 # Per-frontends extra libraries
399 AC_ARG_VAR([conf_EXTRA_LIBS],  [Extra libraries to build the conf frontend] )
400 AC_ARG_VAR([gconf_EXTRA_LIBS], [Extra libraries to build the gconf frontend])
401 AC_ARG_VAR([mconf_EXTRA_LIBS], [Extra libraries to build the mconf frontend])
402 AC_ARG_VAR([nconf_EXTRA_LIBS], [Extra libraries to build the nconf frontend])
403 AC_ARG_VAR([qconf_EXTRA_LIBS], [Extra libraries to build the qconf frontend])
404
405 #---------------------------------------------------------------------------
406 # Now, we know what frontends to enable
407 AS_IF([test "$enable_conf"  = "auto"], [enable_conf=yes ])
408 AS_IF([test "$enable_gconf" = "auto"], [enable_gconf=yes])
409 AS_IF([test "$enable_mconf" = "auto"], [enable_mconf=yes])
410 AS_IF([test "$enable_nconf" = "auto"], [enable_nconf=yes])
411 AS_IF([test "$enable_qconf" = "auto"], [enable_qconf=yes])
412
413 #----------------------------------------
414 # Check if the lxdialog library should be built
415 AS_IF(
416     [test "$enable_mconf" = "yes"],
417     [need_lxdialog=yes],
418     [need_lxdialog=no])
419
420 #----------------------------------------
421 # Check if the images library should be built
422 AS_IF(
423     [test "$enable_gconf" = "yes" -o "$enable_qconf" = "yes"],
424     [need_images=yes],
425     [need_images=no])
426
427 #----------------------------------------
428 # Setup automake conditional build
429 AM_CONDITIONAL(
430     [COND_conf],
431     [test "$enable_conf" = "yes"])
432 AM_CONDITIONAL(
433     [COND_mconf],
434     [test "$enable_mconf" = "yes"])
435 AM_CONDITIONAL(
436     [COND_nconf],
437     [test "$enable_nconf" = "yes"])
438 AM_CONDITIONAL(
439     [COND_gconf],
440     [test "$enable_gconf" = "yes"])
441 AM_CONDITIONAL(
442     [COND_qconf],
443     [test "$enable_qconf" = "yes"])
444 AM_CONDITIONAL(
445     [COND_lxdialog],
446     [test "$need_lxdialog" = "yes"])
447 AM_CONDITIONAL(
448     [COND_images],
449     [test "$need_images" = "yes"])
450 AM_CONDITIONAL(
451     [COND_utils],
452     [test "$enable_utils" = "yes"])
453 AM_CONDITIONAL(
454     [COND_utils_gettext],
455     [test "$has_gettext" = "yes"])
456
457 #----------------------------------------
458 # Get the version to apply to the parser shared library
459 AC_SUBST(
460     [KCONFIGPARSER_LIB_VERSION],
461     [m4_esyscmd_s([./scripts/version.sh --plain])])
462
463 #----------------------------------------
464 # Finalise
465 AC_CONFIG_FILES([
466     Makefile
467     docs/Makefile
468     libs/Makefile
469     libs/images/Makefile
470     libs/lxdialog/Makefile
471     libs/parser/Makefile
472     frontends/Makefile
473     frontends/conf/Makefile
474     frontends/mconf/Makefile
475     frontends/nconf/Makefile
476     frontends/gconf/Makefile
477     frontends/qconf/Makefile
478     utils/Makefile
479     scripts/Makefile
480 ])
481 AC_OUTPUT
482
483 #----------------------------------------
484 # Pretty-print the configuration settings
485 [fe_list=]
486 AS_IF([test "$enable_conf"  = "yes"], [fe_list="$fe_list conf" ])
487 AS_IF([test "$enable_gconf" = "yes"], [fe_list="$fe_list gconf"])
488 AS_IF([test "$enable_mconf" = "yes"], [fe_list="$fe_list mconf"])
489 AS_IF([test "$enable_nconf" = "yes"], [fe_list="$fe_list nconf"])
490 AS_IF([test "$enable_qconf" = "yes"], [fe_list="$fe_list qconf"])
491
492 [lib_list=]
493 AS_IF(
494     [test "$enable_shared" = "yes"],
495     [lib_list="$lib_list shared (version: $KCONFIGPARSER_LIB_VERSION)"])
496 AS_IF(
497     [test "$enable_static" = "yes"],
498     [lib_list="$lib_list${lib_list:+,} static"])
499
500 AC_MSG_NOTICE()
501 AC_MSG_NOTICE([Configured with:])
502 AC_MSG_NOTICE([- parser library     :$lib_list])
503 AC_MSG_NOTICE([  - root-menu prompt : $root_menu])
504 AC_MSG_NOTICE([  - config prefix    : $config_prefix])
505 AC_MSG_NOTICE([- frontends          :$fe_list])
506 AC_MSG_NOTICE([  - localised        : $has_gettext])
507 AC_MSG_NOTICE([- install utilities  : $enable_utils])
508 AC_MSG_NOTICE([- CFLAGS CXXFLAGS    : $wall_CFLAGS $werror_CFLAGS])