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