dnl
dnl Process this file with autoconf to produce a configure script
dnl

AC_PREREQ(2.13)
AC_INIT(Makefile.in)

AC_CONFIG_AUX_DIR(build)
AC_CONFIG_HEADER(lib/apr_iconv_private.h)
AC_PREFIX_DEFAULT(/usr/local/apache2)

sinclude(build/apr-iconv.m4)
sinclude(build/apr_common.m4)
sinclude(build/find_apr.m4)

dnl This is required by autoconf!
AC_PROG_AWK

dnl compute the top directory of the build
# Absolute source/build directory
api_srcdir=`(cd $srcdir && pwd)`
api_builddir=`pwd`
AC_SUBST(api_srcdir)
AC_SUBST(api_builddir)

if test "$api_builddir" != "$api_srcdir"; then
  USE_VPATH=1
fi

dnl check for APR
API_FIND_APR

dnl copy apr's rules.mk into our build directory.
if test ! -d $api_builddir/build ; then
  mkdir $api_builddir/build
fi
cp $APR_BUILD_DIR/apr_rules.mk $api_builddir/build/rules.mk

dnl
dnl set up the compilation flags and stuff
dnl
API_INCLUDES="-I$api_builddir/lib -I$api_builddir/include"
if test -n "$USE_VPATH"; then
  API_INCLUDES="$API_INCLUDES -I$api_srcdir/lib -I$api_srcdir/include"
fi

AC_SUBST(API_INCLUDES)

AC_SUBST(APR_SO_EXT)

dnl Adds in config *.h file
AC_DEFINE_UNQUOTED(ICONV_DEFAULT_PATH,"$prefix/lib/iconv",
	[ Directory where the *.so tables are stored ] )
iconv_libdir=$prefix/lib/iconv
AC_SUBST(iconv_libdir)

dnl
dnl BSD/OS (BSDi) needs to use a different include syntax in the Makefiles
dnl
case "$host_alias" in
*bsdi*)
    INCLUDE_RULES=".include \"$api_builddir/build/rules.mk\""
    ;;
*)
    INCLUDE_RULES="include $api_builddir/build/rules.mk"
    ;;
esac
AC_SUBST(INCLUDE_RULES)

dnl
dnl everthing is done. 
AC_OUTPUT([
	Makefile
	ccs/Makefile
	ces/Makefile
	lib/Makefile
	util/Makefile
	])
