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