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