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