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