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