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(CORE_IMPLIB_FILE)
82 APACHE_SUBST(CORE_IMPLIB)
84 APACHE_SUBST(SH_LIBTOOL)
85 APACHE_SUBST(MK_IMPLIB)
86 APACHE_SUBST(INSTALL_PROG_FLAGS)
87 APACHE_SUBST(DSO_MODULES)
89 abs_srcdir="`(cd $srcdir && pwd)`"
91 echo creating config_vars.mk
92 test -d build || $mkdir_p build
93 > build/config_vars.mk
94 for i in $APACHE_VAR_SUBST; do
95 eval echo "$i = \$$i" >> build/config_vars.mk
99 dnl APACHE_GEN_MAKEFILES
100 dnl Creates Makefiles
101 AC_DEFUN(APACHE_GEN_MAKEFILES,[
102 $SHELL $srcdir/build/fastgen.sh $srcdir $ac_cv_mkdir_p $BSD_MAKEFILE $APACHE_FAST_OUTPUT_FILES
105 dnl ## APACHE_OUTPUT(file)
106 dnl ## adds "file" to the list of files generated by AC_OUTPUT
107 dnl ## This macro can be used several times.
108 AC_DEFUN(APACHE_OUTPUT, [
109 APACHE_OUTPUT_FILES="$APACHE_OUTPUT_FILES $1"
113 dnl APACHE_TYPE_RLIM_T
115 dnl If rlim_t is not defined, define it to int
117 AC_DEFUN(APACHE_TYPE_RLIM_T, [
118 AC_CACHE_CHECK([for rlim_t], ac_cv_type_rlim_t, [
120 #include <sys/types.h>
121 #include <sys/time.h>
122 #include <sys/resource.h>
123 ], [rlim_t spoon;], [
124 ac_cv_type_rlim_t=yes
125 ],[ac_cv_type_rlim_t=no
128 if test "$ac_cv_type_rlim_t" = "no" ; then
129 AC_DEFINE(rlim_t, int,
130 [Define to 'int' if <sys/resource.h> doesn't define it for us])
134 dnl APACHE_MODPATH_INIT(modpath)
135 AC_DEFUN(APACHE_MODPATH_INIT,[
137 modpath_current=modules/$1
140 test -d $1 || $srcdir/build/mkdir.sh $modpath_current
141 > $modpath_current/modules.mk
144 AC_DEFUN(APACHE_MODPATH_FINISH,[
145 echo "DISTCLEAN_TARGETS = modules.mk" >> $modpath_current/modules.mk
146 echo "static = $modpath_static" >> $modpath_current/modules.mk
147 echo "shared = $modpath_shared" >> $modpath_current/modules.mk
148 if test ! -z "$modpath_static" -o ! -z "$modpath_shared"; then
149 MODULE_DIRS="$MODULE_DIRS $current_dir"
151 MODULE_CLEANDIRS="$MODULE_CLEANDIRS $current_dir"
153 APACHE_FAST_OUTPUT($modpath_current/Makefile)
156 dnl APACHE_MODPATH_ADD(name[, shared[, objects [, ldflags[, libs]]]])
157 AC_DEFUN(APACHE_MODPATH_ADD,[
158 if test -z "$3"; then
164 if test -z "$module_standalone"; then
165 if test -z "$2"; then
167 BUILTIN_LIBS="$BUILTIN_LIBS $modpath_current/$libname"
168 modpath_static="$modpath_static $libname"
169 cat >>$modpath_current/modules.mk<<EOF
171 \$(MOD_LINK) $objects
174 apache_need_shared=yes
176 shobjects=`echo $objects | sed 's/\.lo/.slo/g'`
177 modpath_shared="$modpath_shared $libname"
178 cat >>$modpath_current/modules.mk<<EOF
180 \$(SH_LINK) -rpath \$(libexecdir) -module -avoid-version $4 $objects $5
187 dnl APACHE_MODULE(name, helptext[, objects[, structname[, default[, config]]]])
189 dnl default is one of:
190 dnl yes -- enabled by default. user must explicitly disable.
191 dnl no -- disabled under default, most, all. user must explicitly enable.
192 dnl most -- disabled by default. enabled explicitly or with most or all.
193 dnl static -- enabled as static by default, must be explicitly changed.
194 dnl "" -- disabled under default, most. enabled explicitly or with all.
196 dnl basically: yes/no is a hard setting. "most" means follow the "most"
197 dnl setting. otherwise, fall under the "all" setting.
198 dnl explicit yes/no always overrides.
200 AC_DEFUN(APACHE_MODULE,[
201 AC_MSG_CHECKING(whether to enable mod_$1)
202 define([optname],[--]ifelse($5,yes,disable,enable)[-]translit($1,_,-))dnl
203 AC_ARG_ENABLE(translit($1,_,-),APACHE_HELP_STRING(optname(),$2),,enable_$1=ifelse($5,,maybe-all,$5))
204 undefine([optname])dnl
206 dnl When --enable-modules=most is set and the module was not explicitly
207 dnl requested, allow a module to disable itself if its pre-reqs fail.
208 if test "$module_selection" = "most" -a "$enable_$1" = "most"; then
209 _apmod_error_fatal="no"
211 _apmod_error_fatal="yes"
213 if test "$enable_$1" = "static"; then
215 elif test "$enable_$1" = "yes"; then
216 enable_$1=$module_default
217 _apmod_extra_msg=" ($module_selection)"
218 elif test "$enable_$1" = "most"; then
219 if test "$module_selection" = "most" -o "$module_selection" = "all"; then
220 enable_$1=$module_default
221 _apmod_extra_msg=" ($module_selection)"
222 elif test "$enable_$1" != "yes"; then
225 elif test "$enable_$1" = "maybe-all"; then
226 if test "$module_selection" = "all"; then
227 enable_$1=$module_default
228 _apmod_extra_msg=" (all)"
233 if test "$enable_$1" != "no"; then
234 dnl If we plan to enable it, allow the module to run some autoconf magic
235 dnl that may disable it because of missing dependencies.
236 ifelse([$6],,:,[AC_MSG_RESULT([checking dependencies])
238 AC_MSG_CHECKING(whether to enable mod_$1)
239 if test "$enable_$1" = "no"; then
240 if test "$_apmod_error_fatal" = "no"; then
241 _apmod_extra_msg=" (disabled)"
243 AC_MSG_ERROR([mod_$1 has been requested but can not be built due to prerequisite failures])
247 AC_MSG_RESULT($enable_$1$_apmod_extra_msg)
248 if test "$enable_$1" != "no"; then
251 enable_$1=`echo $ac_n $enable_$1$ac_c|sed 's/shared,*//'`
254 DSO_MODULES="$DSO_MODULES $1"
257 MODLIST="$MODLIST ifelse($4,,$1,$4)"
258 if test "$1" = "so"; then
263 APACHE_MODPATH_ADD($1, $shared, $3)
268 dnl APACHE_LAYOUT(configlayout, layoutname)
270 AC_DEFUN(APACHE_LAYOUT,[
271 if test ! -f $srcdir/config.layout; then
272 echo "** Error: Layout file $srcdir/config.layout not found"
273 echo "** Error: Cannot use undefined layout '$LAYOUT'"
278 sed -e "1,/[ ]*<[lL]ayout[ ]*$2[ ]*>[ ]*/d" \
279 -e '/[ ]*<\/Layout>[ ]*/,$d' \
287 for var in prefix exec_prefix bindir sbindir libexecdir mandir \
288 sysconfdir datadir errordir iconsdir htdocsdir cgidir \
289 includedir localstatedir runtimedir logfiledir libdir \
290 manualdir proxycachedir installbuilddir; do
291 eval "val=\"\$$var\""
294 val=`echo $val | sed -e 's;\+$;;'`
295 eval "$var=\"\$val\""
302 val=`echo $val | sed -e 's:\(.\)/*$:\1:'`
303 val=`echo $val | sed -e 's:[\$]\([a-z_]*\):${\1}:g'`
304 if test "$autosuffix" = "yes"; then
305 if echo $val | grep apache >/dev/null; then
310 if test "$addtarget" = "yes"; then
320 dnl APACHE_ENABLE_LAYOUT
322 AC_DEFUN(APACHE_ENABLE_LAYOUT,[
323 AC_ARG_ENABLE(layout,
324 [ --enable-layout=LAYOUT],[
328 if test -z "$LAYOUT"; then
331 APACHE_LAYOUT($srcdir/config.layout, $LAYOUT)
333 AC_MSG_CHECKING(for chosen layout)
334 AC_MSG_RESULT($layout_name)
338 dnl APACHE_ENABLE_MODULES
340 AC_DEFUN(APACHE_ENABLE_MODULES,[
341 module_selection=default
344 AC_ARG_ENABLE(modules,
345 APACHE_HELP_STRING(--enable-modules=MODULE-LIST,Modules to enable),[
346 for i in $enableval; do
347 if test "$i" = "all" -o "$i" = "most"; then
355 AC_ARG_ENABLE(mods-shared,
356 APACHE_HELP_STRING(--enable-mods-shared=MODULE-LIST,Shared modules to enable),[
357 for i in $enableval; do
358 if test "$i" = "all" -o "$i" = "most"; then
360 module_default=shared
362 i=`echo $i | sed 's/-/_/g'`
363 eval "enable_$i=shared"
369 AC_DEFUN(APACHE_REQUIRE_CXX,[
370 if test -z "$apache_cxx_done"; then
378 dnl APACHE_CHECK_SSL_TOOLKIT
380 dnl Find the openssl toolkit installation and check it for the right
381 dnl version, then add its flags to INCLUDES and LIBS. This should
382 dnl really be using a custom AC_TRY_COMPILE function to test the includes
383 dnl and then AC_TRY_LINK to test the libraries directly for the version,
384 dnl but that will require someone who knows how to program openssl.
386 AC_DEFUN(APACHE_CHECK_SSL_TOOLKIT,[
387 if test "x$ap_ssltk_base" = "x"; then
388 AC_MSG_CHECKING(for SSL/TLS toolkit base)
390 AC_ARG_WITH(ssl, APACHE_HELP_STRING(--with-ssl=DIR,SSL/TLS toolkit (OpenSSL)), [
391 if test "x$withval" != "xyes" -a "x$withval" != "x"; then
392 ap_ssltk_base="$withval"
393 if test -f "$ap_ssltk_base/bin/openssl"; then
394 ap_ssltk_version="`$ap_ssltk_base/bin/openssl version`"
396 ap_ssltk_version="unknown"
400 if test "x$ap_ssltk_base" = "x"; then
401 AC_CACHE_VAL(ap_cv_ssltk,[
403 # shotgun approach: find all occurrences of the openssl program
405 # The IFS=... trick eliminates the colons from $PATH, without using an external program
406 for p in `IFS=":$IFS"; echo $PATH` /usr/local/openssl/bin /usr/local/ssl/bin; do
407 if test -f "$p/openssl"; then
408 ap_ssltk_version="`$p/openssl version`"
409 if test "x$ap_ssltk_version" != "x"; then
410 ap_cv_ssltk="`(cd $p/.. && pwd)`"
415 if test "x$ap_cv_ssltk" = "x"; then
416 AC_MSG_ERROR([requires OpenSSL 0.9.6e or higher])
419 ap_ssltk_base="$ap_cv_ssltk"
421 if test ! -d $ap_ssltk_base; then
422 AC_MSG_ERROR([invalid SSL/TLS toolkit base directory $ap_ssltk_base])
424 AC_MSG_RESULT($ap_ssltk_base)
426 AC_MSG_CHECKING(for SSL/TLS toolkit version)
427 AC_MSG_RESULT($ap_ssltk_version)
428 case "$ap_ssltk_version" in
429 "OpenSSL "[[1-9]]* | \
430 "OpenSSL "0.9.6[[e-z]]* | \
431 "OpenSSL "0.9.[[7-9]]* | \
432 "OpenSSL "0.[[1-9]][[0-9]]* )
433 # okay versions that do not have known security holes
436 AC_MSG_WARN([OpenSSL versions prior to 0.9.6e have known security holes])
439 # unknown version -- assume the user knows what they are doing
443 AC_MSG_CHECKING(for SSL/TLS toolkit includes)
445 for p in $ap_ssltk_base/include /usr/local/openssl/include \
446 /usr/local/ssl/include /usr/local/include /usr/include; do
447 if test -f "$p/openssl/ssl.h"; then
450 elif test -f "$p/ssl.h"; then
455 if test "x$ap_ssltk_incdir" = "x"; then
456 AC_MSG_ERROR([OpenSSL headers not found])
458 AC_MSG_RESULT($ap_ssltk_incdir)
460 AC_MSG_CHECKING(for SSL/TLS toolkit libraries)
462 for p in $ap_ssltk_base/lib /usr/local/openssl/lib \
463 /usr/local/ssl/lib /usr/local/lib /usr/lib /lib /usr/lib64; do
464 if test -f "$p/libssl.a" -o -f "$p/libssl.so" -o -f "$p/libssl.dylib"; then
469 if test ".$ap_ssltk_libdir" = .; then
470 AC_MSG_ERROR([OpenSSL libraries not found])
472 AC_MSG_RESULT($ap_ssltk_libdir)
474 dnl # annotate the Apache build environment with determined information
475 APR_ADDTO(INCLUDES, [-I$ap_ssltk_incdir/openssl])
476 if test "x$ap_ssltk_incdir" != "x/usr/include"; then
477 APR_ADDTO(INCLUDES, [-I$ap_ssltk_incdir])
479 if test "x$ap_ssltk_libdir" != "x/usr/lib"; then
480 APR_ADDTO(LDFLAGS, [-L$ap_ssltk_libdir])
481 if test "x$ap_platform_runtime_link_flag" != "x"; then
482 APR_ADDTO(LDFLAGS, [$ap_platform_runtime_link_flag$ap_ssltk_libdir])
485 APR_ADDTO(LIBS, [-lssl -lcrypto])
486 ap_cv_ssltk="$ap_ssltk_base"
491 dnl APACHE_EXPORT_ARGUMENTS
492 dnl Export (via APACHE_SUBST) the various path-related variables that
493 dnl apache will use while generating scripts like autoconf and apxs and
494 dnl the default config file.
496 AC_DEFUN(APACHE_SUBST_EXPANDED_ARG,[
497 APR_EXPAND_VAR(exp_$1, [$]$1)
499 APR_PATH_RELATIVE(rel_$1, [$]exp_$1, ${prefix})
503 AC_DEFUN(APACHE_EXPORT_ARGUMENTS,[
504 APACHE_SUBST_EXPANDED_ARG(exec_prefix)
505 APACHE_SUBST_EXPANDED_ARG(bindir)
506 APACHE_SUBST_EXPANDED_ARG(sbindir)
507 APACHE_SUBST_EXPANDED_ARG(libdir)
508 APACHE_SUBST_EXPANDED_ARG(libexecdir)
509 APACHE_SUBST_EXPANDED_ARG(mandir)
510 APACHE_SUBST_EXPANDED_ARG(sysconfdir)
511 APACHE_SUBST_EXPANDED_ARG(datadir)
512 APACHE_SUBST_EXPANDED_ARG(installbuilddir)
513 APACHE_SUBST_EXPANDED_ARG(errordir)
514 APACHE_SUBST_EXPANDED_ARG(iconsdir)
515 APACHE_SUBST_EXPANDED_ARG(htdocsdir)
516 APACHE_SUBST_EXPANDED_ARG(manualdir)
517 APACHE_SUBST_EXPANDED_ARG(cgidir)
518 APACHE_SUBST_EXPANDED_ARG(includedir)
519 APACHE_SUBST_EXPANDED_ARG(localstatedir)
520 APACHE_SUBST_EXPANDED_ARG(runtimedir)
521 APACHE_SUBST_EXPANDED_ARG(logfiledir)
522 APACHE_SUBST_EXPANDED_ARG(proxycachedir)