]> granicus.if.org Git - apache/blob - acinclude.m4
Remove obsolete "see error log" log messages.
[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(LIBTOOL)
77   APACHE_SUBST(SHELL)
78   APACHE_SUBST(RSYNC)
79   APACHE_SUBST(MODULE_DIRS)
80   APACHE_SUBST(MODULE_CLEANDIRS)
81   APACHE_SUBST(PORT)
82   APACHE_SUBST(SSLPORT)
83   APACHE_SUBST(nonssl_listen_stmt_1)
84   APACHE_SUBST(nonssl_listen_stmt_2)
85   APACHE_SUBST(CORE_IMPLIB_FILE)
86   APACHE_SUBST(CORE_IMPLIB)
87   APACHE_SUBST(SH_LIBS)
88   APACHE_SUBST(SH_LIBTOOL)
89   APACHE_SUBST(MK_IMPLIB)
90   APACHE_SUBST(MKDEP)
91   APACHE_SUBST(INSTALL_PROG_FLAGS)
92   APACHE_SUBST(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             fi
260         fi
261         $4
262     fi
263 ])dnl
264
265 dnl
266 dnl APACHE_MODULE(name, helptext[, objects[, structname[, default[, config]]]])
267 dnl
268 dnl default is one of:
269 dnl   yes    -- enabled by default. user must explicitly disable.
270 dnl   no     -- disabled under default, most, all. user must explicitly enable.
271 dnl   most   -- disabled by default. enabled explicitly or with most or all.
272 dnl   static -- enabled as static by default, must be explicitly changed.
273 dnl   ""     -- disabled under default, most. enabled explicitly or with all.
274 dnl
275 dnl basically: yes/no is a hard setting. "most" means follow the "most"
276 dnl            setting. otherwise, fall under the "all" setting.
277 dnl            explicit yes/no always overrides, except if the user selects
278 dnl            "reallyall".
279 dnl
280 AC_DEFUN(APACHE_MODULE,[
281   AC_MSG_CHECKING(whether to enable mod_$1)
282   define([optname],[--]ifelse($5,yes,disable,enable)[-]translit($1,_,-))dnl
283   AC_ARG_ENABLE(translit($1,_,-),APACHE_HELP_STRING(optname(),$2),,enable_$1=ifelse($5,,maybe-all,$5))
284   undefine([optname])dnl
285   _apmod_extra_msg=""
286   dnl When --enable-modules=most or --enable-modules=reallyall is set and the
287   dnl module was not explicitly requested, allow a module to disable itself if
288   dnl its pre-reqs fail.
289   dnl XXX: Todo: Allow to disable specific modules even with "reallyall".
290   if test "$module_selection" = "most" -a "$enable_$1" = "most" ||
291      test "$module_selection" = "reallyall" -a "$enable_$1" != "yes" -a \
292           "$enable_$1" != "static"
293   then
294     _apmod_error_fatal="no"
295   else
296     _apmod_error_fatal="yes"
297   fi
298   if test "$enable_$1" = "static"; then
299     enable_$1=static
300   elif test "$enable_$1" = "yes"; then
301     enable_$1=$module_default
302   elif test "$enable_$1" = "most"; then
303     if test "$module_selection" = "most" -o "$module_selection" = "all" -o \
304             "$module_selection" = "reallyall"
305     then
306       enable_$1=$module_default
307     elif test "$module_selection" = "few" -o "$module_selection" = "none"; then
308       enable_$1=no
309     fi
310     _apmod_extra_msg=" ($module_selection)"
311   elif test "$enable_$1" = "maybe-all"; then
312     if test "$module_selection" = "all" -o "$module_selection" = "reallyall"
313     then
314       enable_$1=$module_default
315       _apmod_extra_msg=" ($module_selection)"
316     else
317       enable_$1=no
318     fi
319   elif test "$enable_$1" = "no" -a "$module_selection" = "reallyall"; then
320       enable_$1=$module_default
321       _apmod_extra_msg=" ($module_selection)"
322   fi
323   if test "$enable_$1" != "no"; then
324     dnl If we plan to enable it, allow the module to run some autoconf magic
325     dnl that may disable it because of missing dependencies.
326     ifelse([$6],,:,[AC_MSG_RESULT([checking dependencies])
327                     $6
328                     AC_MSG_CHECKING(whether to enable mod_$1)
329                     if test "$enable_$1" = "no"; then
330                       if test "$_apmod_error_fatal" = "no"; then
331                         _apmod_extra_msg=" (disabled)"
332                       else
333                         AC_MSG_ERROR([mod_$1 has been requested but can not be built due to prerequisite failures])
334                       fi
335                     fi])
336   fi
337   AC_MSG_RESULT($enable_$1$_apmod_extra_msg)
338   if test "$enable_$1" != "no"; then
339     case "$enable_$1" in
340     static*)
341       MODLIST="$MODLIST ifelse($4,,$1,$4)"
342       if test "$1" = "so"; then
343           sharedobjs=yes
344       fi
345       shared="";;
346     *)
347       enable_$1=`echo $enable_$1|sed 's/shared,*//'`
348       sharedobjs=yes
349       shared=yes
350       DSO_MODULES="$DSO_MODULES $1"
351       ;;
352     esac
353     define([modprefix], [MOD_]translit($1, [a-z-], [A-Z_]))
354     APACHE_MODPATH_ADD($1, $shared, $3,, [\$(]modprefix[_LDADD)])
355     APACHE_SUBST(modprefix[_LDADD])
356     undefine([modprefix])
357   fi
358 ])dnl
359
360 dnl
361 dnl APACHE_ENABLE_MODULES
362 dnl
363 AC_DEFUN(APACHE_ENABLE_MODULES,[
364   module_selection=most
365   module_default=shared
366
367   dnl Check whether we have DSO support.
368   dnl If "yes", we build shared modules by default.
369   APR_CHECK_APR_DEFINE(APR_HAS_DSO)
370
371   if test $ac_cv_define_APR_HAS_DSO = "no"; then
372     AC_MSG_WARN([Missing DSO support - building static modules by default.])
373     module_default=static
374   fi
375
376
377   AC_ARG_ENABLE(modules,
378   APACHE_HELP_STRING(--enable-modules=MODULE-LIST,Space-separated list of modules to enable | "all" | "most" | "few" | "none"| "reallyall"),[
379     if test "$enableval" = "none"; then
380        module_default=no
381        module_selection=none
382     else
383       for i in $enableval; do
384         if test "$i" = "all" -o "$i" = "most" -o "$i" = "few" -o "$i" = "reallyall"
385         then
386           module_selection=$i
387         else
388           i=`echo $i | sed 's/-/_/g'`
389           eval "enable_$i=shared"
390         fi
391       done
392     fi
393   ])
394   
395   AC_ARG_ENABLE(mods-shared,
396   APACHE_HELP_STRING(--enable-mods-shared=MODULE-LIST,Space-separated list of shared modules to enable | "all" | "most" | "few"| "reallyall"),[
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         module_default=shared
402       else
403         i=`echo $i | sed 's/-/_/g'`
404         eval "enable_$i=shared"
405       fi
406     done
407   ])
408   
409   AC_ARG_ENABLE(mods-static,
410   APACHE_HELP_STRING(--enable-mods-static=MODULE-LIST,Space-separated list of static modules to enable | "all" | "most" | "few"),[
411     for i in $enableval; do
412       if test "$i" = "all" -o "$i" = "most" -o "$i" = "few"; then
413         module_selection=$i
414         module_default=static
415       else
416         i=`echo $i | sed 's/-/_/g'`
417         eval "enable_$i=static"
418       fi
419     done
420   ])
421 ])
422
423 AC_DEFUN(APACHE_REQUIRE_CXX,[
424   if test -z "$apache_cxx_done"; then
425     AC_PROG_CXX
426     AC_PROG_CXXCPP
427     apache_cxx_done=yes
428   fi
429 ])
430
431 dnl
432 dnl APACHE_CHECK_SSL_TOOLKIT
433 dnl
434 dnl Configure for the detected openssl/ssl-c toolkit installation, giving
435 dnl preference to "--with-ssl=<path>" if it was specified.
436 dnl
437 AC_DEFUN(APACHE_CHECK_SSL_TOOLKIT,[
438 if test "x$ap_ssltk_configured" = "x"; then
439   dnl initialise the variables we use
440   ap_ssltk_found=""
441   ap_ssltk_base=""
442   ap_ssltk_libs=""
443   ap_ssltk_type=""
444
445   dnl Determine the SSL/TLS toolkit's base directory, if any
446   AC_MSG_CHECKING([for user-provided SSL/TLS toolkit base])
447   AC_ARG_WITH(sslc, APACHE_HELP_STRING(--with-sslc=DIR,RSA SSL-C SSL/TLS toolkit), [
448     dnl If --with-sslc specifies a directory, we use that directory or fail
449     if test "x$withval" != "xyes" -a "x$withval" != "x"; then
450       dnl This ensures $withval is actually a directory and that it is absolute
451       ap_ssltk_base="`cd $withval ; pwd`"
452     fi
453     ap_ssltk_type="sslc"
454   ])
455   AC_ARG_WITH(ssl, APACHE_HELP_STRING(--with-ssl=DIR,OpenSSL SSL/TLS toolkit), [
456     dnl If --with-ssl specifies a directory, we use that directory or fail
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_ssltk_base="`cd $withval ; pwd`"
460     fi
461   ])
462   if test "x$ap_ssltk_base" = "x"; then
463     AC_MSG_RESULT(none)
464   else
465     AC_MSG_RESULT($ap_ssltk_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 (if not sslc).
475   if test "x$ap_ssltk_type" = "x" -a -n "$PKGCONFIG"; then
476     saved_PKG_CONFIG_PATH="$PKG_CONFIG_PATH"
477     if test "x$ap_ssltk_base" != "x" -a \
478             -f "${ap_ssltk_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_ssltk_base}/lib/pkgconfig${PKG_CONFIG_PATH+:}${PKG_CONFIG_PATH}"
482       export PKG_CONFIG_PATH
483     fi
484     ap_ssltk_libs="`$PKGCONFIG --libs-only-l openssl 2>&1`"
485     if test $? -eq 0; then
486       ap_ssltk_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   if test "x$ap_ssltk_base" != "x" -a "x$ap_ssltk_found" = "x"; then
497     APR_ADDTO(CPPFLAGS, [-I$ap_ssltk_base/include])
498     APR_ADDTO(INCLUDES, [-I$ap_ssltk_base/include])
499     APR_ADDTO(LDFLAGS, [-L$ap_ssltk_base/lib])
500     APR_ADDTO(SSL_LIBS, [-L$ap_ssltk_base/lib])
501     if test "x$ap_platform_runtime_link_flag" != "x"; then
502       APR_ADDTO(LDFLAGS, [$ap_platform_runtime_link_flag$ap_ssltk_base/lib])
503       APR_ADDTO(SSL_LIBS, [$ap_platform_runtime_link_flag$ap_ssltk_base/lib])
504     fi
505   fi
506   if test "x$ap_ssltk_type" = "x"; then
507     dnl First check for manditory headers
508     AC_CHECK_HEADERS([openssl/opensslv.h openssl/ssl.h], [ap_ssltk_type="openssl"], [])
509     if test "$ap_ssltk_type" = "openssl"; then
510       dnl so it's OpenSSL - test for a good version
511       AC_MSG_CHECKING([for OpenSSL version])
512       AC_TRY_COMPILE([#include <openssl/opensslv.h>],[
513 #if !defined(OPENSSL_VERSION_NUMBER)
514 #error "Missing openssl version"
515 #endif
516 #if  (OPENSSL_VERSION_NUMBER < 0x009060af) \
517  || ((OPENSSL_VERSION_NUMBER > 0x00907000) && (OPENSSL_VERSION_NUMBER < 0x0090702f))
518 #error "Insecure openssl version " OPENSSL_VERSION_TEXT
519 #endif],
520       [AC_MSG_RESULT(OK)],
521       [dnl Replace this with OPENSSL_VERSION_TEXT from opensslv.h?
522        AC_MSG_RESULT([not encouraging])
523        AC_MSG_WARN([OpenSSL version may contain security vulnerabilities!]
524                    [ Ensure the latest security patches have been applied!])
525       ])
526     else
527       AC_MSG_RESULT([no OpenSSL headers found])
528     fi
529   fi
530   if test "$ap_ssltk_type" != "openssl"; then
531     dnl Might be SSL-C - report, then test anything relevant
532     AC_CHECK_HEADERS([sslc.h], [ap_ssltk_type="sslc"], [ap_ssltk_type=""])
533     if test "$ap_ssltk_type" = "sslc"; then
534       ap_ssltk_libs="-lsslc"
535       AC_MSG_CHECKING([for SSL-C version])
536       AC_TRY_COMPILE([#include <sslc.h>],[
537 #if !defined(SSLC_VERSION_NUMBER)
538 #error "Missing SSL-C version"
539 #endif
540 #if SSLC_VERSION_NUMBER < 0x2310
541 #define stringize_ver(x) #x
542 #error "Insecure SSL-C version " stringize_ver(SSLC_VERSION_NUMBER)
543 #endif],
544       [AC_MSG_RESULT(OK)],
545       [dnl Replace this with SSLC_VERSION_NUMBER?
546        AC_MSG_RESULT([not encouraging])
547        echo "WARNING: SSL-C version may contain security vulnerabilities!"
548        echo "         Ensure the latest security patches have been applied!"
549       ])
550     else
551       AC_MSG_RESULT([no SSL-C headers found])
552     fi
553   fi
554   if test "x$ap_ssltk_type" = "x"; then
555     AC_MSG_ERROR([...No recognized SSL/TLS toolkit detected])
556   fi
557
558   if test "$ap_ssltk_type" = "openssl" -a "x$ap_ssltk_found" = "x"; then
559     ap_ssltk_found="yes"
560     ap_ssltk_libs="-lssl -lcrypto `$apr_config --libs`"
561   fi
562   APR_ADDTO(SSL_LIBS, [$ap_ssltk_libs])
563   APR_ADDTO(LIBS, [$ap_ssltk_libs])
564   APACHE_SUBST(SSL_LIBS)
565
566   dnl Run library and function checks
567   liberrors=""
568   if test "$ap_ssltk_type" = "openssl"; then
569     AC_CHECK_HEADERS([openssl/engine.h])
570     AC_CHECK_FUNCS([SSLeay_version SSL_CTX_new], [], [liberrors="yes"])
571     AC_CHECK_FUNCS([ENGINE_init ENGINE_load_builtin_engines])
572   else
573     AC_CHECK_FUNCS([SSLC_library_version SSL_CTX_new], [], [liberrors="yes"])
574     AC_CHECK_FUNCS(SSL_set_state)
575   fi
576   dnl restore
577   CPPFLAGS="$saved_CPPFLAGS"
578   LIBS="$saved_LIBS"
579   LDFLAGS="$saved_LDFLAGS"
580   if test "x$liberrors" != "x"; then
581     AC_MSG_ERROR([... Error, SSL/TLS libraries were missing or unusable])
582   fi
583
584   dnl Adjust apache's configuration based on what we found above.
585   dnl (a) define preprocessor symbols
586   if test "$ap_ssltk_type" = "openssl"; then
587     AC_DEFINE(HAVE_OPENSSL, 1, [Define if SSL is supported using OpenSSL])
588   else
589     AC_DEFINE(HAVE_SSLC, 1, [Define if SSL is supported using SSL-C])
590   fi
591 fi
592 ])
593
594 dnl
595 dnl APACHE_CHECK_SERF
596 dnl
597 dnl Configure for the detected libserf, giving preference to
598 dnl "--with-serf=<path>" if it was specified.
599 dnl
600 AC_DEFUN([APACHE_CHECK_SERF], [
601   AC_CACHE_CHECK([for libserf], [ac_cv_serf], [
602     ac_cv_serf=no
603     serf_prefix=/usr
604     SERF_LIBS=""
605     AC_ARG_WITH(serf, APACHE_HELP_STRING([--with-serf=PREFIX],
606                                     [Serf client library]),
607     [
608         if test "$withval" = "yes" ; then
609           serf_prefix=/usr
610         else
611           serf_prefix=$withval
612         fi
613     ])
614
615     if test "$serf_prefix" != "no" ; then
616       save_cppflags="$CPPFLAGS"
617       CPPFLAGS="$CPPFLAGS $APR_INCLUDES $APU_INCLUDES -I$serf_prefix/include/serf-0"
618       AC_CHECK_HEADERS(serf.h,[
619         save_ldflags="$LDFLAGS"
620         LDFLAGS="$LDFLAGS -L$serf_prefix/lib"
621         AC_CHECK_LIB(serf-0, serf_context_create,[ac_cv_serf="yes"])
622         LDFLAGS="$save_ldflags"])
623       CPPFLAGS="$save_cppflags"
624     fi
625   ])
626
627   APACHE_SUBST(SERF_LIBS)
628   if test "$ac_cv_serf" = "yes"; then
629     AC_DEFINE(HAVE_SERF, 1, [Define if libserf is available])
630     APR_SETVAR(SERF_LIBS, [-L$serf_prefix/lib -lserf-0])
631     APR_ADDTO(INCLUDES, [-I$serf_prefix/include/serf-0])
632   fi
633 ])
634
635
636 dnl
637 dnl APACHE_EXPORT_ARGUMENTS
638 dnl Export (via APACHE_SUBST) the various path-related variables that
639 dnl apache will use while generating scripts like autoconf and apxs and
640 dnl the default config file.
641
642 AC_DEFUN(APACHE_SUBST_EXPANDED_ARG,[
643   APR_EXPAND_VAR(exp_$1, [$]$1)
644   APACHE_SUBST(exp_$1)
645   APR_PATH_RELATIVE(rel_$1, [$]exp_$1, ${prefix})
646   APACHE_SUBST(rel_$1)
647 ])
648
649 AC_DEFUN(APACHE_EXPORT_ARGUMENTS,[
650   APACHE_SUBST_EXPANDED_ARG(exec_prefix)
651   APACHE_SUBST_EXPANDED_ARG(bindir)
652   APACHE_SUBST_EXPANDED_ARG(sbindir)
653   APACHE_SUBST_EXPANDED_ARG(libdir)
654   APACHE_SUBST_EXPANDED_ARG(libexecdir)
655   APACHE_SUBST_EXPANDED_ARG(mandir)
656   APACHE_SUBST_EXPANDED_ARG(sysconfdir)
657   APACHE_SUBST_EXPANDED_ARG(datadir)
658   APACHE_SUBST_EXPANDED_ARG(installbuilddir)
659   APACHE_SUBST_EXPANDED_ARG(errordir)
660   APACHE_SUBST_EXPANDED_ARG(iconsdir)
661   APACHE_SUBST_EXPANDED_ARG(htdocsdir)
662   APACHE_SUBST_EXPANDED_ARG(manualdir)
663   APACHE_SUBST_EXPANDED_ARG(cgidir)
664   APACHE_SUBST_EXPANDED_ARG(includedir)
665   APACHE_SUBST_EXPANDED_ARG(localstatedir)
666   APACHE_SUBST_EXPANDED_ARG(runtimedir)
667   APACHE_SUBST_EXPANDED_ARG(logfiledir)
668   APACHE_SUBST_EXPANDED_ARG(proxycachedir)
669 ])
670
671 dnl 
672 dnl APACHE_CHECK_APxVER({apr|apu}, major, minor, 
673 dnl                     [actions-if-ok], [actions-if-not-ok])
674 dnl
675 dnl Checks for APR or APR-util of given major/minor version or later; 
676 dnl if so, runs actions-if-ok; otherwise runs actions-if-not-ok if given.
677 dnl If the version is not satisfactory and actions-if-not-ok is not
678 dnl given, then an error is printed and the configure script is aborted.
679 dnl
680 dnl The first argument must be [apr] or [apu].
681 dnl
682 AC_DEFUN([APACHE_CHECK_APxVER], [
683 define(ap_ckver_major, translit($1, [apru], [APRU])[_MAJOR_VERSION])
684 define(ap_ckver_minor, translit($1, [apru], [APRU])[_MINOR_VERSION])
685 define(ap_ckver_cvar, [ap_cv_$1ver$2$3])
686 define(ap_ckver_name, ifelse([$1],[apr],[APR],[APR-util]))
687
688 ap_ckver_CPPFLAGS="$CPPFLAGS"
689 CPPFLAGS="$CPPFLAGS `$[$1]_config --includes`"
690
691 AC_CACHE_CHECK([for ap_ckver_name version $2.$3.0 or later], ap_ckver_cvar, [
692 AC_EGREP_CPP([good], [
693 #include <$1_version.h>
694 #if ]ap_ckver_major[ > $2 || (]ap_ckver_major[ == $2 && ]ap_ckver_minor[ >= $3)
695 good
696 #endif
697 ], [ap_ckver_cvar=yes], [ap_ckver_cvar=no])])
698
699 if test "$ap_ckver_cvar" = "yes"; then
700   ifelse([$4],[],[:],[$4])
701 else
702   ifelse([$5],[],[AC_MSG_ERROR([ap_ckver_name version $2.$3.0 or later is required])], [$5])
703 fi
704
705 CPPFLAGS="$ap_ckver_CPPFLAGS"
706
707 undefine([ap_ckver_major])
708 undefine([ap_ckver_minor])
709 undefine([ap_ckver_cvar])
710 undefine([ap_ckver_name])
711 ])
712
713 dnl
714 dnl APACHE_CHECK_VOID_PTR_LEN
715 dnl
716 dnl Checks if the size of a void pointer is at least as big as a "long" 
717 dnl integer type.
718 dnl
719 AC_DEFUN([APACHE_CHECK_VOID_PTR_LEN], [
720
721 AC_CACHE_CHECK([for void pointer length], [ap_cv_void_ptr_lt_long],
722 [AC_TRY_RUN([
723 int main(void)
724 {
725     return sizeof(void *) < sizeof(long); 
726 }], [ap_cv_void_ptr_lt_long=no], [ap_cv_void_ptr_lt_long=yes], 
727     [ap_cv_void_ptr_lt_long=yes])])
728
729 if test "$ap_cv_void_ptr_lt_long" = "yes"; then
730     AC_MSG_ERROR([Size of "void *" is less than size of "long"])
731 fi
732 ])