1 |
dnl Process this file with autoconf to produce a configure script. |
2 |
AC_INIT(flood.c) |
3 |
|
4 |
dnl Location for config.guess, config.sub, install.sh, etc. |
5 |
AC_CONFIG_AUX_DIR(build) |
6 |
|
7 |
dnl Override the default prefix with /usr/local/flood |
8 |
AC_PREFIX_DEFAULT(/usr/local/flood) |
9 |
|
10 |
dnl m4 Macros from APR |
11 |
sinclude(build/apr_common.m4) |
12 |
|
13 |
dnl m4 Macros for finding APR and APR-util |
14 |
sinclude(build/find_apr.m4) |
15 |
sinclude(build/find_apu.m4) |
16 |
|
17 |
dnl We need to know our top directory. |
18 |
abs_builddir=`pwd` |
19 |
|
20 |
dnl Initially, we need no subdirs |
21 |
FLOOD_SUBDIRS="" |
22 |
|
23 |
dnl Generate ./config.nice for reproducing runs of configure |
24 |
APR_CONFIG_NICE(config.nice) |
25 |
|
26 |
dnl Checks for programs. |
27 |
AC_PROG_CC |
28 |
AC_PROG_CPP |
29 |
AC_PROG_INSTALL |
30 |
AC_PROG_LN_S |
31 |
AC_PROG_MAKE_SET |
32 |
|
33 |
AC_CANONICAL_SYSTEM |
34 |
|
35 |
AC_ARG_WITH(openssl, |
36 |
[ --with-openssl=PATH Path to OpenSSL (eg. /usr/local/ssl)], |
37 |
[if test "$withval" = "yes"; then |
38 |
AC_MSG_ERROR('option --with-openssl requires a path') |
39 |
else |
40 |
fl_openssl_prefix=$withval |
41 |
|
42 |
if test "x$fl_openssl_prefix" != "x" -a ! -d "$fl_openssl_prefix"; then |
43 |
AC_MSG_ERROR('open --with-openssl requires a path to a directory') |
44 |
fi |
45 |
|
46 |
dnl XXX: We could probably do some better checking here, like looking |
47 |
dnl for headers and libraries with an explicit path. |
48 |
|
49 |
dnl Prefix these to the list, so they override env var settings |
50 |
CPPFLAGS="-I${fl_openssl_prefix}/include $CPPFLAGS" |
51 |
dnl We may need to also include $fl_openssl_prefix/openssl |
52 |
LDFLAGS="-L${fl_openssl_prefix}/lib $LDFLAGS" |
53 |
LIBTOOL_LDFLAGS="-R${fl_openssl_prefix}/lib" |
54 |
fi]) |
55 |
|
56 |
dnl If the OS provides random support, use it. Otherwise, we'll be |
57 |
dnl cheesy. |
58 |
if test -c "/dev/random"; then |
59 |
flood_has_devrand=1 |
60 |
else if test -c "/dev/urandom"; then |
61 |
flood_has_devrand=1 |
62 |
else |
63 |
flood_has_devrand=0 |
64 |
fi |
65 |
fi |
66 |
|
67 |
dnl SSL is disabled by default |
68 |
dnl "Export and import restrictions in some countries require that it be |
69 |
dnl disabled by default." See: <20011116151249.B1943@waka.ebuilt.net> |
70 |
AC_ARG_ENABLE(ssl, |
71 |
[ --enable-ssl Enable SSL support (disabled by default)], |
72 |
[enable_ssl=$enableval], |
73 |
[enable_ssl=no]) |
74 |
|
75 |
flood_has_openssl=0 |
76 |
if test "$enable_ssl" = "yes"; then |
77 |
AC_CHECK_HEADERS(openssl/ssl.h openssl/opensslv.h,, |
78 |
AC_MSG_ERROR('OpenSSL Headers not found at path specified')) |
79 |
AC_TRY_COMPILE([#include <openssl/opensslv.h>], |
80 |
[#if (OPENSSL_VERSION_NUMBER < 0x0090600fL) |
81 |
#error You need OpenSSL version 0.9.6 or greater. |
82 |
#endif],, |
83 |
AC_MSG_ERROR('OpenSSL version 0.9.6 or greater required.')) |
84 |
|
85 |
AC_CHECK_LIB(crypto, SHA1, LIBS="$LIBS -lcrypto") |
86 |
dnl BIO_next only appears in newer versions of OpenSSL |
87 |
dnl Since libssl relies on libcrypto, it *must* appear before -lcrypto. |
88 |
AC_CHECK_LIB(ssl, BIO_next, LIBS="-lssl $LIBS") |
89 |
flood_has_openssl=1 |
90 |
|
91 |
dnl Extra OpenSSL specific options |
92 |
AC_ARG_WITH(capath, |
93 |
[ --with-capath=PATH Path to a directory with c_rehash'd CA files used by OpenSSL (default $OPENSSL_PREFIX/certs)], |
94 |
[if test "$withval" = "yes"; then AC_MSG_ERROR('option --with-capath requires a path'); else CAPATH="$withval"; fi], |
95 |
[if test -d "$fl_openssl_prefix/certs"; then |
96 |
CAPATH="$fl_openssl_prefix/certs" |
97 |
else if test -d "$fl_openssl_prefix/ssl/certs"; then |
98 |
CAPATH="$fl_openssl_prefix/ssl/certs" |
99 |
else if test -d "/usr/lib/ssl/certs"; then |
100 |
CAPATH="/usr/lib/ssl/certs" |
101 |
else if test -d "/usr/share/ssl/certs"; then |
102 |
CAPATH="/usr/share/ssl/certs" |
103 |
else |
104 |
AC_MSG_ERROR('option --with-capath must be specified') |
105 |
fi |
106 |
fi |
107 |
fi |
108 |
fi |
109 |
]) |
110 |
fi |
111 |
|
112 |
APR_FIND_APR(./apr,,1,[1 0]) |
113 |
|
114 |
if test "$apr_found" = "no"; then |
115 |
AC_MSG_ERROR([APR not found. Please read the documentation.]) |
116 |
fi |
117 |
|
118 |
if test "$apr_found" = "reconfig"; then |
119 |
APR_SUBDIR_CONFIG(apr, "$apache_apr_flags --prefix=$prefix") |
120 |
FLOOD_SUBDIRS="$FLOOD_SUBDIRS apr" |
121 |
fi |
122 |
|
123 |
CC="`$apr_config --cc`" |
124 |
CFLAGS="$CFLAGS `$apr_config --cflags`" |
125 |
CPPFLAGS="$CPPFLAGS `$apr_config --cppflags --includes`" |
126 |
LDFLAGS="$LDFLAGS `$apr_config --ldflags`" |
127 |
LIBTOOL="`$apr_config --apr-libtool`" |
128 |
LIBTOOL_LIBS="$LIBTOOL_LIBS `$apr_config --link-libtool --libs`" |
129 |
APR_CONFIG="$apr_config" |
130 |
|
131 |
APR_FIND_APU(./apr-util,,1,[1 0]) |
132 |
|
133 |
if test "$apu_found" = "no"; then |
134 |
AC_MSG_ERROR([APR-util not found. Please read the documentation.]) |
135 |
fi |
136 |
if test "$apu_found" = "reconfig"; then |
137 |
dnl If we are configuring apr-util as source, APR must be source |
138 |
dnl configured. |
139 |
APR_SUBDIR_CONFIG(apr-util, "$apache_apr_flags --with-apr=../apr --prefix=$prefix") |
140 |
FLOOD_SUBDIRS="$FLOOD_SUBDIRS apr-util" |
141 |
fi |
142 |
|
143 |
CPPFLAGS="$CPPFLAGS `$apu_config --includes`" |
144 |
LIBTOOL_LDFLAGS="$LIBTOOL_LDFLAGS `$apu_config --ldflags`" |
145 |
dnl Since libaprutil relies on libapr, it *must* appear before -lapr. |
146 |
LIBTOOL_LIBS="`$apu_config --link-libtool --libs` $LIBTOOL_LIBS" |
147 |
APU_CONFIG="$apu_config" |
148 |
|
149 |
AC_CHECK_FUNC(strtoll, hasstrtoll="1", hasstrtoll="0") |
150 |
AC_CHECK_FUNC(strtoq, hasstrtoq="1", hasstrtoq="0") |
151 |
|
152 |
AC_CHECK_FUNC(rand, hasrand="1", hasrand="0") |
153 |
AC_CHECK_FUNC(lrand48, hasrand48="1", hasrand48="0") |
154 |
AC_CHECK_FUNC(random, hasrandom="1", hasrandom="0") |
155 |
|
156 |
AC_MSG_CHECKING([random number generator to use]) |
157 |
prngrand="0" |
158 |
prngrand48="0" |
159 |
prngrandom="0" |
160 |
if test "$hasrandom" = "1"; then |
161 |
prngrandom="1" |
162 |
AC_MSG_RESULT([random]) |
163 |
else if test "$hasrand48" = "1"; then |
164 |
prngrand48="1" |
165 |
AC_MSG_RESULT([rand48]) |
166 |
else if test "$hasrand" = "1"; then |
167 |
prngrand="1" |
168 |
AC_MSG_RESULT([rand]) |
169 |
else |
170 |
AC_ERROR([No suitable PRNG detected]) |
171 |
fi |
172 |
fi |
173 |
fi |
174 |
|
175 |
AC_SUBST(OPENSSL_PREFIX) |
176 |
AC_SUBST(RANDFILE) |
177 |
AC_SUBST(CAPATH) |
178 |
AC_SUBST(FLOOD_SUBDIRS) |
179 |
AC_SUBST(LIBTOOL) |
180 |
AC_SUBST(LIBTOOL_LDFLAGS) |
181 |
AC_SUBST(LIBTOOL_LIBS) |
182 |
AC_SUBST(prngrand) |
183 |
AC_SUBST(prngrand48) |
184 |
AC_SUBST(prngrandom) |
185 |
AC_SUBST(hasstrtoll) |
186 |
AC_SUBST(hasstrtoq) |
187 |
AC_SUBST(flood_has_openssl) |
188 |
AC_SUBST(flood_has_devrand) |
189 |
AC_SUBST(abs_builddir) |
190 |
|
191 |
AC_SUBST(APR_CONFIG) |
192 |
AC_SUBST(APU_CONFIG) |
193 |
|
194 |
dnl Required for source compatibility with build/rules.mk of httpd-2.0 |
195 |
LTFLAGS="--silent" |
196 |
LTCFLAGS="" |
197 |
SHLTCFLAGS="" |
198 |
AC_SUBST(LTFLAGS) |
199 |
AC_SUBST(LTCFLAGS) |
200 |
AC_SUBST(SHLTCFLAGS) |
201 |
|
202 |
dnl Makefile outputs |
203 |
dnl Note: There can only be one AC_OUTPUT command. |
204 |
AC_OUTPUT(Makefile config.h build/rules.mk build/config_vars.mk) |