2 dnl APACHE_HELP_STRING(LHS, RHS)
3 dnl Autoconf 2.50 can not handle substr correctly. It does have
4 dnl AC_HELP_STRING, so let's try to call it if we can.
5 dnl Note: this define must be on one line so that it can be properly returned
6 dnl as the help string.
7 AC_DEFUN(APACHE_HELP_STRING,[ifelse(regexp(AC_ACVERSION, 2\.1), -1, AC_HELP_STRING($1,$2),[ ]$1 substr([ ],len($1))$2)])dnl
9 dnl APACHE_SUBST(VARIABLE)
10 dnl Makes VARIABLE available in generated files
11 dnl (do not use @variable@ in Makefiles, but $(variable))
12 AC_DEFUN(APACHE_SUBST,[
13 APACHE_VAR_SUBST="$APACHE_VAR_SUBST $1"
17 dnl APACHE_FAST_OUTPUT(FILENAME)
18 dnl Perform substitutions on FILENAME (Makefiles only)
19 AC_DEFUN(APACHE_FAST_OUTPUT,[
20 APACHE_FAST_OUTPUT_FILES="$APACHE_FAST_OUTPUT_FILES $1"
23 dnl APACHE_GEN_CONFIG_VARS
24 dnl Creates config_vars.mk
25 AC_DEFUN(APACHE_GEN_CONFIG_VARS,[
26 APACHE_SUBST(abs_srcdir)
30 APACHE_SUBST(logfiledir)
31 APACHE_SUBST(exec_prefix)
33 APACHE_SUBST(localstatedir)
36 APACHE_SUBST(libexecdir)
37 APACHE_SUBST(htdocsdir)
38 APACHE_SUBST(manualdir)
39 APACHE_SUBST(includedir)
40 APACHE_SUBST(errordir)
41 APACHE_SUBST(iconsdir)
42 APACHE_SUBST(sysconfdir)
43 APACHE_SUBST(installbuilddir)
44 APACHE_SUBST(runtimedir)
45 APACHE_SUBST(proxycachedir)
46 APACHE_SUBST(other_targets)
47 APACHE_SUBST(progname)
53 APACHE_SUBST(CPPFLAGS)
55 APACHE_SUBST(CXXFLAGS)
58 APACHE_SUBST(LT_LDFLAGS)
59 APACHE_SUBST(SH_LDFLAGS)
60 APACHE_SUBST(HTTPD_LDFLAGS)
61 APACHE_SUBST(UTIL_LDFLAGS)
64 APACHE_SUBST(INCLUDES)
65 APACHE_SUBST(NOTEST_CPPFLAGS)
66 APACHE_SUBST(NOTEST_CFLAGS)
67 APACHE_SUBST(NOTEST_CXXFLAGS)
68 APACHE_SUBST(NOTEST_LDFLAGS)
69 APACHE_SUBST(NOTEST_LIBS)
70 APACHE_SUBST(EXTRA_CPPFLAGS)
71 APACHE_SUBST(EXTRA_CFLAGS)
72 APACHE_SUBST(EXTRA_CXXFLAGS)
73 APACHE_SUBST(EXTRA_LDFLAGS)
74 APACHE_SUBST(EXTRA_LIBS)
75 APACHE_SUBST(EXTRA_INCLUDES)
79 APACHE_SUBST(MODULE_DIRS)
80 APACHE_SUBST(MODULE_CLEANDIRS)
82 APACHE_SUBST(nonssl_listen_stmt_1)
83 APACHE_SUBST(nonssl_listen_stmt_2)
84 APACHE_SUBST(CORE_IMPLIB_FILE)
85 APACHE_SUBST(CORE_IMPLIB)
87 APACHE_SUBST(SH_LIBTOOL)
88 APACHE_SUBST(MK_IMPLIB)
90 APACHE_SUBST(INSTALL_PROG_FLAGS)
91 APACHE_SUBST(DSO_MODULES)
92 APACHE_SUBST(APR_BINDIR)
93 APACHE_SUBST(APR_INCLUDEDIR)
94 APACHE_SUBST(APR_VERSION)
95 APACHE_SUBST(APR_CONFIG)
96 APACHE_SUBST(APU_BINDIR)
97 APACHE_SUBST(APU_INCLUDEDIR)
98 APACHE_SUBST(APU_VERSION)
99 APACHE_SUBST(APU_CONFIG)
101 abs_srcdir="`(cd $srcdir && pwd)`"
103 echo creating config_vars.mk
104 test -d build || $mkdir_p build
105 > build/config_vars.mk
106 for i in $APACHE_VAR_SUBST; do
107 eval echo "$i = \$$i" >> build/config_vars.mk
111 dnl APACHE_GEN_MAKEFILES
112 dnl Creates Makefiles
113 AC_DEFUN(APACHE_GEN_MAKEFILES,[
114 $SHELL $srcdir/build/fastgen.sh $srcdir $ac_cv_mkdir_p $BSD_MAKEFILE $APACHE_FAST_OUTPUT_FILES
117 dnl ## APACHE_OUTPUT(file)
118 dnl ## adds "file" to the list of files generated by AC_OUTPUT
119 dnl ## This macro can be used several times.
120 AC_DEFUN(APACHE_OUTPUT, [
121 APACHE_OUTPUT_FILES="$APACHE_OUTPUT_FILES $1"
125 dnl APACHE_TYPE_RLIM_T
127 dnl If rlim_t is not defined, define it to int
129 AC_DEFUN(APACHE_TYPE_RLIM_T, [
130 AC_CACHE_CHECK([for rlim_t], ac_cv_type_rlim_t, [
132 #include <sys/types.h>
133 #include <sys/time.h>
134 #include <sys/resource.h>
135 ], [rlim_t spoon;], [
136 ac_cv_type_rlim_t=yes
137 ],[ac_cv_type_rlim_t=no
140 if test "$ac_cv_type_rlim_t" = "no" ; then
141 AC_DEFINE(rlim_t, int,
142 [Define to 'int' if <sys/resource.h> doesn't define it for us])
146 dnl APACHE_MODPATH_INIT(modpath)
147 AC_DEFUN(APACHE_MODPATH_INIT,[
149 modpath_current=modules/$1
152 test -d $1 || $srcdir/build/mkdir.sh $modpath_current
153 > $modpath_current/modules.mk
156 AC_DEFUN(APACHE_MODPATH_FINISH,[
157 echo "DISTCLEAN_TARGETS = modules.mk" >> $modpath_current/modules.mk
158 echo "static = $modpath_static" >> $modpath_current/modules.mk
159 echo "shared = $modpath_shared" >> $modpath_current/modules.mk
160 if test ! -z "$modpath_static" -o ! -z "$modpath_shared"; then
161 MODULE_DIRS="$MODULE_DIRS $current_dir"
163 MODULE_CLEANDIRS="$MODULE_CLEANDIRS $current_dir"
165 APACHE_FAST_OUTPUT($modpath_current/Makefile)
168 dnl APACHE_MODPATH_ADD(name[, shared[, objects [, ldflags[, libs]]]])
169 AC_DEFUN(APACHE_MODPATH_ADD,[
170 if test -z "$3"; then
176 if test -z "$module_standalone"; then
177 if test -z "$2"; then
178 # The filename of a convenience library must have a "lib" prefix:
179 libname="libmod_$1.la"
180 BUILTIN_LIBS="$BUILTIN_LIBS $modpath_current/$libname"
181 modpath_static="$modpath_static $libname"
182 cat >>$modpath_current/modules.mk<<EOF
184 \$(MOD_LINK) $objects $5
187 apache_need_shared=yes
189 shobjects=`echo $objects | sed 's/\.lo/.slo/g'`
190 modpath_shared="$modpath_shared $libname"
191 cat >>$modpath_current/modules.mk<<EOF
193 \$(SH_LINK) -rpath \$(libexecdir) -module -avoid-version $4 $objects $5
200 dnl APACHE_MODULE(name, helptext[, objects[, structname[, default[, config]]]])
202 dnl default is one of:
203 dnl yes -- enabled by default. user must explicitly disable.
204 dnl no -- disabled under default, most, all. user must explicitly enable.
205 dnl most -- disabled by default. enabled explicitly or with most or all.
206 dnl static -- enabled as static by default, must be explicitly changed.
207 dnl "" -- disabled under default, most. enabled explicitly or with all.
209 dnl basically: yes/no is a hard setting. "most" means follow the "most"
210 dnl setting. otherwise, fall under the "all" setting.
211 dnl explicit yes/no always overrides.
213 AC_DEFUN(APACHE_MODULE,[
214 AC_MSG_CHECKING(whether to enable mod_$1)
215 define([optname],[--]ifelse($5,yes,disable,enable)[-]translit($1,_,-))dnl
216 AC_ARG_ENABLE(translit($1,_,-),APACHE_HELP_STRING(optname(),$2),,enable_$1=ifelse($5,,maybe-all,$5))
217 undefine([optname])dnl
219 dnl When --enable-modules=most is set and the module was not explicitly
220 dnl requested, allow a module to disable itself if its pre-reqs fail.
221 if test "$module_selection" = "most" -a "$enable_$1" = "most"; then
222 _apmod_error_fatal="no"
224 _apmod_error_fatal="yes"
226 if test "$enable_$1" = "static"; then
228 elif test "$enable_$1" = "yes"; then
229 enable_$1=$module_default
230 _apmod_extra_msg=" ($module_selection)"
231 elif test "$enable_$1" = "most"; then
232 if test "$module_selection" = "most" -o "$module_selection" = "all"; then
233 enable_$1=$module_default
234 _apmod_extra_msg=" ($module_selection)"
235 elif test "$enable_$1" != "yes"; then
238 elif test "$enable_$1" = "maybe-all"; then
239 if test "$module_selection" = "all"; then
240 enable_$1=$module_default
241 _apmod_extra_msg=" (all)"
246 if test "$enable_$1" != "no"; then
247 dnl If we plan to enable it, allow the module to run some autoconf magic
248 dnl that may disable it because of missing dependencies.
249 ifelse([$6],,:,[AC_MSG_RESULT([checking dependencies])
251 AC_MSG_CHECKING(whether to enable mod_$1)
252 if test "$enable_$1" = "no"; then
253 if test "$_apmod_error_fatal" = "no"; then
254 _apmod_extra_msg=" (disabled)"
256 AC_MSG_ERROR([mod_$1 has been requested but can not be built due to prerequisite failures])
260 AC_MSG_RESULT($enable_$1$_apmod_extra_msg)
261 if test "$enable_$1" != "no"; then
264 enable_$1=`echo $enable_$1|sed 's/shared,*//'`
267 DSO_MODULES="$DSO_MODULES $1"
270 MODLIST="$MODLIST ifelse($4,,$1,$4)"
271 if test "$1" = "so"; then
276 define([modprefix], [MOD_]translit($1, [a-z-], [A-Z_]))
277 APACHE_MODPATH_ADD($1, $shared, $3,, [\$(]modprefix[_LDADD)])
278 APACHE_SUBST(modprefix[_LDADD])
279 undefine([modprefix])
284 dnl APACHE_ENABLE_MODULES
286 AC_DEFUN(APACHE_ENABLE_MODULES,[
287 module_selection=default
290 AC_ARG_ENABLE(modules,
291 APACHE_HELP_STRING(--enable-modules=MODULE-LIST,Space-separated list of modules to enable | "all" | "most" | "none"),[
292 if test "$enableval" = "none"; then
294 module_selection=none
296 for i in $enableval; do
297 if test "$i" = "all" -o "$i" = "most"; then
300 i=`echo $i | sed 's/-/_/g'`
307 AC_ARG_ENABLE(mods-shared,
308 APACHE_HELP_STRING(--enable-mods-shared=MODULE-LIST,Space-separated list of shared modules to enable | "all" | "most"),[
309 for i in $enableval; do
310 if test "$i" = "all" -o "$i" = "most"; then
312 module_default=shared
314 i=`echo $i | sed 's/-/_/g'`
315 eval "enable_$i=shared"
321 AC_DEFUN(APACHE_REQUIRE_CXX,[
322 if test -z "$apache_cxx_done"; then
330 dnl APACHE_CHECK_SSL_TOOLKIT
332 dnl Configure for the detected openssl/ssl-c toolkit installation, giving
333 dnl preference to "--with-ssl=<path>" if it was specified.
335 AC_DEFUN(APACHE_CHECK_SSL_TOOLKIT,[
336 if test "x$ap_ssltk_configured" = "x"; then
337 dnl initialise the variables we use
343 dnl Determine the SSL/TLS toolkit's base directory, if any
344 AC_MSG_CHECKING(for SSL/TLS toolkit base)
345 AC_ARG_WITH(sslc, APACHE_HELP_STRING(--with-sslc=DIR,RSA SSL-C SSL/TLS toolkit), [
346 dnl If --with-sslc specifies a directory, we use that directory or fail
347 if test "x$withval" != "xyes" -a "x$withval" != "x"; then
348 dnl This ensures $withval is actually a directory and that it is absolute
349 ap_ssltk_base="`cd $withval ; pwd`"
353 AC_ARG_WITH(ssl, APACHE_HELP_STRING(--with-ssl=DIR,OpenSSL SSL/TLS toolkit), [
354 dnl If --with-ssl specifies a directory, we use that directory or fail
355 if test "x$withval" != "xyes" -a "x$withval" != "x"; then
356 dnl This ensures $withval is actually a directory and that it is absolute
357 ap_ssltk_base="`cd $withval ; pwd`"
360 if test "x$ap_ssltk_base" = "x"; then
363 AC_MSG_RESULT($ap_ssltk_base)
366 dnl Run header and version checks
367 saved_CPPFLAGS=$CPPFLAGS
368 if test "x$ap_ssltk_base" != "x"; then
369 ap_ssltk_inc="-I$ap_ssltk_base/include"
370 CPPFLAGS="$CPPFLAGS $ap_ssltk_inc"
372 if test "x$ap_ssltk_type" = "x"; then
373 AC_MSG_CHECKING(for OpenSSL version)
374 dnl First check for manditory headers
375 AC_CHECK_HEADERS([openssl/opensslv.h openssl/ssl.h], [ap_ssltk_type="openssl"], [])
376 if test "$ap_ssltk_type" = "openssl"; then
377 dnl so it's OpenSSL - test for a good version
378 AC_TRY_COMPILE([#include <openssl/opensslv.h>],[
379 #if !defined(OPENSSL_VERSION_NUMBER)
380 #error "Missing openssl version"
382 #if (OPENSSL_VERSION_NUMBER < 0x009060af) \
383 || ((OPENSSL_VERSION_NUMBER > 0x00907000) && (OPENSSL_VERSION_NUMBER < 0x0090702f))
384 #error "Insecure openssl version " OPENSSL_VERSION_TEXT
387 [dnl Replace this with OPENSSL_VERSION_TEXT from opensslv.h?
388 AC_MSG_RESULT([not encouraging])
389 echo "WARNING: OpenSSL version may contain security vulnerabilities!"
390 echo " Ensure the latest security patches have been applied!"
392 dnl Look for additional, possibly missing headers
393 AC_CHECK_HEADERS(openssl/engine.h)
394 if test -n "$PKGCONFIG"; then
396 if test $? -eq 0; then
397 ap_ssltk_inc="$ap_ssltk_inc `$PKGCONFIG --cflags-only-I openssl`"
398 CPPFLAGS="$CPPFLAGS $ap_ssltk_inc"
402 AC_MSG_RESULT([no OpenSSL headers found])
405 if test "$ap_ssltk_type" != "openssl"; then
406 dnl Might be SSL-C - report, then test anything relevant
407 AC_MSG_CHECKING(for SSL-C version)
408 AC_CHECK_HEADERS([sslc.h], [ap_ssltk_type="sslc"], [ap_ssltk_type=""])
409 if test "$ap_ssltk_type" = "sslc"; then
410 AC_MSG_CHECKING(for SSL-C version)
411 AC_TRY_COMPILE([#include <sslc.h>],[
412 #if !defined(SSLC_VERSION_NUMBER)
413 #error "Missing SSL-C version"
415 #if SSLC_VERSION_NUMBER < 0x2310
416 #define stringize_ver(x) #x
417 #error "Insecure SSL-C version " stringize_ver(SSLC_VERSION_NUMBER)
420 [dnl Replace this with SSLC_VERSION_NUMBER?
421 AC_MSG_RESULT([not encouraging])
422 echo "WARNING: SSL-C version may contain security vulnerabilities!"
423 echo " Ensure the latest security patches have been applied!"
426 AC_MSG_RESULT([no SSL-C headers found])
430 CPPFLAGS=$saved_CPPFLAGS
431 if test "x$ap_ssltk_type" = "x"; then
432 AC_MSG_ERROR([...No recognized SSL/TLS toolkit detected])
435 dnl Run library and function checks
436 saved_LDFLAGS=$LDFLAGS
438 if test "x$ap_ssltk_base" != "x"; then
439 if test -d "$ap_ssltk_base/lib"; then
440 ap_ssltk_lib="$ap_ssltk_base/lib"
442 ap_ssltk_lib="$ap_ssltk_base"
444 LDFLAGS="$LDFLAGS -L$ap_ssltk_lib"
446 dnl make sure "other" flags are available so libcrypto and libssl can link
447 LIBS="$LIBS `$apr_config --libs`"
449 if test "$ap_ssltk_type" = "openssl"; then
450 AC_CHECK_LIB(crypto, SSLeay_version, [], [liberrors="yes"])
451 AC_CHECK_LIB(ssl, SSL_CTX_new, [], [liberrors="yes"])
452 AC_CHECK_FUNCS(ENGINE_init)
453 AC_CHECK_FUNCS(ENGINE_load_builtin_engines)
455 AC_CHECK_LIB(sslc, SSLC_library_version, [], [liberrors="yes"])
456 AC_CHECK_LIB(sslc, SSL_CTX_new, [], [liberrors="yes"])
457 AC_CHECK_FUNCS(SSL_set_state)
459 AC_CHECK_FUNCS(SSL_set_cert_store)
461 LDFLAGS=$saved_LDFLAGS
463 if test "x$liberrors" != "x"; then
464 AC_MSG_ERROR([... Error, SSL/TLS libraries were missing or unusable])
467 dnl Adjust apache's configuration based on what we found above.
468 dnl (a) define preprocessor symbols
469 if test "$ap_ssltk_type" = "openssl"; then
470 AC_DEFINE(HAVE_OPENSSL, 1, [Define if SSL is supported using OpenSSL])
472 AC_DEFINE(HAVE_SSLC, 1, [Define if SSL is supported using SSL-C])
474 dnl (b) hook up include paths
475 if test "x$ap_ssltk_inc" != "x"; then
476 APR_ADDTO(INCLUDES, [$ap_ssltk_inc])
478 dnl (c) hook up linker paths
479 if test "x$ap_ssltk_lib" != "x"; then
480 APR_ADDTO(LDFLAGS, ["-L$ap_ssltk_lib"])
481 if test "x$ap_platform_runtime_link_flag" != "x"; then
482 APR_ADDTO(LDFLAGS, ["$ap_platform_runtime_link_flag$ap_ssltk_lib"])
485 # Put SSL libraries in SSL_LIBS.
486 if test "$ap_ssltk_type" = "openssl"; then
487 APR_SETVAR(SSL_LIBS, [-lssl -lcrypto])
488 if test -n "$PKGCONFIG"; then
490 if test $? -eq 0; then
491 ap_ssltk_libdep=`$PKGCONFIG --libs openssl`
492 APR_ADDTO(SSL_LIBS, $ap_ssltk_libdep)
496 APR_SETVAR(SSL_LIBS, [-lsslc])
498 APACHE_SUBST(SSL_LIBS)
503 dnl APACHE_EXPORT_ARGUMENTS
504 dnl Export (via APACHE_SUBST) the various path-related variables that
505 dnl apache will use while generating scripts like autoconf and apxs and
506 dnl the default config file.
508 AC_DEFUN(APACHE_SUBST_EXPANDED_ARG,[
509 APR_EXPAND_VAR(exp_$1, [$]$1)
511 APR_PATH_RELATIVE(rel_$1, [$]exp_$1, ${prefix})
515 AC_DEFUN(APACHE_EXPORT_ARGUMENTS,[
516 APACHE_SUBST_EXPANDED_ARG(exec_prefix)
517 APACHE_SUBST_EXPANDED_ARG(bindir)
518 APACHE_SUBST_EXPANDED_ARG(sbindir)
519 APACHE_SUBST_EXPANDED_ARG(libdir)
520 APACHE_SUBST_EXPANDED_ARG(libexecdir)
521 APACHE_SUBST_EXPANDED_ARG(mandir)
522 APACHE_SUBST_EXPANDED_ARG(sysconfdir)
523 APACHE_SUBST_EXPANDED_ARG(datadir)
524 APACHE_SUBST_EXPANDED_ARG(installbuilddir)
525 APACHE_SUBST_EXPANDED_ARG(errordir)
526 APACHE_SUBST_EXPANDED_ARG(iconsdir)
527 APACHE_SUBST_EXPANDED_ARG(htdocsdir)
528 APACHE_SUBST_EXPANDED_ARG(manualdir)
529 APACHE_SUBST_EXPANDED_ARG(cgidir)
530 APACHE_SUBST_EXPANDED_ARG(includedir)
531 APACHE_SUBST_EXPANDED_ARG(localstatedir)
532 APACHE_SUBST_EXPANDED_ARG(runtimedir)
533 APACHE_SUBST_EXPANDED_ARG(logfiledir)
534 APACHE_SUBST_EXPANDED_ARG(proxycachedir)
538 dnl APACHE_CHECK_APxVER({apr|apu}, major, minor,
539 dnl [actions-if-ok], [actions-if-not-ok])
541 dnl Checks for APR or APR-util of given major/minor version or later;
542 dnl if so, runs actions-if-ok; otherwise runs actions-if-not-ok if given.
543 dnl If the version is not satisfactory and actions-if-not-ok is not
544 dnl given, then an error is printed and the configure script is aborted.
546 dnl The first argument must be [apr] or [apu].
548 AC_DEFUN([APACHE_CHECK_APxVER], [
549 define(ap_ckver_major, translit($1, [apru], [APRU])[_MAJOR_VERSION])
550 define(ap_ckver_minor, translit($1, [apru], [APRU])[_MINOR_VERSION])
551 define(ap_ckver_cvar, [ap_cv_$1ver$2$3])
552 define(ap_ckver_name, ifelse([$1],[apr],[APR],[APR-util]))
554 ap_ckver_CPPFLAGS="$CPPFLAGS"
555 CPPFLAGS="$CPPFLAGS `$[$1]_config --includes`"
557 AC_CACHE_CHECK([for ap_ckver_name version $2.$3.0 or later], ap_ckver_cvar, [
558 AC_EGREP_CPP([good], [
559 #include <$1_version.h>
560 #if ]ap_ckver_major[ > $2 || (]ap_ckver_major[ == $2 && ]ap_ckver_minor[ >= $3)
563 ], [ap_ckver_cvar=yes], [ap_ckver_cvar=no])])
565 if test "$ap_ckver_cvar" = "yes"; then
566 ifelse([$4],[],[:],[$4])
568 ifelse([$5],[],[AC_MSG_ERROR([ap_ckver_name version $2.$3.0 or later is required])], [$5])
571 CPPFLAGS="$ap_ckver_CPPFLAGS"
573 undefine([ap_ckver_major])
574 undefine([ap_ckver_minor])
575 undefine([ap_ckver_cvar])
576 undefine([ap_ckver_name])
580 dnl APACHE_CHECK_VOID_PTR_LEN
582 dnl Checks if the size of a void pointer is at least as big as a "long"
585 AC_DEFUN([APACHE_CHECK_VOID_PTR_LEN], [
587 AC_CACHE_CHECK([for void pointer length], [ap_void_ptr_lt_long],
591 return sizeof(void *) < sizeof(long);
592 }], [ap_void_ptr_lt_long=no], [ap_void_ptr_lt_long=yes],
593 [ap_void_ptr_lt_long=yes])])
595 if test "$ap_void_ptr_lt_long" = "yes"; then
596 AC_MSG_ERROR([Size of "void *" is less than size of "long"])