############################################################
#
# $Id: configure.in,v 1.6 1999/09/23 08:06:56 wiegand Exp $
#
# Configuration template file (for use with GNU AutoConf)
#
# Author(s): Jens-Gero Boehm <jens-gero.boehm@suse.de>
#            Pieter Hollants <pieter.hollants@suse.de>
#            Marius Tomaschewski <mt@suse.de>
#            Volker Wiegand <volker.wiegand@suse.de>
#
# This file is part of the SuSE Proxy Suite
#            See also  http://proxy-suite.suse.de/
#
# This file is an input file used by the GNU "autoconf" program
# to generate the file "configure", which is run during package
# installation to configure the system for the local environment.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version
# 2 of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
#
# A history log can be found at the end of this file.
#

AC_INIT(common/com-syslog.c)
AC_CONFIG_HEADER(config.h)

if test "${prefix}" = "NONE"; then
	prefix=/usr/local/proxy-suite
fi
if test "${exec_prefix}" = "NONE"; then
	exec_prefix=$prefix
fi

# Hmmm, the following is a bit of a kludge ...
if test "${sysconfdir}" = "\${prefix}/etc"; then
	sysconfdir=$prefix/etc
fi
if test "${mandir}" = "\${prefix}/man"; then
	mandir=$prefix/man
fi
if test "${sbindir}" = "\${exec_prefix}/sbin"; then
	sbindir=$exec_prefix/sbin
fi


############################################################
# setup compiler and machine dependent stuff
############################################################

AC_PROG_CC
AC_PROG_INSTALL
AC_PROG_MAKE_SET
AC_PROG_RANLIB

AC_PATH_PROG(AR, ar, ar)
AC_PATH_PROG(RM, rm, rm)

AC_AIX
AC_ISC_POSIX

AC_CANONICAL_HOST
AC_DEFINE_UNQUOTED(HOSTTYPE, "$host")

case "$host" in
	*-*-hpux*)
		if test -z "$GCC"; then
			CFLAGS="$CFLAGS -Ae -D_HPUX_SOURCE"
		fi
		;;
	*-ibm-aix*)
		if test -z "$GCC"; then
			CFLAGS="$CFLAGS -qlanglvl=ansi"
		fi
		;;
	*-*-linux*)
		PROC_FTP="proc_ftp.o"
		;;
	*)
		;;
esac

AC_MSG_CHECKING(whether debugging is enabled)
AC_ARG_ENABLE(debug,
	[  --enable-debug          allow generation of debugging output],
	[ case "$enableval" in
		yes)
			AC_MSG_RESULT(yes)
			CFLAGS="$CFLAGS -DCOMPILE_DEBUG"
			;;
		*)
			AC_MSG_RESULT(no)
			;;
	esac ],
	AC_MSG_RESULT(no)
)

AC_MSG_CHECKING([whether -W -Wall is enabled (for gcc)])
AC_ARG_ENABLE(warnings,
	[  --enable-warnings       enable -W and -Wall if using gcc],
	[ if test -n "$GCC"; then
		AC_MSG_RESULT(yes)
		CFLAGS="$CFLAGS -W -Wall -Dlint"
	else
		AC_MSG_RESULT(n/a)
	fi],
	AC_MSG_RESULT(no)
)

AC_C_INLINE
AC_C_CONST

AC_CHECK_PROG(CTAGS, ctags, ctags)
if test -n "$CTAGS"; then
	TAGS="tags"
else
	TAGS=""
fi


############################################################
# check for header files
############################################################

AC_HEADER_STDC
AC_CHECK_HEADERS(unistd.h)
AC_CHECK_HEADERS(memory.h)

AC_CHECK_HEADERS(syslog.h)
AC_MSG_CHECKING(whether sys/syslog.h is needed)
AC_TRY_COMPILE([#include <syslog.h>],
	[ int level = LOG_KERN; ],
	AC_MSG_RESULT(no),
	AC_MSG_RESULT(yes)
	AC_DEFINE(NEED_SYS_SYSLOG_H)
)

AC_HEADER_TIME
AC_CHECK_HEADERS(sys/time.h)

AC_CHECK_HEADERS(sys/select.h)
AC_CHECK_HEADERS(sys/sockio.h)

AC_CHECK_HEADERS(fcntl.h)
AC_CHECK_HEADERS(sys/fcntl.h)

AC_HEADER_SYS_WAIT


############################################################
# check for specific functions
############################################################

AC_FUNC_WAIT3
AC_CHECK_FUNCS(waitpid)

AC_CHECK_FUNCS(setsid)


############################################################
# check for types to be defined
############################################################

AC_TYPE_MODE_T
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_TYPE_UID_T
AC_TYPE_SIGNAL

AC_CHECK_TYPE(u_int16_t, unsigned short)
AC_CHECK_TYPE(u_int32_t, unsigned int)


############################################################
# check for libraries to scan
############################################################

AC_CHECK_LIB(nsl, gethostent)
AC_CHECK_LIB(socket, connect)


############################################################
# check whether to enable /proc modules
############################################################

AC_MSG_CHECKING(whether to enable /proc modules)
AC_ARG_ENABLE(proc-mods,
	[  --enable-proc-mods      Enable (Linux) /proc diagnostic modules],
	[ case "$enableval" in
		yes)
			AC_MSG_RESULT(yes)
			PROC_FTP="proc_ftp.o"
			;;
		*)
			AC_MSG_RESULT(no)
			PROC_FTP=""
			;;
	esac ],
	if test -n "$PROC_FTP"; then
		AC_MSG_RESULT(yes)
	else
		AC_MSG_RESULT(no)
	fi
)


############################################################
# check whether to enable SO_LINGER
############################################################

AC_MSG_CHECKING(whether to enable SO_LINGER)
AC_ARG_ENABLE(so-linger,
	[  --enable-so-linger      Enable setting SO_LINGER socket option],
	[ case "$enableval" in
		yes)
			AC_MSG_RESULT(yes)
			AC_DEFINE(ENABLE_SO_LINGER)
			;;
		*)
			AC_MSG_RESULT(no)
			;;
	esac ],
	AC_MSG_RESULT(no)
)


############################################################
# check whether to enable RFC 1579 handling
############################################################

AC_MSG_CHECKING(whether to enable RFC 1579 handling)
AC_ARG_ENABLE(rfc1579,
	[  --enable-rfc1579        Enable RFC 1579 (FW-FTP) extensions],
	[ case "$enableval" in
		yes)
			AC_MSG_RESULT(yes)
			AC_DEFINE(ENABLE_RFC1579)
			;;
		*)
			AC_MSG_RESULT(no)
			;;
	esac ],
	AC_MSG_RESULT(no)
)


############################################################
# check whether to enable  RFC 2428 handling
############################################################

AC_MSG_CHECKING(whether to enable RFC 2428 handling)
AC_ARG_ENABLE(rfc2428,
	[  --enable-rfc2428        Enable RFC 2428 (FTP for IPv6) extensions],
	[ case "$enableval" in
		yes)
			AC_MSG_RESULT(yes)
			AC_DEFINE(ENABLE_RFC2428)
			;;
		*)
			AC_MSG_RESULT(no)
			;;
	esac ],
	AC_MSG_RESULT(no)
)


############################################################
# check whether to compile in POSIX RegEx support
############################################################

AC_MSG_CHECKING(whether to use regular expressions)
AC_ARG_WITH(regex,
	[  --with-regex[=PATH]     Use regular expressions for path names],
	[ case "$withval" in
		no)
			AC_MSG_RESULT(no)
			;;
		yes)
			AC_MSG_RESULT(yes)
			AC_CHECK_FUNC(regcomp,
				AC_DEFINE(HAVE_REGEX),
				AC_CHECK_LIB(regex, regcomp, [
					LIB_REGEX="-lregex"
					AC_DEFINE(HAVE_REGEX) ]
				)
			)
			;;
		*)
			AC_MSG_RESULT(yes)
			AC_DEFINE(HAVE_REGEX)
			if test -d "$withval"; then
				LIB_REGEX="-L$withval -lregex"
			else
				LIB_REGEX="$withval"
			fi
			OLDLIBS="$LIBS"
			LIBS="$LIB_REGEX $LIBS"
			AC_TRY_LINK([],
				[ regcomp(); ],
				[],
				[ AC_MSG_ERROR(Could not find libregex) ]
			)
			LIBS="$OLDLIBS"
			;;
	esac ],
	AC_MSG_RESULT(no)
)


############################################################
# check whether to compile in TCP Wrapper support
############################################################

AC_MSG_CHECKING(whether to use libwrap)
AC_ARG_WITH(libwrap,
	[  --with-libwrap[=PATH]   Compile in libwrap (TCP Wrapper) support],
	[ case "$withval" in
		no)
			AC_MSG_RESULT(no)
			;;
		yes)
			AC_MSG_RESULT(yes)
			AC_CHECK_LIB(wrap, request_init, [
				LIB_WRAP="-lwrap"
				AC_DEFINE(HAVE_LIBWRAP) ]
			)
			;;
		*)
			AC_MSG_RESULT(yes)
			AC_DEFINE(HAVE_LIBWRAP)
			if test -d "$withval"; then
				LIB_WRAP="-L$withval -lwrap"
			else
				LIB_WRAP="$withval"
			fi
			OLDLIBS="$LIBS"
			LIBS="$LIB_WRAP $LIBS"
			AC_TRY_LINK([ int allow_severity;
				      int deny_severity; ],
				[ hosts_access(); ],
				[],
				[ AC_MSG_ERROR(Could not find libwrap) ]
			)
			LIBS="$OLDLIBS"
			;;
	esac ],
	AC_MSG_RESULT(no)
)


############################################################
# check whether to compile in LDAP support
############################################################

AC_MSG_CHECKING(whether to use LDAP)
AC_ARG_WITH(libldap,
	[  --with-libldap[=PATH]   Compile in LDAP support],
	[ case "$withval" in
		no)
			AC_MSG_RESULT(no)
			;;
		yes)
			AC_MSG_RESULT(yes)
			AC_CHECK_LIB(ldap, ldap_set_option, [
				LIB_LDAP="-lldap"
				AC_DEFINE(HAVE_LIBLDAP)
				AC_DEFINE(HAVE_LDAP_NETSCAPE)
			],
				AC_CHECK_LIB(lber, ber_init, [
					LIB_LDAP="-lldap -llber"
					AC_DEFINE(HAVE_LIBLDAP)
					AC_DEFINE(HAVE_LDAP_UMICH) ]
				)
			)
			;;
		*)
			AC_MSG_RESULT(yes)
			AC_DEFINE(HAVE_LIBLDAP)
			if test -d "$withval"; then
				LIB_LDAP="-L$withval -lldap"
			else
				LIB_LDAP="$withval"
			fi
			OLDLIBS="$LIBS"
			LIBS="$LIB_LDAP $OLDLIBS"
			AC_TRY_LINK([ char server; ],
			    [ ldap_init(server, 389); ],
			    [ AC_DEFINE(HAVE_LDAP_NETSCAPE) ],
			    [
				LIB_LDAP="$LIB_LDAP -llber"
				LIBS="$LIB_LDAP $OLDLIBS"
				AC_TRY_LINK([ char server; ],
				    [ ldap_init(server, 389); ],
				    [ AC_DEFINE(HAVE_LDAP_UMICH) ],
				    [ AC_MSG_ERROR(Could not find libldap) ]
				)
			    ]
			)
			LIBS="$OLDLIBS"
			;;
	esac ],
	AC_MSG_RESULT(no)
)


############################################################
# Done, now generate the output files
############################################################

AC_SUBST(CC)
AC_SUBST(CFLAGS)
AC_SUBST(TAGS)
AC_SUBST(LIB_WRAP)
AC_SUBST(LIB_LDAP)
AC_SUBST(LIB_REGEX)
AC_SUBST(PROC_FTP)

AC_OUTPUT(	Makefile			\
		doc/Makefile			\
		common/Makefile			\
		ftp-proxy/Makefile		\
		ftp-proxy/ftp-proxy.conf.5	\
		ftp-proxy/ftp-proxy.8		\
	)


############################################################
# $Log: configure.in,v $
# Revision 1.6  1999/09/23 08:06:56  wiegand
# code cleanup, added installation target
#
# Revision 1.5  1999/09/20 05:45:12  wiegand
# added support for man pages
#
# Revision 1.4  1999/09/17 16:32:29  wiegand
# changes from source code review
# added POSIX regular expressions
#
# Revision 1.3  1999/09/15 14:08:03  wiegand
# added doc directory to SUBDIRS
#
# Revision 1.2  1999/09/15 13:20:35  wiegand
# new structure: with subdirectories
#
############################################################

