]> git.ozlabs.org Git - petitboot/blob - configure.ac
discover/grub2: Allow to separate the --id argument using a space char
[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 "$USE_NLS" = "yes" -a -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_ENABLE(
80         [crypt],
81         [AS_HELP_STRING(
82                 [--enable-crypt],
83                 [Include crypt support to enable password use [default=no]]
84         )],
85         [],
86         [enable_crypt=no]
87 )
88 AM_CONDITIONAL([ENABLE_CRYPT], [test "x$enable_crypt" = "xyes"])
89 AS_IF([test "x$enable_crypt" = "xyes"],
90       [AC_DEFINE(CRYPT_SUPPORT, 1, [Enable crypt/password support])],
91       []
92 )
93 AS_IF([test "x$enable_crypt" = "xyes"],
94         AC_CHECK_LIB([crypt], [crypt],
95                 [CRYPT_LIBS=-lcrypt],
96                 [AC_MSG_FAILURE([shadow/crypt libs required])]
97         )
98 )
99
100 AC_ARG_WITH([fdt],
101         AS_HELP_STRING([--without-fdt],
102                 [Build without libfdt (default: no)]))
103
104 AS_IF([test "x$with_fdt" != "xno"],
105         AC_CHECK_LIB([fdt], [fdt_check_header],
106                 [FDT_LIBS=-lfdt; have_libfdt=yes]))
107
108 AM_CONDITIONAL([HAVE_LIBFDT], [test x"$have_libfdt" = xyes])
109
110 AC_CHECK_HEADERS([stdarg.h])
111 AC_CHECK_HEADERS([varargs.h])
112
113 dnl Checking for va_copy availability
114 AC_MSG_CHECKING([for va_copy])
115 AC_TRY_LINK([#include <stdarg.h>
116 va_list ap1,ap2;], [va_copy(ap1,ap2);],
117 have_va_copy=yes,
118 have_va_copy=no)
119 AC_MSG_RESULT($have_va_copy)
120 if test x"$have_va_copy" = x"yes"; then
121     AC_DEFINE(HAVE_VA_COPY,1,[Whether va_copy() is available])
122 else
123     AC_MSG_CHECKING([for __va_copy])
124     AC_TRY_LINK([#include <stdarg.h>
125     va_list ap1,ap2;], [__va_copy(ap1,ap2);],
126     have___va_copy=yes,
127     have___va_copy=no)
128     AC_MSG_RESULT($have___va_copy)
129     if test x"$have___va_copy" = x"yes"; then
130         AC_DEFINE(HAVE___VA_COPY,1,[Whether __va_copy() is available])
131     fi
132 fi
133
134 AC_ARG_WITH(
135         [twin-x11],
136         [AS_HELP_STRING([--with-twin-x11],
137                 [build x11 GUI programs using the twin window system [default=yes]]
138         )],
139         [],
140         [with_twin_x11=no]
141 )
142 AM_CONDITIONAL([WITH_TWIN_X11], [test "x$with_twin_x11" = "xyes"])
143
144 AC_ARG_WITH(
145         [twin-fbdev],
146         [AS_HELP_STRING(
147                 [--with-twin-fbdev],
148                 [build frame buffer GUI programs using the twin window system [default=no]]
149         )],
150         [],
151         [with_twin_fbdev=no]
152 )
153 AM_CONDITIONAL([WITH_TWIN_FBDEV], [test "x$with_twin_fbdev" = "xyes"])
154
155 AM_CONDITIONAL(
156         [WITH_TWIN],
157         [test "x$with_twin_x11" = "xyes" || test "x$with_twin_fbdev" = "xyes"])
158
159 AS_IF(
160         [test "x$with_twin_x11" != "xyes" && \
161                 test "x$with_twin_fbdev" != "xyes" && \
162                 test "x$ax_cv_curses" != "xyes"],
163         [AC_MSG_WARN([ No user interface programs configured.  Consider using --with-ncurses, --with-twin-x11 or --with-twin-fbdev'])]
164 )
165
166 AS_IF(
167         [test "x$with_twin_x11" = "xyes" || test "x$with_twin_fbdev" = "xyes"],
168         [PKG_CHECK_MODULES(
169                 [twin],
170                 [libtwin],
171                 [SAVE_LIBS="$LIBS" LIBS="$LIBS $twin_LIBS"
172                         AC_CHECK_LIB(
173                                 [twin],
174                                 [twin_feature_init],
175                                 [],
176                                 [AC_MSG_FAILURE([--with-twin was given but the test for libtwin failed.])]
177                         )
178                         LIBS="$SAVE_LIBS"
179                 ],
180                 [AC_MSG_RESULT([$twin_PKG_ERRORS])
181                         AC_MSG_FAILURE([ Consider adjusting PKG_CONFIG_PATH environment variable])
182                 ]
183         )]
184 )
185
186 AS_IF(
187         [test "x$with_twin_x11" = "xyes"],
188         [SAVE_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$CPPFLAGS $twin_CFLAGS"
189                 AC_CHECK_HEADERS(
190                         [libtwin/twin_x11.h],
191                         [],
192                         [AC_MSG_FAILURE([ --with-twin-x11 given but libtwin/twin_x11.h not found])]
193                 )
194                 CPPFLAGS="$SAVE_CPPFLAGS"
195         ]
196 )
197
198 AS_IF(
199         [test "x$with_twin_fbdev" = "xyes"],
200         [SAVE_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$CPPFLAGS $twin_CFLAGS"
201                 AC_CHECK_HEADERS(
202                         [libtwin/twin_fbdev.h],
203                         [],
204                         [AC_MSG_FAILURE([ --with-twin-fbdev given but libtwin/twin_fbdev.h not found])]
205                 )
206                 CPPFLAGS="$SAVE_CPPFLAGS"
207         ]
208 )
209
210 AC_ARG_WITH(
211         [signed-boot],
212         [AS_HELP_STRING([--with-signed-boot=@<:@no|yes|gpgme|openssl@:>@],
213                         [Build kernel signature checking support with specified
214                          crypto pacakge. A @<:@yes@:>@ value will first check
215                          for gpgme then openssl and use the first found.
216                          @<:@default=no@:>@]
217         )],
218         [AS_IF([test "x$with_signed_boot" = xno],[],
219                [test "x$with_signed_boot" = xyes],
220                         [AM_PATH_GPGME([1.0.0],
221                                 [sboot=gpgme],
222                                 [AX_CHECK_OPENSSL(
223                                         [sboot=openssl],
224                                         [AC_MSG_FAILURE([--with-signed-boot=yes specified but gpgme or openssl not found])]
225                                 )]
226                         )],
227                [test "x$with_signed_boot" = xgpgme],
228                         [AM_PATH_GPGME([1.0.0],
229                                 [sboot=gpgme],
230                                 [AC_MSG_FAILURE([--with-signed-boot=gpgme specified but gpgme not found])]
231                         )],
232                [test "x$with_signed_boot" = xopenssl],
233                         [AX_CHECK_OPENSSL(
234                                 [sboot=openssl],
235                                 [AC_MSG_FAILURE([--with-signed-boot=openssl specified but openssl not found])]
236                         )],
237                [AC_MSG_FAILURE([--with-signed-boot given invalid option: $with_signed_boot])]
238         )],
239         [with_signed_boot=no]
240 )
241
242 AM_CONDITIONAL([WITH_GPGME], [test "x$sboot" = xgpgme])
243 AM_CONDITIONAL([WITH_OPENSSL], [test "x$sboot" = xopenssl])
244 AM_CONDITIONAL([WITH_SIGNED_BOOT], [test "x$with_signed_boot" != xno])
245 AM_COND_IF([WITH_SIGNED_BOOT],
246            [AC_DEFINE([SIGNED_BOOT], 1, [Define if you have signed boot enabled])],
247            [])
248
249 AC_ARG_VAR(
250         [lockdown_file],
251         [Location of authorized signature file [default = "/etc/pb-lockdown"]]
252 )
253 AS_IF([test "x$lockdown_file" = x], [lockdown_file="/etc/pb-lockdown"])
254 AC_DEFINE_UNQUOTED(LOCKDOWN_FILE, "$lockdown_file", [Lockdown file location])
255
256 AC_ARG_VAR(
257         [KEYRING_PATH],
258         [Path to keyring (gpgme home dir) @<:@default="/etc/gpg"@:>@]
259 )
260 AS_IF([test "x$KEYRING_PATH" = x], [KEYRING_PATH="/etc/gpg"])
261 AC_DEFINE_UNQUOTED(KEYRING_PATH, "$KEYRING_PATH", [gpgme home dir])
262
263 AC_ARG_VAR(
264         [VERIFY_DIGEST],
265         [Signed boot signature verification digest algorithm to use (only valid in openssl) @<:@default="sha256"@:>@]
266 )
267 AS_IF([test "x$VERIFY_DIGEST" = x], [VERIFY_DIGEST="sha256"])
268 AC_DEFINE_UNQUOTED(VERIFY_DIGEST, "$VERIFY_DIGEST", [openssl verify dgst])
269
270 AC_ARG_ENABLE([hard-lockdown],
271               [AS_HELP_STRING([--enable-hard-lockdown],
272                               [if signed boot configured, the absence of the
273                                LOCKDOWN_FILE does not disable signed boot at
274                                runtime @<:@default=no@:>@])],
275               [AC_DEFINE(HARD_LOCKDOWN, 1, [Enable hard lockdown])],
276               [])
277
278 AC_ARG_ENABLE(
279         [busybox],
280         [AS_HELP_STRING(
281                 [--enable-busybox],
282                 [build programs with extra support for busybox [default=no]])
283         ],
284         [],
285         [enable_busybox=no]
286 )
287 AM_CONDITIONAL([ENABLE_BUSYBOX], [test "x$enable_busybox" = "xyes"])
288 AS_IF([test "x$enable_busybox" = "xyes"],
289       [AC_DEFINE(WITH_BUSYBOX, 1, [Busybox environment enabled])],
290       []
291 )
292
293 AC_ARG_ENABLE(
294         [mtd],
295         [AS_HELP_STRING(
296                 [--enable-mtd],
297                 [Add support for MTD devices on certain platforms [default=no]]
298         )],
299         [],
300         [enable_mtd=no]
301 )
302 AM_CONDITIONAL([ENABLE_MTD], [test "x$enable_mtd" = "xyes"])
303 AS_IF([test "x$enable_mtd" = "xyes"],
304       [AC_DEFINE(MTD_SUPPORT, 1, [Enable MTD support])],
305       []
306 )
307
308 AS_IF(
309         [test "x$enable_mtd" = "xyes"],
310                 AC_CHECK_LIB([flash], [arch_flash_init],
311                         [LIBFLASH_LIBS=-lflash],
312                         [AC_MSG_FAILURE([--enable-mtd requires the libflash library])]
313                 )
314 )
315 AS_IF(
316         [test "x$enable_mtd" = "xyes"],
317         [SAVE_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$CPPFLAGS $libflash_CFLAGS"
318                 AC_CHECK_HEADERS(
319                         [libflash/libflash.h],
320                         [],
321                         [AC_MSG_FAILURE([--enable-mtd given but libflash/libflash.h not found])]
322                 )
323                 CPPFLAGS="$SAVE_CPPFLAGS"
324         ]
325 )
326
327 # platform choice
328 AC_ARG_ENABLE(
329         [platform-all],
330         [AS_HELP_STRING(
331                 [--enable-platform-all],
332                 [build support for all platforms [default=no]]
333         )]
334 )
335 AS_IF(
336         [test "x$enable_platform_all" = "xyes"],
337         [enable_platform_arm64="yes"; enable_platform_powerpc="yes"; enable_platform_ps3="yes"]
338 )
339
340 AC_ARG_ENABLE(
341         [platform-auto],
342         [AS_HELP_STRING(
343                 [--enable-platform-auto],
344                 [auto detect platform support to build [default=yes]]
345         )],
346         [],
347         [enable_platform_auto="yes"]
348 )
349 AS_IF(
350         [test "x$enable_platform_auto" = "xyes"],
351         [AS_CASE([$host],
352                 [aarch64-*-*],   [enable_platform_arm64="yes"],
353                 [powerpc*-*-*],  [enable_platform_powerpc="yes"],
354         )]
355 )
356
357 AC_ARG_ENABLE(
358         [platform-arm64],
359         [AS_HELP_STRING(
360                 [--enable-platform-arm64],
361                 [build support for arm64 platforms [default=no]]
362         )]
363 )
364 AM_CONDITIONAL([PLATFORM_ARM64], [test "x$enable_platform_arm64" = "xyes"])
365
366 AC_ARG_ENABLE(
367         [platform-powerpc],
368         [AS_HELP_STRING(
369                 [--enable-platform-powerpc],
370                 [build support for powerpc platforms [default=no]]
371         )]
372 )
373 AM_CONDITIONAL([PLATFORM_POWERPC], [test "x$enable_platform_powerpc" = "xyes"])
374
375 AC_ARG_ENABLE(
376         [platform-ps3],
377         [AS_HELP_STRING(
378                 [--enable-platform-ps3],
379                 [build support for the PS3 game console [default=no]]
380         )])
381 AM_CONDITIONAL([PLATFORM_PS3], [test "x$enable_platform_ps3" = "xyes"])
382
383 AC_ARG_ENABLE(
384         [debug],
385         [AS_HELP_STRING([--enable-debug],
386                 [build programs with extra debug info [default=no]]
387         )],
388         [],
389         [enable_debug=check]
390 )
391
392 AC_ARG_ENABLE(
393         [test-valgrind],
394         [AS_HELP_STRING([--enable-test-valgrind],
395                 [run all tests with valgrind]
396         )],
397 )
398 AM_CONDITIONAL([ENABLE_TEST_VALGRIND], [test "x$enable_test_valgrind" = "xyes"])
399
400 # host program paths
401 AC_DEFUN([DEFINE_HOST_PROG],
402         [
403                 AC_ARG_VAR([HOST_PROG_$1], [Path to "$2" on the host [default $3]])
404                 if test "x$HOST_PROG_$1" = "x"; then
405                         HOST_PROG_$1="$3"
406                 fi
407                 AC_DEFINE_UNQUOTED(HOST_PROG_$1, ["$HOST_PROG_$1"],
408                                 [Path to "$2" on the host])
409         ])
410
411 DEFINE_HOST_PROG(CP, cp, [/bin/cp])
412 DEFINE_HOST_PROG(KEXEC, kexec, [/sbin/kexec])
413 DEFINE_HOST_PROG(MOUNT, mount, [/bin/mount])
414 DEFINE_HOST_PROG(SHUTDOWN, shutdown, [/sbin/shutdown])
415 DEFINE_HOST_PROG(SFTP, sftp, [/usr/bin/sftp])
416 DEFINE_HOST_PROG(TFTP, tftp, [/usr/bin/tftp])
417 DEFINE_HOST_PROG(UMOUNT, umount, [/bin/umount])
418 DEFINE_HOST_PROG(WGET, wget, [/usr/bin/wget])
419 DEFINE_HOST_PROG(IP, ip, [/sbin/ip])
420 DEFINE_HOST_PROG(UDHCPC, udhcpc, [/sbin/udhcpc])
421 DEFINE_HOST_PROG(UDHCPC6, udhcpc6, [/usr/bin/udhcpc6])
422 DEFINE_HOST_PROG(VGSCAN, vgscan, [/usr/sbin/vgscan])
423 DEFINE_HOST_PROG(VGCHANGE, vgchange, [/usr/sbin/vgchange])
424 DEFINE_HOST_PROG(PB_PLUGIN, pb-plugin, [/usr/sbin/pb-plugin])
425 DEFINE_HOST_PROG(PB_EXEC, pb-exec, [/usr/sbin/pb-exec])
426 DEFINE_HOST_PROG(SH, sh, [/bin/sh])
427 DEFINE_HOST_PROG(SCSI_RESCAN, scsi-rescan, [/usr/sbin/scsi-rescan])
428 DEFINE_HOST_PROG(DMIDECODE, dmidecode, [/sbin/dmidecode])
429 DEFINE_HOST_PROG(CRYPTSETUP, CRYPTSETUP, [/usr/sbin/cryptsetup])
430
431 AC_ARG_WITH(
432     [tftp],
433     [AS_HELP_STRING([--with-tftp=TYPE],
434         [Use TYPE-type ftp client (either hpa or busybox) [default=runtime-check]]
435     )],
436     [],
437     [with_tftp=detect]
438 )
439
440 case x$with_tftp in
441 'xhpa')
442     tftp_type='TFTP_TYPE_HPA'
443     ;;
444 'xbusybox')
445     tftp_type='TFTP_TYPE_BUSYBOX'
446     ;;
447 *)
448     tftp_type='TFTP_TYPE_UNKNOWN'
449     ;;
450 esac
451
452 AC_DEFINE_UNQUOTED(TFTP_TYPE, $tftp_type, [tftp client type])
453
454 default_cflags="--std=gnu99 -g \
455         -Wall -W -Wunused -Wstrict-prototypes -Wmissing-prototypes \
456         -Wmissing-declarations -Wredundant-decls"
457
458 AC_ARG_ENABLE(
459         [werror],
460         [AS_HELP_STRING([--enable-werror],
461                 [build programs with -Werror]
462         )],
463         [default_cflags="$default_cflags -Werror"]
464 )
465
466 AS_IF(
467         [test "x$enable_debug" = "xyes"],
468         [
469                 AC_SUBST([DEFAULT_CFLAGS], ["$default_cflags -O0"])
470                 AC_SUBST([DEFAULT_CPPFLAGS], ["-DDEBUG"])
471         ],
472         [
473                 AC_SUBST([DEFAULT_CFLAGS], ["$default_cflags -O2"])
474                 AC_SUBST([DEFAULT_CPPFLAGS], ["-DNDEBUG"])
475         ]
476 )
477  
478 AC_SUBST([UDEV_LIBS])
479 AC_SUBST([DEVMAPPER_LIBS])
480 AC_SUBST([CRYPT_LIBS])
481 AC_SUBST([FDT_LIBS])
482 AC_SUBST([LIBFLASH_LIBS])
483 AC_SUBST([LIBTOOL_DEPS])
484 AC_SUBST([DESTDIR])
485 AC_SUBST([pkgsysconfdir], ["${sysconfdir}/${package}"])
486
487 AC_CONFIG_HEADERS([config.h])
488 AC_CONFIG_FILES([
489         Makefile
490         po/Makefile.in
491 ])
492
493 AC_OUTPUT