1 |
AC_DEFUN([AC_APREQ], [ |
2 |
|
3 |
AC_ARG_ENABLE(profile, |
4 |
AC_HELP_STRING([--enable-profile],[compile libapreq2 with "-pg -fprofile-arcs -ftest-coverage" for gcov/gprof]), |
5 |
[PROFILE=$enableval],[PROFILE="no"]) |
6 |
AC_ARG_ENABLE(perl_glue, |
7 |
AC_HELP_STRING([--enable-perl-glue],[build perl modules Apache::Request and Apache::Cookie]), |
8 |
[PERL_GLUE=$enableval],[PERL_GLUE="no"]) |
9 |
AC_ARG_WITH(perl, |
10 |
AC_HELP_STRING([--with-perl],[path to perl executable]), |
11 |
[PERL=$withval],[PERL="perl"]) |
12 |
AC_ARG_WITH(apache2-apxs, |
13 |
AC_HELP_STRING([--with-apache2-apxs],[path to apache2's apxs]), |
14 |
[APACHE2_APXS=$withval],[APACHE2_APXS="apxs"]) |
15 |
AC_ARG_WITH(apache2-src, |
16 |
AC_HELP_STRING([--with-apache2-src],[path to httpd source]), |
17 |
[APACHE2_SRC=$withval],[APACHE2_SRC=""]) |
18 |
AC_ARG_WITH(apache2-httpd, |
19 |
AC_HELP_STRING([--with-apache2-httpd],[path to httpd binary]), |
20 |
[APACHE2_HTTPD=$withval],[APACHE2_HTTPD=""]) |
21 |
AC_ARG_WITH(apr-config, |
22 |
AC_HELP_STRING([ --with-apr-config],[path to apr-*-config script]), |
23 |
[APR_CONFIG=$withval],[APR_CONFIG=""]) |
24 |
AC_ARG_WITH(apu-config, |
25 |
AC_HELP_STRING([ --with-apu-config],[path to apu-*-config script]), |
26 |
[APU_CONFIG=$withval],[APU_CONFIG=""]) |
27 |
AC_ARG_WITH(apache1-apxs, |
28 |
AC_HELP_STRING([--with-apache1-apxs],[path to apache1's apxs]), |
29 |
[APACHE1_APXS=$withval],[APACHE1_APXS=""]) |
30 |
AC_ARG_WITH(perl-opts, |
31 |
AC_HELP_STRING([--with-perl-opts],[extra PERL options]), |
32 |
[PERL_OPTS=$withval],[PERL_OPTS=""]) |
33 |
AC_ARG_WITH(mm-opts, |
34 |
AC_HELP_STRING([--with-mm-opts], [extra ExtUtils::MakeMaker options]), |
35 |
[MM_OPTS=$withval], [MM_OPTS=""]) |
36 |
AC_ARG_WITH(expat, |
37 |
AC_HELP_STRING([--with-expat],[specify expat location]), |
38 |
[EXPAT_DIR=$withval],[EXPAT_DIR=""]) |
39 |
|
40 |
OS=`$PERL -e 'print $^O'` |
41 |
|
42 |
prereq_check="$PERL $PERL_OPTS build/version_check.pl" |
43 |
|
44 |
if test -n "$APACHE2_SRC"; then |
45 |
# no apxs: must compile httpd from source |
46 |
|
47 |
APACHE2_SRC=`cd $APACHE2_SRC;pwd` |
48 |
|
49 |
AC_CHECK_FILE([$APACHE2_SRC/include/httpd.h],, |
50 |
AC_MSG_ERROR([invalid Apache2 source directory])) |
51 |
|
52 |
APACHE2_INCLUDES=-I$APACHE2_SRC/include |
53 |
|
54 |
if test -z "$APR_CONFIG"; then |
55 |
APR_CONFIG="$APACHE2_SRC/srclib/apr/apr-config" |
56 |
fi |
57 |
|
58 |
if test -z "$APU_CONFIG"; then |
59 |
APU_CONFIG="$APACHE2_SRC/srclib/apr-util/apu-config" |
60 |
fi |
61 |
|
62 |
APACHE2_HTTPD=$APACHE2_SRC/httpd |
63 |
|
64 |
else |
65 |
# have apxs: use it |
66 |
|
67 |
APACHE2_INCLUDES=-I`$APACHE2_APXS -q INCLUDEDIR` |
68 |
|
69 |
APR_MAJOR_VERSION=`$APACHE2_APXS -q APR_VERSION 2>/dev/null | cut -d. -f 1` |
70 |
if test ${APR_MAJOR_VERSION:="0"} -eq 0; then |
71 |
apr_config=apr-config |
72 |
apu_config=apu-config |
73 |
apreq_libs="-lapr -laprutil" |
74 |
else |
75 |
apr_config=apr-$APR_MAJOR_VERSION-config |
76 |
apu_config=apu-$APR_MAJOR_VERSION-config |
77 |
apreq_libs="-lapr-$APR_MAJOR_VERSION -laprutil-$APR_MAJOR_VERSION" |
78 |
fi |
79 |
|
80 |
if test -z "$APR_CONFIG"; then |
81 |
APR_CONFIG=`$APACHE2_APXS -q APR_BINDIR`/$apr_config |
82 |
fi |
83 |
|
84 |
if test -z "$APU_CONFIG"; then |
85 |
APU_CONFIG=`$APACHE2_APXS -q APU_BINDIR`/$apu_config |
86 |
fi |
87 |
|
88 |
if test -z "$APACHE2_HTTPD"; then |
89 |
APACHE2_HTTPD=`$APACHE2_APXS -q SBINDIR`/`$APACHE2_APXS -q progname` |
90 |
fi |
91 |
|
92 |
if test -z "`$prereq_check apache2 $APACHE2_HTTPD`"; then |
93 |
AC_MSG_ERROR([Bad apache2 binary ($APACHE2_HTTPD)]) |
94 |
fi |
95 |
|
96 |
APR_DOC_VERSION=`$APACHE2_APXS -q APR_VERSION 2>/dev/null | cut -d. -f -2` |
97 |
APU_DOC_VERSION=`$APACHE2_APXS -q APU_VERSION 2>/dev/null | cut -d. -f -2` |
98 |
fi |
99 |
|
100 |
dnl Fallback to oldest version available |
101 |
if test "x$APR_DOC_VERSION" = 'x'; then |
102 |
APR_DOC_VERSION=0.9 |
103 |
fi |
104 |
if test "x$APU_DOC_VERSION" = 'x'; then |
105 |
APU_DOC_VERSION=0.9 |
106 |
fi |
107 |
|
108 |
AC_CHECK_FILE([$APR_CONFIG],, |
109 |
AC_MSG_ERROR([invalid apr-config location ($APR_CONFIG)- did you forget to configure apr?])) |
110 |
|
111 |
if test -z "`$prereq_check apr $APR_CONFIG`"; then |
112 |
AC_MSG_ERROR([Bad libapr version]) |
113 |
fi |
114 |
|
115 |
AC_CHECK_FILE([$APU_CONFIG],, |
116 |
AC_MSG_ERROR([invalid apu-config location ($APU_CONFIG)- did you forget to configure apr-util?])) |
117 |
|
118 |
if test -z "`$prereq_check apu $APU_CONFIG`"; then |
119 |
AC_MSG_ERROR([Bad libaprutil version]) |
120 |
fi |
121 |
|
122 |
if test "x$PERL_GLUE" != "xno"; then |
123 |
AC_MSG_CHECKING(for perl) |
124 |
if test -z "`$prereq_check perl $PERL`"; then |
125 |
AC_MSG_ERROR([Bad perl version]) |
126 |
fi |
127 |
AC_MSG_RESULT($PERL) |
128 |
|
129 |
AC_MSG_CHECKING(for ExtUtils::XSBuilder) |
130 |
if test -z "`$prereq_check ExtUtils::XSBuilder`"; then |
131 |
AC_MSG_WARN([Bad ExtUtils::XSBuilder version]) |
132 |
fi |
133 |
AC_MSG_RESULT(yes) |
134 |
|
135 |
AC_MSG_CHECKING(for mod_perl2) |
136 |
if test -z "`$prereq_check mod_perl2`"; then |
137 |
AC_MSG_WARN([Bad mod_perl2 version]) |
138 |
fi |
139 |
AC_MSG_RESULT(yes) |
140 |
|
141 |
AC_MSG_CHECKING(for Apache::Test) |
142 |
if test -z "`$prereq_check Apache::Test`"; then |
143 |
AC_MSG_WARN([Bad Apache::Test version]) |
144 |
fi |
145 |
AC_MSG_RESULT(yes) |
146 |
|
147 |
AC_MSG_CHECKING(for ExtUtils::MakeMaker) |
148 |
if test -z "`$prereq_check ExtUtils::MakeMaker`"; then |
149 |
AC_MSG_WARN([Bad ExtUtils::MakeMaker version]) |
150 |
fi |
151 |
AC_MSG_RESULT(yes) |
152 |
|
153 |
fi |
154 |
|
155 |
AM_CONDITIONAL(ENABLE_PROFILE, test "x$PROFILE" != "xno") |
156 |
AM_CONDITIONAL(BUILD_PERL_GLUE, test "x$PERL_GLUE" != "xno") |
157 |
AM_CONDITIONAL(HAVE_APACHE_TEST, test -n "`$prereq_check Apache::Test`") |
158 |
AM_CONDITIONAL(BUILD_HTTPD, test -n "$APACHE2_SRC") |
159 |
AM_CONDITIONAL(BUILD_APR, test "x$APR_CONFIG" = x`$APR_CONFIG --srcdir`/apr-config) |
160 |
AM_CONDITIONAL(BUILD_APU, test "x$APU_CONFIG" = x`$APU_CONFIG --srcdir`/apu-config) |
161 |
AM_CONDITIONAL(HAVE_APACHE1, test -n "$APACHE1_APXS") |
162 |
|
163 |
dnl Reset the default installation prefix to be the same as apu's |
164 |
ac_default_prefix="`$APU_CONFIG --prefix`" |
165 |
|
166 |
APR_ADDTO([APR_INCLUDES], "`$APR_CONFIG --includes`") |
167 |
APR_ADDTO([APR_INCLUDES], "`$APU_CONFIG --includes`") |
168 |
APR_LA="`$APR_CONFIG --apr-la-file`" |
169 |
APU_LA="`$APU_CONFIG --apu-la-file`" |
170 |
APR_ADDTO([APR_LTFLAGS], "`$APR_CONFIG --link-libtool`") |
171 |
APR_ADDTO([APR_LTFLAGS], "`$APU_CONFIG --link-libtool`") |
172 |
|
173 |
dnl perl glue/tests do not use libtool: need ld linker flags |
174 |
APR_ADDTO([APR_LIBS], "`$APR_CONFIG --libs`") |
175 |
|
176 |
apu_avoid_libs="" |
177 |
if $APU_CONFIG --avoid-ldap >/dev/null 2>&1; then |
178 |
apu_avoid_libs="--avoid-ldap" |
179 |
fi |
180 |
if $APU_CONFIG --avoid-dbm >/dev/null 2>&1; then |
181 |
apu_avoid_libs="--avoid-dbm $apu_avoid_libs" |
182 |
fi |
183 |
|
184 |
dnl ld: fatal: recording name conflict: |
185 |
dnl file `/usr/sfw/lib/gcc/i386-pc-solaris2.10/3.4.3/../../../libexpat.so' and |
186 |
dnl file `httpd/lib/libexpat.so' |
187 |
dnl provide identical dependency names: libexpat.so.0 |
188 |
dnl (possible multiple inclusion of the same file) |
189 |
if test "x$OS" = "xsolaris"; then |
190 |
APU_LIBS="`$APU_CONFIG $apu_avoid_libs --libs | $PERL -pe 's,-lexpat,,'`" |
191 |
else |
192 |
APU_LIBS="`$APU_CONFIG $apu_avoid_libs --libs`" |
193 |
fi |
194 |
APR_ADDTO([APR_LIBS], "$APU_LIBS") |
195 |
|
196 |
APR_ADDTO([APR_LDFLAGS], "`$APU_CONFIG --link-ld --ldflags`") |
197 |
APR_ADDTO([APR_LDFLAGS], "`$APR_CONFIG --link-ld --ldflags`") |
198 |
|
199 |
if test -n "$EXPAT_DIR"; then |
200 |
APR_ADDTO([APR_INCLUDES], "-I$EXPAT_DIR/include") |
201 |
APR_ADDTO([APR_LTFLAGS], "-L$EXPAT_DIR/lib") |
202 |
fi |
203 |
|
204 |
dnl Absolute source/build directory |
205 |
abs_srcdir=`(cd $srcdir && pwd)` |
206 |
abs_builddir=`pwd` |
207 |
top_builddir="$abs_srcdir" |
208 |
|
209 |
if test "$abs_builddir" != "$abs_srcdir"; then |
210 |
USE_VPATH=1 |
211 |
fi |
212 |
|
213 |
if test "x$USE_MAINTAINER_MODE" != "xno"; then |
214 |
APR_ADDTO([CFLAGS],[ |
215 |
-fno-strict-aliasing |
216 |
-Wall -Wmissing-prototypes -Wstrict-prototypes |
217 |
-Wmissing-declarations -Wwrite-strings -Wcast-qual |
218 |
-Wfloat-equal -Wshadow -Wpointer-arith |
219 |
-Wbad-function-cast -Wsign-compare -Waggregate-return |
220 |
-Wmissing-noreturn -Wmissing-format-attribute -Wpacked |
221 |
-Wredundant-decls -Wnested-externs -Wdisabled-optimization |
222 |
-Wno-long-long -Wendif-labels -Wcast-align -Wpacked |
223 |
]) |
224 |
# -Wdeclaration-after-statement is only supported on gcc 3.4+ |
225 |
fi |
226 |
|
227 |
APR_ADDTO([CPPFLAGS], "`$APR_CONFIG --cppflags`") |
228 |
|
229 |
get_version="$SHELL $abs_srcdir/build/get-version.sh" |
230 |
version_hdr="$abs_srcdir/include/apreq_version.h" |
231 |
|
232 |
# set version data |
233 |
|
234 |
APREQ_CONFIG="$top_builddir/apreq2-config" |
235 |
|
236 |
APREQ_MAJOR_VERSION=`$get_version major $version_hdr APREQ` |
237 |
APREQ_MINOR_VERSION=`$get_version minor $version_hdr APREQ` |
238 |
APREQ_PATCH_VERSION=`$get_version patch $version_hdr APREQ` |
239 |
APREQ_DOTTED_VERSION=`$get_version all $version_hdr APREQ` |
240 |
|
241 |
# XXX: APR_MAJOR_VERSION doesn't yet work for static builds |
242 |
APREQ_LIBTOOL_CURRENT=`expr $APREQ_MAJOR_VERSION + $APREQ_MINOR_VERSION + $APR_MAJOR_VERSION` |
243 |
APREQ_LIBTOOL_REVISION=$APREQ_PATCH_VERSION |
244 |
APREQ_LIBTOOL_AGE=$APREQ_MINOR_VERSION |
245 |
|
246 |
APREQ_LIBTOOL_VERSION="$APREQ_LIBTOOL_CURRENT:$APREQ_LIBTOOL_REVISION:$APREQ_LIBTOOL_AGE" |
247 |
|
248 |
APREQ_LIBNAME="apreq$APREQ_MAJOR_VERSION" |
249 |
|
250 |
echo "lib$APREQ_LIBNAME Version: $APREQ_DOTTED_VERSION" |
251 |
|
252 |
## Apparently FC5 doesn't like bsdtar |
253 |
## which is the default /usr/bin/tar on FreeBSD |
254 |
## by default /usr/ports/archivers/gtar installs here |
255 |
if test "x$OS" = 'xfreebsd'; then |
256 |
TAR='/usr/local/bin/gtar' |
257 |
else |
258 |
TAR='tar' |
259 |
fi |
260 |
|
261 |
AC_SUBST(APREQ_CONFIG) |
262 |
AC_SUBST(APREQ_LIBNAME) |
263 |
AC_SUBST(APREQ_LIBTOOL_VERSION) |
264 |
AC_SUBST(APREQ_MAJOR_VERSION) |
265 |
AC_SUBST(APREQ_DOTTED_VERSION) |
266 |
|
267 |
AC_SUBST(APACHE2_APXS) |
268 |
AC_SUBST(APACHE2_SRC) |
269 |
AC_SUBST(APACHE2_INCLUDES) |
270 |
AC_SUBST(APACHE2_HTTPD) |
271 |
|
272 |
AC_SUBST(APACHE1_APXS) |
273 |
|
274 |
AC_SUBST(APU_CONFIG) |
275 |
AC_SUBST(APR_CONFIG) |
276 |
AC_SUBST(APR_INCLUDES) |
277 |
AC_SUBST(APR_LDFLAGS) |
278 |
AC_SUBST(APR_LTFLAGS) |
279 |
AC_SUBST(APR_LIBS) |
280 |
AC_SUBST(APR_LA) |
281 |
AC_SUBST(APU_LA) |
282 |
|
283 |
AC_SUBST(PERL) |
284 |
AC_SUBST(PERL_OPTS) |
285 |
AC_SUBST(MM_OPTS) |
286 |
AC_SUBST(TAR) |
287 |
|
288 |
AC_SUBST(APR_DOC_VERSION) |
289 |
AC_SUBST(APU_DOC_VERSION) |
290 |
|
291 |
if test "x$OS" = "xsolaris"; then |
292 |
$PERL -pi -e 's,^shrext=,shrext_cmds=,' libtool |
293 |
fi |
294 |
]) |
295 |
|
296 |
dnl APR_CONFIG_NICE(filename) |
297 |
dnl |
298 |
dnl Saves a snapshot of the configure command-line for later reuse |
299 |
dnl |
300 |
AC_DEFUN([APR_CONFIG_NICE],[ |
301 |
rm -f $1 |
302 |
cat >$1<<EOF |
303 |
#! /bin/sh |
304 |
# |
305 |
# Created by configure |
306 |
|
307 |
EOF |
308 |
if test -n "$CC"; then |
309 |
echo "CC=\"$CC\"; export CC" >> $1 |
310 |
fi |
311 |
if test -n "$CFLAGS"; then |
312 |
echo "CFLAGS=\"$CFLAGS\"; export CFLAGS" >> $1 |
313 |
fi |
314 |
if test -n "$CPPFLAGS"; then |
315 |
echo "CPPFLAGS=\"$CPPFLAGS\"; export CPPFLAGS" >> $1 |
316 |
fi |
317 |
if test -n "$LDFLAGS"; then |
318 |
echo "LDFLAGS=\"$LDFLAGS\"; export LDFLAGS" >> $1 |
319 |
fi |
320 |
if test -n "$LTFLAGS"; then |
321 |
echo "LTFLAGS=\"$LTFLAGS\"; export LTFLAGS" >> $1 |
322 |
fi |
323 |
if test -n "$LIBS"; then |
324 |
echo "LIBS=\"$LIBS\"; export LIBS" >> $1 |
325 |
fi |
326 |
if test -n "$INCLUDES"; then |
327 |
echo "INCLUDES=\"$INCLUDES\"; export INCLUDES" >> $1 |
328 |
fi |
329 |
if test -n "$NOTEST_CFLAGS"; then |
330 |
echo "NOTEST_CFLAGS=\"$NOTEST_CFLAGS\"; export NOTEST_CFLAGS" >> $1 |
331 |
fi |
332 |
if test -n "$NOTEST_CPPFLAGS"; then |
333 |
echo "NOTEST_CPPFLAGS=\"$NOTEST_CPPFLAGS\"; export NOTEST_CPPFLAGS" >> $1 |
334 |
fi |
335 |
if test -n "$NOTEST_LDFLAGS"; then |
336 |
echo "NOTEST_LDFLAGS=\"$NOTEST_LDFLAGS\"; export NOTEST_LDFLAGS" >> $1 |
337 |
fi |
338 |
if test -n "$NOTEST_LIBS"; then |
339 |
echo "NOTEST_LIBS=\"$NOTEST_LIBS\"; export NOTEST_LIBS" >> $1 |
340 |
fi |
341 |
|
342 |
echo [$]0 [$]ac_configure_args '"[$]@"' >> $1 |
343 |
chmod +x $1 |
344 |
])dnl |
345 |
|
346 |
dnl |
347 |
dnl APR_ADDTO(variable, value) |
348 |
dnl |
349 |
dnl Add value to variable |
350 |
dnl |
351 |
AC_DEFUN([APR_ADDTO],[ |
352 |
if test "x$$1" = "x"; then |
353 |
echo " setting $1 to \"$2\"" |
354 |
$1="$2" |
355 |
else |
356 |
apr_addto_bugger="$2" |
357 |
for i in $apr_addto_bugger; do |
358 |
apr_addto_duplicate="0" |
359 |
for j in $$1; do |
360 |
if test "x$i" = "x$j"; then |
361 |
apr_addto_duplicate="1" |
362 |
break |
363 |
fi |
364 |
done |
365 |
if test $apr_addto_duplicate = "0"; then |
366 |
echo " adding \"$i\" to $1" |
367 |
$1="$$1 $i" |
368 |
fi |
369 |
done |
370 |
fi |
371 |
])dnl |