dnl
dnl The DocBook build stuff is inspired by LogReport's Lire
dnl ( http://www.logreport.org/ ) documentation build system which is
dnl Copyright (C) 2000, 2001, 2002, 2003, 2004 Stichting LogReport Foundation
dnl
dnl Copyright (C) 2001, 2002, 2003, 2004, 2005, 2008, 2015 Joost van Baal
dnl
dnl     This program is free software; you can redistribute it and/or modify
dnl     it under the terms of the GNU General Public License as published by
dnl     the Free Software Foundation; either version 2 of the License, or
dnl     (at your option) any later version.
dnl 
dnl     This program is distributed in the hope that it will be useful,
dnl     but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
dnl     GNU General Public License for more details.
dnl 
dnl     You should have received a copy of the GNU General Public License
dnl     along with this program (see COPYING); if not, check with
dnl     http://www.gnu.org/copyleft/gpl.html or write to the Free Software 
dnl     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
dnl
dnl Run autoscan to regenerate this file.
dnl After editing this file, run automake to regenerate Makefile.in's.
dnl Process this file with autoconf to produce a configure script.

m4_include([VERSION.m4])dnl

AC_INIT([systraq],[ST_VERSION],[joostvb-systraq-20041015@mdcc.cx])

AC_PREREQ(2.61)

AC_COPYRIGHT([
Copyright (C) Copyright 2001-2012, 2014-2016  Joost van Baal
])

AM_INIT_AUTOMAKE()

AC_PROG_INSTALL
AC_PROG_LN_S

# AC_DEFINE_DIR is defined in acinclude.m4
dnl AC_DEFINE_DIR([SYSCONF_PATH], [sysconfdir/$PACKAGE])
dnl AC_DEFINE_DIR(BIN_PATH, bindir)
dnl AC_DEFINE_DIR(SBIN_PATH, sbindir)
dnl AC_DEFINE_DIR(LIBEXEC_PATH, [libexecdir/$PACKAGE])
dnl AC_DEFINE_DIR(LOCALSTATE_PATH, [localstatedir/lib/$PACKAGE])
dnl dnl AC_DEFINE_DIR(SCRIPT_PATH, datadir/systraq)
dnl AC_DEFINE_DIR(DOC_PATH, [datadir/doc/$PACKAGE])
dnl AC_DEFINE_DIR(CRON_PATH, [sysconfdir/cron.d])

dnl dnl homedirectory of systraq user ( /usr/local/var/lib/systraq )
dnl AC_DEFINE_DIR(HOME_PATH, LOCALSTATE_PATH)


dnl local hacks
YEAR=`cat $srcdir/stamp.year`
AC_SUBST(YEAR)
MONTH=`cat $srcdir/stamp.month`
AC_SUBST(MONTH)
DAY=`cat $srcdir/stamp.day`
AC_SUBST(DAY)


dnl lots of stuff used to build the DocBook documentation.
AC_MSG_CHECKING(for SGML Declaration for XML 1.0)
if test -z "$XMLDCL"
then
    if test -f /usr/share/sgml/declaration/xml.dcl
    then
        XMLDCL=/usr/share/sgml/declaration/xml.dcl
        AC_MSG_RESULT($XMLDCL)
    else
        AC_MSG_NOTICE([
            The SGML Declaration for XML 1.0 is required for building.
            No file /usr/share/sgml/declaration/xml.dcl is present on your
            system; I don't know where to find this declaration elsewhere.
            If it is installed in some location on your system, set the
            XMLDCL environment variable to this files full pathname before
            running ./configure.  If you really lack this file:
            It is shipped with the sgml-data Debian package, available from
            http://packages.debian.org/sgml-data.  It can be found elsewhere
            too.])
    fi
else
    AC_MSG_RESULT($XMLDCL)
    if test -f "$XMLDCL"
    then
        :
    else
        AC_MSG_WARN($XMLDCL isn't present on the system)
    fi
fi
AC_SUBST(XMLDCL)

AC_MSG_CHECKING(for DocBook XSL stylesheet for manpages)
if test -z "$MANXSL"
then
    if test -f /usr/share/sgml/docbook/stylesheet/xsl/nwalsh/manpages/docbook.xsl
    then
        MANXSL=/usr/share/sgml/docbook/stylesheet/xsl/nwalsh/manpages/docbook.xsl
        AC_MSG_RESULT($MANXSL)
    else
        AC_MSG_NOTICE([
            A DocBook XSL stylesheet for manpages is required for building.
            No file /usr/share/sgml/docbook/stylesheet/xsl/nwalsh/manpages/docbook.xsl
            is present on your system; I don't know where to find this
            stylesheet elsewhere.  If it is installed in some location on your
            system, set the MANXSL environment variable to this files full
            pathname before running ./configure.  If you really lack this file:
            It is shipped with the docbook-xsl tarball as published via the
            Sourceforge DocBook Open Repository by Norman Walsh e.a., on
            http://docbook.sourceforge.net/projects/xsl/ .  It comes with many
            GNU/Linux and BSD distributions too.])
    fi
else
    AC_MSG_RESULT($MANXSL)
    if test -f "$MANXSL"
    then
        :
    else
        AC_MSG_WARN($MANXSL isn't present on the system)
    fi
fi
AC_SUBST(MANXSL)

AC_PATH_PROGS(XP, xsltproc)
if test -z "$XP"
then
    AC_MSG_NOTICE([
        xsltproc by Daniel Veillard is required for building.
        It can be downloaded from http://xmlsoft.org/XSLT/ and is
        shipped with many GNU/Linux and BSD distributions.])
fi

AC_PATH_PROGS(W3M, w3m)
AC_PATH_PROGS(LYNX, lynx)
if test -z "$W3M"
then
    if test -z "$LYNX"
    then
        AC_MSG_NOTICE([
            Either w3m or Lynx is required for building.  W3m can be
            downloaded from http://sourceforge.net/projects/w3m.  Lynx can be
            downloaded from http://lynx.isc.org/release/.  Both w3m and Lynx
            are shipped with many GNU/Linux and BSD distributions.])
    else
        HTML2TXT="$LYNX -dump -nolist"
    fi
else
    HTML2TXT="$W3M -dump"
fi
AC_SUBST(HTML2TXT)
dnl html2text from http://userpage.fu-berlin.de/~mbayer/tools/ might give
dnl nice results too

AC_PATH_PROGS(JADE, openjade jade)
if test -z "$JADE"
then
    AC_MSG_NOTICE([
        OpenJade or Jade is required for building.
        OpenJade can be downloaded from http://openjade.sourceforge.net/ and is
        shipped with many GNU/Linux and BSD distributions.])
fi

AC_PATH_PROGS(JADETEX, jadetex)
if test -z "$JADETEX"
then
    AC_MSG_NOTICE([
        JadeTeX is required for building.
        It can be downloaded from http://jadetex.sourceforge.net/ and is
        shipped with many GNU/Linux and BSD distributions.])
fi

AC_PATH_PROGS(PDFJADETEX, pdfjadetex)
if test -z "$PDFJADETEX"
then
    AC_MSG_NOTICE([
        JadeTeX's pdfjadetex is required for building.
        It can be downloaded from http://jadetex.sourceforge.net/ and is
        shipped with many GNU/Linux and BSD distributions.])
fi

AC_PATH_PROGS(DVIPS, dvips)
if test -z "$DVIPS"
then
    AC_MSG_NOTICE([
        teTeX's dvips is required for building.
        It can be downloaded from
        ftp://ftp.dante.de:/pub/tex/systems/unix/teTeX and is shipped with
        many GNU/Linux and BSD distributions.])
fi

## AC_PATH_PROGS(PS2PDF, ps2pdf)
## if test -z "$PS2PDF"
## then
##     AC_MSG_ERROR([
##         Ghostscripts's ps2pdf is required for building.
##         Is can be downloaded from
##         ftp://mirror.cs.wisc.edu/pub/mirrors/ghost/GPL/
##         and is shipped with many GNU/Linux and BSD distributions.])
## fi

dnl end of docbook build stuff

dnl end of build-time dependencies

dnl run-time dependencies

AC_PATH_PROGS(RUN_PARTS, run-parts)
if test -z "$RUN_PARTS"
then
    AC_MSG_WARN([
        run-parts is required for running systraq.  run-parts is shipped with
        the debianutils Debian package, which can be downloaded (in both source
        and binary form) from http://packages.debian.org/debianutils .  If you'd
        rather not want to install that on your system you might want to
        reimplement run-parts in a quick and dirty way:

         cat <<EOT > ~/bin/run-parts
         #!/bin/sh
         for f in $1/*; do ./$f; done
         EOT

        (A somewhat less ugly implementation is in the contrib/ directory in
        the systraq source distribution.) Rerun ./configure afterwards.])
fi

dnl list of to be expanded .in files
AC_CONFIG_FILES([
   Makefile
   doc/Makefile
   etc/Makefile
   lib/Makefile
   man/Makefile
   script/systraq
   script/Makefile
   contrib/Makefile
])
AC_OUTPUT
