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(other_targets)
59 APACHE_SUBST(progname)
65 APACHE_SUBST(CPPFLAGS)
67 APACHE_SUBST(CXXFLAGS)
70 APACHE_SUBST(LT_LDFLAGS)
71 APACHE_SUBST(SH_LDFLAGS)
72 APACHE_SUBST(HTTPD_LDFLAGS)
75 APACHE_SUBST(INCLUDES)
76 APACHE_SUBST(NOTEST_CPPFLAGS)
77 APACHE_SUBST(NOTEST_CFLAGS)
78 APACHE_SUBST(NOTEST_CXXFLAGS)
79 APACHE_SUBST(NOTEST_LDFLAGS)
80 APACHE_SUBST(NOTEST_LIBS)
81 APACHE_SUBST(EXTRA_CPPFLAGS)
82 APACHE_SUBST(EXTRA_CFLAGS)
83 APACHE_SUBST(EXTRA_CXXFLAGS)
84 APACHE_SUBST(EXTRA_LDFLAGS)
85 APACHE_SUBST(EXTRA_LIBS)
86 APACHE_SUBST(EXTRA_INCLUDES)
89 APACHE_SUBST(MODULE_DIRS)
90 APACHE_SUBST(MODULE_CLEANDIRS)
92 APACHE_SUBST(CORE_IMPLIB_FILE)
93 APACHE_SUBST(CORE_IMPLIB)
94 APACHE_SUBST(SH_LIBTOOL)
95 APACHE_SUBST(MK_IMPLIB)
96 APACHE_SUBST(INSTALL_PROG_FLAGS)
97 APACHE_SUBST(DSO_MODULES)
99 abs_srcdir="`(cd $srcdir && pwd)`"
102 echo creating config_vars.mk
104 for i in $APACHE_VAR_SUBST; do
105 eval echo "$i = \$$i" >> config_vars.mk
109 dnl APACHE_GEN_MAKEFILES
110 dnl Creates Makefiles
111 AC_DEFUN(APACHE_GEN_MAKEFILES,[
112 $SHELL $srcdir/build/fastgen.sh $srcdir $ac_cv_mkdir_p $BSD_MAKEFILE $APACHE_FAST_OUTPUT_FILES
115 dnl ## APACHE_OUTPUT(file)
116 dnl ## adds "file" to the list of files generated by AC_OUTPUT
117 dnl ## This macro can be used several times.
118 AC_DEFUN(APACHE_OUTPUT, [
119 APACHE_OUTPUT_FILES="$APACHE_OUTPUT_FILES $1"
123 dnl APACHE_TYPE_RLIM_T
125 dnl If rlim_t is not defined, define it to int
127 AC_DEFUN(APACHE_TYPE_RLIM_T, [
128 AC_CACHE_CHECK([for rlim_t], ac_cv_type_rlim_t, [
130 #include <sys/types.h>
131 #include <sys/time.h>
132 #include <sys/resource.h>
133 ], [rlim_t spoon;], [
134 ac_cv_type_rlim_t=yes
135 ],[ac_cv_type_rlim_t=no
138 if test "$ac_cv_type_rlim_t" = "no" ; then
139 AC_DEFINE(rlim_t, int,
140 [Define to 'int' if <sys/resource.h> doesn't define it for us])
144 dnl APACHE_MODPATH_INIT(modpath)
145 AC_DEFUN(APACHE_MODPATH_INIT,[
147 modpath_current=modules/$1
150 test -d $1 || $srcdir/build/mkdir.sh $modpath_current
151 > $modpath_current/modules.mk
154 AC_DEFUN(APACHE_MODPATH_FINISH,[
155 echo "DISTCLEAN_TARGETS = modules.mk" >> $modpath_current/modules.mk
156 echo "static = $modpath_static" >> $modpath_current/modules.mk
157 echo "shared = $modpath_shared" >> $modpath_current/modules.mk
158 if test ! -z "$modpath_static" -o ! -z "$modpath_shared"; then
159 MODULE_DIRS="$MODULE_DIRS $current_dir"
161 MODULE_CLEANDIRS="$MODULE_CLEANDIRS $current_dir"
163 APACHE_FAST_OUTPUT($modpath_current/Makefile)
166 dnl APACHE_MODPATH_ADD(name[, shared[, objects [, ldflags[, libs]]]])
167 AC_DEFUN(APACHE_MODPATH_ADD,[
168 if test -z "$3"; then
174 if test -z "$module_standalone"; then
175 if test -z "$2"; then
177 BUILTIN_LIBS="$BUILTIN_LIBS $modpath_current/$libname"
178 modpath_static="$modpath_static $libname"
179 cat >>$modpath_current/modules.mk<<EOF
181 \$(MOD_LINK) $objects
184 apache_need_shared=yes
186 shobjects=`echo $objects | sed 's/\.lo/.slo/g'`
187 modpath_shared="$modpath_shared $libname"
188 cat >>$modpath_current/modules.mk<<EOF
190 \$(SH_LINK) -rpath \$(libexecdir) -module -avoid-version $4 $objects $5
197 dnl APACHE_MODULE(name, helptext[, objects[, structname[, default[, config]]]])
199 dnl default is one of:
200 dnl yes -- enabled by default. user must explicitly disable.
201 dnl no -- disabled under default, most, all. user must explicitly enable.
202 dnl most -- disabled by default. enabled explicitly or with most or all.
203 dnl static -- enabled as static by default, must be explicitly changed.
204 dnl "" -- disabled under default, most. enabled explicitly or with all.
206 dnl basically: yes/no is a hard setting. "most" means follow the "most"
207 dnl setting. otherwise, fall under the "all" setting.
208 dnl explicit yes/no always overrides.
210 AC_DEFUN(APACHE_MODULE,[
211 AC_MSG_CHECKING(whether to enable mod_$1)
212 define([optname],[--]ifelse($5,yes,disable,enable)[-]translit($1,_,-))dnl
213 AC_ARG_ENABLE(translit($1,_,-),APACHE_HELP_STRING(optname(),$2),,enable_$1=ifelse($5,,maybe-all,$5))
214 undefine([optname])dnl
216 dnl When --enable-modules=most is set and the module was not explicitly
217 dnl requested, allow a module to disable itself if its pre-reqs fail.
218 if test "$module_selection" = "most" -a "$enable_$1" = "most"; then
219 _apmod_error_fatal="no"
221 _apmod_error_fatal="yes"
223 if test "$enable_$1" = "static"; then
225 elif test "$enable_$1" = "yes"; then
226 enable_$1=$module_default
227 _apmod_extra_msg=" ($module_selection)"
228 elif test "$enable_$1" = "most"; then
229 if test "$module_selection" = "most" -o "$module_selection" = "all"; then
230 enable_$1=$module_default
231 _apmod_extra_msg=" ($module_selection)"
232 elif test "$enable_$1" != "yes"; then
235 elif test "$enable_$1" = "maybe-all"; then
236 if test "$module_selection" = "all"; then
237 enable_$1=$module_default
238 _apmod_extra_msg=" (all)"
243 if test "$enable_$1" != "no"; then
244 dnl If we plan to enable it, allow the module to run some autoconf magic
245 dnl that may disable it because of missing dependencies.
246 ifelse([$6],,:,[AC_MSG_RESULT([checking dependencies])
248 AC_MSG_CHECKING(whether to enable mod_$1)
249 if test "$enable_$1" = "no"; then
250 if test "$_apmod_error_fatal" = "no"; then
251 _apmod_extra_msg=" (disabled)"
253 AC_MSG_ERROR([mod_$1 has been requested but can not be built due to prerequisite failures])
257 AC_MSG_RESULT($enable_$1$_apmod_extra_msg)
258 if test "$enable_$1" != "no"; then
261 enable_$1=`echo $ac_n $enable_$1$ac_c|sed 's/shared,*//'`
264 DSO_MODULES="$DSO_MODULES $1"
267 MODLIST="$MODLIST ifelse($4,,$1,$4)"
268 if test "$1" = "so"; then
273 APACHE_MODPATH_ADD($1, $shared, $3)
277 dnl APACHE_LAYOUT(configlayout, layoutname)
278 AC_DEFUN(APACHE_LAYOUT,[
279 if test ! -f $srcdir/config.layout; then
280 echo "** Error: Layout file $srcdir/config.layout not found"
281 echo "** Error: Cannot use undefined layout '$LAYOUT'"
286 sed -e "1,/[ ]*<[lL]ayout[ ]*$2[ ]*>[ ]*/d" \
287 -e '/[ ]*<\/Layout>[ ]*/,$d' \
295 for var in prefix exec_prefix bindir sbindir libexecdir mandir \
296 sysconfdir datadir errordir iconsdir htdocsdir cgidir \
297 includedir localstatedir runtimedir logfiledir \
298 manualdir proxycachedir installbuilddir; do
299 eval "val=\"\$$var\""
302 val=`echo $val | sed -e 's;\+$;;'`
303 eval "$var=\"\$val\""
310 val=`echo $val | sed -e 's:\(.\)/*$:\1:'`
311 val=`echo $val | sed -e 's:[\$]\([a-z_]*\):$(\1):g'`
312 if test "$autosuffix" = "yes"; then
313 if echo $val | grep apache >/dev/null; then
318 if test "$addtarget" = "yes"; then
327 dnl APACHE_ENABLE_LAYOUT
329 AC_DEFUN(APACHE_ENABLE_LAYOUT,[
330 AC_ARG_ENABLE(layout,
331 APACHE_HELP_STRING(--enable-layout=LAYOUT,Default file layout),[
335 if test -z "$LAYOUT"; then
338 APACHE_LAYOUT($srcdir/config.layout, $LAYOUT)
340 AC_MSG_CHECKING(for chosen layout)
341 AC_MSG_RESULT($layout_name)
345 dnl APACHE_ENABLE_MODULES
347 AC_DEFUN(APACHE_ENABLE_MODULES,[
348 module_selection=default
351 AC_ARG_ENABLE(modules,
352 APACHE_HELP_STRING(--enable-modules=MODULE-LIST,Modules to enable),[
353 for i in $enableval; do
354 if test "$i" = "all" -o "$i" = "most"; then
362 AC_ARG_ENABLE(mods-shared,
363 APACHE_HELP_STRING(--enable-mods-shared=MODULE-LIST,Shared modules to enable),[
364 for i in $enableval; do
365 if test "$i" = "all" -o "$i" = "most"; then
367 module_default=shared
369 i=`echo $i | sed 's/-/_/g'`
370 eval "enable_$i=shared"
376 AC_DEFUN(APACHE_REQUIRE_CXX,[
377 if test -z "$apache_cxx_done"; then
385 dnl APACHE_CHECK_SSL_TOOLKIT
387 dnl Find the openssl toolkit installation and check it for the right
388 dnl version, then add its flags to INCLUDES and LIBS. This should
389 dnl really be using a custom AC_TRY_COMPILE function to test the includes
390 dnl and then AC_TRY_LINK to test the libraries directly for the version,
391 dnl but that will require someone who knows how to program openssl.
393 AC_DEFUN(APACHE_CHECK_SSL_TOOLKIT,[
394 if test "x$ap_ssltk_base" = "x"; then
395 AC_MSG_CHECKING(for SSL/TLS toolkit base)
397 AC_ARG_WITH(ssl, APACHE_HELP_STRING(--with-ssl=DIR,SSL/TLS toolkit (OpenSSL)), [
398 if test "x$withval" != "xyes" -a "x$withval" != "x"; then
399 ap_ssltk_base="$withval"
402 if test "x$ap_ssltk_base" = "x"; then
403 AC_CACHE_VAL(ap_cv_ssltk,[
405 # shotgun approach: find all occurrences of the openssl program
408 # The IFS=... trick eliminates the colons from $PATH, without using an external program
409 for p in `IFS=":$IFS"; echo $PATH` /usr/local/openssl/bin /usr/local/ssl/bin; do
410 if test -f "$p/openssl"; then
411 ap_ssltk_try="$ap_ssltk_try $p"
414 if test "x$ap_ssltk_try" = "x"; then
415 AC_MSG_ERROR(['openssl' not found in path])
417 for p in $ap_ssltk_try; do
418 ap_ssltk_version="`$p/openssl version`"
419 case "$ap_ssltk_version" in
420 "OpenSSL "[[1-9]]* | \
421 "OpenSSL "0.9.[[6-9]]* | \
422 "OpenSSL "0.[[1-9]][[0-9]]* )
423 ap_cv_ssltk="`(cd $p/.. && pwd)`"
427 # skip because it is too old or a bad result
431 if test "x$ap_cv_ssltk" = "x"; then
432 AC_MSG_ERROR([requires OpenSSL 0.9.6 or higher])
435 ap_ssltk_base="$ap_cv_ssltk"
437 if test ! -d $ap_ssltk_base; then
438 AC_MSG_ERROR([invalid SSL/TLS toolkit base directory $ap_ssltk_base])
440 AC_MSG_RESULT($ap_ssltk_base)
442 AC_MSG_CHECKING(for SSL/TLS toolkit version)
443 AC_MSG_RESULT($ap_ssltk_version)
445 AC_MSG_CHECKING(for SSL/TLS toolkit includes)
447 for p in $ap_ssltk_base/include /usr/local/openssl/include \
448 /usr/local/ssl/include /usr/local/include /usr/include; do
449 if test -f "$p/openssl/ssl.h"; then
454 if test "x$ap_ssltk_incdir" = "x"; then
455 AC_MSG_ERROR([OpenSSL headers not found])
457 AC_MSG_RESULT($ap_ssltk_incdir)
459 AC_MSG_CHECKING(for SSL/TLS toolkit libraries)
461 for p in $ap_ssltk_base/lib /usr/local/openssl/lib \
462 /usr/local/ssl/lib /usr/local/lib /usr/lib /lib; do
463 if test -f "$p/libssl.a" -o -f "$p/libssl.so"; then
468 if test ".$ap_ssltk_libdir" = .; then
469 AC_MSG_ERROR([OpenSSL libraries not found])
471 AC_MSG_RESULT($ap_ssltk_libdir)
473 dnl # annotate the Apache build environment with determined information
474 APR_ADDTO(INCLUDES, [-I$ap_ssltk_incdir/openssl])
475 if test "x$ap_ssltk_incdir" != "x/usr/include"; then
476 APR_ADDTO(INCLUDES, [-I$ap_ssltk_incdir])
478 if test "x$ap_ssltk_libdir" != "x/usr/lib"; then
479 APR_ADDTO(LIBS, [-L$ap_ssltk_libdir])
480 if test "x$ap_platform_runtime_link_flag" != "x"; then
481 APR_ADDTO(LIBS, [$ap_platform_runtime_link_flag$ap_ssltk_libdir])
484 APR_ADDTO(LIBS, [-lssl -lcrypto])
485 ap_cv_ssltk="$ap_ssltk_base"