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