dnl
dnl  configure.in
dnl
dnl  $Id: configure.in,v 1.6 2001/12/02 02:32:06 sano Exp $
dnl
dnl  Process this file with autoconf to produce a configure script.

AC_INIT(sgmls-1.1)

AC_PROG_INSTALL

AC_PATH_PROG(PERL, perl)
AC_SUBST(PERL)
if echo 'require 5.004;exit' | $PERL
then
  : # Solaris and OSF/1 /bin/sh don't know about negation operators...
else
  AC_MSG_ERROR(You don't have Perl 5.004...)
  exit 1
fi
AC_ARG_WITH(perl-w,
[  --with-perl-w                use perl -w option],
   PERLWARN=-w,
   PERLWARN=
)
AC_SUBST(PERLWARN)
AC_PATH_PROG(GROFF, groff)
AC_SUBST(GROFF)


dnl Check if groff should take -mgs or -ms
AC_CACHE_CHECK(whether ${GROFF} accepts -mgs, ac_cv_linuxdoctools_groff_mgs,
[  if test -z "`${GROFF} -mgs < /dev/null 2>&1`"; then
      ac_cv_linuxdoctools_groff_mgs=yes
   else
      ac_cv_linuxdoctools_groff_mgs=no
   fi
])

if test ${ac_cv_linuxdoctools_groff_mgs:-ERROR} = yes; then
  GROFFMACRO="-mgs"
else
  GROFFMACRO="-ms"
fi
AC_SUBST(GROFFMACRO)

AC_PATH_PROGS(AWK, gawk mawk, notfound)
AC_SUBST(AWK)
   test "$AWK" = "notfound" && AC_MSG_ERROR(neither gawk nor mawk is found)

AC_PATH_PROGS(NSGMLS, nsgmls onsgmls, notfound)
AC_SUBST(NSGMLS)
   test "$NSGMLS" = "notfound" && AC_MSG_ERROR(neither onsgmls nor nsgmls is found)
   BUILD_NSGMLS=
AC_SUBST(BUILD_NSGMLS)

AC_PATH_PROG(SGMLSASP, sgmlsasp)
AC_ARG_WITH(installed-sgmlsasp,
[  --with-installed-sgmlsasp    use installed sgmlsasp],
   test -n "$SGMLSASP" || AC_MSG_ERROR(sgmlsasp not found)
   BUILD_SGMLSASP=,
   SGMLSASP=\${prefix}/bin/sgmlsasp
   BUILD_SGMLSASP=true
) 
AC_SUBST(SGMLSASP)
AC_SUBST(BUILD_SGMLSASP)

AC_ARG_WITH(installed-entity-map,
[  --with-installed-entity-map  use installed entity-map],
   BUILD_ENTITY_MAP=,
   BUILD_ENTITY_MAP=true
)
AC_SUBST(BUILD_ENTITY_MAP)

AC_ARG_WITH(installed-iso-entities,
[  --with-installed-iso-entities  use installed iso-entities],
   BUILD_ISO_ENTITIES=,
   BUILD_ISO_ENTITIES=true
)
AC_SUBST(BUILD_ISO_ENTITIES)

if test "$BUILD_NSGMLS" = "true"
then
  SUB=sp
fi
if test "$BUILD_ENTITY_MAP" = "true"
then
  SUB="$SUB entity-map"
fi

if test "$BUILD_ISO_ENTITIES" = "true"
then
  SUB="$SUB iso-entities"
fi

AC_CONFIG_SUBDIRS($SUB)

AC_OUTPUT(Makefile)

if test "$BUILD_SGMLSASP" = "true"
then
  echo "Configuring sgmls-1.1";
  cd sgmls-1.1; make config.h; cd ..
fi
