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