lib/url: Move URL-handling code to lib
[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_INSTALL
27
28 AM_INIT_AUTOMAKE
29 LT_INIT
30
31 AC_CHECK_HEADERS([stdarg.h])
32 AC_CHECK_HEADERS([varargs.h])
33
34 dnl Checking for va_copy availability
35 AC_MSG_CHECKING([for va_copy])
36 AC_TRY_LINK([#include <stdarg.h>
37 va_list ap1,ap2;], [va_copy(ap1,ap2);],
38 have_va_copy=yes,
39 have_va_copy=no)
40 AC_MSG_RESULT($have_va_copy)
41 if test x"$have_va_copy" = x"yes"; then
42     AC_DEFINE(HAVE_VA_COPY,1,[Whether va_copy() is available])
43 else
44     AC_MSG_CHECKING([for __va_copy])
45     AC_TRY_LINK([#include <stdarg.h>
46     va_list ap1,ap2;], [__va_copy(ap1,ap2);],
47     have___va_copy=yes,
48     have___va_copy=no)
49     AC_MSG_RESULT($have___va_copy)
50     if test x"$have___va_copy" = x"yes"; then
51         AC_DEFINE(HAVE___VA_COPY,1,[Whether __va_copy() is available])
52     fi
53 fi
54
55 AC_ARG_WITH(
56         [ncurses],
57         [AS_HELP_STRING([--with-ncurses],
58                 [build text console UI programs using ncurses [default=yes]]
59         )],
60         [],
61         [with_ncurses=yes]
62 )
63 AM_CONDITIONAL([WITH_NCURSES], [test "x$with_ncurses" = "xyes"])
64
65 AC_ARG_WITH(
66         [twin-x11],
67         [AS_HELP_STRING([--with-twin-x11],
68                 [build x11 GUI programs using the twin window system [default=yes]]
69         )],
70         [],
71         [with_twin_x11=yes]
72 )
73 AM_CONDITIONAL([WITH_TWIN_X11], [test "x$with_twin_x11" = "xyes"])
74
75 AC_ARG_WITH(
76         [twin-fbdev],
77         [AS_HELP_STRING(
78                 [--with-twin-fbdev],
79                 [build frame buffer GUI programs using the twin window system [default=no]]
80         )],
81         [],
82         [with_twin_fbdev=yes]
83 )
84 AM_CONDITIONAL([WITH_TWIN_FBDEV], [test "x$with_twin_fbdev" = "xyes"])
85
86 AM_CONDITIONAL(
87         [WITH_TWIN],
88         [test "x$with_twin_x11" = "xyes" || test "x$with_twin_fbdev" = "xyes"])
89
90 AS_IF(
91         [test "x$with_twin_x11" = "xyes" || test "x$with_twin_fbdev" = "xyes"],
92         [PKG_CHECK_MODULES(
93                 [twin],
94                 [libtwin],
95                 [SAVE_LIBS="$LIBS" LIBS="$LIBS $twin_LIBS"
96                         AC_CHECK_LIB(
97                                 [twin],
98                                 [twin_feature_init],
99                                 [],
100                                 [AC_MSG_FAILURE([--with-twin was given, but test for twin failed])]
101                         )
102                         LIBS="$SAVE_LIBS"
103                 ],
104                 [AC_MSG_RESULT([$twin_PKG_ERRORS])
105                         AC_MSG_FAILURE([ Consider adjusting PKG_CONFIG_PATH environment variable])
106                 ]
107         )]
108 )
109
110 AS_IF(
111         [test "x$with_twin_x11" = "xyes"],
112         [SAVE_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$CPPFLAGS $twin_CFLAGS"
113                 AC_CHECK_HEADERS(
114                         [libtwin/twin_x11.h],
115                         [],
116                         [AC_MSG_FAILURE([ --with-twin-x11 given but libtwin/twin_x11.h not found])]
117                 )
118                 CPPFLAGS="$SAVE_CPPFLAGS"
119         ]
120 )
121
122 AS_IF(
123         [test "x$with_twin_fbdev" = "xyes"],
124         [SAVE_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$CPPFLAGS $twin_CFLAGS"
125                 AC_CHECK_HEADERS(
126                         [libtwin/twin_fbdev.h],
127                         [],
128                         [AC_MSG_FAILURE([ --with-twin-fbdev given but libtwin/twin_fbdev.h not found])]
129                 )
130                 CPPFLAGS="$SAVE_CPPFLAGS"
131         ]
132 )
133
134 AC_ARG_ENABLE(
135         [busybox],
136         [AS_HELP_STRING(
137                 [--enable-busybox],
138                 [build programs with extra support for busybox [default=no]])
139         ],
140         [],
141         [enable_busybox=no]
142 )
143 #AM_CONDITIONAL([ENABLE_BUSYBOX], [test "x$enable_busybox" = "xyes"])
144
145 AC_ARG_ENABLE(
146         [ps3],
147         [AS_HELP_STRING(
148                 [--enable-ps3],
149                 [build additional programs for the PS3 game console [default=no]]
150         )],
151         [],
152         [enable_ps3=no]
153 )
154 AM_CONDITIONAL([ENABLE_PS3], [test "x$enable_ps3" = "xyes"])
155
156 AC_ARG_ENABLE(
157         [debug],
158         [AS_HELP_STRING([--enable-debug],
159                 [build programs with extra debug info [default=no]]
160         )],
161         [],
162         [enable_debug=check]
163 )
164 #AM_CONDITIONAL([ENABLE_DEBUG], [test "x$enable_debug" = "xyes"])
165
166 # host program paths
167 AC_DEFUN([DEFINE_HOST_PROG],
168         [
169                 AC_ARG_VAR([HOST_PROG_$1], [Path to "$2" on the host [default $3]])
170                 if test "x$HOST_PROG_$1" = "x"; then
171                         HOST_PROG_$1="$3"
172                 fi
173                 AC_DEFINE_UNQUOTED(HOST_PROG_$1, ["$HOST_PROG_$1"],
174                                 [Path to "$2" on the host])
175         ])
176
177 DEFINE_HOST_PROG(CP, cp, [/bin/cp])
178 DEFINE_HOST_PROG(KEXEC, kexec, [/sbin/kexec])
179 DEFINE_HOST_PROG(MOUNT, mount, [/bin/mount])
180 DEFINE_HOST_PROG(SHUTDOWN, shutdown, [/sbin/shutdown])
181 DEFINE_HOST_PROG(SFTP, sftp, [/usr/bin/sftp])
182 DEFINE_HOST_PROG(TFTP, tftp, [/usr/bin/tftp])
183 DEFINE_HOST_PROG(UDEVADM, udevadm, [/sbin/udevadm])
184 DEFINE_HOST_PROG(UMOUNT, umount, [/bin/umount])
185 DEFINE_HOST_PROG(WGET, wget, [/usr/bin/wget])
186
187 default_cflags="--std=gnu99 -g \
188         -Wall -W -Wunused -Wstrict-prototypes -Wmissing-prototypes \
189         -Wmissing-declarations -Wredundant-decls -Winline"
190
191 AC_ARG_ENABLE(
192         [werror],
193         [AS_HELP_STRING([--enable-werror],
194                 [build programs with -Werror]
195         )],
196         [default_cflags="$default_cflags -Werror"]
197 )
198
199 AS_IF(
200         [test "x$enable_debug" = "xyes"],
201         [AC_SUBST([DEFAULT_CFLAGS], ["$default_cflags -O0 -DDEBUG"])],
202         [AC_SUBST([DEFAULT_CFLAGS], ["$default_cflags -O2 -DNDEBUG"])]
203 )
204  
205
206 AC_SUBST([LIBTOOL_DEPS])
207 AC_SUBST([DESTDIR])
208
209 AC_CONFIG_HEADERS([config.h])
210 AC_CONFIG_FILES([
211         Makefile
212         discover/Makefile
213         lib/Makefile
214         man/Makefile
215         test/Makefile
216         test/parser/Makefile
217         test/urls/Makefile
218         ui/Makefile
219         ui/common/Makefile
220         ui/ncurses/Makefile
221         ui/test/Makefile
222         ui/twin/Makefile
223         utils/Makefile
224 ])
225
226 AC_OUTPUT