dnl Process this file with 'autoconf' to produce a 'configure' script
dnl $Id: configure.in,v 4.24 2021/01/10 12:27:14 tom Exp $
AC_REVISION($Revision: 4.24 $)
AC_PREREQ(2.52.20200802)
AC_INIT(cproto.c)
AC_CONFIG_HEADER(config.h:config_h.in)
CF_CHECK_CACHE

THIS_SHELL=${CONFIG_SHELL-/bin/sh}
AC_SUBST(THIS_SHELL)

CF_PROG_CC

AC_PROG_CPP
CF_CPP_DOES_COMMENTS

AC_PROG_LEX
AC_PROG_MAKE_SET
AC_PROG_YACC
AC_PROG_INSTALL
CF_MAKE_TAGS
CF_PROG_LINT

CF_NEED_PROG(LEX)
CF_NEED_PROG(YACC)

CF_XOPEN_SOURCE
CF_WITHOUT_X

CF_ENABLE_WARNINGS
CF_DISABLE_ECHO

CF_NEED_PROG(LINT,[cf_have_lint=yes],[cf_have_lint=no])

AC_MSG_CHECKING(if you want to enable lint-library (llib) support)
AC_ARG_ENABLE(llib,
[  --enable-llib           enable lint-library (llib) support],
[cf_enable_llib=$enableval],
[cf_enable_llib=$cf_have_lint])

AC_MSG_RESULT($cf_enable_llib);
if test "$cf_enable_llib" = yes ; then
	AC_DEFINE(OPT_LINTLIBRARY)
fi

###	extra things that we'll substitute in the makefile
AC_SUBST(EXTRA_OBJS)

AC_CONST
AC_STDC_HEADERS
AC_HAVE_HEADERS(stdlib.h unistd.h)
AC_HAVE_HEADERS(getopt.h string.h memory.h)

AC_HAVE_FUNCS(getopt popen strstr tmpfile link unlink)

if test "x$ac_cv_func_getopt" = xno
then
	CPPFLAGS="$CPPFLAGS -I\$(srcdir)/porting"
	EXTRA_OBJS="$EXTRA_OBJS getopt.o"
fi

if test "x$ac_cv_func_popen" = xno
then
	CPPFLAGS="$CPPFLAGS -I\$(srcdir)/porting"
	EXTRA_OBJS="$EXTRA_OBJS popen.o"
fi

###	special configuration tests
CF_MKSTEMP
CF_SIZE_T
CF_YACC_ERROR
CF_POPEN_TEST

###	debugging/testing
AC_ARG_WITH(trace,
[  --with-trace            use trace.c for memory-testing],[
	AC_HEADER_TIME
	AC_HAVE_FUNCS(gettimeofday)
	AC_DEFINE(DOALLOC,10000)
	EXTRA_OBJS="$EXTRA_OBJS trace.o dump.o"])
CF_DISABLE_LEAKS
CF_WITH_MAN2HTML

echo setting other definitions
AC_DEFINE_UNQUOTED(CPP,"$CPP")

###	output makefile and config.h
AC_OUTPUT(Makefile,,,cat)
CF_MAKE_DOCS(cproto,1)
