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

AC_INIT(latin1.txt)
AM_CONFIG_HEADER(config.h)
AC_PREREQ(2.12)

AC_REVISION($Revision: 1.28 $)

dnl Initialize Automake.
AM_INIT_AUTOMAKE(enscript, 1.5.0)

AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE")
AC_DEFINE_UNQUOTED(VERSION, "$VERSION")

AM_PROG_INSTALL


AC_ARG_WITH(cc,
[  --with-cc(=CC)	  use system's native compiler (or compiler CC)],
  if test "X$withval" != "Xno"; then
    if test "X$withval" = "Xyes"; then
      CC='cc'
    else 
      CC=$withval
    fi
    CFLAGS="$CFLAGS -I/usr/local/include"
    LDFLAGS="$LDFLAGS -L/usr/local/lib"
    echo "using compiler CC=$CC"
  fi
)

if test "X$CC" = "X"; then
  AC_PROG_CC
fi

AC_ISC_POSIX
AM_C_PROTOTYPES

dnl Define the default output media.
AC_ARG_WITH(media,
[  --with-media(=MEDIA)	  use output media Letter (MEDIA), default is A4],
  if test "X$withval" != "Xno"; then
    if test "X$withval" = "Xyes"; then
      ac_cv_value_media='Letter'
    else
      ac_cv_value_media=$withval
    fi
  else
    ac_cv_value_media=${MEDIA-A4}
  fi,
  ac_cv_value_media=${MEDIA-A4}
)
MEDIA=$ac_cv_value_media
AC_SUBST(MEDIA)

AC_C_CONST
AC_FUNC_ALLOCA

AC_STDC_HEADERS
AC_HAVE_HEADERS(string.h stdlib.h unistd.h stdarg.h math.h pwd.h)

dnl Check some functions.
AC_CHECK_FUNCS(strchr)
AC_CHECK_FUNC(strerror, AC_DEFINE(HAVE_STRERROR), [
  LIBOBJS="$LIBOBJS strerror.o"
])
AC_CHECK_FUNC(memmove, AC_DEFINE(HAVE_MEMMOVE), [
  LIBOBJS="$LIBOBJS memmove.o"
])
AC_CHECK_FUNC(memcpy, AC_DEFINE(HAVE_MEMCPY), [
  LIBOBJS="$LIBOBJS memcpy.o"
])

AC_CHECK_FUNC(getcwd, AC_DEFINE(HAVE_GETCWD), [
  AC_CHECK_FUNC(getwd, AC_DEFINE(HAVE_GETWD))
])

AC_FUNC_VPRINTF

dnl -lsun is needed on IRIX-4.0 to get the user passwd entry through
dnl the yellow pages / NIS.
AC_CHECK_LIB(sun, main)

dnl Find out where the gethostname() is.
AC_CHECK_FUNC(gethostname, , AC_CHECK_LIB(nsl, main))

AC_PROG_RANLIB
AC_PROG_YACC
AC_PROG_LEX
AC_DECL_YYTEXT

AC_ARG_ENABLE(debug,
[  --enable-debug	  enable debugging], [
  echo enabling debugging
  if test -n "$GCC"; then
    CFLAGS="$CFLAGS -Wall"
  fi
])


dnl Internationalization.
ALL_LINGUAS="de fi fr nl sl"
AM_GNU_GETTEXT
AC_LINK_FILES($nls_cv_header_libgt, $nls_cv_header_intl)

dnl Path separator character.
AC_DEFINE_UNQUOTED(PATH_SEPARATOR, ':')

dnl
dnl Scripts
dnl

dnl diffpp

AC_PATH_PROG(PERL, perl)

dnl substitutions

AC_SUBST(CFLAGS)
AC_SUBST(LDFLAGS)
AC_SUBST(LIBOBJS)


AC_OUTPUT([Makefile enscript.1 compat/Makefile afm/Makefile afmlib/Makefile src/Makefile lib/Makefile scripts/Makefile intl/Makefile po/Makefile.in states/Makefile states/states.1 states/tests/Makefile tests/Makefile], [sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in >po/Makefile; date > stamp-h])
