dnl
dnl  configure.in
dnl
dnl  $Id: configure.in,v 1.12 1998/06/30 06:05:57 cg 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_sgmltools_groff_mgs,
[  if test -z "`${GROFF} -mgs < /dev/null 2>&1`"; then
      ac_cv_sgmltools_groff_mgs=yes
   else
      ac_cv_sgmltools_groff_mgs=no
   fi
])

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


AC_PATH_PROG(NSGMLS, nsgmls)
AC_ARG_WITH(installed-nsgmls,
[  --with-installed-nsgmls      use installed nsgmls],
   test -n "$NSGMLS" || AC_MSG_ERROR(nsgmls not found)
   BUILD_NSGMLS=,
   NSGMLS=\${prefix}/bin/nsgmls
   BUILD_NSGMLS=true
) 
AC_SUBST(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)

dnl
dnl  Set directory names.
dnl
BINDIR='${prefix}/bin'
LIBDIR='${prefix}/lib/sgml-tools'
AC_SUBST(BINDIR)
AC_SUBST(LIBDIR)

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
