1
2dnl APACHE_HELP_STRING(LHS, RHS)
3dnl Autoconf 2.50 can not handle substr correctly.  It does have 
4dnl AC_HELP_STRING, so let's try to call it if we can.
5dnl Note: this define must be on one line so that it can be properly returned
6dnl as the help string.
7AC_DEFUN(APACHE_HELP_STRING,[ifelse(regexp(AC_ACVERSION, 2\.1), -1, AC_HELP_STRING($1,$2),[  ]$1 substr([                       ],len($1))$2)])dnl
8
9dnl APACHE_SUBST(VARIABLE)
10dnl Makes VARIABLE available in generated files
11dnl (do not use @variable@ in Makefiles, but $(variable))
12AC_DEFUN(APACHE_SUBST,[
13  APACHE_VAR_SUBST="$APACHE_VAR_SUBST $1"
14  AC_SUBST($1)
15])
16
17dnl APACHE_FAST_OUTPUT(FILENAME)
18dnl Perform substitutions on FILENAME (Makefiles only)
19AC_DEFUN(APACHE_FAST_OUTPUT,[
20  APACHE_FAST_OUTPUT_FILES="$APACHE_FAST_OUTPUT_FILES $1"
21])
22
23dnl APACHE_GEN_CONFIG_VARS
24dnl Creates config_vars.mk
25AC_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  AC_MSG_NOTICE([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
113dnl APACHE_GEN_MAKEFILES
114dnl Creates Makefiles
115AC_DEFUN(APACHE_GEN_MAKEFILES,[
116  $SHELL $srcdir/build/fastgen.sh $srcdir $ac_cv_mkdir_p $BSD_MAKEFILE $APACHE_FAST_OUTPUT_FILES
117])
118
119dnl ## APACHE_OUTPUT(file)
120dnl ## adds "file" to the list of files generated by AC_OUTPUT
121dnl ## This macro can be used several times.
122AC_DEFUN(APACHE_OUTPUT, [
123  APACHE_OUTPUT_FILES="$APACHE_OUTPUT_FILES $1"
124])
125
126dnl
127dnl APACHE_TYPE_RLIM_T
128dnl
129dnl If rlim_t is not defined, define it to int
130dnl
131AC_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
148dnl the list of build variables which are available for customization on a
149dnl per module subdir basis (to be inserted into modules.mk with a "MOD_"
150dnl prefix, i.e. MOD_CFLAGS etc.). Used in APACHE_MODPATH_{INIT,FINISH}.
151define(mod_buildvars, [CFLAGS CXXFLAGS CPPFLAGS LDFLAGS LIBS INCLUDES])
152dnl
153dnl APACHE_MODPATH_INIT(modpath)
154AC_DEFUN(APACHE_MODPATH_INIT,[
155  current_dir=$1
156  modpath_current=modules/$1
157  modpath_static=
158  modpath_shared=
159  for var in mod_buildvars; do
160    eval MOD_$var=
161  done
162  test -d $1 || $srcdir/build/mkdir.sh $modpath_current
163  > $modpath_current/modules.mk
164])dnl
165dnl
166AC_DEFUN(APACHE_MODPATH_FINISH,[
167  echo "DISTCLEAN_TARGETS = modules.mk" >> $modpath_current/modules.mk
168  echo "static = $modpath_static" >> $modpath_current/modules.mk
169  echo "shared = $modpath_shared" >> $modpath_current/modules.mk
170  for var in mod_buildvars; do
171    if eval val=\"\$MOD_$var\"; test -n "$val"; then
172      echo "MOD_$var = $val" >> $modpath_current/modules.mk
173    fi
174  done
175  if test ! -z "$modpath_static" -o ! -z "$modpath_shared"; then
176    MODULE_DIRS="$MODULE_DIRS $current_dir"
177  else
178    MODULE_CLEANDIRS="$MODULE_CLEANDIRS $current_dir"
179  fi
180  APACHE_FAST_OUTPUT($modpath_current/Makefile)
181])dnl
182dnl
183dnl APACHE_MODPATH_ADD(name[, shared[, objects [, ldflags[, libs]]]])
184AC_DEFUN(APACHE_MODPATH_ADD,[
185  if test -z "$3"; then
186    objects="mod_$1.lo"
187  else
188    objects="$3"
189  fi
190
191  if test -z "$module_standalone"; then
192    if test -z "$2"; then
193      # The filename of a convenience library must have a "lib" prefix:
194      libname="libmod_$1.la"
195      BUILTIN_LIBS="$BUILTIN_LIBS $modpath_current/$libname"
196      modpath_static="$modpath_static $libname"
197      cat >>$modpath_current/modules.mk<<EOF
198$libname: $objects
199	\$(MOD_LINK) $objects $5
200EOF
201      if test ! -z "$5"; then
202        APR_ADDTO(AP_LIBS, [$5])
203      fi
204    else
205      apache_need_shared=yes
206      libname="mod_$1.la"
207      shobjects=`echo $objects | sed 's/\.lo/.slo/g'`
208      modpath_shared="$modpath_shared $libname"
209      cat >>$modpath_current/modules.mk<<EOF
210$libname: $shobjects
211	\$(SH_LINK) -rpath \$(libexecdir) -module -avoid-version $4 $objects $5
212EOF
213    fi
214  fi
215])dnl
216
217dnl
218dnl APACHE_MPM_MODULE(name[, shared[, objects[, config[, path[, libs]]]]])
219dnl
220dnl Provide information for building the MPM.  (Enablement is handled using
221dnl --with-mpm/--enable-mpms-shared.)
222dnl
223dnl name     -- name of MPM, same as MPM directory name
224dnl shared   -- "shared" to indicate shared module build, empty string otherwise
225dnl objects  -- one or more .lo files to link into the MPM module (default: mpmname.lo)
226dnl config   -- configuration logic to run if the MPM is enabled
227dnl path     -- relative path to MPM (default: server/mpm/mpmname)
228dnl libs     -- libs needed by this MPM
229dnl
230AC_DEFUN(APACHE_MPM_MODULE,[
231    if ap_mpm_is_enabled $1; then
232        if test -z "$3"; then
233            objects="$1.lo"
234        else
235            objects="$3"
236        fi
237
238        if test -z "$5"; then
239            mpmpath="server/mpm/$1"
240        else
241            mpmpath=$5
242        fi
243
244        dnl VPATH support
245        test -d $mpmpath || $srcdir/build/mkdir.sh $mpmpath
246
247        APACHE_FAST_OUTPUT($mpmpath/Makefile)
248
249        if test -z "$2"; then
250            APR_ADDTO(AP_LIBS, [$6])
251            libname="lib$1.la"
252            cat >$mpmpath/modules.mk<<EOF
253$libname: $objects
254	\$(MOD_LINK) $objects
255DISTCLEAN_TARGETS = modules.mk
256static = $libname
257shared =
258EOF
259        else
260            apache_need_shared=yes
261            libname="mod_mpm_$1.la"
262            shobjects=`echo $objects | sed 's/\.lo/.slo/g'`
263            cat >$mpmpath/modules.mk<<EOF
264$libname: $shobjects
265	\$(SH_LINK) -rpath \$(libexecdir) -module -avoid-version $objects $6
266DISTCLEAN_TARGETS = modules.mk
267static =
268shared = $libname
269EOF
270            # add default MPM to LoadModule list
271            if test $1 = $default_mpm; then
272                DSO_MODULES="$DSO_MODULES mpm_$1"
273                ENABLED_DSO_MODULES="${ENABLED_DSO_MODULES},mpm_$1"
274            fi
275        fi
276        $4
277    fi
278])dnl
279
280dnl
281dnl APACHE_MODULE(name, helptext[, objects[, structname[, default[, config[, prereq_module]]]]])
282dnl
283dnl default is one of:
284dnl   yes    -- enabled by default. user must explicitly disable.
285dnl   no     -- disabled under default, most, all. user must explicitly enable.
286dnl   most   -- disabled by default. enabled explicitly or with most or all.
287dnl   static -- enabled as static by default, must be explicitly changed.
288dnl   ""     -- disabled under default, most. enabled explicitly or with all.
289dnl             XXX: The arg must really be empty here. Passing an empty shell
290dnl             XXX: variable doesn't work for some reason. This should be
291dnl             XXX: fixed.
292dnl
293dnl basically: yes/no is a hard setting. "most" means follow the "most"
294dnl            setting. otherwise, fall under the "all" setting.
295dnl            explicit yes/no always overrides, except if the user selects
296dnl            "reallyall".
297dnl
298dnl prereq_module is a module (without the "mod_" prefix) that must be enabled
299dnl   if the current module is enabled.  If the current module is built
300dnl   statically, prereq_module must be built statically, too.  If these
301dnl   conditions are not fulfilled, configure will abort if the current module
302dnl   has been enabled explicitly. Otherwise, configure will disable the
303dnl   current module.
304dnl   prereq_module's APACHE_MODULE() statement must have been processed
305dnl   before the current APACHE_MODULE() statement.
306dnl
307AC_DEFUN(APACHE_MODULE,[
308  AC_MSG_CHECKING(whether to enable mod_$1)
309  define([optname],[--]ifelse($5,yes,disable,enable)[-]translit($1,_,-))dnl
310  AC_ARG_ENABLE(translit($1,_,-),APACHE_HELP_STRING(optname(),$2),force_$1=$enableval,enable_$1=ifelse($5,,maybe-all,$5))
311  undefine([optname])dnl
312  _apmod_extra_msg=""
313  dnl When --enable-modules=most or --enable-modules=(really)all is set and the
314  dnl module was not explicitly requested, allow a module to disable itself if
315  dnl its pre-reqs fail.
316  case "$enable_$1" in
317    yes|static|shared)
318      _apmod_required="yes"
319      ;;
320    *)
321      case "$module_selection" in
322      reallyall|all|most)
323        _apmod_required="no"
324        ;;
325      *)
326        _apmod_required="yes"
327        ;;
328      esac
329  esac
330  if test "$enable_$1" = "static"; then
331    enable_$1=static
332  elif test "$enable_$1" = "yes"; then
333    enable_$1=$module_default
334  elif test "$enable_$1" = "most"; then
335    if test "$module_selection" = "most" -o "$module_selection" = "all" -o \
336            "$module_selection" = "reallyall"
337    then
338      enable_$1=$module_default
339    elif test "$module_selection" = "few" -o "$module_selection" = "none"; then
340      enable_$1=no
341    fi
342    _apmod_extra_msg=" ($module_selection)"
343  elif test "$enable_$1" = "maybe-all"; then
344    if test "$module_selection" = "all" -o "$module_selection" = "reallyall"
345    then
346      enable_$1=$module_default
347      _apmod_extra_msg=" ($module_selection)"
348    else
349      enable_$1=no
350    fi
351  elif test "$enable_$1" = "no" -a "$module_selection" = "reallyall" -a \
352            "$force_$1" != "no" ; then
353      enable_$1=$module_default
354      _apmod_extra_msg=" ($module_selection)"
355  fi
356  if test "$enable_$1" != "no"; then
357    dnl If we plan to enable it, allow the module to run some autoconf magic
358    dnl that may disable it because of missing dependencies.
359    ifelse([$6$7],,:,
360           [AC_MSG_RESULT([checking dependencies])
361            ifelse([$7],,:,[if test "$enable_$7" = "no" ; then
362                              enable_$1=no
363                              AC_MSG_WARN("mod_$7 is disabled but required for mod_$1")
364                            elif test "$enable_$1" = "static" && test "$enable_$7" != "static" ; then
365                              enable_$1=no
366                              AC_MSG_WARN("cannot build mod_$1 statically if mod_$7 is built shared")
367                            else])
368            ifelse([$6],,:,[  $6])
369            ifelse([$7],,:,[fi])
370            AC_MSG_CHECKING(whether to enable mod_$1)
371            if test "$enable_$1" = "no"; then
372              if test "$_apmod_required" = "no"; then
373                _apmod_extra_msg=" (disabled)"
374              else
375                AC_MSG_ERROR([mod_$1 has been requested but can not be built due to prerequisite failures])
376              fi
377            fi])
378  fi
379  AC_MSG_RESULT($enable_$1$_apmod_extra_msg)
380  if test "$enable_$1" != "no"; then
381    case "$enable_$1" in
382    static*)
383      MODLIST="$MODLIST ifelse($4,,$1,$4)"
384      if test "$1" = "so"; then
385          sharedobjs=yes
386      fi
387      shared="";;
388    *)
389      enable_$1=`echo $enable_$1|sed 's/shared,*//'`
390      sharedobjs=yes
391      shared=yes
392      DSO_MODULES="$DSO_MODULES $1"
393      if test "$5" = "yes" ; then
394        ENABLED_DSO_MODULES="${ENABLED_DSO_MODULES},$1"
395      fi
396      ;;
397    esac
398    define([modprefix], [MOD_]translit($1, [a-z-], [A-Z_]))
399    APACHE_MODPATH_ADD($1, $shared, $3,, [\$(]modprefix[_LDADD)])
400    APACHE_SUBST(modprefix[_LDADD])
401    undefine([modprefix])
402  fi
403])dnl
404
405dnl
406dnl APACHE_ENABLE_MODULES
407dnl
408AC_DEFUN(APACHE_ENABLE_MODULES,[
409  module_selection=most
410  module_default=shared
411
412  dnl Check whether we have DSO support.
413  dnl If "yes", we build shared modules by default.
414  APR_CHECK_APR_DEFINE(APR_HAS_DSO)
415
416  if test $ac_cv_define_APR_HAS_DSO = "no"; then
417    AC_MSG_WARN([Missing DSO support - building static modules by default.])
418    module_default=static
419  fi
420
421
422  AC_ARG_ENABLE(modules,
423  APACHE_HELP_STRING(--enable-modules=MODULE-LIST,Space-separated list of modules to enable | "all" | "most" | "few" | "none" | "reallyall"),[
424    if test "$enableval" = "none"; then
425       module_default=no
426       module_selection=none
427    else
428      for i in $enableval; do
429        if test "$i" = "all" -o "$i" = "most" -o "$i" = "few" -o "$i" = "reallyall"
430        then
431          module_selection=$i
432        else
433          i=`echo $i | sed 's/-/_/g'`
434          eval "enable_$i=shared"
435        fi
436      done
437    fi
438  ])
439  
440  AC_ARG_ENABLE(mods-shared,
441  APACHE_HELP_STRING(--enable-mods-shared=MODULE-LIST,Space-separated list of shared modules to enable | "all" | "most" | "few" | "reallyall"),[
442    for i in $enableval; do
443      if test "$i" = "all" -o "$i" = "most" -o "$i" = "few" -o "$i" = "reallyall"
444      then
445        module_selection=$i
446        module_default=shared
447      else
448        i=`echo $i | sed 's/-/_/g'`
449    	eval "enable_$i=shared"
450      fi
451    done
452  ])
453  
454  AC_ARG_ENABLE(mods-static,
455  APACHE_HELP_STRING(--enable-mods-static=MODULE-LIST,Space-separated list of static modules to enable | "all" | "most" | "few" | "reallyall"),[
456    for i in $enableval; do
457      if test "$i" = "all" -o "$i" = "most" -o "$i" = "few" -o "$i" = "reallyall"; then
458        module_selection=$i
459        module_default=static
460      else
461        i=`echo $i | sed 's/-/_/g'`
462    	eval "enable_$i=static"
463      fi
464    done
465  ])
466])
467
468AC_DEFUN(APACHE_REQUIRE_CXX,[
469  if test -z "$apache_cxx_done"; then
470    AC_PROG_CXX
471    AC_PROG_CXXCPP
472    apache_cxx_done=yes
473  fi
474])
475
476dnl
477dnl APACHE_CHECK_OPENSSL
478dnl
479dnl Configure for OpenSSL, giving preference to
480dnl "--with-ssl=<path>" if it was specified.
481dnl
482AC_DEFUN(APACHE_CHECK_OPENSSL,[
483  AC_CACHE_CHECK([for OpenSSL], [ac_cv_openssl], [
484    dnl initialise the variables we use
485    ac_cv_openssl=no
486    ap_openssl_found=""
487    ap_openssl_base=""
488    ap_openssl_libs=""
489
490    dnl Determine the OpenSSL base directory, if any
491    AC_MSG_CHECKING([for user-provided OpenSSL base directory])
492    AC_ARG_WITH(ssl, APACHE_HELP_STRING(--with-ssl=PATH,OpenSSL installation directory), [
493      dnl If --with-ssl specifies a directory, we use that directory
494      if test "x$withval" != "xyes" -a "x$withval" != "x"; then
495        dnl This ensures $withval is actually a directory and that it is absolute
496        ap_openssl_base="`cd $withval ; pwd`"
497      fi
498    ])
499    if test "x$ap_openssl_base" = "x"; then
500      AC_MSG_RESULT(none)
501    else
502      AC_MSG_RESULT($ap_openssl_base)
503    fi
504
505    dnl Run header and version checks
506    saved_CPPFLAGS="$CPPFLAGS"
507    saved_LIBS="$LIBS"
508    saved_LDFLAGS="$LDFLAGS"
509
510    dnl Before doing anything else, load in pkg-config variables
511    if test -n "$PKGCONFIG"; then
512      saved_PKG_CONFIG_PATH="$PKG_CONFIG_PATH"
513      if test "x$ap_openssl_base" != "x" -a \
514              -f "${ap_openssl_base}/lib/pkgconfig/openssl.pc"; then
515        dnl Ensure that the given path is used by pkg-config too, otherwise
516        dnl the system openssl.pc might be picked up instead.
517        PKG_CONFIG_PATH="${ap_openssl_base}/lib/pkgconfig${PKG_CONFIG_PATH+:}${PKG_CONFIG_PATH}"
518        export PKG_CONFIG_PATH
519      fi
520      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.]), [
521        if test "$enableval" = "yes"; then
522          PKGCONFIG_LIBOPTS="--static"
523        fi
524      ])
525      ap_openssl_libs="`$PKGCONFIG $PKGCONFIG_LIBOPTS --libs-only-l --silence-errors openssl`"
526      if test $? -eq 0; then
527        ap_openssl_found="yes"
528        pkglookup="`$PKGCONFIG --cflags-only-I openssl`"
529        APR_ADDTO(CPPFLAGS, [$pkglookup])
530        APR_ADDTO(MOD_CFLAGS, [$pkglookup])
531        APR_ADDTO(ab_CFLAGS, [$pkglookup])
532        pkglookup="`$PKGCONFIG $PKGCONFIG_LIBOPTS --libs-only-L openssl`"
533        APR_ADDTO(LDFLAGS, [$pkglookup])
534        APR_ADDTO(MOD_LDFLAGS, [$pkglookup])
535        pkglookup="`$PKGCONFIG $PKGCONFIG_LIBOPTS --libs-only-other openssl`"
536        APR_ADDTO(LDFLAGS, [$pkglookup])
537        APR_ADDTO(MOD_LDFLAGS, [$pkglookup])
538      fi
539      PKG_CONFIG_PATH="$saved_PKG_CONFIG_PATH"
540    fi
541
542    dnl fall back to the user-supplied directory if not found via pkg-config
543    if test "x$ap_openssl_base" != "x" -a "x$ap_openssl_found" = "x"; then
544      APR_ADDTO(CPPFLAGS, [-I$ap_openssl_base/include])
545      APR_ADDTO(MOD_CFLAGS, [-I$ap_openssl_base/include])
546      APR_ADDTO(ab_CFLAGS, [-I$ap_openssl_base/include])
547      APR_ADDTO(LDFLAGS, [-L$ap_openssl_base/lib])
548      APR_ADDTO(MOD_LDFLAGS, [-L$ap_openssl_base/lib])
549      if test "x$ap_platform_runtime_link_flag" != "x"; then
550        APR_ADDTO(LDFLAGS, [$ap_platform_runtime_link_flag$ap_openssl_base/lib])
551        APR_ADDTO(MOD_LDFLAGS, [$ap_platform_runtime_link_flag$ap_openssl_base/lib])
552      fi
553    fi
554
555    AC_MSG_CHECKING([for OpenSSL version >= 0.9.8a])
556    AC_TRY_COMPILE([#include <openssl/opensslv.h>],[
557#if !defined(OPENSSL_VERSION_NUMBER)
558#error "Missing OpenSSL version"
559#endif
560#if OPENSSL_VERSION_NUMBER < 0x0090801f
561#error "Unsupported OpenSSL version " OPENSSL_VERSION_TEXT
562#endif],
563      [AC_MSG_RESULT(OK)
564       ac_cv_openssl=yes],
565      [AC_MSG_RESULT(FAILED)])
566
567    if test "x$ac_cv_openssl" = "xyes"; then
568      ap_openssl_libs="${ap_openssl_libs:--lssl -lcrypto} `$apr_config --libs`"
569      APR_ADDTO(MOD_LDFLAGS, [$ap_openssl_libs])
570      APR_ADDTO(LIBS, [$ap_openssl_libs])
571      APR_SETVAR(ab_LDFLAGS, [$MOD_LDFLAGS])
572      APACHE_SUBST(ab_CFLAGS)
573      APACHE_SUBST(ab_LDFLAGS)
574
575      dnl Run library and function checks
576      liberrors=""
577      AC_CHECK_HEADERS([openssl/engine.h])
578      AC_CHECK_FUNCS([SSLeay_version SSL_CTX_new], [], [liberrors="yes"])
579      AC_CHECK_FUNCS([ENGINE_init ENGINE_load_builtin_engines])
580      if test "x$liberrors" != "x"; then
581        AC_MSG_WARN([OpenSSL libraries are unusable])
582      fi
583    else
584      AC_MSG_WARN([OpenSSL version is too old])
585    fi
586
587    dnl restore
588    CPPFLAGS="$saved_CPPFLAGS"
589    LIBS="$saved_LIBS"
590    LDFLAGS="$saved_LDFLAGS"
591  ])
592  if test "x$ac_cv_openssl" = "xyes"; then
593    AC_DEFINE(HAVE_OPENSSL, 1, [Define if OpenSSL is available])
594  fi
595])
596
597dnl
598dnl APACHE_EXPORT_ARGUMENTS
599dnl Export (via APACHE_SUBST) the various path-related variables that
600dnl apache will use while generating scripts like autoconf and apxs and
601dnl the default config file.
602
603AC_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
610AC_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
632dnl 
633dnl APACHE_CHECK_APxVER({apr|apu}, major, minor, 
634dnl                     [actions-if-ok], [actions-if-not-ok])
635dnl
636dnl Checks for APR or APR-util of given major/minor version or later; 
637dnl if so, runs actions-if-ok; otherwise runs actions-if-not-ok if given.
638dnl If the version is not satisfactory and actions-if-not-ok is not
639dnl given, then an error is printed and the configure script is aborted.
640dnl
641dnl The first argument must be [apr] or [apu].
642dnl
643AC_DEFUN([APACHE_CHECK_APxVER], [
644define(ap_ckver_major, translit($1, [apru], [APRU])[_MAJOR_VERSION])
645define(ap_ckver_minor, translit($1, [apru], [APRU])[_MINOR_VERSION])
646define(ap_ckver_cvar, [ap_cv_$1ver$2$3])
647define(ap_ckver_name, ifelse([$1],[apr],[APR],[APR-util]))
648
649ap_ckver_CPPFLAGS="$CPPFLAGS"
650CPPFLAGS="$CPPFLAGS `$[$1]_config --includes`"
651
652AC_CACHE_CHECK([for ap_ckver_name version $2.$3.0 or later], ap_ckver_cvar, [
653AC_EGREP_CPP([good], [
654#include <$1_version.h>
655#if ]ap_ckver_major[ > $2 || (]ap_ckver_major[ == $2 && ]ap_ckver_minor[ >= $3)
656good
657#endif
658], [ap_ckver_cvar=yes], [ap_ckver_cvar=no])])
659
660if test "$ap_ckver_cvar" = "yes"; then
661  ifelse([$4],[],[:],[$4])
662else
663  ifelse([$5],[],[AC_MSG_ERROR([ap_ckver_name version $2.$3.0 or later is required])], [$5])
664fi
665
666CPPFLAGS="$ap_ckver_CPPFLAGS"
667
668undefine([ap_ckver_major])
669undefine([ap_ckver_minor])
670undefine([ap_ckver_cvar])
671undefine([ap_ckver_name])
672])
673
674dnl
675dnl APACHE_CHECK_VOID_PTR_LEN
676dnl
677dnl Checks if the size of a void pointer is at least as big as a "long" 
678dnl integer type.
679dnl
680AC_DEFUN([APACHE_CHECK_VOID_PTR_LEN], [
681
682AC_CACHE_CHECK([for void pointer length], [ap_cv_void_ptr_lt_long],
683[AC_TRY_RUN([
684int 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
690if test "$ap_cv_void_ptr_lt_long" = "yes"; then
691    AC_MSG_ERROR([Size of "void *" is less than size of "long"])
692fi
693])
694
695dnl
696dnl APACHE_CHECK_APR_HAS_LDAP
697dnl
698dnl Check if APR_HAS_LDAP is 1
699dnl Unfortunately, we can't use APR_CHECK_APR_DEFINE (because it only includes apr.h)
700dnl or APR_CHECK_DEFINE (because it only checks for defined'ness and not for 0/1).
701dnl
702AC_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
709YES_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
716dnl
717dnl APACHE_ADD_GCC_CFLAGS
718dnl
719dnl Check if compiler is gcc and supports flag. If yes, add to CFLAGS.
720dnl
721AC_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])
737