# Required initializer
AC_INIT

# Automake initialization
AM_INIT_AUTOMAKE(mod_dots, 1.0.1)

# Add a test for a compiler.
AC_PROG_CC
AM_PROG_LIBTOOL

# Define a macro that is used to parse a --with-apache-install parameter
# The macro is named "APACHE_INST"
AC_DEFUN([APACHE_INST],[
	AC_ARG_WITH(
		apache-install,
		[  --with-apache-install[=DIR]    Apache installation directory],
		,
		[with_apache_install="no"]
	)
	AC_MSG_CHECKING(for Apache installation directory)
	if test "$with_apache_install" = "no"; then
		AC_MSG_ERROR(You need to specify the Apache installation directory using --with-apache-install)
	else
		# make sure that a well known include file exists
		if test -e $with_apache_install/bin/apxs
        then
			apache_install=$with_apache_install
			AC_MSG_RESULT(Apache installation found!)
		else
			AC_MSG_ERROR($with_apache_install/bin/apxs not found. Check the value you specified with --with-apache-install)
		fi
	fi
])

# Define a macro that is used to parse a --with-apache-source parameter
# The macro is named "APACHE_SRC"
AC_DEFUN([APACHE_SRC],[
	AC_ARG_WITH(
		apache-source,
		[  --with-apache-source[=DIR]     Apache source directory],
		,
		[with_apache_source="no"]
	)
	AC_MSG_CHECKING(for Apache source directory)
	if test "$with_apache_source" = "no"; then
		AC_MSG_ERROR(You need to specify the Apache source directory using --with-apache-source)
	else
		# make sure that a well known file exists
		if test -e $with_apache_source/modules/experimental/mod_cache.c
        then
			apache_source=$with_apache_source
			AC_MSG_RESULT(Apache source found!)
		else
			AC_MSG_ERROR($with_apache_source/modules/experimental/mod_cache.c not found. Check the value you specified with --with-apache-source)
		fi
	fi
])

# Define a macro that is used to parse a --with-bind-install parameter
# The macro is named "BIND_INST"
AC_DEFUN([BIND_INST],[
	AC_ARG_WITH(
		bind-install,
		[  --with-bind-install[=DIR]      BIND installation directory],
		,
		[with_bind_install="no"]
	)
	AC_MSG_CHECKING(for BIND installation directory)
	if test "$with_bind_install" = "no"
    then
		AC_MSG_ERROR(You need to specify the BIND installation directory using --with-bind-install)
	else
		# make sure that a well known file exists
		if test -e $with_bind_install/lib/libbind.a
        then
			bind_install=$with_bind_install
			AC_MSG_RESULT(BIND installation found!)
		else
			AC_MSG_ERROR($with_bind_install/lib/libbind.a not found. Check the value you specified with --with-bind-install)
		fi
	fi
])

# Now call the APACHE_INST macro that was just specified
APACHE_INST
APACHE_SRC
BIND_INST

# Save "apache_install", "apache_source", and "bind_install"
# The AC_SUBST macro causes the variables to be saved in config.status
AC_SUBST(apache_install)
AC_SUBST(apache_source)
AC_SUBST(bind_install)

# Write config.status and the Makefile
AC_OUTPUT(Makefile)
