]> granicus.if.org Git - apache/blob - acinclude.m4
Update transformations.
[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]]]])
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 AC_DEFUN(APACHE_MODULE,[
286   AC_MSG_CHECKING(whether to enable mod_$1)
287   define([optname],[--]ifelse($5,yes,disable,enable)[-]translit($1,_,-))dnl
288   AC_ARG_ENABLE(translit($1,_,-),APACHE_HELP_STRING(optname(),$2),force_$1=$enableval,enable_$1=ifelse($5,,maybe-all,$5))
289   undefine([optname])dnl
290   _apmod_extra_msg=""
291   dnl When --enable-modules=most or --enable-modules=(really)all is set and the
292   dnl module was not explicitly requested, allow a module to disable itself if
293   dnl its pre-reqs fail.
294   case "$enable_$1" in
295     yes|static|shared)
296       _apmod_required="yes"
297       ;;
298     *)
299       case "$module_selection" in
300       reallyall|all|most)
301         _apmod_required="no"
302         ;;
303       *)
304         _apmod_required="yes"
305         ;;
306       esac
307   esac
308   if test "$enable_$1" = "static"; then
309     enable_$1=static
310   elif test "$enable_$1" = "yes"; then
311     enable_$1=$module_default
312   elif test "$enable_$1" = "most"; then
313     if test "$module_selection" = "most" -o "$module_selection" = "all" -o \
314             "$module_selection" = "reallyall"
315     then
316       enable_$1=$module_default
317     elif test "$module_selection" = "few" -o "$module_selection" = "none"; then
318       enable_$1=no
319     fi
320     _apmod_extra_msg=" ($module_selection)"
321   elif test "$enable_$1" = "maybe-all"; then
322     if test "$module_selection" = "all" -o "$module_selection" = "reallyall"
323     then
324       enable_$1=$module_default
325       _apmod_extra_msg=" ($module_selection)"
326     else
327       enable_$1=no
328     fi
329   elif test "$enable_$1" = "no" -a "$module_selection" = "reallyall" -a \
330             "$force_$1" != "no" ; then
331       enable_$1=$module_default
332       _apmod_extra_msg=" ($module_selection)"
333   fi
334   if test "$enable_$1" != "no"; then
335     dnl If we plan to enable it, allow the module to run some autoconf magic
336     dnl that may disable it because of missing dependencies.
337     ifelse([$6],,:,[AC_MSG_RESULT([checking dependencies])
338                     $6
339                     AC_MSG_CHECKING(whether to enable mod_$1)
340                     if test "$enable_$1" = "no"; then
341                       if test "$_apmod_required" = "no"; then
342                         _apmod_extra_msg=" (disabled)"
343                       else
344                         AC_MSG_ERROR([mod_$1 has been requested but can not be built due to prerequisite failures])
345                       fi
346                     fi])
347   fi
348   AC_MSG_RESULT($enable_$1$_apmod_extra_msg)
349   if test "$enable_$1" != "no"; then
350     case "$enable_$1" in
351     static*)
352       MODLIST="$MODLIST ifelse($4,,$1,$4)"
353       if test "$1" = "so"; then
354           sharedobjs=yes
355       fi
356       shared="";;
357     *)
358       enable_$1=`echo $enable_$1|sed 's/shared,*//'`
359       sharedobjs=yes
360       shared=yes
361       DSO_MODULES="$DSO_MODULES $1"
362       if test "$_apmod_required" = "yes" ; then
363         ENABLED_DSO_MODULES="$ENABLED_DSO_MODULES $1"
364       fi
365       ;;
366     esac
367     define([modprefix], [MOD_]translit($1, [a-z-], [A-Z_]))
368     APACHE_MODPATH_ADD($1, $shared, $3,, [\$(]modprefix[_LDADD)])
369     APACHE_SUBST(modprefix[_LDADD])
370     undefine([modprefix])
371   fi
372 ])dnl
373
374 dnl
375 dnl APACHE_ENABLE_MODULES
376 dnl
377 AC_DEFUN(APACHE_ENABLE_MODULES,[
378   module_selection=most
379   module_default=shared
380
381   dnl Check whether we have DSO support.
382   dnl If "yes", we build shared modules by default.
383   APR_CHECK_APR_DEFINE(APR_HAS_DSO)
384
385   if test $ac_cv_define_APR_HAS_DSO = "no"; then
386     AC_MSG_WARN([Missing DSO support - building static modules by default.])
387     module_default=static
388   fi
389
390
391   AC_ARG_ENABLE(modules,
392   APACHE_HELP_STRING(--enable-modules=MODULE-LIST,Space-separated list of modules to enable | "all" | "most" | "few" | "none" | "reallyall"),[
393     if test "$enableval" = "none"; then
394        module_default=no
395        module_selection=none
396     else
397       for i in $enableval; do
398         if test "$i" = "all" -o "$i" = "most" -o "$i" = "few" -o "$i" = "reallyall"
399         then
400           module_selection=$i
401         else
402           i=`echo $i | sed 's/-/_/g'`
403           eval "enable_$i=shared"
404         fi
405       done
406     fi
407   ])
408   
409   AC_ARG_ENABLE(mods-shared,
410   APACHE_HELP_STRING(--enable-mods-shared=MODULE-LIST,Space-separated list of shared modules to enable | "all" | "most" | "few" | "reallyall"),[
411     for i in $enableval; do
412       if test "$i" = "all" -o "$i" = "most" -o "$i" = "few" -o "$i" = "reallyall"
413       then
414         module_selection=$i
415         module_default=shared
416       else
417         i=`echo $i | sed 's/-/_/g'`
418         eval "enable_$i=shared"
419       fi
420     done
421   ])
422   
423   AC_ARG_ENABLE(mods-static,
424   APACHE_HELP_STRING(--enable-mods-static=MODULE-LIST,Space-separated list of static modules to enable | "all" | "most" | "few" | "reallyall"),[
425     for i in $enableval; do
426       if test "$i" = "all" -o "$i" = "most" -o "$i" = "few" -o "$i" = "reallyall"; then
427         module_selection=$i
428         module_default=static
429       else
430         i=`echo $i | sed 's/-/_/g'`
431         eval "enable_$i=static"
432       fi
433     done
434   ])
435 ])
436
437 AC_DEFUN(APACHE_REQUIRE_CXX,[
438   if test -z "$apache_cxx_done"; then
439     AC_PROG_CXX
440     AC_PROG_CXXCPP
441     apache_cxx_done=yes
442   fi
443 ])
444
445 dnl
446 dnl APACHE_CHECK_OPENSSL
447 dnl
448 dnl Configure for OpenSSL, giving preference to
449 dnl "--with-ssl=<path>" if it was specified.
450 dnl
451 AC_DEFUN(APACHE_CHECK_OPENSSL,[
452   AC_CACHE_CHECK([for OpenSSL], [ac_cv_openssl], [
453     dnl initialise the variables we use
454     ac_cv_openssl=no
455     ap_openssl_found=""
456     ap_openssl_base=""
457     ap_openssl_libs=""
458
459     dnl Determine the OpenSSL base directory, if any
460     AC_MSG_CHECKING([for user-provided OpenSSL base directory])
461     AC_ARG_WITH(ssl, APACHE_HELP_STRING(--with-ssl=DIR,OpenSSL base directory), [
462       dnl If --with-ssl specifies a directory, we use that directory
463       if test "x$withval" != "xyes" -a "x$withval" != "x"; then
464         dnl This ensures $withval is actually a directory and that it is absolute
465         ap_openssl_base="`cd $withval ; pwd`"
466       fi
467     ])
468     if test "x$ap_openssl_base" = "x"; then
469       AC_MSG_RESULT(none)
470     else
471       AC_MSG_RESULT($ap_openssl_base)
472     fi
473
474     dnl Run header and version checks
475     saved_CPPFLAGS="$CPPFLAGS"
476     saved_LIBS="$LIBS"
477     saved_LDFLAGS="$LDFLAGS"
478     SSL_LIBS=""
479
480     dnl Before doing anything else, load in pkg-config variables
481     if test -n "$PKGCONFIG"; then
482       saved_PKG_CONFIG_PATH="$PKG_CONFIG_PATH"
483       if test "x$ap_openssl_base" != "x" -a \
484               -f "${ap_openssl_base}/lib/pkgconfig/openssl.pc"; then
485         dnl Ensure that the given path is used by pkg-config too, otherwise
486         dnl the system openssl.pc might be picked up instead.
487         PKG_CONFIG_PATH="${ap_openssl_base}/lib/pkgconfig${PKG_CONFIG_PATH+:}${PKG_CONFIG_PATH}"
488         export PKG_CONFIG_PATH
489       fi
490       ap_openssl_libs="`$PKGCONFIG --libs-only-l openssl 2>&1`"
491       if test $? -eq 0; then
492         ap_openssl_found="yes"
493         pkglookup="`$PKGCONFIG --cflags-only-I openssl`"
494         APR_ADDTO(CPPFLAGS, [$pkglookup])
495         APR_ADDTO(INCLUDES, [$pkglookup])
496         pkglookup="`$PKGCONFIG --libs-only-L --libs-only-other openssl`"
497         APR_ADDTO(LDFLAGS, [$pkglookup])
498         APR_ADDTO(SSL_LIBS, [$pkglookup])
499       fi
500       PKG_CONFIG_PATH="$saved_PKG_CONFIG_PATH"
501     fi
502
503     dnl fall back to the user-supplied directory if not found via pkg-config
504     if test "x$ap_openssl_base" != "x" -a "x$ap_openssl_found" = "x"; then
505       APR_ADDTO(CPPFLAGS, [-I$ap_openssl_base/include])
506       APR_ADDTO(INCLUDES, [-I$ap_openssl_base/include])
507       APR_ADDTO(LDFLAGS, [-L$ap_openssl_base/lib])
508       APR_ADDTO(SSL_LIBS, [-L$ap_openssl_base/lib])
509       if test "x$ap_platform_runtime_link_flag" != "x"; then
510         APR_ADDTO(LDFLAGS, [$ap_platform_runtime_link_flag$ap_openssl_base/lib])
511         APR_ADDTO(SSL_LIBS, [$ap_platform_runtime_link_flag$ap_openssl_base/lib])
512       fi
513     fi
514
515     AC_MSG_CHECKING([for OpenSSL version >= 0.9.7])
516     AC_TRY_COMPILE([#include <openssl/opensslv.h>],[
517 #if !defined(OPENSSL_VERSION_NUMBER)
518 #error "Missing OpenSSL version"
519 #endif
520 #if OPENSSL_VERSION_NUMBER < 0x0090700f
521 #error "Unsupported OpenSSL version " OPENSSL_VERSION_TEXT
522 #endif],
523       [AC_MSG_RESULT(OK)
524        ac_cv_openssl=yes],
525       [AC_MSG_RESULT(FAILED)])
526
527     if test "x$ac_cv_openssl" = "xyes"; then
528       ap_openssl_libs="-lssl -lcrypto `$apr_config --libs`"
529       APR_ADDTO(SSL_LIBS, [$ap_openssl_libs])
530       APR_ADDTO(LIBS, [$ap_openssl_libs])
531       APACHE_SUBST(SSL_LIBS)
532
533       dnl Run library and function checks
534       liberrors=""
535       AC_CHECK_HEADERS([openssl/engine.h])
536       AC_CHECK_FUNCS([SSLeay_version SSL_CTX_new], [], [liberrors="yes"])
537       AC_CHECK_FUNCS([ENGINE_init ENGINE_load_builtin_engines])
538       if test "x$liberrors" != "x"; then
539         AC_MSG_WARN([OpenSSL libraries are unusable])
540       fi
541     else
542       AC_MSG_WARN([OpenSSL version is too old])
543     fi
544
545     dnl restore
546     CPPFLAGS="$saved_CPPFLAGS"
547     LIBS="$saved_LIBS"
548     LDFLAGS="$saved_LDFLAGS"
549   ])
550   if test "x$ac_cv_openssl" = "xyes"; then
551     AC_DEFINE(HAVE_OPENSSL, 1, [Define if OpenSSL is available])
552   fi
553 ])
554
555 dnl
556 dnl APACHE_CHECK_SERF
557 dnl
558 dnl Configure for the detected libserf, giving preference to
559 dnl "--with-serf=<path>" if it was specified.
560 dnl
561 AC_DEFUN([APACHE_CHECK_SERF], [
562   AC_CACHE_CHECK([for libserf], [ac_cv_serf], [
563     ac_cv_serf=no
564     serf_prefix=/usr
565     SERF_LIBS=""
566     AC_ARG_WITH(serf, APACHE_HELP_STRING([--with-serf=PREFIX],
567                                     [Serf client library]),
568     [
569         if test "$withval" = "yes" ; then
570           serf_prefix=/usr
571         else
572           serf_prefix=$withval
573         fi
574     ])
575
576     if test "$serf_prefix" != "no" ; then
577       save_cppflags="$CPPFLAGS"
578       CPPFLAGS="$CPPFLAGS $APR_INCLUDES $APU_INCLUDES -I$serf_prefix/include/serf-0"
579       AC_CHECK_HEADERS(serf.h,[
580         save_ldflags="$LDFLAGS"
581         LDFLAGS="$LDFLAGS -L$serf_prefix/lib"
582         AC_CHECK_LIB(serf-0, serf_context_create,[ac_cv_serf="yes"])
583         LDFLAGS="$save_ldflags"])
584       CPPFLAGS="$save_cppflags"
585     fi
586   ])
587
588   APACHE_SUBST(SERF_LIBS)
589   if test "$ac_cv_serf" = "yes"; then
590     AC_DEFINE(HAVE_SERF, 1, [Define if libserf is available])
591     APR_SETVAR(SERF_LIBS, [-L$serf_prefix/lib -lserf-0])
592     APR_ADDTO(INCLUDES, [-I$serf_prefix/include/serf-0])
593   fi
594 ])
595
596
597 dnl
598 dnl APACHE_EXPORT_ARGUMENTS
599 dnl Export (via APACHE_SUBST) the various path-related variables that
600 dnl apache will use while generating scripts like autoconf and apxs and
601 dnl the default config file.
602
603 AC_DEFUN(APACHE_SUBST_EXPANDED_ARG,[
604   APR_EXPAND_VAR(exp_$1, [$]$1)
605   APACHE_SUBST(exp_$1)
606   APR_PATH_RELATIVE(rel_$1, [$]exp_$1, ${prefix})
607   APACHE_SUBST(rel_$1)
608 ])
609
610 AC_DEFUN(APACHE_EXPORT_ARGUMENTS,[
611   APACHE_SUBST_EXPANDED_ARG(exec_prefix)
612   APACHE_SUBST_EXPANDED_ARG(bindir)
613   APACHE_SUBST_EXPANDED_ARG(sbindir)
614   APACHE_SUBST_EXPANDED_ARG(libdir)
615   APACHE_SUBST_EXPANDED_ARG(libexecdir)
616   APACHE_SUBST_EXPANDED_ARG(mandir)
617   APACHE_SUBST_EXPANDED_ARG(sysconfdir)
618   APACHE_SUBST_EXPANDED_ARG(datadir)
619   APACHE_SUBST_EXPANDED_ARG(installbuilddir)
620   APACHE_SUBST_EXPANDED_ARG(errordir)
621   APACHE_SUBST_EXPANDED_ARG(iconsdir)
622   APACHE_SUBST_EXPANDED_ARG(htdocsdir)
623   APACHE_SUBST_EXPANDED_ARG(manualdir)
624   APACHE_SUBST_EXPANDED_ARG(cgidir)
625   APACHE_SUBST_EXPANDED_ARG(includedir)
626   APACHE_SUBST_EXPANDED_ARG(localstatedir)
627   APACHE_SUBST_EXPANDED_ARG(runtimedir)
628   APACHE_SUBST_EXPANDED_ARG(logfiledir)
629   APACHE_SUBST_EXPANDED_ARG(proxycachedir)
630 ])
631
632 dnl 
633 dnl APACHE_CHECK_APxVER({apr|apu}, major, minor, 
634 dnl                     [actions-if-ok], [actions-if-not-ok])
635 dnl
636 dnl Checks for APR or APR-util of given major/minor version or later; 
637 dnl if so, runs actions-if-ok; otherwise runs actions-if-not-ok if given.
638 dnl If the version is not satisfactory and actions-if-not-ok is not
639 dnl given, then an error is printed and the configure script is aborted.
640 dnl
641 dnl The first argument must be [apr] or [apu].
642 dnl
643 AC_DEFUN([APACHE_CHECK_APxVER], [
644 define(ap_ckver_major, translit($1, [apru], [APRU])[_MAJOR_VERSION])
645 define(ap_ckver_minor, translit($1, [apru], [APRU])[_MINOR_VERSION])
646 define(ap_ckver_cvar, [ap_cv_$1ver$2$3])
647 define(ap_ckver_name, ifelse([$1],[apr],[APR],[APR-util]))
648
649 ap_ckver_CPPFLAGS="$CPPFLAGS"
650 CPPFLAGS="$CPPFLAGS `$[$1]_config --includes`"
651
652 AC_CACHE_CHECK([for ap_ckver_name version $2.$3.0 or later], ap_ckver_cvar, [
653 AC_EGREP_CPP([good], [
654 #include <$1_version.h>
655 #if ]ap_ckver_major[ > $2 || (]ap_ckver_major[ == $2 && ]ap_ckver_minor[ >= $3)
656 good
657 #endif
658 ], [ap_ckver_cvar=yes], [ap_ckver_cvar=no])])
659
660 if test "$ap_ckver_cvar" = "yes"; then
661   ifelse([$4],[],[:],[$4])
662 else
663   ifelse([$5],[],[AC_MSG_ERROR([ap_ckver_name version $2.$3.0 or later is required])], [$5])
664 fi
665
666 CPPFLAGS="$ap_ckver_CPPFLAGS"
667
668 undefine([ap_ckver_major])
669 undefine([ap_ckver_minor])
670 undefine([ap_ckver_cvar])
671 undefine([ap_ckver_name])
672 ])
673
674 dnl
675 dnl APACHE_CHECK_VOID_PTR_LEN
676 dnl
677 dnl Checks if the size of a void pointer is at least as big as a "long" 
678 dnl integer type.
679 dnl
680 AC_DEFUN([APACHE_CHECK_VOID_PTR_LEN], [
681
682 AC_CACHE_CHECK([for void pointer length], [ap_cv_void_ptr_lt_long],
683 [AC_TRY_RUN([
684 int main(void)
685 {
686     return sizeof(void *) < sizeof(long); 
687 }], [ap_cv_void_ptr_lt_long=no], [ap_cv_void_ptr_lt_long=yes], 
688     [ap_cv_void_ptr_lt_long=yes])])
689
690 if test "$ap_cv_void_ptr_lt_long" = "yes"; then
691     AC_MSG_ERROR([Size of "void *" is less than size of "long"])
692 fi
693 ])
694
695 dnl
696 dnl APACHE_CHECK_APR_HAS_LDAP
697 dnl
698 dnl Check if APR_HAS_LDAP is 1
699 dnl Unfortunately, we can't use APR_CHECK_APR_DEFINE (because it only includes apr.h)
700 dnl or APR_CHECK_DEFINE (because it only checks for defined'ness and not for 0/1).
701 dnl
702 AC_DEFUN([APACHE_CHECK_APR_HAS_LDAP], [
703   AC_CACHE_CHECK([for ldap support in apr/apr-util],ac_cv_APR_HAS_LDAP,[
704     apache_old_cppflags="$CPPFLAGS"
705     CPPFLAGS="$CPPFLAGS $INCLUDES"
706     AC_EGREP_CPP(YES_IS_DEFINED, [
707 #include <apr_ldap.h>
708 #if APR_HAS_LDAP
709 YES_IS_DEFINED
710 #endif
711     ], ac_cv_APR_HAS_LDAP=yes, ac_cv_APR_HAS_LDAP=no)
712     CPPFLAGS="$apache_old_cppflags"
713   ])
714 ])
715
716 dnl
717 dnl APACHE_ADD_GCC_CFLAGS
718 dnl
719 dnl Check if compiler is gcc and supports flag. If yes, add to CFLAGS.
720 dnl
721 AC_DEFUN([APACHE_ADD_GCC_CFLAG], [
722   define([ap_gcc_ckvar], [ac_cv_gcc_]translit($1, [-:.=], [____]))
723   if test "$GCC" = "yes"; then
724     AC_CACHE_CHECK([whether gcc accepts $1], ap_gcc_ckvar, [
725       save_CFLAGS="$CFLAGS"
726       CFLAGS="$CFLAGS $1"
727       AC_COMPILE_IFELSE([AC_LANG_SOURCE([int foo() { return 0; }])],
728         [ap_gcc_ckvar=yes], [ap_gcc_ckvar=no])
729       CFLAGS="$save_CFLAGS"
730     ])
731     if test "$]ap_gcc_ckvar[" = "yes" ; then
732        APR_ADDTO(CFLAGS,[$1])
733     fi
734   fi
735   undefine([ap_gcc_ckvar])
736 ])