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