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