]> git.ozlabs.org Git - petitboot/blob - configure.ac
ui/ncurses: Always cancel autoboot on exit
[petitboot] / configure.ac
1 ## configure.ac -- Process this file with autoconf to produce configure
2 #
3 #  This program is free software; you can redistribute it and/or modify
4 #  it under the terms of the GNU General Public License as published by
5 #  the Free Software Foundation; version 2 of the License.
6 #
7 #  This program is distributed in the hope that it will be useful,
8 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
9 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10 #  GNU General Public License for more details.
11 #
12 #  You should have received a copy of the GNU General Public License
13 #  along with this program; if not, write to the Free Software
14 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
15 #
16
17 AC_INIT([petitboot],
18     [m4_esyscmd_s([./version.sh])],
19     [Geoff Levand <geoff@infradead.org>])
20
21 AC_CONFIG_MACRO_DIR([m4])
22
23 AC_PREFIX_DEFAULT([/usr/local])
24
25 AS_IF([test "x$CFLAGS" = "x"], [AC_SUBST([CFLAGS], [""])])
26
27 AC_PROG_CC
28 AC_PROG_LEX
29 AC_PROG_YACC
30 AC_PROG_INSTALL
31
32 AM_INIT_AUTOMAKE
33 AC_GNU_SOURCE
34 AM_GNU_GETTEXT([external])
35 AM_GNU_GETTEXT_VERSION(0.18.1)
36 LT_INIT
37
38 AM_SILENT_RULES([yes])
39
40 AX_WITH_CURSES
41 AX_WITH_CURSES_MENU
42 AX_WITH_CURSES_FORM
43
44 AM_CONDITIONAL([WITH_NCURSES], [test "x$ax_cv_curses" = "xyes"])
45
46 if test "x$ax_cv_curses" = xyes; then
47         if test "x$ax_cv_menu" != xyes; then
48                 AC_MSG_ERROR([--with-ncurses requires the ncurses menu library])
49         fi
50         if test "x$ax_cv_form" != xyes; then
51                 AC_MSG_ERROR([--with-ncurses requires the ncurses form library])
52         fi
53 fi
54
55 AC_CHECK_LIB([udev], [udev_new],
56         [UDEV_LIBS=-ludev],
57         [AC_MSG_FAILURE([The libudev development library is required by petitboot.  Try installing the package libudev-dev or libudev-devel.])]
58 )
59
60 PKG_CHECK_EXISTS(libudev >= 218, [old_udev=no], [old_udev=yes])
61 if test "$old_udev" = "yes" ; then
62       AC_DEFINE(UDEV_LOGGING, 1, [Support old udev logging interface])
63 fi
64
65 AC_CHECK_LIB([devmapper], [dm_task_create],
66         [DEVMAPPER_LIBS=-ldevmapper],
67         [AC_MSG_FAILURE([The libdevmapper development library is required by petitboot.  Try installing the package libdevmapper-dev or device-mapper-devel.])]
68 )
69
70 AC_ARG_WITH([fdt],
71         AS_HELP_STRING([--without-fdt],
72                 [Build without libfdt (default: no)]))
73
74 AS_IF([test "x$with_fdt" != "xno"],
75         AC_CHECK_LIB([fdt], [fdt_check_header],
76                 [FDT_LIBS=-lfdt; have_libfdt=yes]))
77
78 AM_CONDITIONAL([HAVE_LIBFDT], [test x"$have_libfdt" = xyes])
79
80 AC_CHECK_HEADERS([stdarg.h])
81 AC_CHECK_HEADERS([varargs.h])
82
83 dnl Checking for va_copy availability
84 AC_MSG_CHECKING([for va_copy])
85 AC_TRY_LINK([#include <stdarg.h>
86 va_list ap1,ap2;], [va_copy(ap1,ap2);],
87 have_va_copy=yes,
88 have_va_copy=no)
89 AC_MSG_RESULT($have_va_copy)
90 if test x"$have_va_copy" = x"yes"; then
91     AC_DEFINE(HAVE_VA_COPY,1,[Whether va_copy() is available])
92 else
93     AC_MSG_CHECKING([for __va_copy])
94     AC_TRY_LINK([#include <stdarg.h>
95     va_list ap1,ap2;], [__va_copy(ap1,ap2);],
96     have___va_copy=yes,
97     have___va_copy=no)
98     AC_MSG_RESULT($have___va_copy)
99     if test x"$have___va_copy" = x"yes"; then
100         AC_DEFINE(HAVE___VA_COPY,1,[Whether __va_copy() is available])
101     fi
102 fi
103
104 AC_ARG_WITH(
105         [twin-x11],
106         [AS_HELP_STRING([--with-twin-x11],
107                 [build x11 GUI programs using the twin window system [default=yes]]
108         )],
109         [],
110         [with_twin_x11=yes]
111 )
112 AM_CONDITIONAL([WITH_TWIN_X11], [test "x$with_twin_x11" = "xyes"])
113
114 AC_ARG_WITH(
115         [twin-fbdev],
116         [AS_HELP_STRING(
117                 [--with-twin-fbdev],
118                 [build frame buffer GUI programs using the twin window system [default=no]]
119         )],
120         [],
121         [with_twin_fbdev=yes]
122 )
123 AM_CONDITIONAL([WITH_TWIN_FBDEV], [test "x$with_twin_fbdev" = "xyes"])
124
125 AM_CONDITIONAL(
126         [WITH_TWIN],
127         [test "x$with_twin_x11" = "xyes" || test "x$with_twin_fbdev" = "xyes"])
128
129 AS_IF(
130         [test "x$with_twin_x11" = "xyes" || test "x$with_twin_fbdev" = "xyes"],
131         [PKG_CHECK_MODULES(
132                 [twin],
133                 [libtwin],
134                 [SAVE_LIBS="$LIBS" LIBS="$LIBS $twin_LIBS"
135                         AC_CHECK_LIB(
136                                 [twin],
137                                 [twin_feature_init],
138                                 [],
139                                 [AC_MSG_FAILURE([--with-twin was given but the test for libtwin failed.])]
140                         )
141                         LIBS="$SAVE_LIBS"
142                 ],
143                 [AC_MSG_RESULT([$twin_PKG_ERRORS])
144                         AC_MSG_FAILURE([ Consider adjusting PKG_CONFIG_PATH environment variable])
145                 ]
146         )]
147 )
148
149 AS_IF(
150         [test "x$with_twin_x11" = "xyes"],
151         [SAVE_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$CPPFLAGS $twin_CFLAGS"
152                 AC_CHECK_HEADERS(
153                         [libtwin/twin_x11.h],
154                         [],
155                         [AC_MSG_FAILURE([ --with-twin-x11 given but libtwin/twin_x11.h not found])]
156                 )
157                 CPPFLAGS="$SAVE_CPPFLAGS"
158         ]
159 )
160
161 AS_IF(
162         [test "x$with_twin_fbdev" = "xyes"],
163         [SAVE_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$CPPFLAGS $twin_CFLAGS"
164                 AC_CHECK_HEADERS(
165                         [libtwin/twin_fbdev.h],
166                         [],
167                         [AC_MSG_FAILURE([ --with-twin-fbdev given but libtwin/twin_fbdev.h not found])]
168                 )
169                 CPPFLAGS="$SAVE_CPPFLAGS"
170         ]
171 )
172
173 AC_ARG_WITH(
174         [signed-boot],
175         [AS_HELP_STRING([--with-signed-boot],
176                 [build kernel signature checking support [default=no]]
177         )],
178         [],
179         [with_signed_boot=no]
180 )
181
182 AM_CONDITIONAL(
183         [WITH_SIGNED_BOOT],
184         [test "x$with_signed_boot" = "xyes"])
185
186 AS_IF(
187         [test "x$with_signed_boot" = "xyes"],
188         [PKG_CHECK_MODULES(
189                 [GPGME],
190                 [gpgme >= 1.0.0],
191                 [SAVE_LIBS="$LIBS" LIBS="$LIBS $gpgme_LIBS"
192                         AC_CHECK_LIB(
193                                 [gpgme],
194                                 [gpgme_op_verify],
195                                 [],
196                                 [AC_MSG_FAILURE([--with-signed-boot was given but the test for gpgme failed.])]
197                         )
198                         LIBS="$SAVE_LIBS"
199                 ],
200                 [AM_PATH_GPGME([1.0.0], [SAVE_LIBS="$LIBS" LIBS="$LIBS $gpgme_LIBS"
201                         AC_CHECK_LIB(
202                                 [gpgme],
203                                 [gpgme_op_verify],
204                                 [],
205                                 [AC_MSG_FAILURE([--with-signed-boot was given but the test for gpgme failed.])]
206                         )
207                         LIBS="$SAVE_LIBS"],
208                         [AC_MSG_RESULT([$gpgme_PKG_ERRORS])
209                                 AC_MSG_FAILURE([ Consider adjusting PKG_CONFIG_PATH environment variable])
210                         ])
211                 ]
212         )]
213 )
214
215 AS_IF(
216         [test "x$with_signed_boot" = "xyes"],
217         [SAVE_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$CPPFLAGS $gpgme_CFLAGS"
218                 AC_CHECK_HEADERS(
219                         [gpgme.h],
220                         [],
221                         [AC_MSG_FAILURE([ --with-signed-boot given but gpgme.h not found])]
222                 )
223                 CPPFLAGS="$SAVE_CPPFLAGS"
224         ]
225 )
226
227 AM_CONDITIONAL([WITH_GPGME], [test "x$with_signed_boot" = "xyes"])
228
229 AC_ARG_VAR(
230         [lockdown_file],
231         [Location of authorized signature file [default = "/etc/pb-lockdown"]]
232 )
233 AS_IF([test "x$lockdown_file" = x], [lockdown_file="/etc/pb-lockdown"])
234 AC_DEFINE_UNQUOTED(LOCKDOWN_FILE, "$lockdown_file", [Lockdown file location])
235
236 AC_ARG_ENABLE(
237         [busybox],
238         [AS_HELP_STRING(
239                 [--enable-busybox],
240                 [build programs with extra support for busybox [default=no]])
241         ],
242         [],
243         [enable_busybox=no]
244 )
245 AM_CONDITIONAL([ENABLE_BUSYBOX], [test "x$enable_busybox" = "xyes"])
246 AS_IF([test "x$enable_busybox" = "xyes"],
247       [AC_DEFINE(WITH_BUSYBOX, 1, [Busybox environment enabled])],
248       []
249 )
250
251 AC_ARG_ENABLE(
252         [mtd],
253         [AS_HELP_STRING(
254                 [--enable-mtd],
255                 [Add support for MTD devices on certain platforms [default=no]]
256         )],
257         [],
258         [enable_mtd=no]
259 )
260 AM_CONDITIONAL([ENABLE_MTD], [test "x$enable_mtd" = "xyes"])
261 AS_IF([test "x$enable_mtd" = "xyes"],
262       [AC_DEFINE(MTD_SUPPORT, 1, [Enable MTD support])],
263       []
264 )
265
266 AS_IF(
267         [test "x$enable_mtd" = "xyes"],
268                 AC_CHECK_LIB([flash], [arch_flash_init],
269                         [LIBFLASH_LIBS=-lflash],
270                         [AC_MSG_FAILURE([--enable-mtd requires the libflash library])]
271                 )
272 )
273 AS_IF(
274         [test "x$enable_mtd" = "xyes"],
275         [SAVE_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$CPPFLAGS $libflash_CFLAGS"
276                 AC_CHECK_HEADERS(
277                         [libflash/libflash.h],
278                         [],
279                         [AC_MSG_FAILURE([--enable-mtd given but libflash/libflash.h not found])]
280                 )
281                 CPPFLAGS="$SAVE_CPPFLAGS"
282         ]
283 )
284
285 AC_ARG_ENABLE(
286         [ps3],
287         [AS_HELP_STRING(
288                 [--enable-ps3],
289                 [build additional programs for the PS3 game console [default=no]]
290         )],
291         [],
292         [enable_ps3=no]
293 )
294 AM_CONDITIONAL([ENABLE_PS3], [test "x$enable_ps3" = "xyes"])
295
296 AC_ARG_ENABLE(
297         [debug],
298         [AS_HELP_STRING([--enable-debug],
299                 [build programs with extra debug info [default=no]]
300         )],
301         [],
302         [enable_debug=check]
303 )
304 #AM_CONDITIONAL([ENABLE_DEBUG], [test "x$enable_debug" = "xyes"])
305
306 AC_ARG_ENABLE(
307         [test-valgrind],
308         [AS_HELP_STRING([--enable-test-valgrind],
309                 [run all tests with valgrind]
310         )],
311 )
312 AM_CONDITIONAL([ENABLE_TEST_VALGRIND], [test "x$enable_test_valgrind" = "xyes"])
313
314 # host program paths
315 AC_DEFUN([DEFINE_HOST_PROG],
316         [
317                 AC_ARG_VAR([HOST_PROG_$1], [Path to "$2" on the host [default $3]])
318                 if test "x$HOST_PROG_$1" = "x"; then
319                         HOST_PROG_$1="$3"
320                 fi
321                 AC_DEFINE_UNQUOTED(HOST_PROG_$1, ["$HOST_PROG_$1"],
322                                 [Path to "$2" on the host])
323         ])
324
325 DEFINE_HOST_PROG(CP, cp, [/bin/cp])
326 DEFINE_HOST_PROG(KEXEC, kexec, [/sbin/kexec])
327 DEFINE_HOST_PROG(MOUNT, mount, [/bin/mount])
328 DEFINE_HOST_PROG(SHUTDOWN, shutdown, [/sbin/shutdown])
329 DEFINE_HOST_PROG(SFTP, sftp, [/usr/bin/sftp])
330 DEFINE_HOST_PROG(TFTP, tftp, [/usr/bin/tftp])
331 DEFINE_HOST_PROG(UMOUNT, umount, [/bin/umount])
332 DEFINE_HOST_PROG(WGET, wget, [/usr/bin/wget])
333 DEFINE_HOST_PROG(IP, ip, [/sbin/ip])
334 DEFINE_HOST_PROG(UDHCPC, udhcpc, [/sbin/udhcpc])
335 DEFINE_HOST_PROG(VGSCAN, vgscan, [/usr/sbin/vgscan])
336 DEFINE_HOST_PROG(VGCHANGE, vgchange, [/usr/sbin/vgchange])
337 DEFINE_HOST_PROG(PB_PLUGIN, pb-plugin, [/usr/sbin/pb-plugin])
338 DEFINE_HOST_PROG(PB_EXEC, pb-exec, [/usr/sbin/pb-exec])
339 DEFINE_HOST_PROG(SH, sh, [/bin/sh])
340
341 AC_ARG_WITH(
342     [tftp],
343     [AS_HELP_STRING([--with-tftp=TYPE],
344         [Use TYPE-type ftp client (either hpa or busybox) [default=runtime-check]]
345     )],
346     [],
347     [with_tftp=detect]
348 )
349
350 case x$with_tftp in
351 'xhpa')
352     tftp_type='TFTP_TYPE_HPA'
353     ;;
354 'xbusybox')
355     tftp_type='TFTP_TYPE_BUSYBOX'
356     ;;
357 *)
358     tftp_type='TFTP_TYPE_UNKNOWN'
359     ;;
360 esac
361
362 AC_DEFINE_UNQUOTED(TFTP_TYPE, $tftp_type, [tftp client type])
363
364 default_cflags="--std=gnu99 -g \
365         -Wall -W -Wunused -Wstrict-prototypes -Wmissing-prototypes \
366         -Wmissing-declarations -Wredundant-decls"
367
368 AC_ARG_ENABLE(
369         [werror],
370         [AS_HELP_STRING([--enable-werror],
371                 [build programs with -Werror]
372         )],
373         [default_cflags="$default_cflags -Werror"]
374 )
375
376 AS_IF(
377         [test "x$enable_debug" = "xyes"],
378         [
379                 AC_SUBST([DEFAULT_CFLAGS], ["$default_cflags -O0"])
380                 AC_SUBST([DEFAULT_CPPFLAGS], ["-DDEBUG"])
381         ],
382         [
383                 AC_SUBST([DEFAULT_CFLAGS], ["$default_cflags -O2"])
384                 AC_SUBST([DEFAULT_CPPFLAGS], ["-DNDEBUG"])
385         ]
386 )
387  
388 AC_SUBST([UDEV_LIBS])
389 AC_SUBST([DEVMAPPER_LIBS])
390 AC_SUBST([FDT_LIBS])
391 AC_SUBST([LIBFLASH_LIBS])
392 AC_SUBST([LIBTOOL_DEPS])
393 AC_SUBST([DESTDIR])
394 AC_SUBST([pkgsysconfdir], ["${sysconfdir}/${package}"])
395
396 AC_CONFIG_HEADERS([config.h])
397 AC_CONFIG_FILES([
398         Makefile
399         po/Makefile.in
400 ])
401
402 AC_OUTPUT