dnl Process this file with autoconf to produce a configure script.
AC_PREREQ(2.50)
AC_INIT(src/lesson.h)
AC_CANONICAL_HOST

dnl library version
dnl changed or added interfaces: CURRENT++ and AGE++ and REVISION = 0
dnl binary compatibility broken: CURRENT++, REVISION and AGE = 0
dnl interfaces stay the same as before: REVISION++
dnl CURRENT = most recent version of the library that the library supports
dnl REVISION = implementation number of the current interface
dnl AGE = number of versions back this version is still backwards 
dnl       compatible with.
CURRENT=5
REVISION=0
AGE=1

dnl public version
VERSION=0.2.3

AC_SUBST(CURRENT)
AC_SUBST(REVISION)
AC_SUBST(AGE)
AC_SUBST(VERSION)

dnl Checks for programs.
AC_PROG_CC
AC_PROG_INSTALL
AM_PROG_LIBTOOL

dnl automake
AM_INIT_AUTOMAKE(liblingoteach,$VERSION)
AM_CONFIG_HEADER(config.h)
AM_MAINTAINER_MODE

dnl Checks for header files.
AC_HEADER_STDC

dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST

dnl Checks for library functions.
AC_FUNC_MALLOC

dnl other stuff, which should be checked for
dnl AC_ISC_POSIX

dnl  xml stuff
dnl _ldflags="${LDFLAGS}"

AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
if test "x$PKG_CONFIG" = "xno"; then 
  echo "*** The pkg-config script could not be found. Make sure it is"
  echo "*** in your path or set the PKG_CONFIG enviroment variable to"
  echo "*** full path to pkg-config."
  AC_MSG_ERROR([pkg-config could not found.])
fi
PKG_CHECK_MODULES(XML, libxml-2.0 >= 2.5.5)
AC_SUBST(XML_CFLAGS)
AC_SUBST(XML_LIBS)
dnl LDFLAGS=${_ldflags}

dnl arguments for debugging
AC_ARG_ENABLE([debug],AC_HELP_STRING([--enable-debug],
                      [enable additional debugging messages for 
                      lingoteach [[default=no]]]),,
                      enable_debug=no)
if test "x$enable_debug" = "xyes"; then
    AC_MSG_RESULT([Enabling additional debugging features...])
    AC_DEFINE(DEBUG,1,[additional debugging features])
fi

dnl arguments for zlib compression support
AC_ARG_ENABLE([compression],AC_HELP_STRING([--enable-compression],
			    [enable zlib compression for xml files
			    [[default=no]]]),,
                            enable_compression=no)
if test "x$enable_compression" = "xyes"; then
    AC_MSG_RESULT([Enabling zlib compression....])
    AC_DEFINE(WITH_COMP,1,[zlib compression for user data])
fi 

dnl warnings, standards
DFLAGS="-W -Wall -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align \
-Wconversion -Wstrict-prototypes -Wmissing-prototypes \
-Wmissing-declarations -Wredundant-decls -Wnested-externs -Winline \
-ansi"
AC_SUBST(DFLAGS)

dnl output 
AC_OUTPUT([Makefile
	  src/Makefile
	  test/Makefile
	  doc/Makefile
	  liblingoteach.pc])
