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