dnl $LynxId: configure.in,v 1.181 2008/12/31 20:58:39 tom Exp $
dnl
dnl Process this file with autoconf to produce a configure script.
dnl
dnl created jan/1997
dnl by T.E.Dickey <dickey@invisible-island.net>
dnl and Jim Spath <jspath@mail.bcpl.lib.md.us>
dnl
dnl ---------------------------------------------------------------------------
dnl Copyright 1997-2007,2008 by Thomas E. Dickey
dnl 
dnl Permission to use, copy, modify, and distribute this software and its
dnl documentation for any purpose and without fee is hereby granted,
dnl provided that the above copyright notice appear in all copies and that
dnl both that copyright notice and this permission notice appear in
dnl supporting documentation, and that the name of the above listed
dnl copyright holder(s) not be used in advertising or publicity pertaining
dnl to distribution of the software without specific, written prior
dnl permission.
dnl 
dnl THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD
dnl TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
dnl AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE
dnl LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
dnl WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
dnl ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
dnl OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
dnl ---------------------------------------------------------------------------
dnl
dnl ask PRCS to plug-in the project-version for the configure-script.
dnl $Format: "AC_REVISION($ProjectVersion$)"$
AC_REVISION(2.8.7dev.12)

# Save the original $CFLAGS so we can distinguish whether the user set those
# in the environment, or whether autoconf added -O and -g options:
ORIGINAL_CFLAGS="$CFLAGS"

# For autoconf 2.13, make sure we have no cache file at the beginning of this
# script.  That fixes problems with tests whose cached values change from one
# run to the next, as well as with tests that are order-dependent.
rm -f config.cache

AC_PREREQ(2.13.20020210)
AC_INIT(userdefs.h)

# autoconf 2.5x defaults to no cache file; we need the cache file's information
# for building the config page.  But start with it empty to avoid confusion by
# people who don't do a "make distclean" after applying patches.
cache_file=config.cache
rm -f config.cache; touch config.cache

CONFIG_H=lynx_cfg.h
AC_CONFIG_HEADER($CONFIG_H:config.hin)
AC_SUBST(CONFIG_H)

CF_CHECK_CACHE([AC_CANONICAL_SYSTEM])
AC_ARG_WITH(system-type,
[  --with-system-type=XXX  test: override derived host system-type],
[AC_MSG_WARN(overriding system type $host_os to $withval)
 host_os=$withval])

PACKAGE=lynx
dnl ask PRCS to plug-in the project-version for the packages.
# $Format: "VERSION=$ProjectVersion$"$
VERSION=2.8.7dev.12

AC_SUBST(PACKAGE)
AC_SUBST(VERSION)

AC_MSG_CHECKING(for DESTDIR)
CF_WITH_PATH(destdir,
[  --with-destdir=XXX      set DESTDIR destination for install],
DESTDIR,
[$DESTDIR],
[$DESTDIR])
AC_MSG_RESULT($DESTDIR)

AC_PREFIX_DEFAULT(/usr/local)

dnl --------------------------------------------------------------------------
dnl Checks for location of programs
dnl --------------------------------------------------------------------------

dnl Only add to this case statement when a system has a compiler that is not
dnl detected by AC_PROG_CC. 
case $host_os in
openedition)
	: ${CFLAGS="-D_ALL_SOURCE -Wl,EDIT=NO"}
	: ${CC=c89}
	;;
esac

AC_PROG_CC
AC_PROG_CPP
AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_PROG_INSTALL
AC_PROG_YACC
AC_CHECK_PROGS(LINT, lint alint lclint tdlint, [])

AC_AIX
AC_ISC_POSIX

CF_BUILD_CC([#],[])

AC_CHECK_TOOL(RANLIB, ranlib, ':')
AC_CHECK_TOOL(AR, ar, ar)
CF_SUBST(archiver options,AR_OPTS,rv)

dnl --------------------------------------------------------------------------
dnl Debug/development/test
dnl --------------------------------------------------------------------------

CF_HELP_MESSAGE(
Development Options:)

CF_DISABLE_ECHO

# special case for WWW/*
if test -n "$ECHO_CC" ; then
	DONT_ECHO_CC="$SHOW_CC ;"
else
	DONT_ECHO_CC=''
fi
AC_SUBST(DONT_ECHO_CC)

AC_MSG_CHECKING(if you want to check memory-leaks)
CF_ARG_ENABLE(find-leaks,
	[  --enable-find-leaks     logic for testing memory leaks],
	[with_leak_checks=yes],
	[with_leak_checks=no])
AC_MSG_RESULT($with_leak_checks)
test "$with_leak_checks" = "yes" && AC_DEFINE(LY_FIND_LEAKS)

# The comment about adding -g to $CFLAGS is unclear.  Autoconf tries to add
# a -g flag; we remove it if the user's $CFLAGS was not set and debugging is
# disabled.
AC_MSG_CHECKING(if you want to enable debug-code)
CF_ARG_ENABLE(debug,
	[  --enable-debug          compile w/ debugging (if \$CFLAGS is set, add -g there, too)],
	[with_debug=yes],
	[with_debug=no])
AC_MSG_RESULT($with_debug)
if test "$with_debug" = "yes" ; then
	case $host_os in
	ultrix*|osf*)
		test -z "$ORIGINAL_CFLAGS" && CF_STRIP_O_OPT(CFLAGS)
		if test -z "$GCC" ; then
			CFLAGS="$CFLAGS -g3"
		fi
		;;
	esac
else
	case $host_os in
	osf*) #(vi
		test -z "$GCC" && CFLAGS="$CFLAGS -std1"
		test -z "$ORIGINAL_CFLAGS" && CF_STRIP_G_OPT(CFLAGS)
		;;
	*)
		test -z "$ORIGINAL_CFLAGS" && CF_STRIP_G_OPT(CFLAGS)
		;;
	esac
fi

AC_MSG_CHECKING(if you want to enable lynx trace code *recommended* )
CF_ARG_DISABLE(trace,
	[  --disable-trace         disable logic for trace code],
	[with_trace=$enableval],
	[with_trace=yes])
AC_MSG_RESULT($with_trace)
test $with_trace = no && AC_DEFINE(NO_LYNX_TRACE)

AC_MSG_CHECKING(if you want verbose trace code)
CF_ARG_ENABLE(vertrace,
	[  --enable-vertrace       verbose trace code],
	[with_vertrace=yes],
	[with_vertrace=no])
AC_MSG_RESULT($with_vertrace)
test $with_vertrace = yes && AC_DEFINE(LY_TRACELINE,__LINE__)

if test -n "$GCC"
then
AC_MSG_CHECKING(if you want to turn on gcc warnings)
CF_ARG_ENABLE(warnings,
	[  --enable-warnings       GCC compiler warnings],
	[with_warnings=yes],
	[with_warnings=no])
AC_MSG_RESULT($with_warnings)
if test "$with_warnings" = "yes"
then
	CF_GCC_ATTRIBUTES
	CF_GCC_WARNINGS
fi
fi

CF_WITH_DBMALLOC
CF_WITH_DMALLOC

dnl --------------------------------------------------------------------------
dnl Checks for compiler & standard-library characteristics
dnl --------------------------------------------------------------------------

dnl If we're able to run this script, this is true!
AC_DEFINE(UNIX)

AC_C_CONST

dnl Only add to this case statement things that we cannot design tests for.
CF_PROG_EXT
TRY_CFLAGS=
case $host_os in
aix4*)
	TRY_CFLAGS="$TRY_CFLAGS -DAIX4 -D_BSD=44 -D_AIX"
	LIBS="$LIBS -lbsd"
	;;
aix*)
	TRY_CFLAGS="$TRY_CFLAGS -D_ACS_COMPAT_CODE"
	LIBS="$LIBS -lbsd"
	;;
apollo*)
	TRY_CFLAGS="$TRY_CFLAGS -D_BUILTINS -W0,-opt,4"
	;;
bsdi*)
	TRY_CFLAGS="$TRY_CFLAGS -DBSDI"
	;;
clix*)
	# Tested on CLIX 3.1 (T.Dickey).  The original makefile entry
	# contributed by Alex Matulich (matuli_a@marlin.navsea.navy.mil) also
	# references -lmalloc and -lbsd.
	AC_CHECK_LIB(c_s,strcmp)
	;;
convex*)
	TRY_CFLAGS="$TRY_CFLAGS -D__STDC__ -Dunix"
	;;
cygwin*)
	TRY_CFLAGS="$TRY_CFLAGS -DWIN_EX -D_WINDOWS_NSL"
	LIBS="$LIBS -luser32"
	;;
dgux*)
	TRY_CFLAGS="$TRY_CFLAGS -DDGUX"
	;;
hpux*)
	TRY_CFLAGS="$TRY_CFLAGS -DSNAKE -D_XOPEN_SOURCE_EXTENDED"
	test -z "$GCC" && TRY_CFLAGS="$TRY_CFLAGS -Wp,-H600000 -DSYS_HPUX"
	;;
isc*)
	# -DPOSIX_JC is necessary, else LYBookmark.c never finds out what a mode_t is.
	TRY_CFLAGS="$TRY_CFLAGS -DISC -DPOSIX_JC"
	LIBS="$LIBS -linet -lnsl_s -lcposix"
	;;
irix6.*) #(vi
	TRY_CFLAGS="$TRY_CFLAGS -DSYS_IRIX64"
	;;
irix*)
	# The original makefile used the $CFLAGS option -cckr for some form
	# of K&R compatibility.  However, this causes compilation warnings for
	# varargs on IRIX 5.2, and does not appear to be needed.
	;;
linux*)
	TRY_CFLAGS="$TRY_CFLAGS -DLINUX"
	;;
mingw*)
	# put these directlyin CPPFLAGS since they will not work in lynx_cfg.h
	CF_ADD_CFLAGS(\
		-DWIN32_LEAN_AND_MEAN \
		-DDOSPATH \
		-DNOSIGHUP \
		-DNOUSERS \
		-DWIN_EX \
		-D_CONSOLE \
		-D_MBCS \
		-D_WINDOWS \
		-D_WIN_CC \
		-D__WIN32__ \
	)
	EXTRA_OBJS="$EXTRA_OBJS Xsystem\$o"
	;;
msdosdjgpp*)
	LIBS="$LIBS -lwatt"
	TRY_CFLAGS="$TRY_CFLAGS -DDOSPATH -DNOUSERS"
	;;
next*)
	TRY_CFLAGS="$TRY_CFLAGS -DNEXT"
	;;
openbsd* | ekkobsd* | mirbsd*)
	LIBS="$LIBS -lcompat"
	;;
osf4*)
	# The -Olimit flag (see below) is no longer available with
	# Digital C 5.2, which is bundled with Digital UNIX 4.0.
	TRY_CFLAGS="$TRY_CFLAGS -DDSYS5 -DSYS_TRU64"
	;;
osf*)
	# Increase the maximum size of functions that will be optimized.
	test -z "$GCC" && TRY_CFLAGS="$TRY_CFLAGS -O -Olimit 4000"
	TRY_CFLAGS="$TRY_CFLAGS -DDSYS5 -DSYS_TRU64"
	;;
sco3.2v5*)
	test $ac_cv_prog_gcc != yes && TRY_CFLAGS="$TRY_CFLAGS -belf"
	;;
sco*)
	LIBS="$LIBS -lmalloc"
	# It's a little late to do much, but try to warn user if he's using
	# SCO's cc (which is reported to have broken const/volatile).
	case "$CC" in #(vi
	cc|*/cc)
		AC_MSG_WARN(You should consider using gcc or rcc if available)
		unset ac_cv_prog_CC
		AC_CHECK_PROGS(CC,gcc rcc,$CC)
		;;
	esac
	;;
sequent-ptx)
	TRY_CFLAGS="$TRY_CFLAGS -DSVR4_BSDSELECT -DNO_IOCTL -DUSE_FCNTL"
	;;
sequent-ptx2)
	TRY_CFLAGS="$TRY_CFLAGS -DSVR4_BSDSELECT"
	;;
sony-newsos*)
	TRY_CFLAGS="$TRY_CFLAGS -I/usr/sony/include"
	AC_CHECK_HEADERS(jcurses.h)
	;;
svr4)
	TRY_CFLAGS="$TRY_CFLAGS -DSVR4_BSDSELECT -DSVR4"
	;;
sunos3*)
	TRY_CFLAGS="$TRY_CFLAGS -DSUN"
	;;
sunos4*)
	TRY_CFLAGS="$TRY_CFLAGS -DSUN -DSUN4"
	;;
ultrix*)
	# Increase the maximum size of functions that will be optimized.
	test -z "$GCC" && TRY_CFLAGS="$TRY_CFLAGS -O -Olimit 600 -G 7"
	TRY_CFLAGS="$TRY_CFLAGS -DULTRIX"
	AC_CHECK_HEADERS(cursesX.h,
		[AC_DEFINE(HAVE_CURSESX_H)
		 cf_cv_ncurses_header=cursesX.h])
	;;
esac

CF_ANSI_CC_REQD

dnl --------------------------------------------------------------------------
dnl --------------------------------------------------------------------------

CF_HELP_MESSAGE(
Basic Configuration Options:)

CF_LARGEFILE

dnl --------------------------------------------------------------------------
dnl internationalization macros
dnl --------------------------------------------------------------------------

dnl Set of available languages (based on source distribution)
if test -z "$ALL_LINGUAS" ; then
	ALL_LINGUAS=`test -d $srcdir/po && cd $srcdir/po && echo *.po|sed -e 's/\.po//g' -e 's/*//'`
	ALL_LINGUAS="$ALL_LINGUAS en"
fi

CF_BUNDLED_INTL(makefile,disable)

INTLDIR_CPPFLAGS="#"
if test -z "$INTLDIR_MAKE" ; then
	INTLDIR_CPPFLAGS=
fi

AC_SUBST(INTLDIR_CPPFLAGS)

CF_WITH_PATH(nls-datadir,
[  --with-nls-datadir=DIR  NLS data, parent of locale],
NLS_DATADIR,
[PREFIX/DATADIR],
[$prefix/$DATADIRNAME])

dnl --------------------------------------------------------------------------
AC_MSG_CHECKING(if you want full utility pathnames)
CF_ARG_DISABLE(full-paths,
	[  --disable-full-paths    control whether full utility pathnames are used],
	[with_full_paths=no],
	[with_full_paths=yes])
AC_MSG_RESULT($with_full_paths)
test $with_full_paths = no && AC_DEFINE(USE_EXECVP)

CF_DEFINE_PROG(system mailer, SYSTEM_MAIL,
	/usr/mmdf/bin/submit \
	/usr/sbin/sendmail \
	/usr/lib/sendmail  \
	)
CF_SYSTEM_MAIL_FLAGS
if test -n "$SYSTEM_MAIL" ; then
if test $with_full_paths = no ; then
	SYSTEM_MAIL=`basename $SYSTEM_MAIL`
fi
fi

dnl --------------------------------------------------------------------------
CF_XOPEN_SOURCE(600,199506L)
CF_SIGWINCH

dnl Collect tests for compiler options into one place
if test -n "$TRY_CFLAGS" ; then
	CF_CHECK_CFLAGS($TRY_CFLAGS)
fi

dnl --------------------------------------------------------------------------
dnl Checks for library configuration (added right-to-left)
dnl --------------------------------------------------------------------------

### Look for network libraries first, since some functions (such as gethostname)
### are used in a lot of places.
AC_CACHE_CHECK(if you want NSS compatible SSL libraries,cf_cv_use_libnss_compat,[
AC_ARG_WITH(nss-compat,
	[  --with-nss-compat{=path}       link with nss_compat library if available],
	[cf_cv_use_libnss_compat=$withval],
	[cf_cv_use_libnss_compat=no])
])

AC_CACHE_CHECK(if you want ssl library,cf_cv_use_libssl,[
AC_ARG_WITH(ssl,
	[  --with-ssl{=path}       link with ssl library if available],
	[cf_cv_use_libssl=$withval],
	[cf_cv_use_libssl=no])
])

AC_CACHE_CHECK(if you want gnutls support,cf_cv_use_libgnutls,[
AC_ARG_WITH(gnutls,
	[  --with-gnutls{=path}    link with gnutls support],
	[cf_cv_use_libgnutls=$withval],
	[cf_cv_use_libgnutls=no])
])

# this option is mainly for comparing with/without Lynx's wrapper for GNUTLS.
AC_CACHE_CHECK(if you want gnutls-openssl compat,cf_cv_gnutls_compat,[
AC_ARG_ENABLE(gnutls-compat,
	[  --enable-gnutls-compat  link with gnutls-openssl compat],
	[cf_cv_gnutls_compat=$withval],
	[cf_cv_gnutls_compat=no])
])

AC_CACHE_CHECK(if you want socks library,cf_cv_use_libsocks,[
AC_ARG_WITH(socks,
	[  --with-socks{=path}     link with socks library if available],
	[cf_cv_use_libsocks=$withval],
	[cf_cv_use_libsocks=no])
])

AC_CACHE_CHECK(if you want socks5 library,cf_cv_use_libsocks5,[
AC_ARG_WITH(socks5,
	[  --with-socks5{=path}    link with socks5 library if available],
	[cf_cv_use_libsocks5=$withval],
	[cf_cv_use_libsocks5=no])
])

if test "x$cf_cv_use_libsocks" != xno ; then
	CF_SOCKS($cf_cv_use_libsocks)
elif test "x$cf_cv_use_libsocks5" != xno ; then
	CF_SOCKS5($cf_cv_use_libsocks5)
else
	CF_NETLIBS
fi

CF_INET_ADDR

CF_PKG_CONFIG

if test "x$cf_cv_use_libssl"  != xno ; then
	CF_SSL($cf_cv_use_libssl)
elif test "x$cf_cv_use_libgnutls" != xno ; then
    if test "x$cf_cv_gnutls_compat" = xno ; then
        CF_GNUTLS($cf_cv_use_libgnutls,tidy_tls\$o)
    else
        CF_GNUTLS($cf_cv_use_libgnutls)
    fi
elif test "x$cf_cv_use_libnss_compat"  != xno ; then
	CF_NSS_COMPAT($cf_cv_use_libnss_compat)
fi

dnl --------------------------------------------------------------------------
### check for ipv6 support
AC_MSG_CHECKING([whether to enable ipv6])
CF_ARG_ENABLE(ipv6,
[  --enable-ipv6           use ipv6 (with ipv4) support],
	[AC_DEFINE(ENABLE_IPV6)])
AC_MSG_RESULT($enableval)
if test "$enableval" = "yes"; then
	CF_CHECK_IPV6
fi
dnl AC_REPLACE_FUNCS(getaddrinfo getnameinfo)

dnl --------------------------------------------------------------------------
dnl This has to be cached, since there's a lot of interdependent tests.
AC_CACHE_CHECK(for screen type, cf_cv_screen,[
AC_ARG_WITH(screen,
[  --with-screen=XXX       select screen type (XXX is curses (default),
                          ncurses, ncursesw, pdcurses or slang)],
	[
case $withval in
curses|ncurses|ncursesw|pdcurses|slang)
	cf_cv_screen=$withval
	;;
*)	AC_ERROR(Unexpected value)
	;;
esac],
	[cf_cv_screen=curses])])

case $cf_cv_screen in
curses|ncurses*)
	CF_WITH_CURSES_DIR
	;;
esac

cf_wide_curses=no
dft_color_style=yes
case $cf_cv_screen in
curses)
	CF_CURSES_CONFIG
	CF_CURS_PERFORMANCE
	CF_CURS_TOUCHLINE
	;;
ncurses)
	CF_NCURSES_CONFIG
	;;
ncursesw)
	CF_UTF8_LIB
	CF_NCURSES_CONFIG(ncursesw)
	cf_wide_curses=yes
	;;
pdcurses)
	cf_cv_ncurses_header=xcurses.h
	# do this last, since it changes definition of main: CF_PDCURSES_X11
	;;
slang)
	CF_SLANG_UNIX_DEFS
	dft_color_style=no
	;;
esac

AC_MSG_CHECKING(if you want the wide-curses features)
CF_ARG_ENABLE(widec, 
[  --enable-widec          enable wide-curses features], 
	[use_wide_curses=$enableval],
	[use_wide_curses=$cf_wide_curses])
AC_MSG_RESULT($use_wide_curses)

AC_MSG_CHECKING(if color-style code should be used)
CF_ARG_DISABLE(color-style,
[  --disable-color-style   use color style (ncurses/curses)],
	[use_color_style=$enableval],
	[use_color_style=$dft_color_style])

case $use_color_style in
no)
	AC_MSG_RESULT(no)
	INSTALL_LSS=
	;;
*)
	AC_DEFINE(USE_COLOR_STYLE)
	AC_MSG_RESULT(yes)

	AC_MSG_CHECKING(for location of style-sheet file)

CF_WITH_PATH(lss-file,
[  --with-lss-file{=path}  specify the default style-sheet file
                         ],
LYNX_LSS_FILE,
SYSCONFDIR/lynx.lss,
$sysconfdir/lynx.lss)

	AC_MSG_RESULT($LYNX_LSS_FILE)

	test "$LYNX_LSS_FILE" = no && LYNX_LSS_FILE=
	AC_DEFINE_UNQUOTED(LYNX_LSS_FILE,"$LYNX_LSS_FILE")

	INSTALL_LSS=install-lss
	;;
esac
AC_SUBST(INSTALL_LSS)

dnl --------------------------------------------------------------------------

AC_MSG_CHECKING(for the default configuration-file)

CF_WITH_PATH(cfg-file,
[  --with-cfg-file{=path}  specify the default configuration file
                         ],
LYNX_CFG_FILE,
SYSCONFDIR/lynx.cfg,
$sysconfdir/lynx.cfg)

dnl --------------------------------------------------------------------------

AC_MSG_RESULT($LYNX_CFG_FILE)

test "$LYNX_CFG_FILE" = no && LYNX_CFG_FILE=
AC_DEFINE_UNQUOTED(LYNX_CFG_FILE,"$LYNX_CFG_FILE")

dnl --------------------------------------------------------------------------
AC_MSG_CHECKING(if htmlized lynx.cfg should be built)
CF_ARG_ENABLE(htmlized-cfg,
[  --enable-htmlized-cfg   build htmlized lynx.cfg],
	[use_htmlized_cfg=$enableval],
	[use_htmlized_cfg=no])
AC_MSG_RESULT($use_htmlized_cfg)

LYNXCFG_MAKE=''
if test $use_htmlized_cfg = no ; then
	LYNXCFG_MAKE='#'
fi
AC_SUBST(LYNXCFG_MAKE)

dnl --------------------------------------------------------------------------
AC_MSG_CHECKING(if local doc directory should be linked to help page)
CF_ARG_ENABLE(local-docs,
[  --enable-local-docs     link local doc-directory to help-page],
	[use_local_docs=$enableval],
	[use_local_docs=no])
AC_MSG_RESULT($use_local_docs)

LYNXDOC_MAKE=''
if test $use_local_docs = no ; then
	LYNXDOC_MAKE='#'
fi
AC_SUBST(LYNXDOC_MAKE)

dnl --------------------------------------------------------------------------

AC_MSG_CHECKING(for MIME library directory)
CF_WITH_PATH(mime-libdir,
[  --with-mime-libdir=DIR  MIME data, mime.types and mailcap],
MIME_LIBDIR,
[/etc])
AC_MSG_RESULT($MIME_LIBDIR)
MIME_LIBDIR=`echo "$MIME_LIBDIR" | sed -e 's,/$,,' -e 's,$,/,'`
AC_DEFINE_UNQUOTED(MIME_LIBDIR,"$MIME_LIBDIR")

dnl --------------------------------------------------------------------------
AC_MSG_CHECKING(if locale-charset selection logic should be used)
CF_ARG_ENABLE(locale-charset,
[  --enable-locale-charset use locale-charset selection logic],
	[use_locale_charset=$enableval],
	[use_locale_charset=yes])
AC_MSG_RESULT($use_locale_charset)
test $use_locale_charset != no && AC_DEFINE(USE_LOCALE_CHARSET)

dnl --------------------------------------------------------------------------
dnl Check for subsets of compiled-in tables.
dnl --------------------------------------------------------------------------
CHARSET_DEFS=
AC_SUBST(CHARSET_DEFS)

AC_MSG_CHECKING(if you want only a few charsets)
AC_ARG_WITH(charsets,
[  --with-charsets=list    limit charsets to given list of MIME names],
[cf_charsets=$withval],
[cf_charsets=])

if test -n "$cf_charsets" ; then
	AC_MSG_RESULT(yes)
	AC_DEFINE(ALL_CHARSETS,0)
	cf_min_charsets=us-ascii,iso-8859-1,utf-8
	if test "$cf_charsets" = "no" ; then
		cf_charsets=minimal
	fi
	if test "$cf_charsets" = "minimal" ; then
		CF_VERBOSE(using minimal list of charsets: $cf_min_charsets)
	fi
	cf_charsets=`echo $cf_charsets | sed -e "s/minimal/$cf_min_charsets/g" -e 's/,/ /g'`
	for cf_charset in $cf_charsets
	do
		cf_def_charset=`echo $cf_charset | sed -e 's/+/_/g' -e 's/-/_/g'`
		cf_use_charset=no
		# check charsets that are defined via .tbl files
		if ( egrep '^M'$cf_charset'$' $srcdir/src/chrtrans/*.tbl 2>/dev/null >/dev/null )
		then
			cf_use_charset=yes
		# check charsets that are "built-in"
		else
			for cf_tst_charset in big5 euc_cn euc_jp euc_kr shift_jis x_transparent
			do
				if test "$cf_tst_charset" = "$cf_def_charset"
				then
					cf_use_charset=yes
					break
				fi
			done
		fi
		if test $cf_use_charset=yes
		then
			CF_VERBOSE(found $cf_charset)
			CHARSET_DEFS="-DNO_CHARSET_${cf_def_charset}=0 $CHARSET_DEFS"
		else
			CF_VERBOSE(not found $cf_charset)
		fi
	done
else
	AC_MSG_RESULT(no)
fi

dnl --------------------------------------------------------------------------
dnl Checks for standard headers
dnl --------------------------------------------------------------------------

AC_HEADER_STDC
AC_HEADER_TIME
AC_HEADER_DIRENT
dnl Don't check for sys/wait.h here since it is covered by another test.
AC_CHECK_HEADERS( \
	arpa/inet.h \
	fcntl.h \
	limits.h \
	stdlib.h \
	string.h \
	sys/fcntl.h \
	sys/filio.h \
	sys/ioctl.h \
	sys/param.h \
	sys/timeb.h \
	sys/time.h \
	syslog.h \
	termio.h \
	termios.h \
	unistd.h \
	vfork.h \
)
CF_TERMIO_AND_TERMIOS
CF_FUNC_SIGACTION
CF_FUNC_WAIT
AC_TYPE_GETGROUPS
AC_TYPE_OFF_T
AC_TYPE_PID_T
AC_TYPE_UID_T
AC_TYPE_MODE_T
CF_CHECK_TYPE(socklen_t, int, [#include <sys/socket.h>])
CF_TM_GMTOFF

AC_CHECK_SIZEOF(int,4)
AC_CHECK_SIZEOF(long,4)
AC_CHECK_SIZEOF(off_t,4)
AC_CHECK_SIZEOF(time_t,4)

dnl --------------------------------------------------------------------------
dnl Checks for library units
dnl --------------------------------------------------------------------------

AC_FUNC_ALLOCA
AC_FUNC_VFORK
CF_FIONBIO
CF_REMOVE_BROKEN
CF_FUNC_LSTAT
AC_CHECK_FUNCS( \
	ctermid \
	cuserid \
	ftime \
	getcwd \
	getgroups \
	gettimeofday \
	getuid \
	mktemp \
	mkdtemp \
	popen \
	putenv \
	readdir \
	setuid \
	strerror \
	truncate \
	ttyname \
	unsetenv \
	usleep \
	vasprintf \
	waitpid \
	zError \
)
AC_REPLACE_FUNCS( \
	mktime \
	strstr \
)

CF_SRAND(lynx_)
CF_CHECK_FUNCDECLS([#include <string.h>], strstr)
CF_CHECK_FUNCDECLS([
#include <stdio.h>
#include <grp.h>], getgrgid getgrnam)

dnl --------------------------------------------------------------------------
dnl Checks for external-data
dnl --------------------------------------------------------------------------

CF_BOOL_DEFS
CF_ERRNO
CF_SET_ERRNO
CF_LOCALE
CF_NGROUPS
CF_SYS_ERRLIST
CF_UTMP
CF_CHECK_EXTERN_DATA(h_errno,int)

AC_SUBST(EXTRA_OBJS)

dnl --------------------------------------------------------------------------
dnl Experimental options that don't need to test system features
dnl --------------------------------------------------------------------------

CF_HELP_MESSAGE(
Experimental Options:)

AC_MSG_CHECKING(if bibp: URLs should be supported)
CF_ARG_DISABLE(bibp-urls,
[  --disable-bibp-urls     disable support for bibp: URLs],
	[use_bibp_urls=$enableval],
	[use_bibp_urls=yes])
AC_MSG_RESULT($use_bibp_urls)
test $use_bibp_urls = no && AC_DEFINE(DISABLE_BIBP)

AC_MSG_CHECKING(if configuration info should be browsable)
CF_ARG_DISABLE(config-info,
[  --disable-config-info   disable browsable configuration-info],
	[use_config_info=$enableval],
	[use_config_info=yes])
AC_MSG_RESULT($use_config_info)
test $use_config_info = no && AC_DEFINE(NO_CONFIG_INFO)

AC_MSG_CHECKING(if new-style forms-based options screen should be used)
CF_ARG_DISABLE(forms-options,
[  --disable-forms-options disable forms-based options],
	[use_forms_options=$enableval],
	[use_forms_options=yes])
AC_MSG_RESULT($use_forms_options)
test $use_forms_options = no && AC_DEFINE(NO_OPTION_FORMS)

AC_MSG_CHECKING(if old-style options menu should be used)
CF_ARG_DISABLE(menu-options,
[  --disable-menu-options  disable old-style option menu],
	[use_menu_options=$enableval],
	[use_menu_options=yes])
AC_MSG_RESULT($use_menu_options)
test $use_menu_options = no && AC_DEFINE(NO_OPTION_MENU)

AC_MSG_CHECKING(if experimental address-list page should be used)
CF_ARG_ENABLE(addrlist-page,
[  --enable-addrlist-page  use experimental address-list page],
	[use_addrlist_page=$enableval],
	[use_addrlist_page=no])
AC_MSG_RESULT($use_addrlist_page)
test $use_addrlist_page != no && AC_DEFINE(EXP_ADDRLIST_PAGE)

AC_MSG_CHECKING(if experimental ascii case-conversion)
CF_ARG_ENABLE(ascii-ctypes,
[  --enable-ascii-ctypes   use experimental ascii case-conversion],
	[use_ascii_ctypes=$enableval],
	[use_ascii_ctypes=no])
AC_MSG_RESULT($use_ascii_ctypes)
test $use_ascii_ctypes != no && AC_DEFINE(EXP_ASCII_CTYPES)

AC_MSG_CHECKING(if experimental charset-selection logic should be used)
CF_ARG_ENABLE(charset-choice,
[  --enable-charset-choice use experimental charset-selection logic],
	[use_charset_choice=$enableval],
	[use_charset_choice=no])
AC_MSG_RESULT($use_charset_choice)
test $use_charset_choice != no && AC_DEFINE(EXP_CHARSET_CHOICE)

AC_MSG_CHECKING(if experimental CJK logic should be used)
CF_ARG_ENABLE(cjk,
[  --enable-cjk            use experimental CJK logic],
	[use_cjk=$enableval],
	[use_cjk=no])
AC_MSG_RESULT($use_cjk)
test $use_cjk != no && AC_DEFINE(CJK_EX)

AC_MSG_CHECKING(if experimental Japanese UTF-8 logic should be used)
CF_ARG_ENABLE(japanese-utf8,
[  --enable-japanese-utf8  use experimental Japanese UTF-8 logic],
	[use_ja_utf8=$enableval],
	[use_ja_utf8=no])
AC_MSG_RESULT($use_ja_utf8)
if test $use_ja_utf8 != no ; then
	AC_DEFINE(EXP_JAPANESEUTF8_SUPPORT)
	AM_ICONV
	if test "$USE_NLS" != yes ; then
	  LIBS="$LIBICONV $LIBS"
	fi
fi

use_dft_colors=no
case $cf_cv_screen in
curses|slang|ncurses*)
	use_dft_colors=maybe
	;;
esac

if test "$use_dft_colors" != no ; then
AC_MSG_CHECKING(if you want to use default-colors)
CF_ARG_ENABLE(default-colors,
[  --enable-default-colors enable use of default-colors (ncurses/slang)],
	[use_dft_colors=yes],
	[use_dft_colors=no])
AC_MSG_RESULT($use_dft_colors)
test $use_dft_colors = "yes" && AC_DEFINE(USE_DEFAULT_COLORS)
fi

dnl --------------------------------------------------------------------------
AC_MSG_CHECKING(if experimental keyboard-layout logic should be used)
CF_ARG_ENABLE(kbd-layout,
[  --enable-kbd-layout     use experimental keyboard-layout support],
	[use_kbd_layout=$enableval],
	[use_kbd_layout=no])
AC_MSG_RESULT($use_kbd_layout)
test $use_kbd_layout != no && AC_DEFINE(EXP_KEYBOARD_LAYOUT)

dnl --------------------------------------------------------------------------
AC_MSG_CHECKING(if experimental nested-table logic should be used)
CF_ARG_ENABLE(nested-tables,
[  --enable-nested-tables  use experimental nested-table support],
	[use_nested_tables=$enableval],
	[use_nested_tables=no])
AC_MSG_RESULT($use_nested_tables)
test $use_nested_tables != no && AC_DEFINE(EXP_NESTED_TABLES)

dnl --------------------------------------------------------------------------
AC_MSG_CHECKING(if progress-bar code should be used)
CF_ARG_ENABLE(progressbar,
[  --enable-progressbar    use experimental progress-bar],
	[use_progressbar=$enableval],
	[use_progressbar=no])
AC_MSG_RESULT($use_progressbar)
test $use_progressbar != no && AC_DEFINE(USE_PROGRESSBAR)

dnl --------------------------------------------------------------------------
AC_MSG_CHECKING(if scrollbar code should be used)
CF_ARG_ENABLE(scrollbar,
[  --enable-scrollbar      use experimental scrollbar, with mouse],
	[use_scrollbar=$enableval],
	[use_scrollbar=no])
AC_MSG_RESULT($use_scrollbar)

dnl --------------------------------------------------------------------------
AC_MSG_CHECKING(if sessions code should be used)
CF_ARG_ENABLE(sessions,
[  --enable-sessions       use experimental sessions code],
	[use_sessions=$enableval],
	[use_sessions=no])
AC_MSG_RESULT($use_sessions)
if test $use_sessions != no ; then
	AC_DEFINE(USE_SESSIONS)
	EXTRA_OBJS="$EXTRA_OBJS LYSession\$o"
fi

dnl --------------------------------------------------------------------------
AC_MSG_CHECKING(if session-caching code should be used)
CF_ARG_ENABLE(session-cache,
[  --enable-session-cache  use experimental session-caching code],
	[use_session_cache=$enableval],
	[use_session_cache=no])
AC_MSG_RESULT($use_session_cache)
if test $use_session_cache != no ; then
    AC_DEFINE(USE_CACHEJAR)
fi

dnl --------------------------------------------------------------------------
dnl Miscellaneous options that don't need to test system features
dnl --------------------------------------------------------------------------

CF_HELP_MESSAGE(
Miscellaneous Options:)

dnl --------------------------------------------------------------------------
AC_MSG_CHECKING(if alternative line-edit bindings should be used)
CF_ARG_ENABLE(alt-bindings,
[  --disable-alt-bindings  disable alternative line-edit bindings],
	[use_alt_bindings=$enableval],
	[use_alt_bindings=yes])
AC_MSG_RESULT($use_alt_bindings)
test $use_alt_bindings != no && AC_DEFINE(EXP_ALT_BINDINGS)

dnl --------------------------------------------------------------------------
AC_MSG_CHECKING(if you want to use extended HTML DTD logic)
CF_ARG_DISABLE(extended-dtd,
[  --disable-extended-dtd  disable extended HTML DTD logic],
	[use_ext_htmldtd=no],
	[use_ext_htmldtd=yes])
AC_MSG_RESULT($use_ext_htmldtd)
test $use_ext_htmldtd = "no" && AC_DEFINE(NO_EXTENDED_HTMLDTD)

dnl --------------------------------------------------------------------------
AC_MSG_CHECKING(if file-upload logic should be used)
CF_ARG_DISABLE(file-upload,
[  --disable-file-upload   use file-upload support],
	[use_file_upload=$enableval],
	[use_file_upload=yes])
AC_MSG_RESULT($use_file_upload)
test $use_file_upload != no && AC_DEFINE(USE_FILE_UPLOAD)

dnl --------------------------------------------------------------------------
AC_MSG_CHECKING(if element-justification logic should be used)
CF_ARG_DISABLE(justify-elts,
[  --disable-justify-elts  use element-justification logic],
	[use_justify_elts=$enableval],
	[use_justify_elts=yes])
AC_MSG_RESULT($use_justify_elts)
test $use_justify_elts != no && AC_DEFINE(EXP_JUSTIFY_ELTS)

dnl --------------------------------------------------------------------------
AC_MSG_CHECKING(if partial-display should be used)
CF_ARG_DISABLE(partial,
[  --disable-partial       use partial-display logic],
	[use_partial_display=$enableval],
	[use_partial_display=yes])
AC_MSG_RESULT($use_partial_display)
test $use_partial_display != no && AC_DEFINE(DISP_PARTIAL)

dnl --------------------------------------------------------------------------
AC_MSG_CHECKING(if persistent-cookie logic should be used)
CF_ARG_DISABLE(persistent-cookies,
[  --disable-persistent-cookies  disable persistent-cookie support],
	[use_filed_cookies=$enableval],
	[use_filed_cookies=yes])
AC_MSG_RESULT($use_filed_cookies)
test $use_filed_cookies != no && AC_DEFINE(USE_PERSISTENT_COOKIES)

dnl --------------------------------------------------------------------------
AC_MSG_CHECKING(if html source should be colorized)
CF_ARG_DISABLE(prettysrc,
[  --disable-prettysrc     colorize HTML source],
	[use_prettysrc=$enableval],
	[use_prettysrc=yes])
AC_MSG_RESULT($use_prettysrc)
test $use_prettysrc != no && AC_DEFINE(USE_PRETTYSRC)

dnl --------------------------------------------------------------------------
AC_MSG_CHECKING(if read-progress message should show ETA)
CF_ARG_DISABLE(read-eta,
[  --disable-read-eta      read-progress message shows ETA],
	[use_read_eta=$enableval],
	[use_read_eta=yes])
AC_MSG_RESULT($use_read_eta)
test $use_read_eta != no && AC_DEFINE(USE_READPROGRESS)

dnl --------------------------------------------------------------------------
AC_MSG_CHECKING(if source caching should be used)
CF_ARG_DISABLE(source-cache,
[  --disable-source-cache  cache HTML source for parse mode changes],
	[use_source_cache=$enableval],
	[use_source_cache=yes])
AC_MSG_RESULT($use_source_cache)
test $use_source_cache != no && AC_DEFINE(USE_SOURCE_CACHE)

dnl --------------------------------------------------------------------------
AC_MSG_CHECKING(if you want to use external commands)
CF_ARG_ENABLE(externs,
[  --enable-externs        use external commands],
	[use_externs=yes],
	[use_externs=no])
AC_MSG_RESULT($use_externs)
if test $use_externs != "no" ; then
	AC_DEFINE(USE_EXTERNALS)
	EXTRA_OBJS="$EXTRA_OBJS LYExtern\$o"
fi

dnl --------------------------------------------------------------------------
AC_MSG_CHECKING(if you want to use setfont support)
CF_ARG_ENABLE(font-switch,
[  --enable-font-switch    use Linux setfont for character-translation],
	[use_setfont=yes],
	[use_setfont=no])
AC_MSG_RESULT($use_setfont)
if test $use_setfont = yes ; then
	case $host_os in
	linux*)
		CF_PATH_PROG(SETFONT, consolechars, setfont)
		;;
	os2*)
		SETFONT=built-in
		CF_VERBOSE(Assume $host_os has font-switching)
		;;
	*)
		SETFONT=unknown
		CF_VERBOSE(Assume $host_os has no font-switching)
		;;
	esac
	if test -z "$SETFONT" ; then
		AC_MSG_WARN(Cannot find a font-setting program)
	elif test "$SETFONT" != unknown ; then
		AC_DEFINE(EXP_CHARTRANS_AUTOSWITCH)
	fi
fi

dnl --------------------------------------------------------------------------
AC_MSG_CHECKING(if you want cgi-link support)
CF_ARG_ENABLE(cgi-links,
[  --enable-cgi-links      support cgi links w/o a http daemon],
	[AC_DEFINE(LYNXCGI_LINKS)])
AC_MSG_RESULT($enableval)

dnl --------------------------------------------------------------------------
AC_MSG_CHECKING(if you want change-exec support)
CF_ARG_ENABLE(change-exec,
[  --enable-change-exec    allow users to change exec options],
	[use_change_exec=yes],
	[use_change_exec=no])
AC_MSG_RESULT($use_change_exec)
test $use_change_exec = yes && AC_DEFINE(ENABLE_OPTS_CHANGE_EXEC)

dnl --------------------------------------------------------------------------
AC_MSG_CHECKING(if you want exec-links support)
CF_ARG_OPTION(exec-links,
[  --enable-exec-links     allow lynx to execute programs accessed via a link],
	[use_exec_links=$enableval],
	[use_exec_links=$enableval],
	[$use_change_exec])
AC_MSG_RESULT($use_exec_links)
test $use_exec_links = yes && AC_DEFINE(EXEC_LINKS)

dnl --------------------------------------------------------------------------
AC_MSG_CHECKING(if you want exec-scripts support)
CF_ARG_OPTION(exec-scripts,
[  --enable-exec-scripts   allow lynx to execute programs inferred from a link],
	[use_exec_scripts=$enableval],
	[use_exec_scripts=$enableval],
	[$use_change_exec])
AC_MSG_RESULT($use_exec_scripts)
test $use_exec_scripts = yes && AC_DEFINE(EXEC_SCRIPTS)

dnl --------------------------------------------------------------------------
AC_MSG_CHECKING(if you want internal-links feature)
CF_ARG_ENABLE(internal-links,
[  --enable-internal-links handle following links to same doc differently],
	[use_internal_links=yes],
	[use_internal_links=no])
AC_MSG_RESULT($use_internal_links)
test $use_internal_links = no && AC_DEFINE(DONT_TRACK_INTERNAL_LINKS)

dnl --------------------------------------------------------------------------
AC_MSG_CHECKING(if you want to fork NSL requests)
CF_ARG_ENABLE(nsl-fork,
[  --enable-nsl-fork       fork NSL requests, allowing them to be aborted],
	[use_nsl_fork=yes],
	[use_nsl_fork=no])
AC_MSG_RESULT($use_nsl_fork)
if test $use_nsl_fork = yes ; then
	case $host_os in
	mingw*)
		AC_DEFINE(_WINDOWS_NSL)
		;;
	*)
		AC_DEFINE(NSL_FORK)
		;;
	esac
fi

dnl --------------------------------------------------------------------------
AC_MSG_CHECKING(if you want to log URL requests via syslog)
CF_ARG_ENABLE(syslog,
[  --enable-syslog         log URL requests via syslog],
	[use_syslog=yes],
	[use_syslog=no])
AC_MSG_RESULT($use_syslog)
test $use_syslog = yes && AC_DEFINE(SYSLOG_REQUESTED_URLS)

dnl --------------------------------------------------------------------------
AC_MSG_CHECKING(if you want to underline links)
CF_ARG_ENABLE(underlines,
[  --enable-underlines     underline links rather than using boldface],
	[use_underline=yes],
	[use_underline=no])
AC_MSG_RESULT($use_underline)
test $use_underline = yes && AC_DEFINE(UNDERLINE_LINKS,1)
test $use_underline = no  && AC_DEFINE(UNDERLINE_LINKS,0)

dnl --------------------------------------------------------------------------
AC_MSG_CHECKING(if help files should be gzip'ed)
CF_ARG_ENABLE(gzip-help,
[  --enable-gzip-help      install gzip'ed help files],
	[use_gzip_help=$enableval],
	[use_gzip_help=no])
AC_MSG_RESULT($use_gzip_help)

dnl --------------------------------------------------------------------------
AC_MSG_CHECKING(if you want to use libbz2 for decompression of some bzip2 files)
AC_ARG_WITH(bzlib,
[  --with-bzlib            use libbz2 for decompression of some bzip2 files],
	[use_bzlib=$withval],
	[use_bzlib=no])
AC_MSG_RESULT($use_bzlib)

if test ".$use_bzlib" != ".no" ; then
	CF_WITH_BZLIB($use_bzlib)
	AC_DEFINE(USE_BZLIB)
fi

dnl --------------------------------------------------------------------------
AC_MSG_CHECKING(if you want to use zlib for decompression of some gzip files)
AC_ARG_WITH(zlib,
[  --with-zlib             use zlib for decompression of some gzip files],
	[use_zlib=$withval],
	[use_zlib=no])
AC_MSG_RESULT($use_zlib)

if test ".$use_zlib" != ".no" ; then
	CF_WITH_ZLIB($use_zlib)
	AC_DEFINE(USE_ZLIB)
fi

dnl --------------------------------------------------------------------------
CF_HELP_MESSAGE(
Other Network Services:)

dnl --------------------------------------------------------------------------
AC_MSG_CHECKING(if you want to exclude FINGER code)
CF_ARG_DISABLE(finger,
[  --disable-finger        disable FINGER logic],
	[use_finger=yes],
	[use_finger=no])
AC_MSG_RESULT($use_finger)
test $use_finger != "no" && AC_DEFINE(DISABLE_FINGER)

dnl --------------------------------------------------------------------------
AC_MSG_CHECKING(if you want to exclude GOPHER code)
CF_ARG_DISABLE(gopher,
[  --disable-gopher        disable GOPHER logic],
	[use_gopher=yes],
	[use_gopher=no])
AC_MSG_RESULT($use_gopher)
test $use_gopher != "no" && AC_DEFINE(DISABLE_GOPHER)

dnl --------------------------------------------------------------------------
AC_MSG_CHECKING(if you want to exclude NEWS code)
CF_ARG_DISABLE(news,
[  --disable-news          disable NEWS logic],
      [use_news=yes],
      [use_news=no])
AC_MSG_RESULT($use_news)
test $use_news != "no" && AC_DEFINE(DISABLE_NEWS)

dnl --------------------------------------------------------------------------
AC_MSG_CHECKING(if you want to exclude FTP code)
CF_ARG_DISABLE(ftp,
[  --disable-ftp           disable FTP logic],
      [use_ftp=yes],
      [use_ftp=no])
AC_MSG_RESULT($use_ftp)
test $use_ftp != "no" && AC_DEFINE(DISABLE_FTP)

dnl --------------------------------------------------------------------------
dnl DirEd (directory-editor) options
dnl --------------------------------------------------------------------------

CF_HELP_MESSAGE(
Directory Editor Options:)

# All DirEd functions that were enabled on compilation can be disabled
# or modified at run time via DIRED_MENU symbols in lynx.cfg.
AC_MSG_CHECKING(if directory-editor code should be used)
CF_ARG_DISABLE(dired,
[  --disable-dired          disable optional directory-editor, DirEd],
	[use_dired=$enableval],
	[use_dired=yes])
AC_MSG_RESULT($use_dired)

if test ".$use_dired" != ".no" ; then
	EXTRA_OBJS="$EXTRA_OBJS LYLocal\$o"
	AC_DEFINE(DIRED_SUPPORT)

	AC_MSG_CHECKING(if you wish to allow extracting from archives via DirEd)
	CF_ARG_DISABLE(dired-dearchive,
	[  --disable-dired-dearchive disable dearchiving commands],[AC_DEFINE(ARCHIVE_ONLY)])
	AC_MSG_RESULT($enableval)

	AC_MSG_CHECKING(if DirEd mode should override keys)
	CF_ARG_DISABLE(dired-override,
	[  --disable-dired-override disable DirEd override keymap],,[AC_DEFINE(OK_OVERRIDE)])
	AC_MSG_RESULT($enableval)

	AC_MSG_CHECKING(if you wish to allow permissions commands via DirEd)
	CF_ARG_DISABLE(dired-permit,
	[  --disable-dired-permit  disable chmod/attrib commands],,[AC_DEFINE(OK_PERMIT)])
	AC_MSG_RESULT($enableval)

	AC_MSG_CHECKING(if you wish to allow executable-permission commands via DirEd)
	CF_ARG_DISABLE(dired-xpermit,
	[  --disable-dired-xpermit disable chmod/attrib commands],[AC_DEFINE(NO_CHANGE_EXECUTE_PERMS)])
	AC_MSG_RESULT($enableval)

	AC_MSG_CHECKING(if you wish to allow "tar" commands from DirEd)
	CF_ARG_DISABLE(dired-tar,
	[  --disable-dired-tar     disable "tar" command],,[AC_DEFINE(OK_TAR)])
	AC_MSG_RESULT($enableval)

	AC_MSG_CHECKING(if you wish to allow "uudecode" commands from DirEd)
	CF_ARG_DISABLE(dired-uudecode,
	[  --disable-dired-uudecode disable "uudecode" command],,[AC_DEFINE(OK_UUDECODE)])
	AC_MSG_RESULT($enableval)

	AC_MSG_CHECKING(if you wish to allow "zip" and "unzip" commands from DirEd)
	CF_ARG_DISABLE(dired-zip,
	[  --disable-dired-zip     disable "zip", "unzip"  commands],,[AC_DEFINE(OK_ZIP)])
	AC_MSG_RESULT($enableval)

	AC_MSG_CHECKING(if you wish to allow "gzip" and "gunzip" commands from DirEd)
	CF_ARG_DISABLE(dired-gzip,
	[  --disable-dired-gzip    disable "gzip", "gunzip" commands],,[AC_DEFINE(OK_GZIP)])
	AC_MSG_RESULT($enableval)
fi

dnl --------------------------------------------------------------------------
AC_MSG_CHECKING(if you want long-directory listings)
CF_ARG_DISABLE(long-list,
[  --disable-long-list     disable long "ls -l" directory listings],,
	[AC_DEFINE(LONG_LIST)])
AC_MSG_RESULT($enableval)

dnl --------------------------------------------------------------------------
AC_MSG_CHECKING(if parent-directory references are permitted)
CF_ARG_DISABLE(parent-dir-refs,
[  --disable-parent-dir-refs
                          disable "Up-to" links in directory listings],
	[AC_DEFINE(NO_PARENT_DIR_REFERENCE)])
AC_MSG_RESULT($enableval)

dnl --------------------------------------------------------------------------
CF_PATH_PROG(TELNET,	telnet)
CF_PATH_PROG(TN3270,	tn3270)
CF_PATH_PROG(RLOGIN,	rlogin)

CF_PATH_PROG(MV,	mv)

CF_PATH_PROG(GZIP,	gzip)
CF_PATH_PROG(UNCOMPRESS,gunzip)
CF_PATH_PROG(UNZIP,	unzip)
CF_PATH_PROG(BZIP2,	bzip2)

CF_PATH_PROG(TAR,	tar, pax gtar gnutar bsdtar star)
CF_TAR_OPTIONS($TAR)
AC_DEFINE_UNQUOTED(TAR_UP_OPTIONS,   "$TAR_UP_OPTIONS")
AC_DEFINE_UNQUOTED(TAR_DOWN_OPTIONS, "$TAR_DOWN_OPTIONS")
AC_DEFINE_UNQUOTED(TAR_FILE_OPTIONS, "$TAR_FILE_OPTIONS")
AC_DEFINE_UNQUOTED(TAR_PIPE_OPTIONS, "$TAR_PIPE_OPTIONS")

dnl --------------------------------------------------------------------------
dnl Test features that rely on configure-definitions
dnl --------------------------------------------------------------------------
if test ".$use_dired" != ".no" ; then

CF_PATH_PROG(COMPRESS,	compress)
CF_PATH_PROG(RM,	rm)
CF_PATH_PROG(UUDECODE,	uudecode)
CF_PATH_PROG(ZCAT,	zcat)
CF_PATH_PROG(ZIP,	zip)

dnl 'INSTALL' is a special case, since the configure script has to find a
dnl BSD-compatible one so the build/install works properly.
case "$INSTALL" in
$srcdir*) # (vi
	AC_DEFINE_UNQUOTED(INSTALL_PATH,"install")
	;;
*) # (vi
	cf_save_INSTALL="$INSTALL"
	CF_PATH_PROG(INSTALL,	install)
	INSTALL="$cf_save_INSTALL"
	;;
esac
fi

COMPRESS_PROG=
COMPRESS_EXT=
if test $use_gzip_help = yes ; then
	COMPRESS_PROG="$ac_cv_path_GZIP -9"
	COMPRESS_EXT=.gz
fi
AC_SUBST(COMPRESS_PROG)
AC_SUBST(COMPRESS_EXT)

if test $cf_cv_screen = pdcurses ; then
	CF_HELP_MESSAGE(Special Libraries for PDCurses X11:)
	CF_PDCURSES_X11
else
	CF_TERMIO_AND_CURSES(LYCurses.h)
fi

### These tests must be run after establishing the curses library.
if test $cf_cv_screen != slang ; then
	AC_CHECK_HEADERS($cf_cv_screen/term.h term.h)
	CF_ALT_CHAR_SET
	CF_FANCY_CURSES
	CF_FUNC_CURSES_VERSION
	CF_NCURSES_BROKEN
	CF_COLOR_CURSES
	CF_SIZECHANGE
	CF_TTYTYPE
	if test "$use_wide_curses" = yes ; then
		CF_WIDEC_CURSES
	fi
	CF_CURSES_FUNCS( \
		assume_default_colors \
		cbreak \
		define_key \
		delscreen \
		getattrs \
		getbegx \
		getbegy \
		keypad \
		napms \
		newpad \
		newterm \
		pnoutrefresh \
		resizeterm \
		touchline \
		touchwin \
		use_default_colors \
		use_legacy_coding \
		wattr_get \
		wborder \
		wredrawln \
		wresize \
		)
	AC_CHECK_FUNCS( \
		_nc_free_and_exit \
		_nc_freeall \
		)
fi

if test $use_color_style != no ; then
	if test .$cf_cv_color_curses != .yes ; then
		AC_ERROR(Configuration does not support color-styles)
	fi
	if test $cf_cv_screen = slang ; then
		AC_ERROR(Configuration does not support color-styles)
	fi
fi

if test $use_scrollbar != no ; then
	if test .$cf_cv_fancy_curses != .yes ; then
		AC_MSG_WARN(Configuration does not support ACS_xxx definitions)
	else
		AC_DEFINE(USE_SCROLLBAR)
	fi
fi

### Finally, build config.h and the makefiles
test -z "$CONFIG_SHELL" && CONFIG_SHELL=/bin/sh
AC_SUBST(CONFIG_SHELL)

CFLAGS="$CFLAGS $EXTRA_CFLAGS"
srcdir="$srcdir"
SRCDIR_CLEAN="#"
if test -n "$srcdir" ; then
	echo srcdir is $srcdir
	$CONFIG_SHELL $MKINSTALLDIRS WWW/Library/Implementation
	$CONFIG_SHELL $MKINSTALLDIRS src/chrtrans
	test "$USE_INCLUDED_LIBINTL" = yes && $CONFIG_SHELL $MKINSTALLDIRS intl
	test "$srcdir" != "." && SRCDIR_CLEAN=""
fi

AC_SUBST(SRCDIR_CLEAN)
AC_OUTPUT(
	[makefile \
	WWW/Library/Implementation/makefile \
	src/makefile \
	src/chrtrans/makefile \
	$SUB_MAKEFILE
	],[
	if test "$USE_NLS" = yes ; then
	if test "$use_our_messages" = yes ; then
		echo creating po/makefile
		rm -f	po/temp$$
		sed	-e 's%^.*LYMessages.c%	../LYMessages.c%' \
			-e '$s/\\//' po/POTFILES >po/temp$$
		sed	-e "/POTFILES =/r po/temp$$" \
			po/makefile.in > po/makefile
		rm -f	po/temp$$
	fi
	fi
	],[
	USE_NLS=$USE_NLS
	use_our_messages=$use_our_messages
	]
)
