+#
+# If no --enable-apache-xx specified
+# find a default and fake the specific parameters
+#
+
+# simple macro to peek at an enable or a with
+AC_DEFUN([Peek],
+if test "[${[$1]_][$2]+set}" = set; then
+ peekval="${[$1]_[$2]}"
+ $3
+fi; dnl
+)
+
+AC_MSG_CHECKING(if default apache needed)
+need_default=yes
+Peek(enable,apache_13,need_default=no)
+Peek(enable,apache_20,need_default=no)
+Peek(enable,apache_22,need_default=no)
+AC_MSG_RESULT($need_default)
+
+if test "$need_default" = "yes"; then
+ # find an apxs, then the httpd
+ xs=
+ Peek(with,apxs,xs="$peekval")
+ Peek(with,apxs2,xs="$peekval")
+ Peek(with,apxs22,xs="$peekval")
+ if test "x$xs" = "x"; then
+ AC_PATH_PROGS(xs, apxs2 apxs,
+ AC_MSG_ERROR(No apxs, no apache found. Try --with-apxs),
+ [/usr/local/apache2/bin:/usr/local/apache/bin:/usr/sbin:$PATH])
+ fi
+ # ask the daemon for the version and set parameters
+ AC_MSG_CHECKING(default apache version)
+ httpd="`$xs -q SBINDIR`/`$xs -q TARGET`"
+ if test "x$httpd" != "x" && test -f $httpd ; then
+ v=`$httpd -v|$SED -n -e 's/.*Apache\/\.*//p'`
+ case $v in
+ 1.3*) [enable_apache_13]=yes
+ [with_apxs]=$xs
+ AC_MSG_RESULT(1.3)
+ ;;
+ 2.0*) [enable_apache_20]=yes
+ [with_apxs2]=$xs
+ AC_MSG_RESULT(2.0)
+ ;;
+ 2.2*) [enable_apache_22]=yes
+ [with_apxs22]=$xs
+ AC_MSG_RESULT(2.2)
+ ;;
+ *) AC_MSG_ERROR(unusable apache versions: $v. Try setting --with-apxs)
+ esac
+ else
+ AC_MSG_RESULT(cannot determine version. Try setting --with-apxs)
+ fi
+fi
+
+# Apache 1.3 (mod_shib_13)
+# --enable-apache-13
+# --with-apxs (DSO build, the normal way, uses apxs to derive build flags)
+
+AC_ARG_ENABLE(apache-13,
+ AC_HELP_STRING([--enable-apache-13], [enable the Apache 1.3 module]),
+ [ if test "x$enableval" = "x" ; then
+ WANT_APACHE_13=yes
+ else
+ WANT_APACHE_13="$enableval"
+ fi
+ ],[ WANT_APACHE_13=no ])
+AC_MSG_CHECKING(whether to build Apache 1.3 module)
+if test "$WANT_APACHE_13" != yes && test "$WANT_APACHE_13" != no ; then
+ WANT_APACHE_13=yes
+fi
+AC_MSG_RESULT($WANT_APACHE_13)
+
+if test "$WANT_APACHE_13" = "yes" ; then
+ AC_ARG_WITH(apxs,
+ AC_HELP_STRING([--with-apxs=FILE], [Specifies where to find the Apache 1.3 apxs script.]),
+ [
+ AC_MSG_CHECKING(for user-specified apxs name/location)
+ if test "$withval" != "no" ; then
+ if test "$withval" != "yes"; then
+ APXS=$withval
+ AC_MSG_RESULT("$withval")
+ fi
+ fi
+ ],
+ [
+ AC_PATH_PROG(APXS, apxs, no)
+ if test "$APXS" = "no" ; then
+ for i in /usr/sbin /usr/local/apache/bin ; do
+ if test "$APXS" = "no" && test -f "$i/apxs"; then
+ APXS="$i/apxs"
+ fi
+ done
+ fi
+ ])
+
+ AC_MSG_CHECKING([to see if apxs was located])
+ if test ! -f "$APXS" ; then
+ AC_MSG_RESULT(no)
+ AC_MSG_ERROR([Unable to locate apxs script. An Apache development package may be missing from your server, or you may need to use the --with-apxs option.])
+ fi
+ AC_MSG_RESULT($APXS)
+ AC_SUBST(APXS)