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