dnl Process this file with autoconf to produce a configure script.
AC_INIT(src/aspell.cc)
AM_CONFIG_HEADER(as_config.h)
AM_INIT_AUTOMAKE(aspell, .28.3)
AM_PROG_LIBTOOL

dnl Checks for programs.
AC_PROG_CC
AC_GCC_TRADITIONAL
AM_C_PROTOTYPES
AC_PROG_CXX
AC_LANG_CPLUSPLUS

AC_ARG_ENABLE(dict-dir, \
[  --enable-dict-dir=DIR   dictionary files in DIR [LIBDIR/aspell] ], \
dictdir=$enable_dict_dir, dictdir=${libdir}/aspell )
AC_SUBST(dictdir)

AC_ARG_ENABLE(doc-dir, \
[  --enable-doc-dir=DIR    documentation files in DIR [PREFIX/doc/aspell] ], \
pkgdocdir=$enable_doc_dir, pkgdocdir=\${prefix}/doc/aspell )
AC_SUBST(pkgdocdir)

AC_ARG_ENABLE(pkgdata-dir, \
[  --enable-pkgdata-dir=DIR], \
pkgdatadir=$enable_pkgdata_dir, pkgdatadir=\${datadir}/aspell )
AC_SUBST(pkgdatadir)

AC_ARG_ENABLE(debug, \
[  --enable-debug          compile with debug information [enabled] ], \
if test "$enable_debug" = yes; then debug="-g"; else debug=""; fi, debug="-g")

AC_ARG_ENABLE(opt, \
[  --enable-opt            compile with optimization flags [enabled] ], \
if test "$enable_opt" = yes; then opt="-O2"; else opt=""; fi, opt="-O2")

CFLAGS="$debug $opt"
CXXFLAGS="$debug $opt"

dnl Specific checks

addlib() {
  l=$1
  shift
  case "$target" in 
    *-*-solaris*)       LIBS="$LIBS -L$l -R $l $*";;
    *)          LIBS="$LIBS -L$l $*";;
  esac
}

AC_CHECK_HEADERS(unistd.h alloca.h libintl.h)
AC_MSG_CHECKING(for /usr/ucblib in LIBS)
if test -d /usr/ucblib ; then
	if test "$build" = "mips-sni-sysv4" ; then
		addlib /usr/ccs/lib -lc
	fi

	addlib /usr/ucblib
	
	AC_MSG_RESULT(yes)
else
	AC_MSG_RESULT(no)
fi

AC_CHECK_FUNCS(strerror)
AC_CHECK_FUNCS(gettext)
AC_CHECK_FUNCS(dgettext)
AC_CHECK_FUNC(setreuid, [], [
    AC_CHECK_LIB(ucb, setreuid, [if echo $LIBS | grep -- -lucb >/dev/null ;then :; else LIBS="$LIBS -lc -lucb" USEUCB=y;fi])
])

AC_OUTPUT(Makefile lib/Makefile lib/inc/Makefile src/Makefile \
  data/Makefile scripts/Makefile util/Makefile popt/Makefile \
  manual/Makefile manual/man-html/Makefile manual/man-text/Makefile )
