+#
+# Build FastCGI support?
+#
+AC_MSG_CHECKING(for FastCGI support)
+AC_ARG_WITH(fastcgi,
+ AC_HELP_STRING([--with-fastcgi=DIR], [Build FastCGI support]),
+ [WANT_FASTCGI=$withval],[WANT_FASTCGI=no])
+AC_MSG_RESULT($WANT_FASTCGI)
+
+if test "$WANT_FASTCGI" != "no"; then
+ if test "$WANT_FASTCGI" != "yes"; then
+ if test x_$WANT_FASTCGI != x_/usr; then
+ FASTCGI_INCLUDE="-I$WANT_FASTCGI/include"
+ FASTCGI_LDFLAGS="-L$WANT_FASTCGI/lib"
+ fi
+ fi
+ AC_CHECK_HEADER([fcgio.h],,
+ AC_MSG_ERROR([unable to find FastCGI header files]))
+ FASTCGI_LIBS="-lfcgi -lfcgi++"
+fi
+
+AC_SUBST(FASTCGI_INCLUDE)
+AC_SUBST(FASTCGI_LDFLAGS)
+AC_SUBST(FASTCGI_LIBS)
+
+# always output the Makefile, even if you don't use it
+AC_CONFIG_FILES([fastcgi/Makefile])
+AM_CONDITIONAL(BUILD_FASTCGI,test ! "$WANT_FASTCGI" = "no")
+
+if test ! "$WANT_FASTCGI" = "no" ; then
+ WANT_SUBDIRS="$WANT_SUBDIRS fastcgi"
+fi
+
+
+#
+# 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
+