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_MKDIR_P_CHECK
24 dnl checks whether mkdir -p works
25 AC_DEFUN(APACHE_MKDIR_P_CHECK,[
26 AC_CACHE_CHECK(for working mkdir -p, ac_cv_mkdir_p,[
27 test -d conftestdir && rm -rf conftestdir
28 mkdir -p conftestdir/somedir >/dev/null 2>&1
29 if test -d conftestdir/somedir; then
38 dnl APACHE_GEN_CONFIG_VARS
39 dnl Creates config_vars.mk
40 AC_DEFUN(APACHE_GEN_CONFIG_VARS,[
41 APACHE_SUBST(abs_srcdir)
45 APACHE_SUBST(logfiledir)
46 APACHE_SUBST(exec_prefix)
48 APACHE_SUBST(localstatedir)
50 APACHE_SUBST(libexecdir)
51 APACHE_SUBST(htdocsdir)
52 APACHE_SUBST(manualdir)
53 APACHE_SUBST(includedir)
54 APACHE_SUBST(errordir)
55 APACHE_SUBST(iconsdir)
56 APACHE_SUBST(sysconfdir)
57 APACHE_SUBST(installbuilddir)
58 APACHE_SUBST(runtimedir)
59 APACHE_SUBST(proxycachedir)
60 APACHE_SUBST(other_targets)
61 APACHE_SUBST(progname)
67 APACHE_SUBST(CPPFLAGS)
69 APACHE_SUBST(CXXFLAGS)
72 APACHE_SUBST(LT_LDFLAGS)
73 APACHE_SUBST(SH_LDFLAGS)
74 APACHE_SUBST(HTTPD_LDFLAGS)
75 APACHE_SUBST(UTIL_LDFLAGS)
78 APACHE_SUBST(INCLUDES)
79 APACHE_SUBST(NOTEST_CPPFLAGS)
80 APACHE_SUBST(NOTEST_CFLAGS)
81 APACHE_SUBST(NOTEST_CXXFLAGS)
82 APACHE_SUBST(NOTEST_LDFLAGS)
83 APACHE_SUBST(NOTEST_LIBS)
84 APACHE_SUBST(EXTRA_CPPFLAGS)
85 APACHE_SUBST(EXTRA_CFLAGS)
86 APACHE_SUBST(EXTRA_CXXFLAGS)
87 APACHE_SUBST(EXTRA_LDFLAGS)
88 APACHE_SUBST(EXTRA_LIBS)
89 APACHE_SUBST(EXTRA_INCLUDES)
92 APACHE_SUBST(MODULE_DIRS)
93 APACHE_SUBST(MODULE_CLEANDIRS)
95 APACHE_SUBST(CORE_IMPLIB_FILE)
96 APACHE_SUBST(CORE_IMPLIB)
98 APACHE_SUBST(SH_LIBTOOL)
99 APACHE_SUBST(MK_IMPLIB)
100 APACHE_SUBST(INSTALL_PROG_FLAGS)
101 APACHE_SUBST(DSO_MODULES)
103 abs_srcdir="`(cd $srcdir && pwd)`"
106 echo creating config_vars.mk
108 for i in $APACHE_VAR_SUBST; do
109 eval echo "$i = \$$i" >> config_vars.mk
113 dnl APACHE_GEN_MAKEFILES
114 dnl Creates Makefiles
115 AC_DEFUN(APACHE_GEN_MAKEFILES,[
116 $SHELL $srcdir/build/fastgen.sh $srcdir $ac_cv_mkdir_p $BSD_MAKEFILE $APACHE_FAST_OUTPUT_FILES
119 dnl ## APACHE_OUTPUT(file)
120 dnl ## adds "file" to the list of files generated by AC_OUTPUT
121 dnl ## This macro can be used several times.
122 AC_DEFUN(APACHE_OUTPUT, [
123 APACHE_OUTPUT_FILES="$APACHE_OUTPUT_FILES $1"
127 dnl APACHE_TYPE_RLIM_T
129 dnl If rlim_t is not defined, define it to int
131 AC_DEFUN(APACHE_TYPE_RLIM_T, [
132 AC_CACHE_CHECK([for rlim_t], ac_cv_type_rlim_t, [
134 #include <sys/types.h>
135 #include <sys/time.h>
136 #include <sys/resource.h>
137 ], [rlim_t spoon;], [
138 ac_cv_type_rlim_t=yes
139 ],[ac_cv_type_rlim_t=no
142 if test "$ac_cv_type_rlim_t" = "no" ; then
143 AC_DEFINE(rlim_t, int,
144 [Define to 'int' if <sys/resource.h> doesn't define it for us])
148 dnl APACHE_MODPATH_INIT(modpath)
149 AC_DEFUN(APACHE_MODPATH_INIT,[
151 modpath_current=modules/$1
154 test -d $1 || $srcdir/build/mkdir.sh $modpath_current
155 > $modpath_current/modules.mk
158 AC_DEFUN(APACHE_MODPATH_FINISH,[
159 echo "DISTCLEAN_TARGETS = modules.mk" >> $modpath_current/modules.mk
160 echo "static = $modpath_static" >> $modpath_current/modules.mk
161 echo "shared = $modpath_shared" >> $modpath_current/modules.mk
162 if test ! -z "$modpath_static" -o ! -z "$modpath_shared"; then
163 MODULE_DIRS="$MODULE_DIRS $current_dir"
165 MODULE_CLEANDIRS="$MODULE_CLEANDIRS $current_dir"
167 APACHE_FAST_OUTPUT($modpath_current/Makefile)
170 dnl APACHE_MODPATH_ADD(name[, shared[, objects [, ldflags[, libs]]]])
171 AC_DEFUN(APACHE_MODPATH_ADD,[
172 if test -z "$3"; then
178 if test -z "$module_standalone"; then
179 if test -z "$2"; then
181 BUILTIN_LIBS="$BUILTIN_LIBS $modpath_current/$libname"
182 modpath_static="$modpath_static $libname"
183 cat >>$modpath_current/modules.mk<<EOF
185 \$(MOD_LINK) $objects
188 apache_need_shared=yes
190 shobjects=`echo $objects | sed 's/\.lo/.slo/g'`
191 modpath_shared="$modpath_shared $libname"
192 cat >>$modpath_current/modules.mk<<EOF
194 \$(SH_LINK) -rpath \$(libexecdir) -module -avoid-version $4 $objects $5
201 dnl APACHE_MODULE(name, helptext[, objects[, structname[, default[, config]]]])
203 dnl default is one of:
204 dnl yes -- enabled by default. user must explicitly disable.
205 dnl no -- disabled under default, most, all. user must explicitly enable.
206 dnl most -- disabled by default. enabled explicitly or with most or all.
207 dnl static -- enabled as static by default, must be explicitly changed.
208 dnl "" -- disabled under default, most. enabled explicitly or with all.
210 dnl basically: yes/no is a hard setting. "most" means follow the "most"
211 dnl setting. otherwise, fall under the "all" setting.
212 dnl explicit yes/no always overrides.
214 AC_DEFUN(APACHE_MODULE,[
215 AC_MSG_CHECKING(whether to enable mod_$1)
216 define([optname],[--]ifelse($5,yes,disable,enable)[-]translit($1,_,-))dnl
217 AC_ARG_ENABLE(translit($1,_,-),APACHE_HELP_STRING(optname(),$2),,enable_$1=ifelse($5,,maybe-all,$5))
218 undefine([optname])dnl
220 dnl When --enable-modules=most is set and the module was not explicitly
221 dnl requested, allow a module to disable itself if its pre-reqs fail.
222 if test "$module_selection" = "most" -a "$enable_$1" = "most"; then
223 _apmod_error_fatal="no"
225 _apmod_error_fatal="yes"
227 if test "$enable_$1" = "static"; then
229 elif test "$enable_$1" = "yes"; then
230 enable_$1=$module_default
231 _apmod_extra_msg=" ($module_selection)"
232 elif test "$enable_$1" = "most"; then
233 if test "$module_selection" = "most" -o "$module_selection" = "all"; then
234 enable_$1=$module_default
235 _apmod_extra_msg=" ($module_selection)"
236 elif test "$enable_$1" != "yes"; then
239 elif test "$enable_$1" = "maybe-all"; then
240 if test "$module_selection" = "all"; then
241 enable_$1=$module_default
242 _apmod_extra_msg=" (all)"
247 if test "$enable_$1" != "no"; then
248 dnl If we plan to enable it, allow the module to run some autoconf magic
249 dnl that may disable it because of missing dependencies.
250 ifelse([$6],,:,[AC_MSG_RESULT([checking dependencies])
252 AC_MSG_CHECKING(whether to enable mod_$1)
253 if test "$enable_$1" = "no"; then
254 if test "$_apmod_error_fatal" = "no"; then
255 _apmod_extra_msg=" (disabled)"
257 AC_MSG_ERROR([mod_$1 has been requested but can not be built due to prerequisite failures])
261 AC_MSG_RESULT($enable_$1$_apmod_extra_msg)
262 if test "$enable_$1" != "no"; then
265 enable_$1=`echo $ac_n $enable_$1$ac_c|sed 's/shared,*//'`
268 DSO_MODULES="$DSO_MODULES $1"
271 MODLIST="$MODLIST ifelse($4,,$1,$4)"
272 if test "$1" = "so"; then
277 APACHE_MODPATH_ADD($1, $shared, $3)
282 dnl APACHE_LAYOUT_DEFAULTS
284 AC_DEFUN(APACHE_LAYOUT_DEFAULTS,[
285 dnl Apache defaults for autoconf variables.
286 test "x${prefix}" = "xNONE" && prefix='/usr/local/apache2'
287 test "x${exec_prefix}" = "xNONE" && exec_prefix='${prefix}'
288 dnl Now we need to check the non-autoconf variables.
289 test "x${cgidir}" = "x" && cgidir='${datadir}/cgi-bin'
290 test "x${logfiledir}" = "x" && logfiledir='${localstatedir}/logs'
291 test "x${htdocsdir}" = "x" && htdocsdir='${datadir}/htdocs'
292 test "x${manualdir}" = "x" && manualdir='${datadir}/manual'
293 test "x${errordir}" = "x" && errordir='${datadir}/error'
294 test "x${iconsdir}" = "x" && iconsdir='${datadir}/icons'
295 test "x${installbuilddir}" = "x" && installbuilddir='${datadir}/build'
296 test "x${runtimedir}" = "x" && runtimedir='${localstatedir}/logs'
297 test "x${proxycachedir}" = "x" && proxycachedir='${localstatedir}/proxy'
301 dnl APACHE_LAYOUT(configlayout, layoutname)
303 AC_DEFUN(APACHE_LAYOUT,[
304 if test ! -f $srcdir/config.layout; then
305 echo "** Error: Layout file $srcdir/config.layout not found"
306 echo "** Error: Cannot use undefined layout '$LAYOUT'"
311 sed -e "1,/[ ]*<[lL]ayout[ ]*$2[ ]*>[ ]*/d" \
312 -e '/[ ]*<\/Layout>[ ]*/,$d' \
320 for var in prefix exec_prefix bindir sbindir libexecdir mandir \
321 sysconfdir datadir errordir iconsdir htdocsdir cgidir \
322 includedir localstatedir runtimedir logfiledir \
323 manualdir proxycachedir installbuilddir; do
324 eval "val=\"\$$var\""
327 val=`echo $val | sed -e 's;\+$;;'`
328 eval "$var=\"\$val\""
335 val=`echo $val | sed -e 's:\(.\)/*$:\1:'`
336 val=`echo $val | sed -e 's:[\$]\([a-z_]*\):${\1}:g'`
337 if test "$autosuffix" = "yes"; then
338 if echo $val | grep apache >/dev/null; then
343 if test "$addtarget" = "yes"; then
353 dnl APACHE_ENABLE_LAYOUT
355 AC_DEFUN(APACHE_ENABLE_LAYOUT,[
356 AC_ARG_ENABLE(layout,
357 [ --enable-layout=LAYOUT],[
361 if test -z "$LAYOUT"; then
364 APACHE_LAYOUT($srcdir/config.layout, $LAYOUT)
366 AC_MSG_CHECKING(for chosen layout)
367 AC_MSG_RESULT($layout_name)
371 dnl APACHE_ENABLE_MODULES
373 AC_DEFUN(APACHE_ENABLE_MODULES,[
374 module_selection=default
377 AC_ARG_ENABLE(modules,
378 APACHE_HELP_STRING(--enable-modules=MODULE-LIST,Modules to enable),[
379 for i in $enableval; do
380 if test "$i" = "all" -o "$i" = "most"; then
388 AC_ARG_ENABLE(mods-shared,
389 APACHE_HELP_STRING(--enable-mods-shared=MODULE-LIST,Shared modules to enable),[
390 for i in $enableval; do
391 if test "$i" = "all" -o "$i" = "most"; then
393 module_default=shared
395 i=`echo $i | sed 's/-/_/g'`
396 eval "enable_$i=shared"
402 AC_DEFUN(APACHE_REQUIRE_CXX,[
403 if test -z "$apache_cxx_done"; then
411 dnl APACHE_CHECK_SSL_TOOLKIT
413 dnl Find the openssl toolkit installation and check it for the right
414 dnl version, then add its flags to INCLUDES and LIBS. This should
415 dnl really be using a custom AC_TRY_COMPILE function to test the includes
416 dnl and then AC_TRY_LINK to test the libraries directly for the version,
417 dnl but that will require someone who knows how to program openssl.
419 AC_DEFUN(APACHE_CHECK_SSL_TOOLKIT,[
420 if test "x$ap_ssltk_base" = "x"; then
421 AC_MSG_CHECKING(for SSL/TLS toolkit base)
423 AC_ARG_WITH(ssl, APACHE_HELP_STRING(--with-ssl=DIR,SSL/TLS toolkit (OpenSSL)), [
424 if test "x$withval" != "xyes" -a "x$withval" != "x"; then
425 ap_ssltk_base="$withval"
428 if test "x$ap_ssltk_base" = "x"; then
429 AC_CACHE_VAL(ap_cv_ssltk,[
431 # shotgun approach: find all occurrences of the openssl program
434 # The IFS=... trick eliminates the colons from $PATH, without using an external program
435 for p in `IFS=":$IFS"; echo $PATH` /usr/local/openssl/bin /usr/local/ssl/bin; do
436 if test -f "$p/openssl"; then
437 ap_ssltk_try="$ap_ssltk_try $p"
440 if test "x$ap_ssltk_try" = "x"; then
441 AC_MSG_ERROR(['openssl' not found in path])
443 for p in $ap_ssltk_try; do
444 ap_ssltk_version="`$p/openssl version`"
445 case "$ap_ssltk_version" in
446 "OpenSSL "[[1-9]]* | \
447 "OpenSSL "0.9.[[6-9]]* | \
448 "OpenSSL "0.[[1-9]][[0-9]]* )
449 ap_cv_ssltk="`(cd $p/.. && pwd)`"
453 # skip because it is too old or a bad result
457 if test "x$ap_cv_ssltk" = "x"; then
458 AC_MSG_ERROR([requires OpenSSL 0.9.6 or higher])
461 ap_ssltk_base="$ap_cv_ssltk"
463 if test ! -d $ap_ssltk_base; then
464 AC_MSG_ERROR([invalid SSL/TLS toolkit base directory $ap_ssltk_base])
466 AC_MSG_RESULT($ap_ssltk_base)
468 AC_MSG_CHECKING(for SSL/TLS toolkit version)
469 AC_MSG_RESULT($ap_ssltk_version)
471 AC_MSG_CHECKING(for SSL/TLS toolkit includes)
473 for p in $ap_ssltk_base/include /usr/local/openssl/include \
474 /usr/local/ssl/include /usr/local/include /usr/include; do
475 if test -f "$p/openssl/ssl.h"; then
478 elif test -f "$p/ssl.h"; then
483 if test "x$ap_ssltk_incdir" = "x"; then
484 AC_MSG_ERROR([OpenSSL headers not found])
486 AC_MSG_RESULT($ap_ssltk_incdir)
488 AC_MSG_CHECKING(for SSL/TLS toolkit libraries)
490 for p in $ap_ssltk_base/lib /usr/local/openssl/lib \
491 /usr/local/ssl/lib /usr/local/lib /usr/lib /lib; do
492 if test -f "$p/libssl.a" -o -f "$p/libssl.so"; then
497 if test ".$ap_ssltk_libdir" = .; then
498 AC_MSG_ERROR([OpenSSL libraries not found])
500 AC_MSG_RESULT($ap_ssltk_libdir)
502 dnl # annotate the Apache build environment with determined information
503 APR_ADDTO(INCLUDES, [-I$ap_ssltk_incdir/openssl])
504 if test "x$ap_ssltk_incdir" != "x/usr/include"; then
505 APR_ADDTO(INCLUDES, [-I$ap_ssltk_incdir])
507 if test "x$ap_ssltk_libdir" != "x/usr/lib"; then
508 APR_ADDTO(LDFLAGS, [-L$ap_ssltk_libdir])
509 if test "x$ap_platform_runtime_link_flag" != "x"; then
510 APR_ADDTO(LDFLAGS, [$ap_platform_runtime_link_flag$ap_ssltk_libdir])
513 APR_ADDTO(LIBS, [-lssl -lcrypto])
514 ap_cv_ssltk="$ap_ssltk_base"
519 dnl APACHE_PARSE_ARGUMENTS
520 dnl a reimplementation of autoconf's argument parser,
521 dnl used here to allow us to co-exist layouts and argument based
523 AC_DEFUN(APACHE_PARSE_ARGUMENTS,[
527 # If the previous option needs an argument, assign it.
528 if test -n "$ac_prev"; then
529 eval "$ac_prev=\$ac_option"
534 ac_optarg=`expr "x$ac_option" : 'x[[^=]]*=\(.*\)'`
538 -bindir | --bindir | --bindi | --bind | --bin | --bi)
540 -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
543 -datadir | --datadir | --datadi | --datad | --data | --dat | --da)
545 -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \
547 datadir=$ac_optarg ;;
549 -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
550 | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
551 | --exec | --exe | --ex)
552 ac_prev=exec_prefix ;;
553 -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
554 | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
555 | --exec=* | --exe=* | --ex=*)
556 exec_prefix=$ac_optarg ;;
558 -includedir | --includedir | --includedi | --included | --include \
559 | --includ | --inclu | --incl | --inc)
560 ac_prev=includedir ;;
561 -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
562 | --includ=* | --inclu=* | --incl=* | --inc=*)
563 includedir=$ac_optarg ;;
565 -infodir | --infodir | --infodi | --infod | --info | --inf)
567 -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
568 infodir=$ac_optarg ;;
570 -libdir | --libdir | --libdi | --libd)
572 -libdir=* | --libdir=* | --libdi=* | --libd=*)
575 -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
576 | --libexe | --libex | --libe)
577 ac_prev=libexecdir ;;
578 -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
579 | --libexe=* | --libex=* | --libe=*)
580 libexecdir=$ac_optarg ;;
582 -localstatedir | --localstatedir | --localstatedi | --localstated \
583 | --localstate | --localstat | --localsta | --localst \
584 | --locals | --local | --loca | --loc | --lo)
585 ac_prev=localstatedir ;;
586 -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
587 | --localstate=* | --localstat=* | --localsta=* | --localst=* \
588 | --locals=* | --local=* | --loca=* | --loc=* | --lo=*)
589 localstatedir=$ac_optarg ;;
591 -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
593 -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
596 -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
598 -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
601 -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
603 -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
605 sbindir=$ac_optarg ;;
607 -sharedstatedir | --sharedstatedir | --sharedstatedi \
608 | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
609 | --sharedst | --shareds | --shared | --share | --shar \
611 ac_prev=sharedstatedir ;;
612 -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
613 | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
614 | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
616 sharedstatedir=$ac_optarg ;;
618 -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
619 | --syscon | --sysco | --sysc | --sys | --sy)
620 ac_prev=sysconfdir ;;
621 -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
622 | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
623 sysconfdir=$ac_optarg ;;
628 # Be sure to have absolute paths.
629 for ac_var in exec_prefix prefix
631 eval ac_val=$`echo $ac_var`
633 [[\\/$]]* | ?:[[\\/]]* | NONE | '' ) ;;
634 *) AC_MSG_ERROR([expected an absolute path for --$ac_var: $ac_val]);;