]> git.sur5r.net Git - kconfig-frontends/blob - configure.ac
utils: don't build gettext if intl support is missing
[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
32
33 #----------------------------------------
34 # Prepare libtool
35 LT_PREREQ([2.2.6])
36 LT_INIT([disable-static])
37
38 #---------------------------------------------------------------------------
39 # Set misc options
40
41 # By default, do not build with -Wall, unless the user asks for it
42 AC_ARG_ENABLE(
43     [wall],
44     [AS_HELP_STRING(
45         [--enable-wall],
46         [build with -Wall (default=no)])],
47     [AS_CASE(
48         ["$enableval"],
49         [yes], [wall_CFLAGS=-Wall],
50         [*],   [wall_CFLAGS=""])])
51 AC_SUBST([wall_CFLAGS],[${wall_CFLAGS}])
52
53 # By default, do not build with -Werror, unless the user asks for it
54 AC_ARG_ENABLE(
55     [werror],
56     [AS_HELP_STRING(
57         [--enable-werror],
58         [build with -Werror (default=no)])],
59     [AS_CASE(
60         ["$enableval"],
61         [yes], [werror_CFLAGS=-Werror],
62         [*],   [werror_CFLAGS=""])])
63 AC_SUBST([werror_CFLAGS],[${werror_CFLAGS}])
64
65 # Although there is a default (="linux") in the code, we do provide
66 # a default here, to get a consistent autostuff behavior
67 AC_ARG_ENABLE(
68     [root-menu-prompt],
69     [AS_HELP_STRING(
70         [--enable-root-menu-prompt=PROMPT],
71         [set the root-menu prompt (default=Configuration)])],
72     [AS_CASE(
73         ["$enableval"],
74         [yes], [root_menu=Configuration],
75         [no],  [root_menu=],
76                [# Escape the $ signs, otherwise they would get munged by make
77                 # Also, append a space at the end, to separate the package
78                 # name from the literal 'Configuration'
79                 root_menu="$( echo "$enableval" |sed -r -e 's/\$/\\$$/g;' )"])])
80 AC_SUBST([root_menu], [${root_menu=Configuration}])
81
82 AC_ARG_ENABLE(
83     [config-prefix],
84     [AS_HELP_STRING(
85         [--enable-config-prefix=PREFIX],
86         [the prefix to the config option (default=CONFIG_)])],
87     [AS_CASE(
88         ["$enableval"],
89         [*" "*],[AC_MSG_ERROR([config prefix can not contain spaces: '$enableval'])],
90         [yes],  [config_prefix=CONFIG_],
91         [no],   [config_prefix=],
92                 [config_prefix=$enableval])])
93 AC_SUBST([config_prefix], [${config_prefix-CONFIG_}])
94
95 AC_ARG_ENABLE(
96     [utils],
97     [AS_HELP_STRING(
98         [--disable-utils],
99         [install utilities to manage .config files (default=no)])])
100 AC_SUBST([enable_utils], [${enable_utils:-yes}])
101
102 #----------------------------------------
103 # Options to selectively enable/disable frontends
104 # All are selected by default
105 AC_ARG_ENABLE(
106     [conf],
107     [AS_HELP_STRING(
108         [--disable-conf],
109         [conf, the stdin-based frontend (default=auto)])])
110 AC_SUBST([enable_conf], [${enable_conf:-auto}])
111 AC_ARG_ENABLE(
112     [mconf],
113     [AS_HELP_STRING(
114         [--disable-mconf],
115         [mconf, the traditional ncurses-based frontend (default=auto)])])
116 AC_SUBST([enable_mconf], [${enable_mconf:-auto}])
117 AC_ARG_ENABLE(
118     [nconf],
119     [AS_HELP_STRING(
120         [--disable-nconf],
121         [nconf, the modern ncurses-based frontend (default=auto)])])
122 AC_SUBST([enable_nconf], [${enable_nconf:-auto}])
123 AC_ARG_ENABLE(
124     [gconf],
125     [AS_HELP_STRING(
126         [--disable-gconf],
127         [gconf, the GTK-based frontend (default=auto)])])
128 AC_SUBST([enable_gconf], [${enable_gconf:-auto}])
129 AC_ARG_ENABLE(
130     [qconf],
131     [AS_HELP_STRING(
132         [--disable-qconf],
133         [qconf, the QT-based frontend (default=auto)])])
134 AC_SUBST([enable_qconf], [${enable_qconf:-auto}])
135
136 AC_ARG_ENABLE(
137     [frontends],
138     [AS_HELP_STRING(
139         [--enable-frontends=list],
140         [enables only the set of frontends in comma-separated 'list'
141          (default: auto selection), takes precedence over all
142          --enable-*conf, above])],
143     [for f in conf mconf nconf gconf qconf; do
144         AS_CASE(
145             ["$enableval"],
146             [yes],      [eval enable_$f=yes],
147             ["$f"],     [eval enable_$f=yes],
148             ["$f",*],   [eval enable_$f=yes],
149             [*,"$f"],   [eval enable_$f=yes],
150             [*,"$f",*], [eval enable_$f=yes],
151                         [eval enable_$f=no])
152      done])
153 AC_SUBST([enable_frontends])
154
155 #----------------------------------------
156 # What extra CFLAGS we will be using
157 AC_SUBST([kf_CFLAGS], ["$wall_CFLAGS $werror_CFLAGS"])
158
159 #----------------------------------------
160 # Dependencies that will be needed, depending on the frontends
161 AS_CASE(
162     ["$enable_mconf":"$enable_nconf"],
163     [*yes*],  [need_curses=yes],
164     [*auto*], [need_curses=auto],
165               [need_curses=no])
166 [need_panel_menu="$enable_nconf"]
167 AS_CASE(
168     ["$enable_gconf":"$enable_qconf"],
169     [*yes*],  [need_pkgconfig=yes],
170     [*auto*], [need_pkgconfig=yes],
171               [need_pkgconfig=no ])
172 [need_gtk="$enable_gconf"]
173 [need_qt="$enable_qconf"]
174
175 #---------------------------------------------------------------------------
176 # Now check we have the required stuff
177
178 #----------------------------------------
179 # Some program checks
180 AC_PROG_CC
181 AM_PROG_CC_C_O
182 AC_PROG_CXX
183 AC_C_INLINE
184 AC_PROG_MAKE_SET
185 AC_CHECK_PROGS(
186     [GPERF],
187     [gperf])
188 AS_IF(
189     [test -z "$GPERF"],
190     [AC_MSG_ERROR([can not find gperf])])
191 AS_IF(
192     [test "$need_pkgconfig" = "yes"],
193     [PKG_PROG_PKG_CONFIG()])
194 AC_PROG_LEX
195 AC_SUBST([AM_LFLAGS], ["-L -P zconf"])
196 AC_PROG_YACC
197 AC_SUBST([AM_YFLAGS], ["-t -l -p zconf"])
198
199 #----------------------------------------
200 # Check for standard headers
201 AC_HEADER_STDC
202 AC_HEADER_STDBOOL
203 AC_CHECK_HEADERS([ fcntl.h limits.h locale.h ])
204 AC_CHECK_HEADERS([ stdlib.h string.h sys/time.h unistd.h ])
205 AC_TYPE_SIZE_T
206
207 #----------------------------------------
208 # Checks for library functions.
209 AC_FUNC_MALLOC
210 AC_FUNC_REALLOC
211 AC_FUNC_ALLOCA
212 AC_CHECK_FUNCS([ bzero memmove memset ])
213 AC_CHECK_FUNCS([ strcasecmp strchr strcspn strdup strncasecmp strpbrk strrchr strspn strtol ])
214 AC_CHECK_FUNCS([ gettimeofday mkdir regcomp setlocale uname ])
215
216 #----------------------------------------
217 # Check for gettext, for the kconfig frontends
218 [has_gettext=yes]
219 AC_CHECK_HEADERS(
220     [libintl.h],
221     [ac_ct_gettext_hdr=$ac_header; break],
222     [has_gettext=no])
223 AS_IF(
224     [test "$has_gettext" = "yes"],
225     [AC_CHECK_DECL(
226         [gettext],,
227         [has_gettext=no],
228         [#include <$ac_ct_gettext_hdr>])])
229 AS_IF(
230     [test "$has_gettext" = "yes"],
231     [LIBS_old="$LIBS"
232      LIBS=
233      AC_SEARCH_LIBS(
234         [gettext],
235         [intl],,
236         [has_gettext=no])
237     intl_LIBS="$LIBS"
238     LIBS="$LIBS_old"])
239 AS_IF(
240     [test "$has_gettext" = "no"],
241     [intl_CPPFLAGS=-DKBUILD_NO_NLS])
242 AC_SUBST([intl_CPPFLAGS])
243 AC_SUBST([intl_LIBS])
244
245 #----------------------------------------
246 # Check for ncurses, for the mconf & nconf frontends
247 AS_IF(
248     [test "$need_curses" = "yes" -o "$need_curses" = "auto"],
249     [AC_SUBST([CURSES_LOC])
250      AC_SUBST([ncurses_LIBS])
251      LIBS_old="$LIBS"
252      LIBS=
253      AC_CHECK_HEADERS(
254         [ncurses/ncurses.h ncurses/curses.h ncursesw/curses.h ncurses.h curses.h],
255         [CURSES_LOC=$ac_header; break])
256      AS_IF(
257         [test -z "$CURSES_LOC"],
258         [AS_IF(
259             [test "$need_curses" = "yes"],
260             [AC_MSG_ERROR([could not find curses headers (frontends: mconf/nconf)])],
261             [has_curses=no])])
262      AC_SEARCH_LIBS(
263         [initscr],
264         [ncursesw ncurses curses],
265         [ac_ct_curses_lib_found=yes; break])
266      AS_IF(
267         [test -z "$ac_ct_curses_lib_found"],
268         [AS_IF(
269             [test "$need_curses" = "yes"],
270             [AC_MSG_ERROR([could not find curses library (frontends: mconf/nconf)])],
271             [has_curses=no])])
272      ncurses_LIBS="$LIBS"
273      LIBS=$LIBS_old])
274
275 AS_IF(
276     [test "$has_curses" = "no" ],
277     [enable_mconf=no; enable_nconf=no])
278
279 #----------------------------------------
280 # Check for libpanel and libmenu, for the nconf frontend
281 AS_IF(
282     [test "$need_panel_menu" = "yes" -o "$need_panel_menu" = "auto"],
283     [AC_SUBST([ncurses_extra_LIBS])
284      LIBS_old="$LIBS"
285      LIBS=
286      AC_SEARCH_LIBS(
287         [new_panel],
288         [panelw panel],
289         [ac_ct_panel_lib_found=yes; break],,
290         [$ncurses_LIBS])
291      AS_IF(
292         [test -z "$ac_ct_panel_lib_found"],
293         [AS_IF(
294             [test "$need_panel_menu" = "yes"],
295             [AC_MSG_ERROR([could not find libpanel library (frontend: nconf)])],
296             [has_panel_menu=no])])
297      AC_SEARCH_LIBS(
298         [menu_init],
299         [menuw menu],
300         [ac_ct_menu_lib_found=yes; break],,
301         [$ncurses_LIBS])
302      AS_IF(
303         [test -z "$ac_ct_panel_lib_found"],
304         [AS_IF(
305             [test "$need_panel_menu" = "yes"],
306             [AC_MSG_ERROR([could not find libmenu library (frontend: nconf)])],
307             [has_panel_menu=no])])
308      ncurses_extra_LIBS="$LIBS"
309      LIBS=$LIBS_old])
310
311 AS_IF(
312     [test "$has_panel_menu" = "no" ],
313     [enable_nconf=no])
314
315 #----------------------------------------
316 # Check headers and libs for gconf
317 AS_IF(
318     [test "$need_gtk" = "yes" -o "$need_gtk" = "auto"],
319     [PKG_CHECK_MODULES(
320         [gtk],
321         [gtk+-2.0 gmodule-2.0 libglade-2.0],
322         [has_gtk=yes],
323         [AS_IF(
324             [test "$need_gtk" = "yes"],
325             [AC_MSG_ERROR([could not find GTK+ headers and/or libraries (frontend: gconf)])],
326             [has_gtk=no])])])
327
328 AS_IF(
329     [test "$has_gtk" = "no" ],
330     [enable_gconf=no])
331
332 #----------------------------------------
333 # Check headers and libs for qconf
334 AS_IF(
335     [test "$need_qt" = "yes" -o "$need_qt" = "auto"],
336     [PKG_CHECK_MODULES(
337         [qt4],
338         [QtCore QtGui Qt3Support],
339         [has_qt=yes; need_moc="$need_qt"],
340         [AS_IF(
341             [test "$need_qt" = "yes"],
342             [AC_MSG_ERROR([could not find QT4 headers and/or libraries (frontend: qconf)])],
343             [has_qt=no; need_moc=no])])])
344
345 AC_ARG_VAR([MOC], [Qt meta object compiler (moc) command])
346 AS_IF(
347     [test "$need_moc" = "yes" -o "$need_moc" = "auto"],
348     [QT4_BINDIR=`$PKG_CONFIG Qt --variable bindir`
349      AC_PATH_PROGS(
350         [MOC],
351         [moc-qt4 moc],,
352         [$QT4_BINDIR:$PATH])
353      AS_IF(
354         [test -n "$MOC"],
355         [has_moc=yes],
356         [AS_IF(
357             [test "$need_moc" = "yes"],
358             [AC_MSG_ERROR([could not find moc (frontend: qconf)])],
359             [has_moc=no])])])
360
361 AS_IF(
362     [test "$has_qt" = "no" -o "$has_moc" = "no"],
363     [enable_qconf=no])
364
365 #----------------------------------------
366 # Per-frontends extra libraries
367 AC_ARG_VAR([conf_EXTRA_LIBS],  [Extra libraries to build the conf frontend] )
368 AC_ARG_VAR([gconf_EXTRA_LIBS], [Extra libraries to build the gconf frontend])
369 AC_ARG_VAR([mconf_EXTRA_LIBS], [Extra libraries to build the mconf frontend])
370 AC_ARG_VAR([nconf_EXTRA_LIBS], [Extra libraries to build the nconf frontend])
371 AC_ARG_VAR([qconf_EXTRA_LIBS], [Extra libraries to build the qconf frontend])
372
373 #---------------------------------------------------------------------------
374 # Now, we know what frontends to enable
375 AS_IF([test "$enable_conf"  = "auto"], [enable_conf=yes ])
376 AS_IF([test "$enable_gconf" = "auto"], [enable_gconf=yes])
377 AS_IF([test "$enable_mconf" = "auto"], [enable_mconf=yes])
378 AS_IF([test "$enable_nconf" = "auto"], [enable_nconf=yes])
379 AS_IF([test "$enable_qconf" = "auto"], [enable_qconf=yes])
380
381 #----------------------------------------
382 # Check if the lxdialog library should be built
383 AS_IF(
384     [test "$enable_mconf" = "yes"],
385     [need_lxdialog=yes],
386     [need_lxdialog=no])
387
388 #----------------------------------------
389 # Check if the images library should be built
390 AS_IF(
391     [test "$enable_gconf" = "yes" -o "$enable_qconf" = "yes"],
392     [need_images=yes],
393     [need_images=no])
394
395 #----------------------------------------
396 # Setup automake conditional build
397 AM_CONDITIONAL(
398     [COND_conf],
399     [test "$enable_conf" = "yes"])
400 AM_CONDITIONAL(
401     [COND_mconf],
402     [test "$enable_mconf" = "yes"])
403 AM_CONDITIONAL(
404     [COND_nconf],
405     [test "$enable_nconf" = "yes"])
406 AM_CONDITIONAL(
407     [COND_gconf],
408     [test "$enable_gconf" = "yes"])
409 AM_CONDITIONAL(
410     [COND_qconf],
411     [test "$enable_qconf" = "yes"])
412 AM_CONDITIONAL(
413     [COND_lxdialog],
414     [test "$need_lxdialog" = "yes"])
415 AM_CONDITIONAL(
416     [COND_images],
417     [test "$need_images" = "yes"])
418 AM_CONDITIONAL(
419     [COND_utils],
420     [test "$enable_utils" = "yes"])
421 AM_CONDITIONAL(
422     [COND_utils_gettext],
423     [test "$has_gettext" = "yes"])
424
425 #----------------------------------------
426 # Get the version to apply to the parser shared library
427 AC_SUBST(
428     [KCONFIGPARSER_LIB_VERSION],
429     [m4_esyscmd_s([./scripts/version.sh --plain])])
430
431 #----------------------------------------
432 # Finalise
433 AC_CONFIG_FILES([
434     Makefile
435     docs/Makefile
436     libs/Makefile
437     libs/images/Makefile
438     libs/lxdialog/Makefile
439     libs/parser/Makefile
440     frontends/Makefile
441     frontends/conf/Makefile
442     frontends/mconf/Makefile
443     frontends/nconf/Makefile
444     frontends/gconf/Makefile
445     frontends/qconf/Makefile
446     utils/Makefile
447     scripts/Makefile
448 ])
449 AC_OUTPUT
450
451 #----------------------------------------
452 # Pretty-print the configuration settings
453 [fe_list=]
454 AS_IF([test "$enable_conf"  = "yes"], [fe_list="$fe_list conf" ])
455 AS_IF([test "$enable_gconf" = "yes"], [fe_list="$fe_list gconf"])
456 AS_IF([test "$enable_mconf" = "yes"], [fe_list="$fe_list mconf"])
457 AS_IF([test "$enable_nconf" = "yes"], [fe_list="$fe_list nconf"])
458 AS_IF([test "$enable_qconf" = "yes"], [fe_list="$fe_list qconf"])
459
460 [lib_list=]
461 AS_IF(
462     [test "$enable_shared" = "yes"],
463     [lib_list="$lib_list shared (version: $KCONFIGPARSER_LIB_VERSION)"])
464 AS_IF(
465     [test "$enable_static" = "yes"],
466     [lib_list="$lib_list${lib_list:+,} static"])
467
468 AC_MSG_NOTICE()
469 AC_MSG_NOTICE([Configured with:])
470 AC_MSG_NOTICE([- parser library     :$lib_list])
471 AC_MSG_NOTICE([  - root-menu prompt : $root_menu])
472 AC_MSG_NOTICE([  - config prefix    : $config_prefix])
473 AC_MSG_NOTICE([- frontends          :$fe_list])
474 AC_MSG_NOTICE([  - transform name   : $program_transform_name])
475 AC_MSG_NOTICE([  - localised        : $has_gettext])
476 AC_MSG_NOTICE([- install utilities  : $enable_utils])
477 AC_MSG_NOTICE([- CFLAGS CXXFLAGS    : $wall_CFLAGS $werror_CFLAGS])