dnl Process this file with autoconf to produce a configure script.
AC_INIT(src/stty.c)
AC_SUBST(PROGS)dnl
AC_SUBST(MAN)dnl
AC_PROG_CC
AC_PROG_CPP
AC_GCC_TRADITIONAL
AC_PROG_INSTALL
AC_PROG_RANLIB
AC_AIX
AC_MINIX
AC_ISC_POSIX
AC_SCO_INTL
AC_FUNC_CHECK(uname, PROGS="$PROGS uname" MAN="$MAN uname.1" have_uname=1)
AC_HEADER_CHECK(limits.h, AC_DEFINE(HAVE_LIMITS_H))
AC_HEADER_CHECK(syslog.h, AC_DEFINE(HAVE_SYSLOG_H))
echo checking for shadow password routines
AC_HEADER_EGREP(sp_pwdp, shadow.h, AC_DEFINE(HAVE_SHADOW_H))
AC_STDC_HEADERS
AC_UNISTD_H
AC_USG
AC_UID_T
AC_SIZE_T
AC_REPLACE_FUNCS(gethostname getusershell mktime stime strcspn strstr strtol strtoul strtod)
AC_HAVE_FUNCS(strerror ftime)

AC_COMPILE_CHECK(setpriority,
[#include <sys/time.h>
#include <sys/resource.h>],
[setpriority(0, 0, 0);],
PROGS="$PROGS nice nohup" MAN="$MAN nice.1 nohup.1")
case "$PROGS" in
*nice*) ;;
*)
AC_COMPILE_CHECK(nice, , nice();, 
AC_DEFINE(NICE_PRIORITY) PROGS="$PROGS nice nohup" MAN="$MAN nice.1 nohup.1") ;;
esac

case "$LIBOBJS" in
*gethostname*) test -n "$have_uname" && AC_DEFINE(HAVE_UNAME)
;;
esac

AC_COMPILE_CHECK(ut_host in struct utmp,
[#include <sys/types.h>
#include <utmp.h>], [struct utmp ut; ut.ut_host;],
AC_DEFINE(HAVE_UT_HOST))

AC_COMPILE_CHECK(POSIX termios,
[#include <sys/types.h>
#include <unistd.h>
#include <termios.h>],
[/* SunOS 4.0.3 has termios.h but not the library calls.  */
tcgetattr(0, 0);], have_termios=1)
if test -n "$have_termios"; then
PROGS="$PROGS stty" MAN="$MAN stty.1"
AC_COMPILE_CHECK(c_line in struct termios,
[#include <sys/types.h>
#include <termios.h>], [struct termios t; t.c_line;], AC_DEFINE(HAVE_C_LINE))

AC_HEADER_CHECK([sys/ptem.h], have_ptem=1 AC_DEFINE(WINSIZE_IN_PTEM))
echo checking for broken window size ioctl
echo "#include <sys/types.h>
#include <termios.h>" > conftest.c
test -n "$have_ptem" && echo "#include <sys/ptem.h>" >> conftest.c
echo "main() {
#ifndef TIOCGWINSZ
exit(0);
#else
struct winsize w;
exit(ioctl(0, TIOCGWINSZ, &w));
#endif
}" >> conftest.c
eval $compile
if test -s conftest && ./conftest 2>/dev/null; then :
else AC_DEFINE(GWINSZ_BROKEN)
fi
rm -f conftest conftest.c
fi

AC_VPRINTF
AC_ALLOCA
AC_STRUCT_TM
AC_TIMEZONE
AC_XENIX_DIR
echo checking for libinet
# Needed on ISC for syslog.
test -f /usr/lib/libinet.a && LIBS="$LIBS -linet"

echo checking for libsec
# Needed on SysV for shadow passwords.
test -f /usr/lib/libsec.a && LIBS="$LIBS -lsec"

AC_OUTPUT(Makefile lib/Makefile src/Makefile man/Makefile)
