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