dnl Process this file with autoconf to produce a configure script.
AC_INIT(cpio.h)
PROGS="cpio"
AC_SUBST(PROGS)dnl
AC_PROG_CC
AC_PROG_CPP
AC_PROG_GCC_TRADITIONAL
AC_PROG_INSTALL
AC_AIX
AC_MINIX
AC_ISC_POSIX
AC_TYPE_SIGNAL
AC_HEADER_MAJOR

AC_CHECKING(for remote tape and socket header files)
AC_CHECK_HEADER(sys/mtio.h,
[AC_DEFINE(HAVE_SYS_MTIO_H)
PROGS="$PROGS mt"
AC_TRY_CPP([#include <sgtty.h>
#include <sys/socket.h>], PROGS="$PROGS rmt")])

AC_CHECKING(for remote shell)
if test -f /usr/ucb/rsh || test -f /usr/bin/remsh || test -f /usr/bin/rsh ||
  test -f /usr/bsd/rsh || test -f /usr/bin/nsh; then
  RTAPELIB=rtapelib.o
else
  AC_CHECK_HEADER(netdb.h, AC_DEFINE(HAVE_NETDB_H) RTAPELIB=rtapelib.o,
    AC_DEFINE(NO_REMOTE))
fi
AC_SUBST(RTAPELIB)dnl

AC_C_CONST
AC_TYPE_UID_T
AC_HEADER_STDC
AC_CHECK_HEADERS(unistd.h string.h fcntl.h sys/io/trioctl.h)
AC_REPLACE_FUNCS(bcopy mkdir strdup)

AC_MSG_CHECKING(for utime.h)
AC_TRY_COMPILE([#include <sys/types.h>
#include <utime.h>], [struct utimbuf foo],
  [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_UTIME_H)], [AC_MSG_RESULT(no)])

dnl Checks for fnmatch
have_fnmatch=no
AC_MSG_CHECKING(for working fnmatch)
dnl Some versions of Soalris have a fnmatch() function, but it doesn't work!
dnl So we run a test program.  If we're cross-compiling, do it th old way.
AC_TRY_RUN([
main() {
if (fnmatch ("a*", "abc", 0) == 0) return 0;
else return 1; }],
have_fnmatch=yes, have_fnmatch=no, have_fnmatch=no)
if test $have_fnmatch = yes ; then
  AC_MSG_RESULT(yes)
  FNMATCH=""
else
  AC_MSG_RESULT(no)
  FNMATCH="fnmatch.o"
fi
AC_SUBST(FNMATCH)
AC_CHECK_FUNCS(strerror lchown)
AC_FUNC_VPRINTF
AC_FUNC_ALLOCA
AC_HEADER_DIRENT
AC_CHECK_LIB(nsl, gethostname, [LIBS="$LIBS -lnsl"])
AC_CHECK_LIB(socket, setsockopt, [LIBS="$LIBS -lsocket"])
AC_OUTPUT(Makefile)
