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