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.
24 AC_PATH_PROGS(PERL, [perl perl5], )
25 AC_PATH_PROGS(ENV_CMD, [env printenv], )
27 # Checks for header files.
29 AC_CHECK_HEADERS([fcntl.h limits.h stdlib.h string.h unistd.h sys/types.h sys/stat.h])
31 # Checks for typedefs, structures, and compiler characteristics.
40 # Checks for library functions.
43 AC_CHECK_FUNCS([atexit getcwd memmove memset strcasecmp strchr strdup strerror strncasecmp strrchr strstr strtol])
47 MSC_PKGBASE_DIR="$MSC_BASE_DIR/.."
48 MSC_TEST_DIR="$MSC_BASE_DIR/t"
49 MSC_REGRESSION_DIR="$MSC_TEST_DIR/regression"
50 MSC_REGRESSION_SERVERROOT_DIR="$MSC_REGRESSION_DIR/server_root"
51 MSC_REGRESSION_CONF_DIR="$MSC_REGRESSION_SERVERROOT_DIR/conf"
52 MSC_REGRESSION_LOGS_DIR="$MSC_REGRESSION_SERVERROOT_DIR/logs"
53 MSC_REGRESSION_DOCROOT_DIR="$MSC_REGRESSION_SERVERROOT_DIR/htdocs"
55 AC_SUBST(MSC_BASE_DIR)
56 AC_SUBST(MSC_PKGBASE_DIR)
57 AC_SUBST(MSC_TEST_DIR)
58 AC_SUBST(MSC_REGRESSION_DIR)
59 AC_SUBST(MSC_REGRESSION_SERVERROOT_DIR)
60 AC_SUBST(MSC_REGRESSION_CONF_DIR)
61 AC_SUBST(MSC_REGRESSION_LOGS_DIR)
62 AC_SUBST(MSC_REGRESSION_DOCROOT_DIR)
66 # Ignore configure errors
68 AS_HELP_STRING([--disable-errors],
69 [Disable errors during configure.]),
71 if test "$enableval" != "no"; then
82 AC_ARG_ENABLE(verbose-output,
83 AS_HELP_STRING([--enable-verbose-output],
84 [Enable more verbose configure output.]),
86 if test "$enableval" != "no"; then
97 AC_ARG_ENABLE(strict-compile,
98 AS_HELP_STRING([--enable-strict-compile],
99 [Enable strict compilation (warnings are errors).]),
101 if test "$enableval" != "no"; then
102 strict_compile="-std=c99 -Wstrict-overflow=1 -Wextra -Wno-missing-field-initializers -Wshadow -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -Wno-unused-parameter -Wformat -Wformat-security -Werror -fstack-protector -D_FORTIFY_SOURCE=2"
112 AC_ARG_ENABLE(debug-conf,
113 AS_HELP_STRING([--enable-debug-conf],
114 [Enable debug during configuration.]),
116 if test "$enableval" != "no"; then
117 debug_conf="-DDEBUG_CONF"
127 AC_ARG_ENABLE(debug-cache,
128 AS_HELP_STRING([--enable-debug-cache],
129 [Enable debug for transformation caching.]),
131 if test "$enableval" != "no"; then
132 debug_cache="-DCACHE_DEBUG"
142 AC_ARG_ENABLE(debug-acmp,
143 AS_HELP_STRING([--enable-debug-acmp],
144 [Enable debugging acmp code.]),
146 if test "$enableval" != "no"; then
147 debug_acmp="-DDEBUG_ACMP"
157 AC_ARG_ENABLE(debug-mem,
158 AS_HELP_STRING([--enable-debug-mem],
159 [Enable debug during configuration.]),
161 if test "$enableval" != "no"; then
162 debug_mem="-DDEBUG_MEM"
171 # PERFORMANCE_MEASUREMENT
172 AC_ARG_ENABLE(performance-measurement,
173 AS_HELP_STRING([--enable-performance-measurement],
174 [Enable performance-measurement stats.]),
176 if test "$enableval" != "no"; then
177 perf_meas="-DPERFORMANCE_MEASUREMENT"
187 AC_ARG_ENABLE(modsec-api,
188 AS_HELP_STRING([--disable-modsec-api],
189 [Disable the API; compiling against some older Apache versions require this.]),
191 if test "$enableval" != "yes"; then
192 modsec_api="-DNO_MODSEC_API"
202 AC_MSG_NOTICE(looking for Apache module support via DSO through APXS)
204 [AS_HELP_STRING([[--with-apxs=FILE]],
205 [FILE is the path to apxs; defaults to "apxs".])],
207 if test "$withval" = "yes"; then
214 if test -z "$APXS"; then
215 for i in /usr/local/apache22/bin \
216 /usr/local/apache2/bin \
217 /usr/local/apache/bin \
223 if test -f "$i/apxs2"; then
226 elif test -f "$i/apxs"; then
233 # arbitrarily picking the same version subversion looks for, don't know how
234 # accurate this really is, but at least it'll force us to have apache2...
235 HTTPD_WANTED_MMN=20020903
237 if test -n "$APXS" -a "$APXS" != "no" -a -x "$APXS" ; then
238 APXS_INCLUDE="`$APXS -q INCLUDEDIR`"
239 if test -r $APXS_INCLUDE/httpd.h; then
240 AC_MSG_NOTICE(found apxs at $APXS)
241 AC_MSG_NOTICE(checking httpd version)
242 AC_EGREP_CPP(VERSION_OK,
244 #include "$APXS_INCLUDE/ap_mmn.h"
245 #if AP_MODULE_MAGIC_AT_LEAST($HTTPD_WANTED_MMN,0)
248 [AC_MSG_NOTICE(httpd is recent enough)],
250 if test "$report_errors" -eq 1; then
251 AC_MSG_ERROR(apache is too old, mmn must be at least $HTTPD_WANTED_MMN)
253 AC_MSG_NOTICE(apache is too old, mmn must be at least $HTTPD_WANTED_MMN)
257 APXS_INCLUDEDIR="`$APXS -q INCLUDEDIR`"
258 if test "$verbose_output" -eq 1; then AC_MSG_NOTICE(apxs INCLUDEDIR: $APXS_INCLUDEDIR); fi
259 # Make sure the include dir is used
260 if test -n "$APXS_INCLUDEDIR"; then
261 APXS_INCLUDES="-I${APXS_INCLUDEDIR} `$APXS -q INCLUDES` `$APXS -q EXTRA_INCLUDES`"
263 APXS_INCLUDES="`$APXS -q INCLUDES` `$APXS -q EXTRA_INCLUDES`"
265 if test "$verbose_output" -eq 1; then AC_MSG_NOTICE(apxs INCLUDES: $APXS_INCLUDES); fi
266 APXS_CFLAGS="`$APXS -q CFLAGS` `$APXS -q EXTRA_CFLAGS`"
267 if test "$verbose_output" -eq 1; then AC_MSG_NOTICE(apxs CFLAGS: $APXS_CFLAGS); fi
268 APXS_LDFLAGS="`$APXS -q LDFLAGS` `$APXS -q EXTRA_LDFLAGS`"
269 if test "$verbose_output" -eq 1; then AC_MSG_NOTICE(apxs LDFLAGS: $APXS_LDFLAGS); fi
270 APXS_LIBDIR="`$APXS -q LIBDIR`"
271 if test "$verbose_output" -eq 1; then AC_MSG_NOTICE(apxs LIBDIR: $APXS_LIBDIR); fi
272 # Make sure the lib dir is used
273 if test -n "$APXS_LIBDIR"; then
274 APXS_LIBS="-L{$APXS_LIBDIR} `$APXS -q LIBS` `$APXS -q EXTRA_LIBS`"
276 APXS_LIBS="`$APXS -q LIBS` `$APXS -q EXTRA_LIBS`"
278 if test "$verbose_output" -eq 1; then AC_MSG_NOTICE(apxs LIBS: $APXS_LIBS); fi
279 APXS_LIBTOOL="`$APXS -q LIBTOOL`"
280 if test "$verbose_output" -eq 1; then AC_MSG_NOTICE(apxs LIBTOOL: $APXS_LIBTOOL); fi
281 APXS_CC="`$APXS -q CC`"
282 if test "$verbose_output" -eq 1; then AC_MSG_NOTICE(apxs CC: $APXS_CC); fi
283 APXS_BINDIR="`$APXS -q BINDIR`"
284 if test "$verbose_output" -eq 1; then AC_MSG_NOTICE(apxs BINDIR: $APXS_BINDIR); fi
285 APXS_SBINDIR="`$APXS -q SBINDIR`"
286 if test "$verbose_output" -eq 1; then AC_MSG_NOTICE(apxs SBINDIR: $APXS_SBINDIR); fi
287 APXS_PROGNAME="`$APXS -q PROGNAME`"
288 if test "$verbose_output" -eq 1; then AC_MSG_NOTICE(apxs PROGNAME: $APXS_PROGNAME); fi
289 APXS_LIBEXECDIR="`$APXS -q LIBEXECDIR`"
290 if test "$verbose_output" -eq 1; then AC_MSG_NOTICE(apxs LIBEXECDIR: $APXS_LIBEXECDIR); fi
291 if test "$APXS_SBINDIR" = "/"; then
292 APXS_HTTPD="$APXS_SBINDIR/$APXS_PROGNAME"
294 APXS_HTTPD="$APXS_SBINDIR/$APXS_PROGNAME"
296 if test "$verbose_output" -eq 1; then AC_MSG_NOTICE(apxs HTTPD: $APXS_HTTPD); fi
298 if test "$report_errors" -eq 1; then
299 AC_MSG_ERROR(couldn't find APXS)
301 AC_MSG_NOTICE(couldn't find APXS)
306 sinclude(build/find_pcre.m4)
307 sinclude(build/find_apr.m4)
308 sinclude(build/find_apu.m4)
309 sinclude(build/find_xml.m4)
310 sinclude(build/find_lua.m4)
311 sinclude(build/find_curl.m4)
314 ### Build *EXTRA_CFLAGS vars
316 # Allow overriding EXTRA_CFLAGS
317 if $ENV_CMD | $GREP "^EXTRA_CFLAGS" > /dev/null 2>&1; then
318 if test -z "$debug_mem"; then
319 EXTRA_CFLAGS="$EXTRA_CFLAGS $strict_compile"
322 if test -n "$debug_mem"; then
323 EXTRA_CFLAGS="-O0 -g -Wall"
325 EXTRA_CFLAGS="-O2 -g -Wall $strict_compile"
328 MODSEC_EXTRA_CFLAGS="$debug_conf $debug_cache $debug_acmp $debug_mem $perf_meas $modsec_api"
330 APXS_WRAPPER=build/apxs-wrapper
332 for f in $EXTRA_CFLAGS; do
333 APXS_EXTRA_CFLAGS="$APXS_EXTRA_CFLAGS -Wc,$f"
335 MODSEC_APXS_EXTRA_CFLAGS=""
336 for f in $MODSEC_EXTRA_CFLAGS; do
337 MODSEC_APXS_EXTRA_CFLAGS="$MODSEC_APXS_EXTRA_CFLAGS -Wc,$f"
340 ### Substitute the vars
342 save_CPPFLAGS=$CPPFLAGS
343 CPPFLAGS="$APXS_INCLUDES $CPPFLAGS"
344 save_LDFLAGS=$LDFLAGS
345 LDFLAGS="$APXS_LDFLAGS $LDFLAGS"
347 AC_SUBST(EXTRA_CFLAGS)
348 AC_SUBST(MODSEC_EXTRA_CFLAGS)
350 AC_SUBST(APXS_WRAPPER)
351 AC_SUBST(APXS_INCLUDEDIR)
352 AC_SUBST(APXS_INCLUDES)
353 AC_SUBST(APXS_EXTRA_CFLAGS)
354 AC_SUBST(MODSEC_APXS_EXTRA_CFLAGS)
355 AC_SUBST(APXS_LDFLAGS)
357 AC_SUBST(APXS_CFLAGS)
358 AC_SUBST(APXS_LIBTOOL)
360 AC_SUBST(APXS_LIBDIR)
361 AC_SUBST(APXS_BINDIR)
362 AC_SUBST(APXS_SBINDIR)
363 AC_SUBST(APXS_PROGNAME)
364 AC_SUBST(APXS_LIBEXECDIR)
374 AC_CONFIG_FILES([Makefile])
375 AC_CONFIG_FILES([build/apxs-wrapper], [chmod +x build/apxs-wrapper])
376 if test -e "$PERL"; then
377 AC_CONFIG_FILES([mlogc-src/mlogc-batch-load.pl], [chmod +x mlogc-src/mlogc-batch-load.pl])
378 AC_CONFIG_FILES([t/run-unit-tests.pl], [chmod +x t/run-unit-tests.pl])
379 AC_CONFIG_FILES([t/run-regression-tests.pl], [chmod +x t/run-regression-tests.pl])
380 AC_CONFIG_FILES([t/gen_rx-pm.pl], [chmod +x t/gen_rx-pm.pl])
381 AC_CONFIG_FILES([t/csv_rx-pm.pl], [chmod +x t/csv_rx-pm.pl])
382 AC_CONFIG_FILES([t/regression/server_root/conf/httpd.conf])
385 AC_CONFIG_FILES([../tools/rules-updater.pl], [chmod +x ../tools/rules-updater.pl])
387 if test -e "mlogc-src/Makefile.in"; then
388 AC_CONFIG_FILES([mlogc-src/Makefile])