]> git.ozlabs.org Git - petitboot/blob - configure.ac.in
discover/network: In static config mode, only configure defined interfaces
[petitboot] / configure.ac.in
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], [@version@], [Geoff Levand <geoff@infradead.org>])
18
19 AC_CONFIG_MACRO_DIR([m4])
20
21 AC_PREFIX_DEFAULT([/usr/local])
22
23 AS_IF([test "x$CFLAGS" = "x"], [AC_SUBST([CFLAGS], [""])])
24
25 AC_PROG_CC
26 AC_PROG_LEX
27 AC_PROG_YACC
28 AC_PROG_INSTALL
29
30 AM_INIT_AUTOMAKE
31 LT_INIT
32
33 AX_WITH_CURSES
34 AX_WITH_CURSES_MENU
35 AX_WITH_CURSES_FORM
36
37 AM_CONDITIONAL([WITH_NCURSES], [test "x$ax_cv_curses" = "xyes"])
38
39 if test "x$ax_cv_curses" = xyes; then
40         if test "x$ax_cv_menu" != xyes; then
41                 AC_MSG_ERROR([--with-ncurses requires the ncurses menu library])
42         fi
43         if test "x$ax_cv_form" != xyes; then
44                 AC_MSG_ERROR([--with-ncurses requires the ncurses form library])
45         fi
46 fi
47
48 AC_CHECK_LIB([udev], [udev_new],
49         [],
50         [AC_MSG_FAILURE([The libudev development library is required by petitboot.  Try installing the package libudev-dev or libudev-devel.])]
51 )
52
53 AC_CHECK_HEADERS([stdarg.h])
54 AC_CHECK_HEADERS([varargs.h])
55
56 dnl Checking for va_copy availability
57 AC_MSG_CHECKING([for va_copy])
58 AC_TRY_LINK([#include <stdarg.h>
59 va_list ap1,ap2;], [va_copy(ap1,ap2);],
60 have_va_copy=yes,
61 have_va_copy=no)
62 AC_MSG_RESULT($have_va_copy)
63 if test x"$have_va_copy" = x"yes"; then
64     AC_DEFINE(HAVE_VA_COPY,1,[Whether va_copy() is available])
65 else
66     AC_MSG_CHECKING([for __va_copy])
67     AC_TRY_LINK([#include <stdarg.h>
68     va_list ap1,ap2;], [__va_copy(ap1,ap2);],
69     have___va_copy=yes,
70     have___va_copy=no)
71     AC_MSG_RESULT($have___va_copy)
72     if test x"$have___va_copy" = x"yes"; then
73         AC_DEFINE(HAVE___VA_COPY,1,[Whether __va_copy() is available])
74     fi
75 fi
76
77 AC_ARG_WITH(
78         [twin-x11],
79         [AS_HELP_STRING([--with-twin-x11],
80                 [build x11 GUI programs using the twin window system [default=yes]]
81         )],
82         [],
83         [with_twin_x11=yes]
84 )
85 AM_CONDITIONAL([WITH_TWIN_X11], [test "x$with_twin_x11" = "xyes"])
86
87 AC_ARG_WITH(
88         [twin-fbdev],
89         [AS_HELP_STRING(
90                 [--with-twin-fbdev],
91                 [build frame buffer GUI programs using the twin window system [default=no]]
92         )],
93         [],
94         [with_twin_fbdev=yes]
95 )
96 AM_CONDITIONAL([WITH_TWIN_FBDEV], [test "x$with_twin_fbdev" = "xyes"])
97
98 AM_CONDITIONAL(
99         [WITH_TWIN],
100         [test "x$with_twin_x11" = "xyes" || test "x$with_twin_fbdev" = "xyes"])
101
102 AS_IF(
103         [test "x$with_twin_x11" = "xyes" || test "x$with_twin_fbdev" = "xyes"],
104         [PKG_CHECK_MODULES(
105                 [twin],
106                 [libtwin],
107                 [SAVE_LIBS="$LIBS" LIBS="$LIBS $twin_LIBS"
108                         AC_CHECK_LIB(
109                                 [twin],
110                                 [twin_feature_init],
111                                 [],
112                                 [AC_MSG_FAILURE([--with-twin was given but the test for libtwin failed.])]
113                         )
114                         LIBS="$SAVE_LIBS"
115                 ],
116                 [AC_MSG_RESULT([$twin_PKG_ERRORS])
117                         AC_MSG_FAILURE([ Consider adjusting PKG_CONFIG_PATH environment variable])
118                 ]
119         )]
120 )
121
122 AS_IF(
123         [test "x$with_twin_x11" = "xyes"],
124         [SAVE_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$CPPFLAGS $twin_CFLAGS"
125                 AC_CHECK_HEADERS(
126                         [libtwin/twin_x11.h],
127                         [],
128                         [AC_MSG_FAILURE([ --with-twin-x11 given but libtwin/twin_x11.h not found])]
129                 )
130                 CPPFLAGS="$SAVE_CPPFLAGS"
131         ]
132 )
133
134 AS_IF(
135         [test "x$with_twin_fbdev" = "xyes"],
136         [SAVE_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$CPPFLAGS $twin_CFLAGS"
137                 AC_CHECK_HEADERS(
138                         [libtwin/twin_fbdev.h],
139                         [],
140                         [AC_MSG_FAILURE([ --with-twin-fbdev given but libtwin/twin_fbdev.h not found])]
141                 )
142                 CPPFLAGS="$SAVE_CPPFLAGS"
143         ]
144 )
145
146 AC_ARG_ENABLE(
147         [busybox],
148         [AS_HELP_STRING(
149                 [--enable-busybox],
150                 [build programs with extra support for busybox [default=no]])
151         ],
152         [],
153         [enable_busybox=no]
154 )
155 #AM_CONDITIONAL([ENABLE_BUSYBOX], [test "x$enable_busybox" = "xyes"])
156
157 AC_ARG_ENABLE(
158         [ps3],
159         [AS_HELP_STRING(
160                 [--enable-ps3],
161                 [build additional programs for the PS3 game console [default=no]]
162         )],
163         [],
164         [enable_ps3=no]
165 )
166 AM_CONDITIONAL([ENABLE_PS3], [test "x$enable_ps3" = "xyes"])
167
168 AC_ARG_ENABLE(
169         [debug],
170         [AS_HELP_STRING([--enable-debug],
171                 [build programs with extra debug info [default=no]]
172         )],
173         [],
174         [enable_debug=check]
175 )
176 #AM_CONDITIONAL([ENABLE_DEBUG], [test "x$enable_debug" = "xyes"])
177
178 AC_ARG_ENABLE(
179         [test-valgrind],
180         [AS_HELP_STRING([--enable-test-valgrind],
181                 [run all tests with valgrind]
182         )],
183 )
184 AM_CONDITIONAL([ENABLE_TEST_VALGRIND], [test "x$enable_test_valgrind" = "xyes"])
185
186 # host program paths
187 AC_DEFUN([DEFINE_HOST_PROG],
188         [
189                 AC_ARG_VAR([HOST_PROG_$1], [Path to "$2" on the host [default $3]])
190                 if test "x$HOST_PROG_$1" = "x"; then
191                         HOST_PROG_$1="$3"
192                 fi
193                 AC_DEFINE_UNQUOTED(HOST_PROG_$1, ["$HOST_PROG_$1"],
194                                 [Path to "$2" on the host])
195         ])
196
197 DEFINE_HOST_PROG(CP, cp, [/bin/cp])
198 DEFINE_HOST_PROG(KEXEC, kexec, [/sbin/kexec])
199 DEFINE_HOST_PROG(MOUNT, mount, [/bin/mount])
200 DEFINE_HOST_PROG(SHUTDOWN, shutdown, [/sbin/shutdown])
201 DEFINE_HOST_PROG(SFTP, sftp, [/usr/bin/sftp])
202 DEFINE_HOST_PROG(TFTP, tftp, [/usr/bin/tftp])
203 DEFINE_HOST_PROG(UMOUNT, umount, [/bin/umount])
204 DEFINE_HOST_PROG(WGET, wget, [/usr/bin/wget])
205 DEFINE_HOST_PROG(IP, ip, [/sbin/ip])
206 DEFINE_HOST_PROG(UDHCPC, udhcpc, [/sbin/udhcpc])
207
208 AC_ARG_WITH(
209     [tftp],
210     [AS_HELP_STRING([--with-tftp=TYPE],
211         [Use TYPE-type ftp client (either hpa or busybox) [default=runtime-check]]
212     )],
213     [],
214     [with_tftp=detect]
215 )
216
217 case x$with_tftp in
218 'xhpa')
219     tftp_type='TFTP_TYPE_HPA'
220     ;;
221 'xbusybox')
222     tftp_type='TFTP_TYPE_BUSYBOX'
223     ;;
224 *)
225     tftp_type='TFTP_TYPE_UNKNOWN'
226     ;;
227 esac
228
229 AC_DEFINE_UNQUOTED(TFTP_TYPE, $tftp_type, [tftp client type])
230
231 default_cflags="--std=gnu99 -g \
232         -Wall -W -Wunused -Wstrict-prototypes -Wmissing-prototypes \
233         -Wmissing-declarations -Wredundant-decls"
234
235 AC_ARG_ENABLE(
236         [werror],
237         [AS_HELP_STRING([--enable-werror],
238                 [build programs with -Werror]
239         )],
240         [default_cflags="$default_cflags -Werror"]
241 )
242
243 AS_IF(
244         [test "x$enable_debug" = "xyes"],
245         [AC_SUBST([DEFAULT_CFLAGS], ["$default_cflags -O0 -DDEBUG"])],
246         [AC_SUBST([DEFAULT_CFLAGS], ["$default_cflags -O2 -DNDEBUG"])]
247 )
248  
249
250 AC_SUBST([LIBTOOL_DEPS])
251 AC_SUBST([DESTDIR])
252 AC_SUBST([pkgsysconfdir], ["${sysconfdir}/${package}"])
253
254 AC_CONFIG_HEADERS([config.h])
255 AC_CONFIG_FILES([
256         Makefile
257         discover/Makefile
258         discover/grub2/Makefile
259         lib/Makefile
260         man/Makefile
261         test/Makefile
262         test/lib/Makefile
263         test/parser/Makefile
264         test/urls/Makefile
265         ui/Makefile
266         ui/common/Makefile
267         ui/ncurses/Makefile
268         ui/test/Makefile
269         ui/twin/Makefile
270         utils/Makefile
271 ])
272
273 AC_OUTPUT