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