Imported Upstream version 2.5.11
[libapache-mod-security.git] / apache2 / configure.in
1 dnl
2 dnl Autoconf configuration for ModSecurity
3 dnl
4 dnl     Use ./buildconf to produce a configure script
5 dnl
6
7 AC_PREREQ(2.63)
8
9 AC_INIT
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])
14
15 # Checks for programs.
16 AC_PROG_AWK
17 AC_PROG_CC
18 AC_PROG_CPP
19 AC_PROG_INSTALL
20 AC_PROG_LN_S
21 AC_PROG_MAKE_SET
22 AC_PROG_RANLIB
23 AC_PROG_GREP
24 AC_PATH_PROGS(PERL, [perl perl5], )
25 AC_PATH_PROGS(ENV_CMD, [env printenv], )
26
27 # Checks for header files.
28 AC_HEADER_STDC
29 AC_CHECK_HEADERS([fcntl.h limits.h stdlib.h string.h unistd.h sys/types.h sys/stat.h])
30
31 # Checks for typedefs, structures, and compiler characteristics.
32 AC_C_CONST
33 AC_C_INLINE
34 AC_C_RESTRICT
35 AC_TYPE_PID_T
36 AC_TYPE_SIZE_T
37 AC_STRUCT_TM
38 AC_TYPE_UINT8_T
39
40 # Checks for library functions.
41 AC_FUNC_MALLOC
42 AC_FUNC_MEMCMP
43 AC_CHECK_FUNCS([atexit getcwd memmove memset strcasecmp strchr strdup strerror strncasecmp strrchr strstr strtol])
44
45 # Some directories
46 MSC_BASE_DIR=`pwd`
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"
54
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)
63
64 ### Configure Options
65
66 # Ignore configure errors
67 AC_ARG_ENABLE(errors,
68               AS_HELP_STRING([--disable-errors],
69                              [Disable errors during configure.]),
70 [
71   if test "$enableval" != "no"; then
72     report_errors=1
73   else
74     report_errors=0
75   fi
76 ],
77 [
78   report_errors=1
79 ])
80
81 # Verbose output
82 AC_ARG_ENABLE(verbose-output,
83               AS_HELP_STRING([--enable-verbose-output],
84                              [Enable more verbose configure output.]),
85 [
86   if test "$enableval" != "no"; then
87     verbose_output=1
88   else
89     verbose_output=0
90   fi
91 ],
92 [
93   verbose_output=0
94 ])
95
96 # Strict Compile
97 AC_ARG_ENABLE(strict-compile,
98               AS_HELP_STRING([--enable-strict-compile],
99                              [Enable strict compilation (warnings are errors).]),
100 [
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"
103   else
104     strict_compile=
105   fi
106 ],
107 [
108   strict_compile=
109 ])
110
111 # DEBUG_CONF
112 AC_ARG_ENABLE(debug-conf,
113               AS_HELP_STRING([--enable-debug-conf],
114                              [Enable debug during configuration.]),
115 [
116   if test "$enableval" != "no"; then
117     debug_conf="-DDEBUG_CONF"
118   else
119     debug_conf=
120   fi
121 ],
122 [
123   debug_conf=
124 ])
125
126 # CACHE_DEBUG
127 AC_ARG_ENABLE(debug-cache,
128               AS_HELP_STRING([--enable-debug-cache],
129                              [Enable debug for transformation caching.]),
130 [
131   if test "$enableval" != "no"; then
132     debug_cache="-DCACHE_DEBUG"
133   else
134     debug_cache=
135   fi
136 ],
137 [
138   debug_cache=
139 ])
140
141 # DEBUG_ACMP
142 AC_ARG_ENABLE(debug-acmp,
143               AS_HELP_STRING([--enable-debug-acmp],
144                              [Enable debugging acmp code.]),
145 [
146   if test "$enableval" != "no"; then
147     debug_acmp="-DDEBUG_ACMP"
148   else
149     debug_acmp=
150   fi
151 ],
152 [
153   debug_acmp=
154 ])
155
156 # DEBUG_MEM
157 AC_ARG_ENABLE(debug-mem,
158               AS_HELP_STRING([--enable-debug-mem],
159                              [Enable debug during configuration.]),
160 [
161   if test "$enableval" != "no"; then
162     debug_mem="-DDEBUG_MEM"
163   else
164     debug_mem=
165   fi
166 ],
167 [
168   debug_mem=
169 ])
170
171 # PERFORMANCE_MEASUREMENT
172 AC_ARG_ENABLE(performance-measurement,
173               AS_HELP_STRING([--enable-performance-measurement],
174                              [Enable performance-measurement stats.]),
175 [
176   if test "$enableval" != "no"; then
177     perf_meas="-DPERFORMANCE_MEASUREMENT"
178   else
179     perf_meas=
180   fi
181 ],
182 [
183   perf_meas=
184 ])
185
186 # NO_MODSEC_API
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.]),
190 [
191   if test "$enableval" != "yes"; then
192     modsec_api="-DNO_MODSEC_API"
193   else
194     modsec_api=
195   fi
196 ],
197 [
198   modsec_api=
199 ])
200
201 # Find apxs
202 AC_MSG_NOTICE(looking for Apache module support via DSO through APXS)
203 AC_ARG_WITH(apxs,
204             [AS_HELP_STRING([[--with-apxs=FILE]],
205                             [FILE is the path to apxs; defaults to "apxs".])],
206 [
207   if test "$withval" = "yes"; then
208     APXS=apxs
209   else
210     APXS="$withval"
211   fi
212 ])
213
214 if test -z "$APXS"; then
215   for i in /usr/local/apache22/bin \
216            /usr/local/apache2/bin \
217            /usr/local/apache/bin \
218            /usr/local/sbin \
219            /usr/local/bin \
220            /usr/sbin \
221            /usr/bin;
222   do
223     if test -f "$i/apxs2"; then
224       APXS="$i/apxs2"
225       break
226     elif test -f "$i/apxs"; then
227       APXS="$i/apxs"
228       break
229     fi
230   done
231 fi
232
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
236
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,
243     [
244 #include "$APXS_INCLUDE/ap_mmn.h"
245 #if AP_MODULE_MAGIC_AT_LEAST($HTTPD_WANTED_MMN,0)
246 VERSION_OK
247 #endif],
248     [AC_MSG_NOTICE(httpd is recent enough)],
249     [
250      if test "$report_errors" -eq 1; then
251        AC_MSG_ERROR(apache is too old, mmn must be at least $HTTPD_WANTED_MMN)
252      else
253        AC_MSG_NOTICE(apache is too old, mmn must be at least $HTTPD_WANTED_MMN)
254      fi
255     ])
256   fi
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`"
262   else
263     APXS_INCLUDES="`$APXS -q INCLUDES` `$APXS -q EXTRA_INCLUDES`"
264   fi
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`"
275   else
276     APXS_LIBS="`$APXS -q LIBS` `$APXS -q EXTRA_LIBS`"
277   fi
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"
293   else
294     APXS_HTTPD="$APXS_SBINDIR/$APXS_PROGNAME"
295   fi
296   if test "$verbose_output" -eq 1; then AC_MSG_NOTICE(apxs HTTPD: $APXS_HTTPD); fi
297 else
298   if test "$report_errors" -eq 1; then
299     AC_MSG_ERROR(couldn't find APXS)
300   else
301     AC_MSG_NOTICE(couldn't find APXS)
302   fi
303 fi
304
305 # Include M4 macros
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)
312
313
314 ### Build *EXTRA_CFLAGS vars
315
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"
320   fi
321 else
322   if test -n "$debug_mem"; then
323     EXTRA_CFLAGS="-O0 -g -Wall"
324   else
325     EXTRA_CFLAGS="-O2 -g -Wall $strict_compile"
326   fi
327 fi
328 MODSEC_EXTRA_CFLAGS="$debug_conf $debug_cache $debug_acmp $debug_mem $perf_meas $modsec_api"
329
330 APXS_WRAPPER=build/apxs-wrapper
331 APXS_EXTRA_CFLAGS=""
332 for f in $EXTRA_CFLAGS; do
333     APXS_EXTRA_CFLAGS="$APXS_EXTRA_CFLAGS -Wc,$f"
334 done;
335 MODSEC_APXS_EXTRA_CFLAGS=""
336 for f in $MODSEC_EXTRA_CFLAGS; do
337     MODSEC_APXS_EXTRA_CFLAGS="$MODSEC_APXS_EXTRA_CFLAGS -Wc,$f"
338 done;
339
340 ### Substitute the vars
341
342 save_CPPFLAGS=$CPPFLAGS
343 CPPFLAGS="$APXS_INCLUDES $CPPFLAGS"
344 save_LDFLAGS=$LDFLAGS
345 LDFLAGS="$APXS_LDFLAGS $LDFLAGS"
346
347 AC_SUBST(EXTRA_CFLAGS)
348 AC_SUBST(MODSEC_EXTRA_CFLAGS)
349 AC_SUBST(APXS)
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)
356 AC_SUBST(APXS_LIBS)
357 AC_SUBST(APXS_CFLAGS)
358 AC_SUBST(APXS_LIBTOOL)
359 AC_SUBST(APXS_CC)
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)
365 AC_SUBST(APXS_HTTPD)
366
367 CHECK_PCRE()
368 CHECK_APR()
369 CHECK_APU()
370 CHECK_LIBXML2()
371 CHECK_LUA()
372 CHECK_CURL()
373
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])
383
384     # Perl based tools
385     AC_CONFIG_FILES([../tools/rules-updater.pl], [chmod +x ../tools/rules-updater.pl])
386 fi
387 if test -e "mlogc-src/Makefile.in"; then
388     AC_CONFIG_FILES([mlogc-src/Makefile])
389 fi
390
391 AC_OUTPUT