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