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

AC_INIT(src/wordseg.cpp)
dnl Every other copy of the package version number gets its value from here
AM_INIT_AUTOMAKE(swath, 0.3.1)

AC_SUBST(VERSION)

ISODATE=`date +%Y-%m-%d`
AC_SUBST(ISODATE)

dnl Checks for programs.
AC_PROG_CXX
AC_PROG_CC
AC_PROG_CPP
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
AM_PROG_LIBTOOL
dnl ** to use midatrie **
dnl AC_PATH_PROG(PKG_CONFIG, pkg-config, no)

dnl Checks for libraries.

dnl ** to use midatrie **
dnl dnl midatrie
dnl if test x$PKG_CONFIG != xno; then
dnl   AC_MSG_CHECKING(for midatrie >= 0.3.3)
dnl   if $PKG_CONFIG --exists 'midatrie >= 0.3.3'; then
dnl     AC_MSG_RESULT(yes (`$PKG_CONFIG --modversion midatrie`))
dnl     MIDATRIE_CFLAGS=`$PKG_CONFIG --cflags midatrie`
dnl     MIDATRIE_LIBS=`$PKG_CONFIG --libs midatrie`
dnl   else
dnl     AC_MSG_RESULT(no)
dnl     AC_MSG_ERROR([midatrie >= 0.3.3 missing (maybe, PKG_CONFIG_PATH setting?)])
dnl   fi
dnl fi
dnl AC_SUBST(MIDATRIE_CFLAGS)
dnl AC_SUBST(MIDATRIE_LIBS)

dnl Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS(limits.h malloc.h)

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

dnl Checks for library functions.
AC_CHECK_FUNCS(strstr)

dnl Check commandline options
AC_ARG_ENABLE(debug,
              [AC_HELP_STRING([--enable-debug],
                              [enable assertion checks])],
              , enable_debug="no")
if test "x$enable_debug" = "xno"; then
  CPPFLAGS="$CPPFLAGS -DNDEBUG"
fi

AC_ARG_ENABLE(catthai,
              [AC_HELP_STRING([--enable-catthai],
                              [enable catenation of Thai lines])],
              , enable_catthai="no")
if test "x$enable_catthai" = "xyes"; then
  CPPFLAGS="$CPPFLAGS -DCAT_THAI_LINES"
fi

AC_OUTPUT(
  Makefile
  swath.spec
  conv/Makefile
  misc/Makefile
  vmem/Makefile
  trie/Makefile
  src/Makefile
  data/Makefile)
