# Process this file with autoconf to produce a configure script
AC_INIT(src/auth.c)
AC_CONFIG_HEADER(config.h)

# Make sure they have a fairly recent version
AC_PREREQ(2.10)

AC_CONFIG_AUX_DIR(support)

PACKAGE=server
VERSION=1.0
AC_SUBST(PACKAGE)
AC_SUBST(VERSION)

# Do stuff with OS
AC_CANONICAL_HOST

# Setup some definitions based on the OS
case "$host_os" in
sun*) LDEFS=-DSUN;;
solaris*) LDEFS=-DSUN;;
svr4*) LDEFS=-DSUN;;
sysv*) LDEFS=-DSUN;;
linux*) LDEFS=-DLINUX;;
*bsd*) LDEFS=-DBSD;;
sco*) LDEFS=-DSCO;;
osf*) LDEFS=-DOSF;;
aix*) LDEFS=-DAIX;;
hpux*) LDEFS=-DHPUX;;
dgux*) LDEFS=-DDGUX;;
qnx*) LDEFS=-DQNX;;
next*) LDEFS-DNEXT;;
irix*) LDEFS=-DIRIX;;
*) LDEFS=-DDEFOS;;
esac

AC_SUBST(LDEFS)

bindir=../bin
AC_SUBST(bindir)

AC_ARG_PROGRAM

# Checks for programs.
AC_PROG_CC
AC_PROG_INSTALL
AC_PROG_MAKE_SET
AC_PROG_LN_S

# Checks the systems.
AC_AIX
AC_ISC_POSIX
AC_MINIX

# Checks for libraries.
AC_HAVE_LIBRARY(nsl)
AC_HAVE_LIBRARY(socket)

AC_HAVE_LIBRARY(crypto)
AC_HAVE_LIBRARY(ssl)

# Probably not needed...
# AC_CHECK_LIB(elf, main)

# Checks for header files.
AC_HEADER_STDC
AC_HEADER_TIME
AC_HEADER_SYS_WAIT

AC_SYS_RESTARTABLE_SYSCALLS

AC_CHECK_HEADERS(asm/page.h compat.h db.h fcntl.h features.h getopt.h \
kvm.h limits.h malloc.h memory.h paths.h posix_opt.h sys/select.h     \
sys/shm.h sys/time.h sys/times.h syslog.h unistd.h utime.h)

# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST

AC_STRUCT_TM
AC_STRUCT_TIMEZONE

AC_TYPE_UID_T
AC_TYPE_PID_T
AC_TYPE_SIZE_T

AC_TYPE_SIGNAL

# Checks for library functions.
AC_FUNC_MMAP
AC_FUNC_VPRINTF
AC_FUNC_GETLOADAVG

# AC_SUBST(host_os)

AC_CHECK_FUNCS(getcwd gethostname memcpy mkdir select setreuid shmat \
shmctl shmdt shmget socket strerror strstr)

AC_OUTPUT(Makefile src/Makefile, 
[test -z "$CONFIG_HEADERS" || date > stamp-h])
