]> granicus.if.org Git - apache/blob - acinclude.m4
7d498a1b72f91ce1183172158c7f0d24806eab53
[apache] / acinclude.m4
1
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
8
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"
14   AC_SUBST($1)
15 ])
16
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"
21 ])
22
23 dnl APACHE_GEN_CONFIG_VARS
24 dnl Creates config_vars.mk
25 AC_DEFUN(APACHE_GEN_CONFIG_VARS,[
26   APACHE_SUBST(abs_srcdir)
27   APACHE_SUBST(bindir)
28   APACHE_SUBST(sbindir)
29   APACHE_SUBST(cgidir)
30   APACHE_SUBST(logfiledir)
31   APACHE_SUBST(exec_prefix)
32   APACHE_SUBST(datadir)
33   APACHE_SUBST(localstatedir)
34   APACHE_SUBST(mandir)
35   APACHE_SUBST(libdir)
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)
48   APACHE_SUBST(prefix)
49   APACHE_SUBST(AWK)
50   APACHE_SUBST(CC)
51   APACHE_SUBST(CPP)
52   APACHE_SUBST(CXX)
53   APACHE_SUBST(CPPFLAGS)
54   APACHE_SUBST(CFLAGS)
55   APACHE_SUBST(CXXFLAGS)
56   APACHE_SUBST(LTFLAGS)
57   APACHE_SUBST(LDFLAGS)
58   APACHE_SUBST(LT_LDFLAGS)
59   APACHE_SUBST(SH_LDFLAGS)
60   APACHE_SUBST(HTTPD_LDFLAGS)
61   APACHE_SUBST(UTIL_LDFLAGS)
62   APACHE_SUBST(LIBS)
63   APACHE_SUBST(DEFS)
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)
76   APACHE_SUBST(INTERNAL_CPPFLAGS)
77   APACHE_SUBST(LIBTOOL)
78   APACHE_SUBST(SHELL)
79   APACHE_SUBST(RSYNC)
80   APACHE_SUBST(MODULE_DIRS)
81   APACHE_SUBST(MODULE_CLEANDIRS)
82   APACHE_SUBST(PORT)
83   APACHE_SUBST(SSLPORT)
84   APACHE_SUBST(CORE_IMPLIB_FILE)
85   APACHE_SUBST(CORE_IMPLIB)
86   APACHE_SUBST(SH_LIBS)
87   APACHE_SUBST(SH_LIBTOOL)
88   APACHE_SUBST(MK_IMPLIB)
89   APACHE_SUBST(MKDEP)
90   APACHE_SUBST(INSTALL_PROG_FLAGS)
91   APACHE_SUBST(DSO_MODULES)
92   APACHE_SUBST(ENABLED_DSO_MODULES)
93   APACHE_SUBST(LOAD_ALL_MODULES)
94   APACHE_SUBST(APR_BINDIR)
95   APACHE_SUBST(APR_INCLUDEDIR)
96   APACHE_SUBST(APR_VERSION)
97   APACHE_SUBST(APR_CONFIG)
98   APACHE_SUBST(APU_BINDIR)
99   APACHE_SUBST(APU_INCLUDEDIR)
100   APACHE_SUBST(APU_VERSION)
101   APACHE_SUBST(APU_CONFIG)
102   APACHE_SUBST(APREQ_MAJOR_VERSION)
103   APACHE_SUBST(APREQ_LIBTOOL_VERSION)
104
105   abs_srcdir="`(cd $srcdir && pwd)`"
106
107   echo creating config_vars.mk
108   test -d build || $mkdir_p build
109   > build/config_vars.mk
110   for i in $APACHE_VAR_SUBST; do
111     eval echo "$i = \$$i" >> build/config_vars.mk
112   done
113 ])
114
115 dnl APACHE_GEN_MAKEFILES
116 dnl Creates Makefiles
117 AC_DEFUN(APACHE_GEN_MAKEFILES,[
118   $SHELL $srcdir/build/fastgen.sh $srcdir $ac_cv_mkdir_p $BSD_MAKEFILE $APACHE_FAST_OUTPUT_FILES
119 ])
120
121 dnl ## APACHE_OUTPUT(file)
122 dnl ## adds "file" to the list of files generated by AC_OUTPUT
123 dnl ## This macro can be used several times.
124 AC_DEFUN(APACHE_OUTPUT, [
125   APACHE_OUTPUT_FILES="$APACHE_OUTPUT_FILES $1"
126 ])
127
128 dnl
129 dnl APACHE_TYPE_RLIM_T
130 dnl
131 dnl If rlim_t is not defined, define it to int
132 dnl
133 AC_DEFUN(APACHE_TYPE_RLIM_T, [
134   AC_CACHE_CHECK([for rlim_t], ac_cv_type_rlim_t, [
135     AC_TRY_COMPILE([
136 #include <sys/types.h>
137 #include <sys/time.h>
138 #include <sys/resource.h>
139 ], [rlim_t spoon;], [
140       ac_cv_type_rlim_t=yes
141     ],[ac_cv_type_rlim_t=no
142     ])
143   ])
144   if test "$ac_cv_type_rlim_t" = "no" ; then
145       AC_DEFINE(rlim_t, int,
146           [Define to 'int' if <sys/resource.h> doesn't define it for us])
147   fi
148 ])
149
150 dnl APACHE_MODPATH_INIT(modpath)
151 AC_DEFUN(APACHE_MODPATH_INIT,[
152   current_dir=$1
153   modpath_current=modules/$1
154   modpath_static=
155   modpath_shared=
156   test -d $1 || $srcdir/build/mkdir.sh $modpath_current
157   > $modpath_current/modules.mk
158 ])dnl
159 dnl
160 AC_DEFUN(APACHE_MODPATH_FINISH,[
161   echo "DISTCLEAN_TARGETS = modules.mk" >> $modpath_current/modules.mk
162   echo "static = $modpath_static" >> $modpath_current/modules.mk
163   echo "shared = $modpath_shared" >> $modpath_current/modules.mk
164   if test ! -z "$modpath_static" -o ! -z "$modpath_shared"; then
165     MODULE_DIRS="$MODULE_DIRS $current_dir"
166   else
167     MODULE_CLEANDIRS="$MODULE_CLEANDIRS $current_dir"
168   fi
169   APACHE_FAST_OUTPUT($modpath_current/Makefile)
170 ])dnl
171 dnl
172 dnl APACHE_MODPATH_ADD(name[, shared[, objects [, ldflags[, libs]]]])
173 AC_DEFUN(APACHE_MODPATH_ADD,[
174   if test -z "$3"; then
175     objects="mod_$1.lo"
176   else
177     objects="$3"
178   fi
179
180   if test -z "$module_standalone"; then
181     if test -z "$2"; then
182       # The filename of a convenience library must have a "lib" prefix:
183       libname="libmod_$1.la"
184       BUILTIN_LIBS="$BUILTIN_LIBS $modpath_current/$libname"
185       modpath_static="$modpath_static $libname"
186       cat >>$modpath_current/modules.mk<<EOF
187 $libname: $objects
188         \$(MOD_LINK) $objects $5
189 EOF
190       if test ! -z "$5"; then
191         APR_ADDTO(AP_LIBS, [$5])
192       fi
193     else
194       apache_need_shared=yes
195       libname="mod_$1.la"
196       shobjects=`echo $objects | sed 's/\.lo/.slo/g'`
197       modpath_shared="$modpath_shared $libname"
198       cat >>$modpath_current/modules.mk<<EOF
199 $libname: $shobjects
200         \$(SH_LINK) -rpath \$(libexecdir) -module -avoid-version $4 $objects $5
201 EOF
202     fi
203   fi
204 ])dnl
205
206 dnl
207 dnl APACHE_MPM_MODULE(name[, shared[, objects[, config[, path[, libs]]]]])
208 dnl
209 dnl Provide information for building the MPM.  (Enablement is handled using
210 dnl --with-mpm/--enable-mpms-shared.)
211 dnl
212 dnl name     -- name of MPM, same as MPM directory name
213 dnl shared   -- "shared" to indicate shared module build, empty string otherwise
214 dnl objects  -- one or more .lo files to link into the MPM module (default: mpmname.lo)
215 dnl config   -- configuration logic to run if the MPM is enabled
216 dnl path     -- relative path to MPM (default: server/mpm/mpmname)
217 dnl libs     -- libs needed by this MPM
218 dnl
219 AC_DEFUN(APACHE_MPM_MODULE,[
220     if ap_mpm_is_enabled $1; then
221         if test -z "$3"; then
222             objects="$1.lo"
223         else
224             objects="$3"
225         fi
226
227         if test -z "$5"; then
228             mpmpath="server/mpm/$1"
229         else
230             mpmpath=$5
231         fi
232
233         dnl VPATH support
234         test -d $mpmpath || $srcdir/build/mkdir.sh $mpmpath
235
236         APACHE_FAST_OUTPUT($mpmpath/Makefile)
237
238         if test -z "$2"; then
239             APR_ADDTO(AP_LIBS, [$6])
240             libname="lib$1.la"
241             cat >$mpmpath/modules.mk<<EOF
242 $libname: $objects
243         \$(MOD_LINK) $objects
244 DISTCLEAN_TARGETS = modules.mk
245 static = $libname
246 shared =
247 EOF
248         else
249             apache_need_shared=yes
250             libname="mod_mpm_$1.la"
251             shobjects=`echo $objects | sed 's/\.lo/.slo/g'`
252             cat >$mpmpath/modules.mk<<EOF
253 $libname: $shobjects
254         \$(SH_LINK) -rpath \$(libexecdir) -module -avoid-version $objects $6
255 DISTCLEAN_TARGETS = modules.mk
256 static =
257 shared = $libname
258 EOF
259             # add default MPM to LoadModule list
260             if test $1 = $default_mpm; then
261                 DSO_MODULES="$DSO_MODULES mpm_$1"
262                 ENABLED_DSO_MODULES="${ENABLED_DSO_MODULES},mpm_$1"
263             fi
264         fi
265         $4
266     fi
267 ])dnl
268
269 dnl
270 dnl APACHE_MODULE(name, helptext[, objects[, structname[, default[, config[, prereq_module]]]]])
271 dnl
272 dnl default is one of:
273 dnl   yes    -- enabled by default. user must explicitly disable.
274 dnl   no     -- disabled under default, most, all. user must explicitly enable.
275 dnl   most   -- disabled by default. enabled explicitly or with most or all.
276 dnl   static -- enabled as static by default, must be explicitly changed.
277 dnl   ""     -- disabled under default, most. enabled explicitly or with all.
278 dnl             XXX: The arg must really be empty here. Passing an empty shell
279 dnl             XXX: variable doesn't work for some reason. This should be
280 dnl             XXX: fixed.
281 dnl
282 dnl basically: yes/no is a hard setting. "most" means follow the "most"
283 dnl            setting. otherwise, fall under the "all" setting.
284 dnl            explicit yes/no always overrides, except if the user selects
285 dnl            "reallyall".
286 dnl
287 dnl prereq_module is a module (without the "mod_" prefix) that must be enabled
288 dnl   if the current module is enabled.  If the current module is built
289 dnl   statically, prereq_module must be built statically, too.  If these
290 dnl   conditions are not fulfilled, configure will abort if the current module
291 dnl   has been enabled explicitly. Otherwise, configure will disable the
292 dnl   current module.
293 dnl   prereq_module's APACHE_MODULE() statement must have been processed
294 dnl   before the current APACHE_MODULE() statement.
295 dnl
296 AC_DEFUN(APACHE_MODULE,[
297   AC_MSG_CHECKING(whether to enable mod_$1)
298   define([optname],[--]ifelse($5,yes,disable,enable)[-]translit($1,_,-))dnl
299   AC_ARG_ENABLE(translit($1,_,-),APACHE_HELP_STRING(optname(),$2),force_$1=$enableval,enable_$1=ifelse($5,,maybe-all,$5))
300   undefine([optname])dnl
301   _apmod_extra_msg=""
302   dnl When --enable-modules=most or --enable-modules=(really)all is set and the
303   dnl module was not explicitly requested, allow a module to disable itself if
304   dnl its pre-reqs fail.
305   case "$enable_$1" in
306     yes|static|shared)
307       _apmod_required="yes"
308       ;;
309     *)
310       case "$module_selection" in
311       reallyall|all|most)
312         _apmod_required="no"
313         ;;
314       *)
315         _apmod_required="yes"
316         ;;
317       esac
318   esac
319   if test "$enable_$1" = "static"; then
320     enable_$1=static
321   elif test "$enable_$1" = "yes"; then
322     enable_$1=$module_default
323   elif test "$enable_$1" = "most"; then
324     if test "$module_selection" = "most" -o "$module_selection" = "all" -o \
325             "$module_selection" = "reallyall"
326     then
327       enable_$1=$module_default
328     elif test "$module_selection" = "few" -o "$module_selection" = "none"; then
329       enable_$1=no
330     fi
331     _apmod_extra_msg=" ($module_selection)"
332   elif test "$enable_$1" = "maybe-all"; then
333     if test "$module_selection" = "all" -o "$module_selection" = "reallyall"
334     then
335       enable_$1=$module_default
336       _apmod_extra_msg=" ($module_selection)"
337     else
338       enable_$1=no
339     fi
340   elif test "$enable_$1" = "no" -a "$module_selection" = "reallyall" -a \
341             "$force_$1" != "no" ; then
342       enable_$1=$module_default
343       _apmod_extra_msg=" ($module_selection)"
344   fi
345   if test "$enable_$1" != "no"; then
346     dnl If we plan to enable it, allow the module to run some autoconf magic
347     dnl that may disable it because of missing dependencies.
348     ifelse([$6$7],,:,[AC_MSG_RESULT([checking dependencies])
349                       ifelse([$7],,:,[if test "$enable_$7" = "no" ; then
350                                         enable_$1=no
351                                         AC_MSG_WARN("mod_$7 is disabled but required for mod_$1")
352                                       elif test "$enable_$1" = "static" && test "$enable_$7" != "static" ; then
353                                         enable_$1=no
354                                         AC_MSG_WARN("cannot build mod_$1 statically if mod_$7 is built shared")
355                                       else])
356                                         ifelse([$6],,:,[$6])
357                       ifelse([$7],,:,[fi])
358                     AC_MSG_CHECKING(whether to enable mod_$1)
359                     if test "$enable_$1" = "no"; then
360                       if test "$_apmod_required" = "no"; then
361                         _apmod_extra_msg=" (disabled)"
362                       else
363                         AC_MSG_ERROR([mod_$1 has been requested but can not be built due to prerequisite failures])
364                       fi
365                     fi])
366   fi
367   AC_MSG_RESULT($enable_$1$_apmod_extra_msg)
368   if test "$enable_$1" != "no"; then
369     case "$enable_$1" in
370     static*)
371       MODLIST="$MODLIST ifelse($4,,$1,$4)"
372       if test "$1" = "so"; then
373           sharedobjs=yes
374       fi
375       shared="";;
376     *)
377       enable_$1=`echo $enable_$1|sed 's/shared,*//'`
378       sharedobjs=yes
379       shared=yes
380       DSO_MODULES="$DSO_MODULES $1"
381       if test "$5" = "yes" ; then
382         ENABLED_DSO_MODULES="${ENABLED_DSO_MODULES},$1"
383       fi
384       ;;
385     esac
386     define([modprefix], [MOD_]translit($1, [a-z-], [A-Z_]))
387     APACHE_MODPATH_ADD($1, $shared, $3,, [\$(]modprefix[_LDADD)])
388     APACHE_SUBST(modprefix[_LDADD])
389     undefine([modprefix])
390   fi
391 ])dnl
392
393 dnl
394 dnl APACHE_ENABLE_MODULES
395 dnl
396 AC_DEFUN(APACHE_ENABLE_MODULES,[
397   module_selection=most
398   module_default=shared
399
400   dnl Check whether we have DSO support.
401   dnl If "yes", we build shared modules by default.
402   APR_CHECK_APR_DEFINE(APR_HAS_DSO)
403
404   if test $ac_cv_define_APR_HAS_DSO = "no"; then
405     AC_MSG_WARN([Missing DSO support - building static modules by default.])
406     module_default=static
407   fi
408
409
410   AC_ARG_ENABLE(modules,
411   APACHE_HELP_STRING(--enable-modules=MODULE-LIST,Space-separated list of modules to enable | "all" | "most" | "few" | "none" | "reallyall"),[
412     if test "$enableval" = "none"; then
413        module_default=no
414        module_selection=none
415     else
416       for i in $enableval; do
417         if test "$i" = "all" -o "$i" = "most" -o "$i" = "few" -o "$i" = "reallyall"
418         then
419           module_selection=$i
420         else
421           i=`echo $i | sed 's/-/_/g'`
422           eval "enable_$i=shared"
423         fi
424       done
425     fi
426   ])
427   
428   AC_ARG_ENABLE(mods-shared,
429   APACHE_HELP_STRING(--enable-mods-shared=MODULE-LIST,Space-separated list of shared modules to enable | "all" | "most" | "few" | "reallyall"),[
430     for i in $enableval; do
431       if test "$i" = "all" -o "$i" = "most" -o "$i" = "few" -o "$i" = "reallyall"
432       then
433         module_selection=$i
434         module_default=shared
435       else
436         i=`echo $i | sed 's/-/_/g'`
437         eval "enable_$i=shared"
438       fi
439     done
440   ])
441   
442   AC_ARG_ENABLE(mods-static,
443   APACHE_HELP_STRING(--enable-mods-static=MODULE-LIST,Space-separated list of static modules to enable | "all" | "most" | "few" | "reallyall"),[
444     for i in $enableval; do
445       if test "$i" = "all" -o "$i" = "most" -o "$i" = "few" -o "$i" = "reallyall"; then
446         module_selection=$i
447         module_default=static
448       else
449         i=`echo $i | sed 's/-/_/g'`
450         eval "enable_$i=static"
451       fi
452     done
453   ])
454 ])
455
456 AC_DEFUN(APACHE_REQUIRE_CXX,[
457   if test -z "$apache_cxx_done"; then
458     AC_PROG_CXX
459     AC_PROG_CXXCPP
460     apache_cxx_done=yes
461   fi
462 ])
463
464 dnl
465 dnl APACHE_CHECK_OPENSSL
466 dnl
467 dnl Configure for OpenSSL, giving preference to
468 dnl "--with-ssl=<path>" if it was specified.
469 dnl
470 AC_DEFUN(APACHE_CHECK_OPENSSL,[
471   AC_CACHE_CHECK([for OpenSSL], [ac_cv_openssl], [
472     dnl initialise the variables we use
473     ac_cv_openssl=no
474     ap_openssl_found=""
475     ap_openssl_base=""
476     ap_openssl_libs=""
477
478     dnl Determine the OpenSSL base directory, if any
479     AC_MSG_CHECKING([for user-provided OpenSSL base directory])
480     AC_ARG_WITH(ssl, APACHE_HELP_STRING(--with-ssl=DIR,OpenSSL base directory), [
481       dnl If --with-ssl specifies a directory, we use that directory
482       if test "x$withval" != "xyes" -a "x$withval" != "x"; then
483         dnl This ensures $withval is actually a directory and that it is absolute
484         ap_openssl_base="`cd $withval ; pwd`"
485       fi
486     ])
487     if test "x$ap_openssl_base" = "x"; then
488       AC_MSG_RESULT(none)
489     else
490       AC_MSG_RESULT($ap_openssl_base)
491     fi
492
493     dnl Run header and version checks
494     saved_CPPFLAGS="$CPPFLAGS"
495     saved_LIBS="$LIBS"
496     saved_LDFLAGS="$LDFLAGS"
497     SSL_LIBS=""
498
499     dnl Before doing anything else, load in pkg-config variables
500     if test -n "$PKGCONFIG"; then
501       saved_PKG_CONFIG_PATH="$PKG_CONFIG_PATH"
502       if test "x$ap_openssl_base" != "x" -a \
503               -f "${ap_openssl_base}/lib/pkgconfig/openssl.pc"; then
504         dnl Ensure that the given path is used by pkg-config too, otherwise
505         dnl the system openssl.pc might be picked up instead.
506         PKG_CONFIG_PATH="${ap_openssl_base}/lib/pkgconfig${PKG_CONFIG_PATH+:}${PKG_CONFIG_PATH}"
507         export PKG_CONFIG_PATH
508       fi
509       ap_openssl_libs="`$PKGCONFIG --libs-only-l openssl 2>&1`"
510       if test $? -eq 0; then
511         ap_openssl_found="yes"
512         pkglookup="`$PKGCONFIG --cflags-only-I openssl`"
513         APR_ADDTO(CPPFLAGS, [$pkglookup])
514         APR_ADDTO(INCLUDES, [$pkglookup])
515         pkglookup="`$PKGCONFIG --libs-only-L --libs-only-other openssl`"
516         APR_ADDTO(LDFLAGS, [$pkglookup])
517         APR_ADDTO(SSL_LIBS, [$pkglookup])
518       fi
519       PKG_CONFIG_PATH="$saved_PKG_CONFIG_PATH"
520     fi
521
522     dnl fall back to the user-supplied directory if not found via pkg-config
523     if test "x$ap_openssl_base" != "x" -a "x$ap_openssl_found" = "x"; then
524       APR_ADDTO(CPPFLAGS, [-I$ap_openssl_base/include])
525       APR_ADDTO(INCLUDES, [-I$ap_openssl_base/include])
526       APR_ADDTO(LDFLAGS, [-L$ap_openssl_base/lib])
527       APR_ADDTO(SSL_LIBS, [-L$ap_openssl_base/lib])
528       if test "x$ap_platform_runtime_link_flag" != "x"; then
529         APR_ADDTO(LDFLAGS, [$ap_platform_runtime_link_flag$ap_openssl_base/lib])
530         APR_ADDTO(SSL_LIBS, [$ap_platform_runtime_link_flag$ap_openssl_base/lib])
531       fi
532     fi
533
534     AC_MSG_CHECKING([for OpenSSL version >= 0.9.7])
535     AC_TRY_COMPILE([#include <openssl/opensslv.h>],[
536 #if !defined(OPENSSL_VERSION_NUMBER)
537 #error "Missing OpenSSL version"
538 #endif
539 #if OPENSSL_VERSION_NUMBER < 0x0090700f
540 #error "Unsupported OpenSSL version " OPENSSL_VERSION_TEXT
541 #endif],
542       [AC_MSG_RESULT(OK)
543        ac_cv_openssl=yes],
544       [AC_MSG_RESULT(FAILED)])
545
546     if test "x$ac_cv_openssl" = "xyes"; then
547       ap_openssl_libs="-lssl -lcrypto `$apr_config --libs`"
548       APR_ADDTO(SSL_LIBS, [$ap_openssl_libs])
549       APR_ADDTO(LIBS, [$ap_openssl_libs])
550       APACHE_SUBST(SSL_LIBS)
551
552       dnl Run library and function checks
553       liberrors=""
554       AC_CHECK_HEADERS([openssl/engine.h])
555       AC_CHECK_FUNCS([SSLeay_version SSL_CTX_new], [], [liberrors="yes"])
556       AC_CHECK_FUNCS([ENGINE_init ENGINE_load_builtin_engines])
557       if test "x$liberrors" != "x"; then
558         AC_MSG_WARN([OpenSSL libraries are unusable])
559       fi
560     else
561       AC_MSG_WARN([OpenSSL version is too old])
562     fi
563
564     dnl restore
565     CPPFLAGS="$saved_CPPFLAGS"
566     LIBS="$saved_LIBS"
567     LDFLAGS="$saved_LDFLAGS"
568   ])
569   if test "x$ac_cv_openssl" = "xyes"; then
570     AC_DEFINE(HAVE_OPENSSL, 1, [Define if OpenSSL is available])
571   fi
572 ])
573
574 dnl
575 dnl APACHE_CHECK_SERF
576 dnl
577 dnl Configure for the detected libserf, giving preference to
578 dnl "--with-serf=<path>" if it was specified.
579 dnl
580 AC_DEFUN([APACHE_CHECK_SERF], [
581   AC_CACHE_CHECK([for libserf], [ac_cv_serf], [
582     ac_cv_serf=no
583     serf_prefix=/usr
584     SERF_LIBS=""
585     AC_ARG_WITH(serf, APACHE_HELP_STRING([--with-serf=PREFIX],
586                                     [Serf client library]),
587     [
588         if test "$withval" = "yes" ; then
589           serf_prefix=/usr
590         else
591           serf_prefix=$withval
592         fi
593     ])
594
595     if test "$serf_prefix" != "no" ; then
596       save_cppflags="$CPPFLAGS"
597       CPPFLAGS="$CPPFLAGS $APR_INCLUDES $APU_INCLUDES -I$serf_prefix/include/serf-0"
598       AC_CHECK_HEADERS(serf.h,[
599         save_ldflags="$LDFLAGS"
600         LDFLAGS="$LDFLAGS -L$serf_prefix/lib"
601         AC_CHECK_LIB(serf-0, serf_context_create,[ac_cv_serf="yes"])
602         LDFLAGS="$save_ldflags"])
603       CPPFLAGS="$save_cppflags"
604     fi
605   ])
606
607   APACHE_SUBST(SERF_LIBS)
608   if test "$ac_cv_serf" = "yes"; then
609     AC_DEFINE(HAVE_SERF, 1, [Define if libserf is available])
610     APR_SETVAR(SERF_LIBS, [-L$serf_prefix/lib -lserf-0])
611     APR_ADDTO(INCLUDES, [-I$serf_prefix/include/serf-0])
612   fi
613 ])
614
615
616 dnl
617 dnl APACHE_EXPORT_ARGUMENTS
618 dnl Export (via APACHE_SUBST) the various path-related variables that
619 dnl apache will use while generating scripts like autoconf and apxs and
620 dnl the default config file.
621
622 AC_DEFUN(APACHE_SUBST_EXPANDED_ARG,[
623   APR_EXPAND_VAR(exp_$1, [$]$1)
624   APACHE_SUBST(exp_$1)
625   APR_PATH_RELATIVE(rel_$1, [$]exp_$1, ${prefix})
626   APACHE_SUBST(rel_$1)
627 ])
628
629 AC_DEFUN(APACHE_EXPORT_ARGUMENTS,[
630   APACHE_SUBST_EXPANDED_ARG(exec_prefix)
631   APACHE_SUBST_EXPANDED_ARG(bindir)
632   APACHE_SUBST_EXPANDED_ARG(sbindir)
633   APACHE_SUBST_EXPANDED_ARG(libdir)
634   APACHE_SUBST_EXPANDED_ARG(libexecdir)
635   APACHE_SUBST_EXPANDED_ARG(mandir)
636   APACHE_SUBST_EXPANDED_ARG(sysconfdir)
637   APACHE_SUBST_EXPANDED_ARG(datadir)
638   APACHE_SUBST_EXPANDED_ARG(installbuilddir)
639   APACHE_SUBST_EXPANDED_ARG(errordir)
640   APACHE_SUBST_EXPANDED_ARG(iconsdir)
641   APACHE_SUBST_EXPANDED_ARG(htdocsdir)
642   APACHE_SUBST_EXPANDED_ARG(manualdir)
643   APACHE_SUBST_EXPANDED_ARG(cgidir)
644   APACHE_SUBST_EXPANDED_ARG(includedir)
645   APACHE_SUBST_EXPANDED_ARG(localstatedir)
646   APACHE_SUBST_EXPANDED_ARG(runtimedir)
647   APACHE_SUBST_EXPANDED_ARG(logfiledir)
648   APACHE_SUBST_EXPANDED_ARG(proxycachedir)
649 ])
650
651 dnl 
652 dnl APACHE_CHECK_APxVER({apr|apu}, major, minor, 
653 dnl                     [actions-if-ok], [actions-if-not-ok])
654 dnl
655 dnl Checks for APR or APR-util of given major/minor version or later; 
656 dnl if so, runs actions-if-ok; otherwise runs actions-if-not-ok if given.
657 dnl If the version is not satisfactory and actions-if-not-ok is not
658 dnl given, then an error is printed and the configure script is aborted.
659 dnl
660 dnl The first argument must be [apr] or [apu].
661 dnl
662 AC_DEFUN([APACHE_CHECK_APxVER], [
663 define(ap_ckver_major, translit($1, [apru], [APRU])[_MAJOR_VERSION])
664 define(ap_ckver_minor, translit($1, [apru], [APRU])[_MINOR_VERSION])
665 define(ap_ckver_cvar, [ap_cv_$1ver$2$3])
666 define(ap_ckver_name, ifelse([$1],[apr],[APR],[APR-util]))
667
668 ap_ckver_CPPFLAGS="$CPPFLAGS"
669 CPPFLAGS="$CPPFLAGS `$[$1]_config --includes`"
670
671 AC_CACHE_CHECK([for ap_ckver_name version $2.$3.0 or later], ap_ckver_cvar, [
672 AC_EGREP_CPP([good], [
673 #include <$1_version.h>
674 #if ]ap_ckver_major[ > $2 || (]ap_ckver_major[ == $2 && ]ap_ckver_minor[ >= $3)
675 good
676 #endif
677 ], [ap_ckver_cvar=yes], [ap_ckver_cvar=no])])
678
679 if test "$ap_ckver_cvar" = "yes"; then
680   ifelse([$4],[],[:],[$4])
681 else
682   ifelse([$5],[],[AC_MSG_ERROR([ap_ckver_name version $2.$3.0 or later is required])], [$5])
683 fi
684
685 CPPFLAGS="$ap_ckver_CPPFLAGS"
686
687 undefine([ap_ckver_major])
688 undefine([ap_ckver_minor])
689 undefine([ap_ckver_cvar])
690 undefine([ap_ckver_name])
691 ])
692
693 dnl
694 dnl APACHE_CHECK_VOID_PTR_LEN
695 dnl
696 dnl Checks if the size of a void pointer is at least as big as a "long" 
697 dnl integer type.
698 dnl
699 AC_DEFUN([APACHE_CHECK_VOID_PTR_LEN], [
700
701 AC_CACHE_CHECK([for void pointer length], [ap_cv_void_ptr_lt_long],
702 [AC_TRY_RUN([
703 int main(void)
704 {
705     return sizeof(void *) < sizeof(long); 
706 }], [ap_cv_void_ptr_lt_long=no], [ap_cv_void_ptr_lt_long=yes], 
707     [ap_cv_void_ptr_lt_long=yes])])
708
709 if test "$ap_cv_void_ptr_lt_long" = "yes"; then
710     AC_MSG_ERROR([Size of "void *" is less than size of "long"])
711 fi
712 ])
713
714 dnl
715 dnl APACHE_CHECK_APR_HAS_LDAP
716 dnl
717 dnl Check if APR_HAS_LDAP is 1
718 dnl Unfortunately, we can't use APR_CHECK_APR_DEFINE (because it only includes apr.h)
719 dnl or APR_CHECK_DEFINE (because it only checks for defined'ness and not for 0/1).
720 dnl
721 AC_DEFUN([APACHE_CHECK_APR_HAS_LDAP], [
722   AC_CACHE_CHECK([for ldap support in apr/apr-util],ac_cv_APR_HAS_LDAP,[
723     apache_old_cppflags="$CPPFLAGS"
724     CPPFLAGS="$CPPFLAGS $INCLUDES"
725     AC_EGREP_CPP(YES_IS_DEFINED, [
726 #include <apr_ldap.h>
727 #if APR_HAS_LDAP
728 YES_IS_DEFINED
729 #endif
730     ], ac_cv_APR_HAS_LDAP=yes, ac_cv_APR_HAS_LDAP=no)
731     CPPFLAGS="$apache_old_cppflags"
732   ])
733 ])
734
735 dnl
736 dnl APACHE_ADD_GCC_CFLAGS
737 dnl
738 dnl Check if compiler is gcc and supports flag. If yes, add to CFLAGS.
739 dnl
740 AC_DEFUN([APACHE_ADD_GCC_CFLAG], [
741   define([ap_gcc_ckvar], [ac_cv_gcc_]translit($1, [-:.=], [____]))
742   if test "$GCC" = "yes"; then
743     AC_CACHE_CHECK([whether gcc accepts $1], ap_gcc_ckvar, [
744       save_CFLAGS="$CFLAGS"
745       CFLAGS="$CFLAGS $1"
746       AC_COMPILE_IFELSE([AC_LANG_SOURCE([int foo() { return 0; }])],
747         [ap_gcc_ckvar=yes], [ap_gcc_ckvar=no])
748       CFLAGS="$save_CFLAGS"
749     ])
750     if test "$]ap_gcc_ckvar[" = "yes" ; then
751        APR_ADDTO(CFLAGS,[$1])
752     fi
753   fi
754   undefine([ap_gcc_ckvar])
755 ])