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