dnl process this file with GNU autoconf to produce a configure script.
dnl
dnl $Id: configure.in,v 1.1 2001/08/28 00:20:06 papowell Exp papowell $

dnl ----------------------------------------------------------------------------
dnl ----------------- START OF GENERAL CONFIGURATION ---------------------------
AC_INIT(Makefile.in)

PACKAGE=LPRngTool
VERSION=1.3.2

AC_CONFIG_AUX_DIR(.)
AC_CANONICAL_SYSTEM
AC_CONFIG_HEADER(config.h)

AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE")
AC_DEFINE_UNQUOTED(VERSION, "$VERSION")
AC_SUBST(PACKAGE)
AC_SUBST(VERSION)
ALL_LINGUAS="fr"

AC_PREFIX_DEFAULT(/usr/local)
AC_SUBST(INSTALL)
AC_SUBST(INSTALL_MAN)
AC_SUBST(SHELL)
AC_SUBST(CPP)
AC_SUBST(CFLAGS)
AC_SUBST(CPPFLAGS)
AC_SUBST(LDFLAGS)
AC_SUBST(LDCC)

dnl ----------------------------------------------------------------------------
dnl -----------   Program checks       -----------------------------------------
AC_PROG_INSTALL
AC_PROG_MAKE_SET

AC_PATH_PROG(FILEUTIL,file,FILE_UTILITY_NOT_FOUND)dnl
if expr "$FILEUTIL" : ".*NOT" >/dev/null;  then
	v="cannot open";
else
	v=`${FILEUTIL} - </etc/passwd 2>/dev/null`;
fi
if expr "$v" : ".*cannot open.*" >/dev/null;  then
	echo "
Please use a file(1) utility where 'file - ' reads STDIN
You can obtain one from: ftp://ftp.astron.com/pub/file/
if necessary, use the FILEUTIL environment variable to specify the path
to the file(1) utility'
"
fi
AC_SUBST(FILEUTIL)dnl

AC_PATH_PROG(GS,gs,GHOSTSCRIPT_NOT_FOUND)dnl
if expr "$GS" : ".*NOT" >/dev/null;  then
	echo "
Please install ghostscript
You can it from: http://www.cs.wisc.edu/~ghost;
if necessary, use the GS environment variable to specify the path
to the gs(1) utility
"
fi
AC_SUBST(GS)dnl

AC_PATH_PROG(SMBCLIENT,smbclient,SMBCLIENT_NOT_FOUND)dnl
AC_SUBST(SMBCLIENT)dnl
AC_PATH_PROG(A2PS,a2ps,A2PS_NOT_FOUND)dnl
AC_SUBST(A2PS)dnl
AC_PATH_PROG(MPAGE,mpage,MPAGE_NOT_FOUND)dnl
AC_SUBST(MPAGE)dnl
AC_PATH_PROG(GZIP,gzip,GZIP_NOT_FOUND)dnl
AC_SUBST(GZIP)dnl
AC_PATH_PROG(PAP,pap,PAP_NOT_FOUND)dnl
AC_SUBST(PAP)dnl
AC_PATH_PROG(NPRINT,nprint,NPRINT_NOT_FOUND)dnl
AC_SUBST(NPRINT)dnl

if ( expr "$A2PS" : ".*NOT.*" && expr "$MPAGE" : ".*NOT.*" ) >/dev/null ; then
echo "
You do not have a text to PostScript conversion utility
Please install one of the following:
a2ps - Ascii Text to PostScript Converter
   http://www-inf.enst.fr/~demaille/a2ps
   ftp://ftp.enst.fr/pub/unix/a2ps/
mpage - SGI FreeWare  Ascii Text to PostScript Converter
   http://toolbox.sgi.com/TasteOfDT/public/freeware1.0/fw_MPHmpage/
"
fi

dnl ----------------------------------------------------------------------------
dnl -----------   C compiler checks    -----------------------------------------
AC_PROG_CC
AC_PROG_CPP


AC_MSG_CHECKING(tcl/tk version > 8.3 )
AC_PATH_PROG(WISH,wish8.3,WISH_NOT_FOUND)dnl
if test "$WISH" = "WISH_NOT_FOUND" ; then
	AC_MSG_CHECKING( - trying for default wish)
	AC_PATH_PROG(WISH8,wish,WISH_NOT_FOUND)dnl
	WISH=$WISH8
fi
AC_SUBST(WISH)dnl
if test "$WISH" = "WISH_NOT_FOUND";  then
echo "
You do not have Tcl/Tk installed or you do not have
'wish8.3' or 'wish' in the search path.  Please correct this and
retry.
"
	exit 1
fi

dnl ----------------------------------------------------------------------------
dnl ----------- XXXXXX START OF OPTIONS ----------------------------------------

dnl  lprngtool.conf location
dnl
AC_MSG_CHECKING(lprngtool.conf location)
AC_ARG_WITH(lprngtool_conf,
[  --with-lprngtool_conf=PATH   location of lprngtool.conf (default \${sysconfdir}/lprngtool.conf)],
LPRNGTOOL_CONF=$withval,
LPRNGTOOL_CONF=\${sysconfdir}/lprngtool.conf,
)
AC_MSG_RESULT($LPRNGTOOL_CONF)
AC_SUBST(LPRNGTOOL_CONF)

dnl  printcap location
dnl
AC_MSG_CHECKING(printcap location)
AC_ARG_WITH(printcap_path,
[  --with-printcap_path=PATH    location of printcap file (default \${sysconfdir}/printcap)],
PRINTCAP_PATH=$withval,
PRINTCAP_PATH=\${sysconfdir}/printcap,
)
AC_MSG_RESULT($PRINTCAP_PATH)
AC_SUBST(PRINTCAP_PATH)

dnl  spool directory location
dnl
AC_MSG_CHECKING(spool directory)
AC_ARG_WITH(spool_directory,
[  --with-spool_directory=PATH  location of spool directories (default /var/spool/lpd)],
SPOOL_DIR=$withval,
SPOOL_DIR=/var/spool/lpd,
)
AC_MSG_RESULT($SPOOL_DIR)
AC_SUBST(SPOOL_DIR)

AC_MSG_CHECKING(ifhp filter path)
AC_ARG_WITH(ifhp_path,
[  --with-ifhp_path=PATH        location of ifhp filter (default: \${FILTER_DIR}/ifhp)],
IFHP_PATH=$withval,
IFHP_PATH=\${FILTER_DIR}/ifhp,
)
AC_MSG_RESULT($IFHP_PATH)
AC_SUBST(IFHP_PATH)


AC_MSG_CHECKING(ifhp.conf path)
AC_ARG_WITH(ifhp_conf,
[  --with-ifhp_conf=PATH        location of ifhp configuration file (default: \${sysconfdir}/ifhp.conf)],
IFHP_CONF=$withval,
IFHP_CONF=\${sysconfdir}/ifhp.conf,
)
AC_MSG_RESULT($IFHP_CONF)
AC_SUBST(IFHP_CONF)

AC_MSG_CHECKING(filter directory)
AC_ARG_WITH(filterdir,
[  --with-filterdir=DIR         filter directory (default \${libexecdir}/filters)],
FILTER_DIR=$withval,
FILTER_DIR=\${libexecdir}/filters,
)
AC_MSG_RESULT($FILTER_DIR)
AC_SUBST(FILTER_DIR)

dnl ----------------------------------------------------------------------------
dnl ----------- XXXXXX END OF OPTIONS ------------------------------------------

AC_ISC_POSIX
AC_MINIX
AC_AIX


changequote(, )dnl
release=`uname -r 2>/dev/null; exit 0`;
version=`echo $target_os | sed -e 's/[^0-9][^0-9]*//' -e 's/\./X/' -e 's/\.//g' -e 's/X/./' \
	| awk '{ v=$1+0; if( v > 0 ){ while( v < 100 ){v = v * 10;}}; print v; }' `;
if test "$version" -eq 0 ; then
	version=`echo $release | sed -e 's/-.*//' -e 's/\.//g' \
	| awk '{ v=$1+0; if( v > 0 ){ while( v < 100 ){v = v * 10;}}; print v; }' `;
fi
osword=`echo $target_os | sed -e 's/[0-9].*//'`; export osword
changequote([, ])dnl
AC_MSG_RESULT([Target is $target, arch $target_cpu, os $target_os, release $release, version $version])

AC_DEFINE_UNQUOTED(ARCHITECTURE,"$target_cpu")
AC_DEFINE_UNQUOTED(OSNAME,"$osword")
AC_DEFINE_UNQUOTED(OSVERSION,$version)
OSNAME=$osword
OSVERSION=$version
AC_SUBST(OSNAME)dnl
AC_SUBST(OSVERSION)dnl

dnl ----------------------------------------------------------------------------
dnl ----------------- INCLUDE FILES   ------------------------------------------

AC_CHECK_HEADERS(unistd.h)


dnl ----------------------------------------------------------------------------
dnl ----------------- VERSIONS        ------------------------------------------

PAGER="$A2PS"
if expr "$OSNAME" : "linux" >/dev/null ; then
        PAGER="$MPAGE"
fi
AC_SUBST(PAGER)dnl


dnl ----------------------------------------------------------------------------
dnl ----------------- START OF OUTPUT ------------------------------------------

AC_OUTPUT(
[
Makefile
lprngtool.1
]
)

dnl ----------------------------------------------------------------------------
dnl ----------------- END OF OUTPUT --------------------------------------------
