dnl Process this file with autoconf to produce a configure script.
dnl This config.in requires autoconf 2.0 or greater.
dnl 
dnl  $Id: configure.in,v 1.8 1994/11/08 20:36:22 ejb Exp $
dnl  $Source: /home/ejb/source/util/RCS/configure.in,v $
dnl  $Author: ejb $
dnl 
AC_INIT(login/ask.c)
AC_REVISION($Revision: 1.8 $)dnl
AC_CONFIG_HEADER(include/config.h)
AC_SUBST(WFLAGS)dnl
AC_PROG_CC
AC_MINIX
AC_HEADER_STDC
dnl some systems have stdarg.h and stdlib.h without other stdc headers
AC_CHECK_HEADERS(stdarg.h stdlib.h unistd.h)
AC_CHECK_HEADERS(string.h memory.h sys/param.h)
AC_HEADER_TIME
AC_CHECK_HEADERS(sys/time.h sys/select.h)
AC_CHECK_HEADERS(termios.h bstring.h)
AC_HEADER_DIRENT
AC_FUNC_VPRINTF
AC_HEADER_STAT
AC_C_CONST
AC_TYPE_SIGNAL
AC_CHECK_FUNCS(getcwd strerror waitpid sigsuspend setenv killpg)
AC_CHECK_FUNCS(sigaddset)

MISSING_DECLARATIONS=0
AC_MSG_CHECKING(for definition of sys_errlist)
AC_CACHE_VAL(qutils_cv_VAR_SYSERRLIST,
[AC_TRY_LINK([], [extern char *sys_errlist[]; char *msg = sys_errlist[0];],
	     qutils_cv_VAR_SYSERRLIST=yes,
	     qutils_cv_VAR_SYSERRLIST=no)])
if test "$qutils_cv_VAR_SYSERRLIST" = "yes"; then
   AC_MSG_RESULT(yes)
   AC_DEFINE(SYS_ERRLIST_DEFINED)
   SYS_ERRLIST_DEFINED=1
else
   AC_MSG_RESULT(no)
   SYS_ERRLIST_DEFINED=0
fi

if test $SYS_ERRLIST_DEFINED -eq 1; then
  AC_MSG_CHECKING(for declaration of sys_errlist in errno.h)
  AC_CACHE_VAL(qutils_cv_DECL_SYSERRLIST,
  [AC_TRY_LINK([#include <errno.h>], [char *msg = sys_errlist[0];],
	       qutils_cv_DECL_SYSERRLIST=yes,
	       qutils_cv_DECL_SYSERRLIST=no)])
  if test "$qutils_cv_DECL_SYSERRLIST" = "yes"; then
     AC_DEFINE(SYS_ERRLIST_DECLARED)
     AC_MSG_RESULT(yes)
  else
     AC_MSG_RESULT(no)
  fi
fi

AC_MSG_CHECKING(for declaration of errno in errno.h)
AC_CACHE_VAL(qutils_cv_DECL_ERRNO,
[AC_TRY_LINK([#include <errno.h>], [int a =  errno;],
	     qutils_cv_DECL_ERRNO=yes,
	     qutils_cv_DECL_ERRNO=no)])
if test "$qutils_cv_DECL_ERRNO" = "yes"; then
   AC_DEFINE(ERRNO_DECLARED)
   AC_MSG_RESULT(yes)
else
   AC_MSG_RESULT(no)
fi

AC_MSG_CHECKING(for declaration of printf)
AC_CACHE_VAL(qutils_cv_DECL_PRINTF,
[AC_TRY_LINK([#include <stdlib.h>
#include <stdio.h>], [void *f = printf;],
	     qutils_cv_DECL_PRINTF=yes,
	     qutils_cv_DECL_PRINTF=no)])
if test "$qutils_cv_DECL_PRINTF" = "yes"; then
   AC_DEFINE(PRINTF_DECLARED)
   AC_MSG_RESULT(yes)
else
   MISSING_DECLARATIONS=1
   AC_MSG_RESULT(no)
fi
if test "$CC" = "gcc" ; then
   if test "$MISSING_DECLARATIONS" -eq "1"; then
      WFLAGS="$WFLAGS -Wall -Wno-implicit"
   else
      WFLAGS="$WFLAGS -Wall"
   fi
fi

AC_MSG_CHECKING(working CRTSCTS)
AC_CACHE_VAL(qutils_cv_VAR_CRTSCTS_working,
[AC_TRY_LINK([#include <termios.h>], [int a = CRTSCTS;],
	     qutils_cv_VAR_CRTSCTS_working=yes,
	     qutils_cv_VAR_CRTSCTS_working=no)])
if test "$qutils_cv_VAR_CRTSCTS_working" = "yes"; then
   AC_DEFINE(WORKING_CRTSCTS)
   AC_MSG_RESULT(yes)
else
   AC_MSG_RESULT(no)
fi

AC_OUTPUT(make/config.mk)
