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