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)
78 APACHE_SUBST(MODULE_DIRS)
79 APACHE_SUBST(MODULE_CLEANDIRS)
81 APACHE_SUBST(nonssl_listen_stmt_1)
82 APACHE_SUBST(nonssl_listen_stmt_2)
83 APACHE_SUBST(CORE_IMPLIB_FILE)
84 APACHE_SUBST(CORE_IMPLIB)
86 APACHE_SUBST(SH_LIBTOOL)
87 APACHE_SUBST(MK_IMPLIB)
89 APACHE_SUBST(INSTALL_PROG_FLAGS)
90 APACHE_SUBST(DSO_MODULES)
91 APACHE_SUBST(APR_BINDIR)
92 APACHE_SUBST(APR_INCLUDEDIR)
93 APACHE_SUBST(APU_BINDIR)
94 APACHE_SUBST(APU_INCLUDEDIR)
96 abs_srcdir="`(cd $srcdir && pwd)`"
98 echo creating config_vars.mk
99 test -d build || $mkdir_p build
100 > build/config_vars.mk
101 for i in $APACHE_VAR_SUBST; do
102 eval echo "$i = \$$i" >> build/config_vars.mk
106 dnl APACHE_GEN_MAKEFILES
107 dnl Creates Makefiles
108 AC_DEFUN(APACHE_GEN_MAKEFILES,[
109 $SHELL $srcdir/build/fastgen.sh $srcdir $ac_cv_mkdir_p $BSD_MAKEFILE $APACHE_FAST_OUTPUT_FILES
112 dnl ## APACHE_OUTPUT(file)
113 dnl ## adds "file" to the list of files generated by AC_OUTPUT
114 dnl ## This macro can be used several times.
115 AC_DEFUN(APACHE_OUTPUT, [
116 APACHE_OUTPUT_FILES="$APACHE_OUTPUT_FILES $1"
120 dnl APACHE_TYPE_RLIM_T
122 dnl If rlim_t is not defined, define it to int
124 AC_DEFUN(APACHE_TYPE_RLIM_T, [
125 AC_CACHE_CHECK([for rlim_t], ac_cv_type_rlim_t, [
127 #include <sys/types.h>
128 #include <sys/time.h>
129 #include <sys/resource.h>
130 ], [rlim_t spoon;], [
131 ac_cv_type_rlim_t=yes
132 ],[ac_cv_type_rlim_t=no
135 if test "$ac_cv_type_rlim_t" = "no" ; then
136 AC_DEFINE(rlim_t, int,
137 [Define to 'int' if <sys/resource.h> doesn't define it for us])
141 dnl APACHE_MODPATH_INIT(modpath)
142 AC_DEFUN(APACHE_MODPATH_INIT,[
144 modpath_current=modules/$1
147 test -d $1 || $srcdir/build/mkdir.sh $modpath_current
148 > $modpath_current/modules.mk
151 AC_DEFUN(APACHE_MODPATH_FINISH,[
152 echo "DISTCLEAN_TARGETS = modules.mk" >> $modpath_current/modules.mk
153 echo "static = $modpath_static" >> $modpath_current/modules.mk
154 echo "shared = $modpath_shared" >> $modpath_current/modules.mk
155 if test ! -z "$modpath_static" -o ! -z "$modpath_shared"; then
156 MODULE_DIRS="$MODULE_DIRS $current_dir"
158 MODULE_CLEANDIRS="$MODULE_CLEANDIRS $current_dir"
160 APACHE_FAST_OUTPUT($modpath_current/Makefile)
163 dnl APACHE_MODPATH_ADD(name[, shared[, objects [, ldflags[, libs]]]])
164 AC_DEFUN(APACHE_MODPATH_ADD,[
165 if test -z "$3"; then
171 if test -z "$module_standalone"; then
172 if test -z "$2"; then
174 BUILTIN_LIBS="$BUILTIN_LIBS $modpath_current/$libname"
175 modpath_static="$modpath_static $libname"
176 cat >>$modpath_current/modules.mk<<EOF
178 \$(MOD_LINK) $objects
181 apache_need_shared=yes
183 shobjects=`echo $objects | sed 's/\.lo/.slo/g'`
184 modpath_shared="$modpath_shared $libname"
185 cat >>$modpath_current/modules.mk<<EOF
187 \$(SH_LINK) -rpath \$(libexecdir) -module -avoid-version $4 $objects $5
194 dnl APACHE_MODULE(name, helptext[, objects[, structname[, default[, config]]]])
196 dnl default is one of:
197 dnl yes -- enabled by default. user must explicitly disable.
198 dnl no -- disabled under default, most, all. user must explicitly enable.
199 dnl most -- disabled by default. enabled explicitly or with most or all.
200 dnl static -- enabled as static by default, must be explicitly changed.
201 dnl "" -- disabled under default, most. enabled explicitly or with all.
203 dnl basically: yes/no is a hard setting. "most" means follow the "most"
204 dnl setting. otherwise, fall under the "all" setting.
205 dnl explicit yes/no always overrides.
207 AC_DEFUN(APACHE_MODULE,[
208 AC_MSG_CHECKING(whether to enable mod_$1)
209 define([optname],[--]ifelse($5,yes,disable,enable)[-]translit($1,_,-))dnl
210 AC_ARG_ENABLE(translit($1,_,-),APACHE_HELP_STRING(optname(),$2),,enable_$1=ifelse($5,,maybe-all,$5))
211 undefine([optname])dnl
213 dnl When --enable-modules=most is set and the module was not explicitly
214 dnl requested, allow a module to disable itself if its pre-reqs fail.
215 if test "$module_selection" = "most" -a "$enable_$1" = "most"; then
216 _apmod_error_fatal="no"
218 _apmod_error_fatal="yes"
220 if test "$enable_$1" = "static"; then
222 elif test "$enable_$1" = "yes"; then
223 enable_$1=$module_default
224 _apmod_extra_msg=" ($module_selection)"
225 elif test "$enable_$1" = "most"; then
226 if test "$module_selection" = "most" -o "$module_selection" = "all"; then
227 enable_$1=$module_default
228 _apmod_extra_msg=" ($module_selection)"
229 elif test "$enable_$1" != "yes"; then
232 elif test "$enable_$1" = "maybe-all"; then
233 if test "$module_selection" = "all"; then
234 enable_$1=$module_default
235 _apmod_extra_msg=" (all)"
240 if test "$enable_$1" != "no"; then
241 dnl If we plan to enable it, allow the module to run some autoconf magic
242 dnl that may disable it because of missing dependencies.
243 ifelse([$6],,:,[AC_MSG_RESULT([checking dependencies])
245 AC_MSG_CHECKING(whether to enable mod_$1)
246 if test "$enable_$1" = "no"; then
247 if test "$_apmod_error_fatal" = "no"; then
248 _apmod_extra_msg=" (disabled)"
250 AC_MSG_ERROR([mod_$1 has been requested but can not be built due to prerequisite failures])
254 AC_MSG_RESULT($enable_$1$_apmod_extra_msg)
255 if test "$enable_$1" != "no"; then
258 enable_$1=`echo $ac_n $enable_$1$ac_c|sed 's/shared,*//'`
261 DSO_MODULES="$DSO_MODULES $1"
264 MODLIST="$MODLIST ifelse($4,,$1,$4)"
265 if test "$1" = "so"; then
270 APACHE_MODPATH_ADD($1, $shared, $3)
275 dnl APACHE_ENABLE_MODULES
277 AC_DEFUN(APACHE_ENABLE_MODULES,[
278 module_selection=default
281 AC_ARG_ENABLE(modules,
282 APACHE_HELP_STRING(--enable-modules=MODULE-LIST,Modules to enable),[
283 for i in $enableval; do
284 if test "$i" = "all" -o "$i" = "most"; then
292 AC_ARG_ENABLE(mods-shared,
293 APACHE_HELP_STRING(--enable-mods-shared=MODULE-LIST,Shared modules to enable),[
294 for i in $enableval; do
295 if test "$i" = "all" -o "$i" = "most"; then
297 module_default=shared
299 i=`echo $i | sed 's/-/_/g'`
300 eval "enable_$i=shared"
306 AC_DEFUN(APACHE_REQUIRE_CXX,[
307 if test -z "$apache_cxx_done"; then
315 dnl APACHE_CHECK_SSL_TOOLKIT
317 dnl Find the openssl toolkit installation and check it for the right
318 dnl version, then add its flags to INCLUDES and LIBS. This should
319 dnl really be using a custom AC_TRY_COMPILE function to test the includes
320 dnl and then AC_TRY_LINK to test the libraries directly for the version,
321 dnl but that will require someone who knows how to program openssl.
323 AC_DEFUN(APACHE_CHECK_SSL_TOOLKIT,[
324 if test "x$ap_ssltk_base" = "x"; then
325 AC_MSG_CHECKING(for SSL/TLS toolkit base)
327 AC_ARG_WITH(ssl, APACHE_HELP_STRING(--with-ssl=DIR,SSL/TLS toolkit (OpenSSL)), [
328 if test "x$withval" != "xyes" -a "x$withval" != "x"; then
329 ap_ssltk_base="$withval"
330 if test -f "$ap_ssltk_base/bin/openssl"; then
331 ap_ssltk_version="`$ap_ssltk_base/bin/openssl version`"
333 ap_ssltk_version="unknown"
337 if test "x$ap_ssltk_base" = "x"; then
338 AC_CACHE_VAL(ap_cv_ssltk,[
340 # shotgun approach: find all occurrences of the openssl program
342 # The IFS=... trick eliminates the colons from $PATH, without using an external program
343 for p in `IFS=":$IFS"; echo $PATH` /usr/local/openssl/bin /usr/local/ssl/bin; do
344 if test -f "$p/openssl"; then
345 ap_ssltk_version="`$p/openssl version`"
346 if test "x$ap_ssltk_version" != "x"; then
347 ap_cv_ssltk="`(cd $p/.. && pwd)`"
352 if test "x$ap_cv_ssltk" = "x"; then
353 AC_MSG_ERROR([requires OpenSSL 0.9.6e or higher])
356 ap_ssltk_base="$ap_cv_ssltk"
358 if test ! -d $ap_ssltk_base; then
359 AC_MSG_ERROR([invalid SSL/TLS toolkit base directory $ap_ssltk_base])
361 AC_MSG_RESULT($ap_ssltk_base)
363 AC_MSG_CHECKING(for SSL/TLS toolkit version)
364 AC_MSG_RESULT($ap_ssltk_version)
365 case "$ap_ssltk_version" in
366 "OpenSSL "[[1-9]]* | \
367 "OpenSSL "0.9.6[[e-z]]* | \
368 "OpenSSL "0.9.[[7-9]]* | \
369 "OpenSSL "0.[[1-9]][[0-9]]* )
370 # okay versions that do not have known security holes
373 AC_MSG_WARN([OpenSSL versions prior to 0.9.6e have known security holes])
376 # unknown version -- assume the user knows what they are doing
380 AC_MSG_CHECKING(for SSL/TLS toolkit includes)
382 for p in $ap_ssltk_base/include /usr/local/openssl/include \
383 /usr/local/ssl/include /usr/local/include /usr/include; do
384 if test -f "$p/openssl/ssl.h"; then
387 elif test -f "$p/ssl.h"; then
392 if test "x$ap_ssltk_incdir" = "x"; then
393 AC_MSG_ERROR([OpenSSL headers not found])
395 AC_MSG_RESULT($ap_ssltk_incdir)
397 AC_MSG_CHECKING(for SSL/TLS toolkit libraries)
399 for p in $ap_ssltk_base/lib /usr/local/openssl/lib \
400 /usr/local/ssl/lib /usr/local/lib /usr/lib /lib /usr/lib64; do
401 if test -f "$p/libssl.a" -o -f "$p/libssl.so" -o -f "$p/libssl.dylib"; then
406 if test ".$ap_ssltk_libdir" = .; then
407 AC_MSG_ERROR([OpenSSL libraries not found])
409 AC_MSG_RESULT($ap_ssltk_libdir)
411 dnl # annotate the Apache build environment with determined information
412 APR_ADDTO(INCLUDES, [-I$ap_ssltk_incdir/openssl])
413 if test "x$ap_ssltk_incdir" != "x/usr/include"; then
414 APR_ADDTO(INCLUDES, [-I$ap_ssltk_incdir])
416 if test "x$ap_ssltk_libdir" != "x/usr/lib"; then
417 APR_ADDTO(LDFLAGS, [-L$ap_ssltk_libdir])
418 if test "x$ap_platform_runtime_link_flag" != "x"; then
419 APR_ADDTO(LDFLAGS, [$ap_platform_runtime_link_flag$ap_ssltk_libdir])
422 APR_ADDTO(LIBS, [-lssl -lcrypto])
423 ap_cv_ssltk="$ap_ssltk_base"
428 dnl APACHE_EXPORT_ARGUMENTS
429 dnl Export (via APACHE_SUBST) the various path-related variables that
430 dnl apache will use while generating scripts like autoconf and apxs and
431 dnl the default config file.
433 AC_DEFUN(APACHE_SUBST_EXPANDED_ARG,[
434 APR_EXPAND_VAR(exp_$1, [$]$1)
436 APR_PATH_RELATIVE(rel_$1, [$]exp_$1, ${prefix})
440 AC_DEFUN(APACHE_EXPORT_ARGUMENTS,[
441 APACHE_SUBST_EXPANDED_ARG(exec_prefix)
442 APACHE_SUBST_EXPANDED_ARG(bindir)
443 APACHE_SUBST_EXPANDED_ARG(sbindir)
444 APACHE_SUBST_EXPANDED_ARG(libdir)
445 APACHE_SUBST_EXPANDED_ARG(libexecdir)
446 APACHE_SUBST_EXPANDED_ARG(mandir)
447 APACHE_SUBST_EXPANDED_ARG(sysconfdir)
448 APACHE_SUBST_EXPANDED_ARG(datadir)
449 APACHE_SUBST_EXPANDED_ARG(installbuilddir)
450 APACHE_SUBST_EXPANDED_ARG(errordir)
451 APACHE_SUBST_EXPANDED_ARG(iconsdir)
452 APACHE_SUBST_EXPANDED_ARG(htdocsdir)
453 APACHE_SUBST_EXPANDED_ARG(manualdir)
454 APACHE_SUBST_EXPANDED_ARG(cgidir)
455 APACHE_SUBST_EXPANDED_ARG(includedir)
456 APACHE_SUBST_EXPANDED_ARG(localstatedir)
457 APACHE_SUBST_EXPANDED_ARG(runtimedir)
458 APACHE_SUBST_EXPANDED_ARG(logfiledir)
459 APACHE_SUBST_EXPANDED_ARG(proxycachedir)