utils/hooks: Write offb device address to device tree
[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 AC_ARG_WITH([fdt],
61         AS_HELP_STRING([--without-fdt],
62                 [Build without libfdt (default: no)]))
63
64 AS_IF([test "x$with_fdt" != "xno"],
65         AC_CHECK_LIB([fdt], [fdt_check_header],
66                 [FDT_LIBS=-lfdt; have_libfdt=yes]))
67
68 AM_CONDITIONAL([HAVE_LIBFDT], [test x"$have_libfdt" = xyes])
69
70 AC_CHECK_HEADERS([stdarg.h])
71 AC_CHECK_HEADERS([varargs.h])
72
73 dnl Checking for va_copy availability
74 AC_MSG_CHECKING([for va_copy])
75 AC_TRY_LINK([#include <stdarg.h>
76 va_list ap1,ap2;], [va_copy(ap1,ap2);],
77 have_va_copy=yes,
78 have_va_copy=no)
79 AC_MSG_RESULT($have_va_copy)
80 if test x"$have_va_copy" = x"yes"; then
81     AC_DEFINE(HAVE_VA_COPY,1,[Whether va_copy() is available])
82 else
83     AC_MSG_CHECKING([for __va_copy])
84     AC_TRY_LINK([#include <stdarg.h>
85     va_list ap1,ap2;], [__va_copy(ap1,ap2);],
86     have___va_copy=yes,
87     have___va_copy=no)
88     AC_MSG_RESULT($have___va_copy)
89     if test x"$have___va_copy" = x"yes"; then
90         AC_DEFINE(HAVE___VA_COPY,1,[Whether __va_copy() is available])
91     fi
92 fi
93
94 AC_ARG_WITH(
95         [twin-x11],
96         [AS_HELP_STRING([--with-twin-x11],
97                 [build x11 GUI programs using the twin window system [default=yes]]
98         )],
99         [],
100         [with_twin_x11=yes]
101 )
102 AM_CONDITIONAL([WITH_TWIN_X11], [test "x$with_twin_x11" = "xyes"])
103
104 AC_ARG_WITH(
105         [twin-fbdev],
106         [AS_HELP_STRING(
107                 [--with-twin-fbdev],
108                 [build frame buffer GUI programs using the twin window system [default=no]]
109         )],
110         [],
111         [with_twin_fbdev=yes]
112 )
113 AM_CONDITIONAL([WITH_TWIN_FBDEV], [test "x$with_twin_fbdev" = "xyes"])
114
115 AM_CONDITIONAL(
116         [WITH_TWIN],
117         [test "x$with_twin_x11" = "xyes" || test "x$with_twin_fbdev" = "xyes"])
118
119 AS_IF(
120         [test "x$with_twin_x11" = "xyes" || test "x$with_twin_fbdev" = "xyes"],
121         [PKG_CHECK_MODULES(
122                 [twin],
123                 [libtwin],
124                 [SAVE_LIBS="$LIBS" LIBS="$LIBS $twin_LIBS"
125                         AC_CHECK_LIB(
126                                 [twin],
127                                 [twin_feature_init],
128                                 [],
129                                 [AC_MSG_FAILURE([--with-twin was given but the test for libtwin failed.])]
130                         )
131                         LIBS="$SAVE_LIBS"
132                 ],
133                 [AC_MSG_RESULT([$twin_PKG_ERRORS])
134                         AC_MSG_FAILURE([ Consider adjusting PKG_CONFIG_PATH environment variable])
135                 ]
136         )]
137 )
138
139 AS_IF(
140         [test "x$with_twin_x11" = "xyes"],
141         [SAVE_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$CPPFLAGS $twin_CFLAGS"
142                 AC_CHECK_HEADERS(
143                         [libtwin/twin_x11.h],
144                         [],
145                         [AC_MSG_FAILURE([ --with-twin-x11 given but libtwin/twin_x11.h not found])]
146                 )
147                 CPPFLAGS="$SAVE_CPPFLAGS"
148         ]
149 )
150
151 AS_IF(
152         [test "x$with_twin_fbdev" = "xyes"],
153         [SAVE_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$CPPFLAGS $twin_CFLAGS"
154                 AC_CHECK_HEADERS(
155                         [libtwin/twin_fbdev.h],
156                         [],
157                         [AC_MSG_FAILURE([ --with-twin-fbdev given but libtwin/twin_fbdev.h not found])]
158                 )
159                 CPPFLAGS="$SAVE_CPPFLAGS"
160         ]
161 )
162
163 AC_ARG_ENABLE(
164         [busybox],
165         [AS_HELP_STRING(
166                 [--enable-busybox],
167                 [build programs with extra support for busybox [default=no]])
168         ],
169         [],
170         [enable_busybox=no]
171 )
172 #AM_CONDITIONAL([ENABLE_BUSYBOX], [test "x$enable_busybox" = "xyes"])
173
174 AC_ARG_ENABLE(
175         [mtd],
176         [AS_HELP_STRING(
177                 [--enable-mtd],
178                 [Add support for MTD devices on certain platforms [default=no]]
179         )],
180         [],
181         [enable_mtd=no]
182 )
183 AM_CONDITIONAL([ENABLE_MTD], [test "x$enable_mtd" = "xyes"])
184 AS_IF([test "x$enable_mtd" = "xyes"],
185       [AC_DEFINE(MTD_SUPPORT, 1, [Enable MTD support])],
186       []
187 )
188
189 AC_ARG_ENABLE(
190         [ps3],
191         [AS_HELP_STRING(
192                 [--enable-ps3],
193                 [build additional programs for the PS3 game console [default=no]]
194         )],
195         [],
196         [enable_ps3=no]
197 )
198 AM_CONDITIONAL([ENABLE_PS3], [test "x$enable_ps3" = "xyes"])
199
200 AC_ARG_ENABLE(
201         [debug],
202         [AS_HELP_STRING([--enable-debug],
203                 [build programs with extra debug info [default=no]]
204         )],
205         [],
206         [enable_debug=check]
207 )
208 #AM_CONDITIONAL([ENABLE_DEBUG], [test "x$enable_debug" = "xyes"])
209
210 AC_ARG_ENABLE(
211         [test-valgrind],
212         [AS_HELP_STRING([--enable-test-valgrind],
213                 [run all tests with valgrind]
214         )],
215 )
216 AM_CONDITIONAL([ENABLE_TEST_VALGRIND], [test "x$enable_test_valgrind" = "xyes"])
217
218 # host program paths
219 AC_DEFUN([DEFINE_HOST_PROG],
220         [
221                 AC_ARG_VAR([HOST_PROG_$1], [Path to "$2" on the host [default $3]])
222                 if test "x$HOST_PROG_$1" = "x"; then
223                         HOST_PROG_$1="$3"
224                 fi
225                 AC_DEFINE_UNQUOTED(HOST_PROG_$1, ["$HOST_PROG_$1"],
226                                 [Path to "$2" on the host])
227         ])
228
229 DEFINE_HOST_PROG(CP, cp, [/bin/cp])
230 DEFINE_HOST_PROG(KEXEC, kexec, [/sbin/kexec])
231 DEFINE_HOST_PROG(MOUNT, mount, [/bin/mount])
232 DEFINE_HOST_PROG(SHUTDOWN, shutdown, [/sbin/shutdown])
233 DEFINE_HOST_PROG(SFTP, sftp, [/usr/bin/sftp])
234 DEFINE_HOST_PROG(TFTP, tftp, [/usr/bin/tftp])
235 DEFINE_HOST_PROG(UMOUNT, umount, [/bin/umount])
236 DEFINE_HOST_PROG(WGET, wget, [/usr/bin/wget])
237 DEFINE_HOST_PROG(IP, ip, [/sbin/ip])
238 DEFINE_HOST_PROG(UDHCPC, udhcpc, [/sbin/udhcpc])
239
240 AC_ARG_WITH(
241     [tftp],
242     [AS_HELP_STRING([--with-tftp=TYPE],
243         [Use TYPE-type ftp client (either hpa or busybox) [default=runtime-check]]
244     )],
245     [],
246     [with_tftp=detect]
247 )
248
249 case x$with_tftp in
250 'xhpa')
251     tftp_type='TFTP_TYPE_HPA'
252     ;;
253 'xbusybox')
254     tftp_type='TFTP_TYPE_BUSYBOX'
255     ;;
256 *)
257     tftp_type='TFTP_TYPE_UNKNOWN'
258     ;;
259 esac
260
261 AC_DEFINE_UNQUOTED(TFTP_TYPE, $tftp_type, [tftp client type])
262
263 default_cflags="--std=gnu99 -g \
264         -Wall -W -Wunused -Wstrict-prototypes -Wmissing-prototypes \
265         -Wmissing-declarations -Wredundant-decls"
266
267 AC_ARG_ENABLE(
268         [werror],
269         [AS_HELP_STRING([--enable-werror],
270                 [build programs with -Werror]
271         )],
272         [default_cflags="$default_cflags -Werror"]
273 )
274
275 AS_IF(
276         [test "x$enable_debug" = "xyes"],
277         [
278                 AC_SUBST([DEFAULT_CFLAGS], ["$default_cflags -O0"])
279                 AC_SUBST([DEFAULT_CPPFLAGS], ["-DDEBUG"])
280         ],
281         [
282                 AC_SUBST([DEFAULT_CFLAGS], ["$default_cflags -O2"])
283                 AC_SUBST([DEFAULT_CPPFLAGS], ["-DNDEBUG"])
284         ]
285 )
286  
287 AC_SUBST([UDEV_LIBS])
288 AC_SUBST([FDT_LIBS])
289 AC_SUBST([LIBTOOL_DEPS])
290 AC_SUBST([DESTDIR])
291 AC_SUBST([pkgsysconfdir], ["${sysconfdir}/${package}"])
292
293 AC_CONFIG_HEADERS([config.h])
294 AC_CONFIG_FILES([
295         Makefile
296         po/Makefile.in
297 ])
298
299 AC_OUTPUT