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