2
dnl Autoconf configuration for ModSecurity
4
dnl Use ./buildconf to produce a configure script
10
dnl AC_INIT(ModSecurity, 2.5, mod-security-users@lists.sourceforge.net, modsecurity-apache)
11
AC_CONFIG_SRCDIR([mod_security2.c])
12
AC_CONFIG_HEADER([mod_security2_config.h])
13
AC_CONFIG_AUX_DIR([build])
15
# Checks for programs.
23
AC_PATH_PROGS(PERL, [perl perl5], )
25
# Checks for header files.
27
AC_CHECK_HEADERS([fcntl.h limits.h stdlib.h string.h unistd.h])
29
# Checks for typedefs, structures, and compiler characteristics.
37
# Checks for library functions.
40
AC_CHECK_FUNCS([atexit fchmod getcwd memset strcasecmp strchr strdup strerror strncasecmp strrchr strstr strtol])
44
MSC_PKGBASE_DIR="$MSC_BASE_DIR/.."
45
MSC_TEST_DIR="$MSC_BASE_DIR/t"
46
MSC_REGRESSION_DIR="$MSC_TEST_DIR/regression"
47
MSC_REGRESSION_SERVERROOT_DIR="$MSC_REGRESSION_DIR/server_root"
48
MSC_REGRESSION_CONF_DIR="$MSC_REGRESSION_SERVERROOT_DIR/conf"
49
MSC_REGRESSION_LOGS_DIR="$MSC_REGRESSION_SERVERROOT_DIR/logs"
50
MSC_REGRESSION_DOCROOT_DIR="$MSC_REGRESSION_SERVERROOT_DIR/htdocs"
52
AC_SUBST(MSC_BASE_DIR)
53
AC_SUBST(MSC_PKGBASE_DIR)
54
AC_SUBST(MSC_TEST_DIR)
55
AC_SUBST(MSC_REGRESSION_DIR)
56
AC_SUBST(MSC_REGRESSION_SERVERROOT_DIR)
57
AC_SUBST(MSC_REGRESSION_CONF_DIR)
58
AC_SUBST(MSC_REGRESSION_LOGS_DIR)
59
AC_SUBST(MSC_REGRESSION_DOCROOT_DIR)
62
AC_MSG_NOTICE(looking for Apache module support via DSO through APXS)
64
[AS_HELP_STRING([[--with-apxs=FILE]],
65
[FILE is the path to apxs; defaults to "apxs".])],
67
if test "$withval" = "yes"; then
74
if test -z "$APXS"; then
75
for i in /usr/local/apache22/bin \
76
/usr/local/apache2/bin \
77
/usr/local/apache/bin \
83
if test -f "$i/apxs2"; then
86
elif test -f "$i/apxs"; then
93
# arbitrarily picking the same version subversion looks for, don't know how
94
# accurate this really is, but at least it'll force us to have apache2...
95
HTTPD_WANTED_MMN=20020903
97
if test -n "$APXS" -a "$APXS" != "no" -a -x "$APXS" ; then
98
APXS_INCLUDE="`$APXS -q INCLUDEDIR`"
99
if test -r $APXS_INCLUDE/httpd.h; then
100
AC_MSG_NOTICE(found apxs at $APXS)
101
AC_MSG_NOTICE(checking httpd version)
102
AC_EGREP_CPP(VERSION_OK,
104
#include "$APXS_INCLUDE/ap_mmn.h"
105
#if AP_MODULE_MAGIC_AT_LEAST($HTTPD_WANTED_MMN,0)
108
[AC_MSG_NOTICE(httpd is recent enough)],
109
[AC_MSG_ERROR(apache is too old, mmn must be at least $HTTPD_WANTED_MMN)])
111
APXS_INCLUDEDIR="`$APXS -q INCLUDEDIR`"
112
# Make sure the include dir is used
113
if test -n "$APXS_INCLUDEDIR"; then
114
APXS_INCLUDES="-I${APXS_INCLUDEDIR} `$APXS -q INCLUDES` `$APXS -q EXTRA_INCLUDES`"
116
APXS_INCLUDES="`$APXS -q INCLUDES` `$APXS -q EXTRA_INCLUDES`"
118
APXS_CFLAGS="`$APXS -q CFLAGS` `$APXS -q EXTRA_CFLAGS`"
119
APXS_LDFLAGS="`$APXS -q LDFLAGS` `$APXS -q EXTRA_LDFLAGS`"
120
APXS_LIBDIR="`$APXS -q LIBDIR`"
121
# Make sure the lib dir is used
122
if test -n "$APXS_LIBDIR"; then
123
APXS_LIBS="-L{$APXS_LIBDIR} `$APXS -q LIBS` `$APXS -q EXTRA_LIBS`"
125
APXS_LIBS="`$APXS -q LIBS` `$APXS -q EXTRA_LIBS`"
127
APXS_LIBTOOL="`$APXS -q LIBTOOL`"
128
APXS_CC="`$APXS -q CC`"
129
APXS_BINDIR="`$APXS -q BINDIR`"
130
APXS_SBINDIR="`$APXS -q SBINDIR`"
131
APXS_PROGNAME="`$APXS -q PROGNAME`"
132
if test "$APXS_SBINDIR" = "/"; then
133
APXS_HTTPD="$APXS_SBINDIR/$APXS_PROGNAME"
135
APXS_HTTPD="$APXS_SBINDIR/$APXS_PROGNAME"
138
AC_MSG_ERROR(couldn't find APXS)
141
# Use Apache httpd source srclib as base for pcre, apr and apu config scripts
142
AC_ARG_WITH(httpd-src,
143
[AS_HELP_STRING([[--with-httpd-src=PATH]],
144
[PATH is to the Apache httpd source tree where srclib will be used as a base for pcre, apr and apu config scripts.])],
146
if test -n "$withval"; then
147
CPPFLAGS="$CPPFLAGS -I$withval/srclib/pcre"
148
LDFLAGS="$LDFLAGS -L$withval/srclib/pcre"
149
pcre_path="$withval/srclib/pcre"
150
apr_path="$withval/srclib/apr"
151
apu_path="$withval/srclib/apr-util"
153
AC_MSG_ERROR(--with-httpd-src requires a path)
158
sinclude(build/find_pcre.m4)
159
sinclude(build/find_apr.m4)
160
sinclude(build/find_apu.m4)
161
sinclude(build/find_xml.m4)
162
sinclude(build/find_lua.m4)
163
sinclude(build/find_curl.m4)
166
### Configure Options
169
AC_ARG_ENABLE(strict-compile,
170
AS_HELP_STRING([--enable-strict-compile],
171
[Enable strict compilation (warnings are errors).]),
173
if test "$enableval" != "no"; then
174
strict_compile="-Werror"
184
AC_ARG_ENABLE(debug-conf,
185
AS_HELP_STRING([--enable-debug-conf],
186
[Enable debug during configuration.]),
188
if test "$enableval" != "no"; then
189
debug_conf="-DDEBUG_CONF"
199
AC_ARG_ENABLE(debug-cache,
200
AS_HELP_STRING([--enable-debug-cache],
201
[Enable debug for transformation caching.]),
203
if test "$enableval" != "no"; then
204
debug_cache="-DCACHE_DEBUG"
214
AC_ARG_ENABLE(debug-acmp,
215
AS_HELP_STRING([--enable-debug-acmp],
216
[Enable debugging acmp code.]),
218
if test "$enableval" != "no"; then
219
debug_acmp="-DDEBUG_ACMP"
229
AC_ARG_ENABLE(debug-mem,
230
AS_HELP_STRING([--enable-debug-mem],
231
[Enable debug during configuration.]),
233
if test "$enableval" != "no"; then
234
debug_mem="-DDEBUG_MEM"
243
# PERFORMANCE_MEASUREMENT
244
AC_ARG_ENABLE(performance-measurement,
245
AS_HELP_STRING([--enable-performance-measurement],
246
[Enable performance-measurement stats.]),
248
if test "$enableval" != "no"; then
249
perf_meas="-DPERFORMANCE_MEASUREMENT"
259
AC_ARG_ENABLE(modsec-api,
260
AS_HELP_STRING([--disable-modsec-api],
261
[Disable the API; compiling against some older Apache versions require this.]),
263
if test "$enableval" != "yes"; then
264
modsec_api="-DNO_MODSEC_API"
273
### Build *EXTRA_CFLAGS vars
275
if test -n "$debug_mem"; then
276
EXTRA_CFLAGS="-O0 -g -Wall"
278
EXTRA_CFLAGS="-O2 -g -Wall $strict_compile"
280
MODSEC_EXTRA_CFLAGS="$debug_conf $debug_cache $debug_acmp $debug_mem $perf_meas $modsec_api"
282
APXS_WRAPPER=build/apxs-wrapper
284
for f in $EXTRA_CFLAGS; do
285
APXS_EXTRA_CFLAGS="$APXS_EXTRA_CFLAGS -Wc,$f"
287
MODSEC_APXS_EXTRA_CFLAGS=""
288
for f in $MODSEC_EXTRA_CFLAGS; do
289
MODSEC_APXS_EXTRA_CFLAGS="$MODSEC_APXS_EXTRA_CFLAGS -Wc,$f"
292
### Substitute the vars
294
save_CPPFLAGS=$CPPFLAGS
295
CPPFLAGS="$APXS_INCLUDES $CPPFLAGS"
296
save_LDFLAGS=$LDFLAGS
297
LDFLAGS="$APXS_LDFLAGS $LDFLAGS"
299
AC_SUBST(EXTRA_CFLAGS)
300
AC_SUBST(MODSEC_EXTRA_CFLAGS)
302
AC_SUBST(APXS_WRAPPER)
303
AC_SUBST(APXS_INCLUDEDIR)
304
AC_SUBST(APXS_INCLUDES)
305
AC_SUBST(APXS_EXTRA_CFLAGS)
306
AC_SUBST(MODSEC_APXS_EXTRA_CFLAGS)
307
AC_SUBST(APXS_LDFLAGS)
309
AC_SUBST(APXS_CFLAGS)
310
AC_SUBST(APXS_LIBTOOL)
312
AC_SUBST(APXS_LIBDIR)
313
AC_SUBST(APXS_BINDIR)
314
AC_SUBST(APXS_SBINDIR)
315
AC_SUBST(APXS_PROGNAME)
325
AC_CONFIG_FILES([Makefile])
326
AC_CONFIG_FILES([build/apxs-wrapper], [chmod +x build/apxs-wrapper])
327
if test -e "$PERL"; then
328
AC_CONFIG_FILES([t/run-unit-tests.pl], [chmod +x t/run-unit-tests.pl])
329
AC_CONFIG_FILES([t/run-regression-tests.pl], [chmod +x t/run-regression-tests.pl])
330
AC_CONFIG_FILES([t/gen_rx-pm.pl], [chmod +x t/gen_rx-pm.pl])
331
AC_CONFIG_FILES([t/csv_rx-pm.pl], [chmod +x t/csv_rx-pm.pl])
332
AC_CONFIG_FILES([t/regression/server_root/conf/httpd.conf])
335
AC_CONFIG_FILES([../tools/rules-updater.pl], [chmod +x ../tools/rules-updater.pl])
337
if test -e "mlogc-src/Makefile.in"; then
338
AC_CONFIG_FILES([mlogc-src/Makefile])