OpenBSD-4.6/usr.sbin/afs/src/configure.in

dnl Process this file with autoconf to produce a configure script
dnl This requires autoconf 2.13
AC_REVISION($KTH: 1.465.2.78 $)dnl
AC_PREREQ(2.13)
AC_INIT(arlad/arla.c)
AC_CONFIG_HEADER(include/config.h)

dnl
dnl definitions
dnl

PACKAGE=arla
AC_SUBST(PACKAGE)dnl
VERSION=0.35.7
AC_SUBST(VERSION)dnl
AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [what package is this?])dnl
AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [and what version?])dnl

# This may be overridden using --prefix=/usr to configure
AC_PREFIX_DEFAULT(/usr/arla)

CFLAGS="-g ${CFLAGS}"

if test "$AS" = ""; then
  AS=as
fi
AC_SUBST(AS)dnl

AC_PROG_CC
AC_PROG_CC_FLAGS
AC_PROG_CPP
AC_PROG_MAKE_SET
AC_PROG_INSTALL
AC_PROG_RANLIB
AC_PROG_LN_S
AC_PROG_LEX
AC_PROG_YACC
AC_CANONICAL_HOST
CANONICAL_HOST=$host
AC_SUBST(CANONICAL_HOST)
AC_CHECK_PROGS(SYMORDER, symorder, :)
AC_CHECK_PROGS(MAKEINFO, makeinfo, :)
AC_CHECK_PROGS(DVI2PS, dvi2ps, :)
AC_CHECK_PROGS(TEXI2DVI, texi2dvi, :)
AC_CHECK_PROGS(TEXI2PDF, texi2pdf, :)
AC_CHECK_PROGS(TEXI2HTML, texi2html, :)
AC_CHECK_PROGS(DVIPS, dvips, :)
AC_CHECK_PROGS(chmod, chmod, :)
AC_PATH_PROGS(GUILE_GTK, guile-gtk, /bin/false)


dnl 
dnl See if there is any X11 present
dnl
KRB_CHECK_X
if test "$no_x" = "yes" ; then
	MAKE_X_PROGS_BIN=""
else
	MAKE_X_PROGS_BIN='$(X_PROGS_BIN)'
fi
AC_SUBST(MAKE_X_PROGS_BIN)dnl


AC_FUNC_NTOHL

AC_ARG_ENABLE(smp,
[  --enable-smp            compile for SMP (for Linux and FreeBSD)],
[if test "$enableval" = "yes"; then
  smp="-DSMP -D__SMP__"
else
  smp="no"
fi
])


AC_ARG_ENABLE(kld,
[  --enable-kld            build kld modules (only FreeBSD 3.0)],
[if test "$enableval" = "yes"; then
  kld="yes"
else
  kld="no"
fi
])

# what kind of lwp

LWP_PROCESS="process.o"
LWP_C="lwp_asm.c"
LWP_O="lwp_asm.o"
LWP_H="lwp_asm.h"
PLWP_LIB_FLAGS=""
PLWP_INC_FLAGS=""

AC_ARG_WITH(pthreads,
[  --with-pthreads=dir       compile liblwp as pthreads wrapper using pthreads in dir],
[if test "$with_pthreads" = "windows"; then
  with_pthreads=win
elif test "$with_pthreads" != "no"; then
  LWP_PROCESS=""
  LWP_C="plwp.c"
  LWP_O="plwp.o"
  LWP_H="plwp.h"
  PLWP_INC_FLAGS="-DPTHREADS_LWP"
  if test "$with_pthreads" != "yes"; then
    AC_FIND_FUNC_NO_LIBS(pthread_create, pthread,,,[-L${with_pthreads}/lib])
    PLWP_LIB_FLAGS="-L${with_pthreads}/lib $LIB_pthread_create"
    PLWP_INC_FLAGS="-I${with_pthreads}/include -DPTHREADS_LWP"
  else
    AC_FIND_FUNC_NO_LIBS(pthread_create, pthread)
    PLWP_LIB_FLAGS="$LIB_pthread_create"
    PLWP_INC_FLAGS="-DPTHREADS_LWP"
  fi
fi],[with_pthreads=no])

# where the source tree is located

case "$target_os" in
    linux*)
    default_sys=/usr/src/linux
    ;;
    *)
    default_sys=/sys
    ;;
esac
AC_ARG_WITH(sys,
[  --with-sys=dir          use dir as your kernel source code directory
                          default $default_sys],
[SYS=$withval],
[SYS="$default_sys"])
AC_SUBST(SYS)

xfs_target="$target_os"
AC_ARG_ENABLE(xfs,
[  --disable-xfs	   build arla w/o xfs],
[if test "$enableval" = "no" ; then
  xfs_target="without_xfs";
fi])

AC_MSG_CHECKING(for kernel stuff)
case "$xfs_target" in
sunos4.1*) 
  KERNEL_INCLUDE=-I`(cd $srcdir; pwd)`/xfs/sunos
  KERNEL_SRCS='sunos-subr.c'
  KERNEL_HDRS=''
  XFS_SUBDIR=sunos
  KERNEL=/vmunix
  AC_MSG_RESULT(SunOS 4.1.x)
  ;;
solaris*)
  KERNEL_INCLUDE=-I`(cd $srcdir; pwd)`/xfs/solaris
  KERNEL_SRCS='solaris-subr.c'
  KERNEL_HDRS=''
  XFS_SUBDIR=solaris
  KERNEL=/dev/ksyms
  KERNEL_CPPFLAGS="${KERNEL_CPPFLAGS} -D_KERNEL"
  AC_MSG_RESULT(Solaris)
  case "$target_cpu" in
  sparc64) AC_DEFINE(NEED_VICEIOCTL32, 1,
	[define if you need 32 bit compat pioctl])
	   KERNEL_CPPFLAGS="${KERNEL_CPPFLAGS} -D_SYSCALL32 -D_SYSCALL32_IMPL"
           ;;
  esac
  ;;
irix*)
  KERNEL_INCLUDE=-I`(cd $srcdir; pwd)`/xfs/irix
  KERNEL_SRCS='irix-subr.c'
  KERNEL_HDRS=''
  ip=`hinv -c processor | awk '$4 ~ /IP/ { print $4}'`
  cpu=`hinv -t cpu | awk '{print $3}'`
  KERNEL_CPPFLAGS="${KERNEL_CPPFLAGS} -D$ip -D$cpu -DR4000"
  XFS_SUBDIR=irix
  KERNEL=/unix
  case "$target_os" in
changequote(, )dnl
  irix6.[4-9])
changequote([,])dnl
    AC_DEFINE(IRIX_64, 1, [define this if on Irix6.4 or higher]) ;;
  esac
  AC_MSG_RESULT(Irix)
  ;;
hpux*)
  KERNEL_SRCS='hpux-subr.c'
  AC_MSG_RESULT(hp-ux)
  KERNEL=/hp-ux
  KERNEL_INCLUDE=-I`(cd $srcdir; pwd)`/xfs/unknown
  AC_MSG_WARN(No kernel support for $target_os, compiling only user-level stuff)
  ;;
aix*)
  KERNEL_INCLUDE=-I`(cd $srcdir; pwd)`/xfs/aix
  KERNEL_SRCS='aix-subr.c'
  KERNEL_HDRS=''
  XFS_SUBDIR=aix
  AC_MSG_RESULT(AIX)
  ;;  
openbsd*)
  KERNEL_INCLUDE=-I`(cd $srcdir; pwd)`/xfs/bsd
  KERNEL_SRCS='bsd-subr.c'
  KERNEL_HDRS=''
  MODULE=xfs_mod.o
  cat > conftest.mk << END
.include <bsd.lkm.mk>
.if defined(UVM) && (\${UVM} != "no")
CFLAGS+=-DUVM
.endif
.if PMAP_NEW
CFLAGS+=-DPMAP_NEW
.endif
echo:
	@echo \$(CFLAGS)
END
  ac_out=`/usr/bin/make S=$SYS -f conftest.mk echo 2> /dev/null`
  incl=-I$SYS
  defs= flags=
  for i in $ac_out; do
	case "$i" in
		-I*)	if test "$i" != -I. -a "$i" != "-I`pwd`"; then
				incl="$incl${incl:+ }$i"
			fi
			;;
		-D*)	defs="$defs${defs:+ }$i" ;;
		-m*)	flags="$flags${flags:+ }$i" ;;
		*) 	;;
	esac
  done
## -DKERNEL -DLKM -DACTUALLY_LKM_NOT_KERNEL ??
  # make sure we compile with -mno-fp-regs on alpha
  if test `uname -m` = alpha -a `expr "$flags" : ".*-mno-fp-regs"` -eq 0
  then
	flags="$flags${flags:+ }-mno-fp-regs"
  fi
  KERNEL_CPPFLAGS="${KERNEL_CPPFLAGS} -D_LKM"
  KERNEL_CPPFLAGS="${KERNEL_CPPFLAGS} $defs${defs:+ }$flags${flags:+ }$incl"
  test_KERNEL_CFLAGS="${KERNEL_CFLAGS}"
  KERNEL_LD='ld'
  XFS_SRCS='xfs_wrap-bsd.c xfs_common-bsd.c xfs_dev-common.c xfs_dev-bsd.c xfs_syscalls-common.c xfs_syscalls-wrap-bsd.c xfs_node-bsd.c xfs_vfsops-common.c xfs_vfsops-bsd.c xfs_vfsops-openbsd.c xfs_vnodeops-common.c xfs_vnodeops-bsd.c'
  XFS_SUBDIR=bsd
  KERNEL=/bsd
  MODLOAD=modload
  MODUNLOAD=modunload
  AC_MSG_RESULT(OpenBSD)
  ;;
netbsd* | netbsdelf*)
  dnl There is a nasty bug in 1.4.2 that make shared libs
  dnl together with syscall(2) fail with bus error.
  case "$target_os" in
  netbsd1.4.2)
    if test X"$GCC" = Xyes ; then
      CC="$CC -static"
    else
      AC_MSG_WARN([There is a problem with netbsd 1.4.2, you should build it static])
    fi
    ;;
  esac
  KERNEL_INCLUDE=-I`(cd $srcdir; pwd)`/xfs/bsd
  KERNEL_SRCS='bsd-subr.c'
  KERNEL_HDRS=''
  MODULE=xfs_mod.o
  cat > conftest.mk << END
.include <bsd.kmod.mk>
.if UVM
CFLAGS+=-DUVM
.endif
.if PMAP_NEW
CFLAGS+=-DPMAP_NEW
.endif
echo:
	@echo \$(CFLAGS)
END
  ac_out=`/usr/bin/make S=$SYS -f conftest.mk echo 2> /dev/null`
  incl=-I$SYS
  defs= flags=
  for i in $ac_out; do
	case "$i" in
		-I*)	if test "$i" != -I. -a "$i" != "-I`pwd`"; then
				incl="$incl${incl:+ }$i"
			fi
			;;
		-D*)	defs="$defs${defs:+ }$i" ;;
		-m*)	flags="$flags${flags:+ }$i" ;;
		*) 	;;
	esac
  done
## -DKERNEL -DLKM -DACTUALLY_LKM_NOT_KERNEL ??
  # make sure we compile with -mno-fp-regs on alpha
  if test `uname -m` = alpha -a `expr "$flags" : ".*-mno-fp-regs"` -eq 0
  then
	flags="$flags${flags:+ }-mno-fp-regs"
  fi
  KERNEL_CPPFLAGS="${KERNEL_CPPFLAGS} $defs${defs:+ }$flags${flags:+ }$incl"
  test_KERNEL_CFLAGS="${KERNEL_CFLAGS}"
  KERNEL_LD='ld'
  XFS_SRCS='xfs_wrap-bsd.c xfs_common-bsd.c xfs_dev-common.c xfs_dev-bsd.c xfs_syscalls-common.c xfs_syscalls-wrap-bsd.c xfs_node-bsd.c xfs_vfsops-common.c xfs_vfsops-bsd.c xfs_vfsops-netbsd.c xfs_vnodeops-common.c xfs_vnodeops-bsd.c'
  XFS_SUBDIR=bsd
  KERNEL=/netbsd
  MODLOAD=modload
  MODUNLOAD=modunload
  AC_MSG_RESULT(NetBSD)
  ;;
changequote(, )dnl
freebsd[345]* | freebsdelf[345]*)
  AC_MSG_RESULT(FreeBSD [345].x)
changequote([,])dnl
  KERNEL_INCLUDE=-I`(cd $srcdir; pwd)`/xfs/bsd
  KERNEL_SRCS='bsd-subr.c'
  KERNEL_HDRS=''
  KERNEL=`sysctl -n kern.bootfile`
  AC_MSG_CHECKING(for kernel object format)
  kernobjformat=aout
  case `file $KERNEL 2>/dev/null` in
  *ELF*)  kernobjformat=elf ;;
  esac
  AC_MSG_RESULT($kernobjformat)

  AC_MSG_CHECKING(if /kernel and headers match)
  HDRVERSION=`awk '/#define __FreeBSD_version/ { printf("%2.1f\n",$3/100000); }' < $SYS/sys/param.h`
  KERNELVERSION=`uname -r | cut -f1 -d-`

  if test X"${HDRVERSION}" != X"${KERNELVERSION}" ; then
	AC_MSG_ERROR([version mismatch headerfiles $HDRVERSION != kernel $KERNELVERSION])
  fi
  AC_MSG_RESULT(yes)

  AC_MSG_CHECKING(for kld)
  dnl Default to kld if freebsd4.0
  case "$target_os" in
changequote(, )dnl
  	freebsd[45]*)
changequote([,])dnl
	if test "X$kld" = "X"; then
		kld="yes";
	fi
	if test "X$smp" != "Xno" -a "X$smp" != "X"; then
		smp="-DAPIC_IO $smp"
	else
		smp=""
	fi
	;;
  esac
  dnl Or if the kernel is ELF
  case "$kernobjformat" in
	elf*)
	if test "X$kld" = "X"; then
		kld=yes;
	fi
	;;
  esac
  KERNEL_CFLAGS="${KERNEL_CFLAGS}${KERNEL_CFLAGS:+ }-O"
  if test `uname -m` = alpha -a `expr "$KERNEL_CFLAGS" : ".*-mno-fp-regs"` -eq 0
  then
	KERNEL_CFLAGS="${KERNEL_CFLAGS}${KERNEL_CFLAGS:+ }-mno-fp-regs"
  fi
  if test "$kld" = "yes"; then
    KERNEL_CPPFLAGS="${KERNEL_CPPFLAGS} $smp -DKERNEL -D_KERNEL -DVFS_KLD -DKLD_MODULE -I$SYS/arch -I$SYS -I."
    test_KERNEL_CFLAGS="-$kernobjformat ${KERNEL_CFLAGS}"
    KERNEL_LD='ld'
    case "$kernobjformat" in
    aout) extra_LDFLAGS="-A" ;;
    elf)  extra_LDFLAGS="-R" ;;
    *) AC_MSG_ERROR([Unknown object format $kernobjformat])
    esac
    ac_kernel_ld='${LD-ld} -$kernobjformat -o conftest $LDFLAGS $extra_LDFLAGS $KERNEL conftest.o -e _foo 1>&AC_FD_CC'
    MODULE=xfs.ko
    AC_MSG_RESULT(yes)
  else
    if test "$kernobjformat" != "aout"; then
      AC_MSG_WARN([You cannot build LKMs against $kernobjformat kernels])
    fi
    KERNEL_CPPFLAGS="${KERNEL_CPPFLAGS} $smp -DKERNEL -D_KERNEL -DLKM -D_LKM -DVFS_LKM -DACTUALLY_LKM_NOT_KERNEL -I$SYS/arch -I$SYS -I."
    test_KERNEL_CFLAGS="-aout ${KERNEL_CFLAGS}"
    KERNEL_LD='ld -aout'
    ac_kernel_ld='${LD-ld} -aout -o conftest $LDFLAGS -A $KERNEL conftest.o -e _foo 1>&AC_FD_CC'
    MODULE=xfs_mod.o
    AC_MSG_RESULT(no)
  fi

  XFS_SUBDIR=bsd
  XFS_SRCS='xfs_wrap-bsd.c xfs_common-bsd.c xfs_dev-common.c xfs_dev-bsd.c xfs_syscalls-common.c xfs_syscalls-wrap-freebsd.c xfs_node-bsd.c xfs_vfsops-common.c xfs_vfsops-bsd.c xfs_vfsops-freebsd.c xfs_vnodeops-common.c xfs_vnodeops-bsd.c'
  MODLOAD=modload
  MODUNLOAD=modunload

  ;;
macos*|darwin*)
  AC_MSG_RESULT(MacOS)
  KERNEL_INCLUDE=-I`(cd $srcdir; pwd)`/xfs/bsd
  KERNEL_SRCS='bsd-subr.c'
  KERNEL_HDRS=''
  KERNEL=/mach

  ac_cv_func_mmap_fixed_mapped=no		dnl disable mmap for darwin

  KERNEL_CPPFLAGS="${KERNEL_CPPFLAGS} -DKERNEL -D_KERNEL -I/System/Library/Frameworks/Kernel.framework/Headers -static -DKERNEL_PRIVATE -DDIAGNOSTIC -DUSE_SELECT -DMACH_USER_API -traditional-cpp"
  CFLAGS="${CFLAGS} -traditional-cpp"
  LDFLAGS="${LDFLAGS} -flat_namespace"
  KERNEL_CFLAGS="${KERNEL_CFLAGS} -fno-common -Wno-format -pipe -finline -fno-keep-inline-functions -force_cpusubtype_ALL -msoft-float -mlong-branch"
  test_KERNEL_CFLAGS="${KERNEL_CFLAGS}"
  KERNEL_LD='ld'
  MODULE=xfs_mod.o

  MODLOAD=kmodload
  MODUNLOAD=kmodunload

  XFS_SUBDIR=bsd
  XFS_SRCS='xfs_wrap-bsd.c xfs_common-bsd.c xfs_dev-common.c xfs_dev-bsd.c xfs_syscalls-common.c xfs_syscalls-wrap-macos.c xfs_node-bsd.c xfs_vfsops-common.c xfs_vfsops-bsd.c xfs_vfsops-macos.c xfs_vnodeops-common.c xfs_vnodeops-bsd.c xfs_info.c'

  ;;
linux*)
  AC_MSG_RESULT(Linux)
  KERNEL_INCLUDE=-I`(cd $srcdir; pwd)`/xfs/linux
  KERNEL_SRCS='bsd-subr.c'
  KERNEL_HDRS=''
  AC_MSG_CHECKING(for smp)
if test "X$smp" = "Xno"; then
  smp=
elif test "X$smp" = "X"; then
  AC_EGREP_CPP(
changequote(, )dnl
smp_[0-9a-z_]*,dnl
changequote([,])dnl
[#include <linux/config.h>
#ifdef CONFIG_MODVERSIONS
#define MODVERSIONS
#include <linux/modversions.h>
#endif
__ver_get_module_symbol], smp='-D__SMP__', [
changequote(, )dnl
if grep 'smp_[0-9a-zA-Z_]*\>' /proc/ksyms >/dev/null || test `grep -c '^processor' /proc/cpuinfo` -gt 1; then
  smp='-D__SMP__'
fi
changequote([,])dnl
fi
])
  if test "X$smp" = "X"; then
     AC_MSG_RESULT(no)
  else
     AC_MSG_RESULT(yes)
  fi
  KERNEL_CPPFLAGS="-I$SYS/include -DMODULE -D__KERNEL__ $smp ${KERNEL_CPPFLAGS} "
  case "$target_cpu" in
  alpha*)
    KERNEL_CC=${KERNEL_CC:-$CC}
    KERNEL_CFLAGS="${KERNEL_CFLAGS} -mno-fp-regs -ffixed-8" ;;
  sparc64*)
    KERNEL_CFLAGS="${KERNEL_CFLAGS} -mno-fpu -ffixed-g4 -fcall-used-g5 -fcall-used-g7"
    KERNEL_LDFLAGS="-m elf64_sparc"
    KERNEL_CC=${KERNEL_CC:-sparc64-linux-gcc}
    AC_DEFINE(NEED_VICEIOCTL32, 1,
	[define if you need 32 bit compat pioctl]) ;;
   *)
    KERNEL_CC=${KERNEL_CC:-$CC} ;;
  esac
  test_KERNEL_CFLAGS="${KERNEL_CFLAGS}"
  XFS_SUBDIR=linux
  KERNEL=/dev/null
  ;;
osf*)
  KERNEL_INCLUDE=-I`(cd $srcdir; pwd)`/xfs/bsd
  KERNEL_SRCS=bsd-subr.c
  KERNEL_HDRS=
  KERNEL_CPPFLAGS="${KERNEL_CPPFLAGS} -DKERNEL -D_KERNEL -DMACH"
  XFS_SRCS='xfs_wrap-osf.c xfs_common-osf.c xfs_dev-common.c xfs_dev-osf.c xfs_syscalls-common.c xfs_syscalls-wrap-osf.c xfs_node-osf.c xfs_vfsops-common.c xfs_vfsops-osf.c xfs_vnodeops-common.c xfs_vnodeops-osf.c'
  # XXX find kernel include dir
  nodename=`hostname | sed 's/\..*//' | tr 'a-z' 'A-Z'`
  foo=`ls $SYS/inet.h $SYS/GENERIC/inet.h $SYS/$nodename/inet.h $SYS/*/inet.h 2> /dev/null | head -1 | sed -e 's,/inet.h,,'`
  KERNEL_CPPFLAGS="${KERNEL_CPPFLAGS} -I/usr/sys/include -I$foo"
  test_KERNEL_CFLAGS="-w2 ${KERNEL_CFLAGS}"
  KERNEL_LD='ld'
  KERNEL_CC="cc -std0"
  XFS_SUBDIR=bsd
  AC_MSG_RESULT(osf/1)
  KERNEL=/vmunix
  case "$CC" in
  cc)
	CC="$CC -std1"
	;;
  esac
  MODLOAD=modload
  MODUNLOAD=modunload
  ;;
cygwin*)
  AC_MSG_RESULT(cygwin/VC)
  AC_MSG_WARN([Only kernel support for NT])
  if test "$with_pthreads" = "windows"; then
    AC_MSG_WARN([Using LWP on windows native threads])
    LWP_PROCESS=""
    LWP_C="plwp.c"
    LWP_O="plwp.o"
    LWP_H="plwp.h"
    PLWP_INC_FLAGS="-DWINDOWS_THREADS_LWP"
  else
    AC_MSG_WARN([Using LWP on asm threads or pthreads])
  fi
  KERNEL_INCLUDE=-I`(cd $srcdir; pwd)`/xfs/unknown
  KERNEL_SRCS=unknown-subr.c
  KERNEL_HDRS=
  KERNEL=/dev/null
  XFS_SUBDIR=
  ;;
*)
  AC_MSG_RESULT(none)
  if test "$xfs_target" != "without_xfs"; then
    AC_MSG_WARN([No kernel support for $target_os, compiling only user-level stuff])
  fi
  KERNEL_INCLUDE=-I`(cd $srcdir; pwd)`/xfs/unknown
  KERNEL_SRCS=unknown-subr.c
  KERNEL_HDRS=
  KERNEL=/dev/null
  XFS_SUBDIR=
  ;;
esac
if test "$XFS_SUBDIR" != ""; then
  XFS_SUBDIR_Makefile=xfs/$XFS_SUBDIR/Makefile
  XFS_SUBDIR_BIN_Makefile=xfs/$XFS_SUBDIR/bin/Makefile
fi

AM_CONDITIONAL(OSF1, test "`uname`" = OSF1)dnl

# Check where to put the cache

AC_ARG_WITH(arlacachedir,
[  --with-arlacachedir=dir use dir as cachedir instead of \$prefix/cache],
[ARLACACHEDIR=$withval],
[ARLACACHEDIR='${prefix}/cache'])

# Check where to find the configuration

AC_ARG_WITH(arlaconffile,
[  --with-arlaconffile=file use file for configuration instead of \$prefix/etc/arla.conf],
[ARLACONFFILE=$withval],
[ARLACONFFILE='${sysconfdir}/arla.conf'])

# Do we want knfs ?

ARLA_KNFS=""
AC_ARG_ENABLE(knfs,
[  --enable-knfs           make afs nfs-mountable],
[ARLA_KNFS="-DARLA_KNFS"])
AC_SUBST(ARLA_KNFS)

dnl
dnl
dnl

AC_CHECK_ROKEN

dnl
dnl If we want to use pthreads
dnl

AC_SUBST(LWP_PROCESS)
AC_SUBST(PLWP_LIB_FLAGS)
AC_SUBST(PLWP_INC_FLAGS)
AC_SUBST(LWP_C)
AC_SUBST(LWP_O)
AC_SUBST(LWP_H)

AC_CHECK_KERBEROS(45auto)
AC_CHECK_KAFS

if test "X$ac_cv_found_krb4" = "Xyes"; then
  RXKAD="rxkad"
  RXKAD_MAKEFILE="rxkad/Makefile"
  RXKAD_LIBS="-L../rxkad -lrxkad $KRB4_LIB_FLAGS"
  MILKO_RXKAD_LIBS=`echo $RXKAD_LIBS | sed s,\.\./,\.\./\.\./,`
  MILKO_RXKAD_LIBS2=`echo $MILKO_RXKAD_LIBS | sed s,\.\./,\.\./\.\./,`
  APPL_SUBDIRS='afsutils amon fs'
else
  APPL_SUBDIRS=
fi

#
# check for tf_util
#

AC_FIND_FUNC_NO_LIBS2(tf_init, "", , , [$KRB4_LIB_FLAGS])

if test "$ac_cv_func_tf_init" = yes; then
	APPL_SUBDIRS="$APPL_SUBDIRS kalog"
fi


AC_SUBST(APPL_SUBDIRS)dnl

AC_TYPE_MSGHDR
AC_TYPE_IOVEC
AC_TYPE_KRB_PRINCIPAL
AC_FUNC_KRB_GET_ERR_TEXT
AC_FUNC_KRB_GET_DEFAULT_TKT_ROOT
AC_FUNC_KRB_GET_DEFAULT_PRINCIPAL
AC_FUNC_KRB_KDCTIMEOFDAY

dnl AC_TYPE_MODE_T
dnl AC_CHECK_TYPE(nlink_t, int)

dnl
dnl Tests for readline/editline
dnl

AC_TEST_PACKAGE_NEW(readline,[
#include <stdio.h>
#include <readline.h>
],-lreadline)

if test "$with_readline" = "no"; then
	AC_FIND_FUNC_NO_LIBS(tgetent, termcap ncurses curses)
	if test "$ac_cv_funclib_tgetent" = "no"; then
		AC_MSG_ERROR([Could not find tgetent, needed by edit/editline])
	fi
	AC_FIND_FUNC_NO_LIBS(readline, editline edit readline, [], [], [$LIB_tgetent])
	if test "$ac_cv_func_readline" = "no"; then
		AC_FIND_FUNC_NO_LIBS(el_init, edit, [], [], [$LIB_tgetent])
		if test "$ac_cv_func_el_init" = yes; then
			editline_OBJS=edit_compat.o
			LIB_readline='-L'`pwd`'/lib/editline -leditline '"$LIB_el_init";
			INCLUDE_readline='-I'`pwd`'/lib/editline -I$(top_srcdir)/lib/editline'
		else
			editline_OBJS="editline.o complete.o sysunix.o"
			LIB_readline='-L'`pwd`'/lib/editline -leditline'
			INCLUDE_readline='-I'`pwd`'/lib/editline -I$(top_srcdir)/lib/editline'
		fi
	fi
fi
AC_DEFINE(HAVE_READLINE, 1, [define if you have a function readline])dnl
LIB_readline="$LIB_readline \$(LIB_tgetent)"

AC_ARG_ENABLE(mmap,
[  --disable-mmap          don't use mmap],
[if test "$enableval" = "no"; then
  ac_cv_func_mmap_fixed_mapped=no
 fi])

AC_ARG_ENABLE(mmaptime, 
[  --enable-mmaptime       use mmaptime time, read the README before use (disable by default)],
[if test "$enableval" = "yes" -o "X$enableval" = "X"; then
  AC_DEFINE(USE_MMAPTIME, 1, [define if you want to use mmaptime])
fi])

aix_dynamic_afs=yes
AC_ARG_ENABLE(dynamic-afs,
[  --disable-dynamic-afs   don't use loaded AFS library with AIX],[
if test "$enableval" = "no"; then
	aix_dynamic_afs=no
fi
])

AC_CHECK_LFS
AC_CHECK_GLIBC

AC_SUBST(LIB_readline)
AC_SUBST(INCLUDE_readline)
AC_SUBST(editline_OBJS)dnl
if test "$editline_OBJS" != ""; then
  editline_dir=editline
fi
AC_SUBST(editline_dir)

AC_SUBST(GCC)
AC_SUBST(CFLAGS)
AC_SUBST(LDFLAGS)
AC_SUBST(KERNEL_INCLUDE)
AC_SUBST(KERNEL_SRCS)
AC_SUBST(KERNEL_HDRS)
AC_SUBST(KERNEL_CPPFLAGS)
AC_SUBST(KERNEL_CFLAGS)
AC_SUBST(KERNEL_LDFLAGS)
AC_SUBST(KERNEL_CC)
AC_SUBST(KERNEL_LD)
AC_SUBST(MODLOAD)
AC_SUBST(MODUNLOAD)
AC_SUBST(MODULE)
AC_SUBST(XFS_SUBDIR)
AC_SUBST(XFS_SRCS)
AC_SUBST(RXKAD)
AC_SUBST(MILKO_RXKAD_LIBS)
AC_SUBST(MILKO_RXKAD_LIBS2)
AC_SUBST(RXKAD_LIBS)
AC_SUBST(ARLACACHEDIR)
AC_SUBST(ARLACONFFILE)
AC_FUNC_MMAP

dnl
dnl Various checks for headers and their contents
dnl

AC_HEADER_STDC
AC_HEADER_TIME

AC_CHECK_HEADERS([				\
		arpa/inet.h			\
		arpa/nameser.h			\
		crypt.h				\
		dbm.h				\
		dirent.h			\
		errno.h				\
		fcntl.h				\
		grp.h				\
		inttypes.h			\
		kvm.h				\
		libelf/nlist.h			\
		machine/alpha/asm.h		\
		machine/asm.h			\
		machine/endian.h		\
		machine/regdef.h		\
		miscfs/genfs/genfs.h		\
		ndbm.h				\
		netdb.h				\
		netinet/in.h			\
		netinet/in6.h			\
		netinet/in6_machtypes.h		\
		netinet6/in6.h			\
		nlist.h				\
		paths.h				\
		pwd.h				\
		regdef.h			\
		resolv.h			\
		rpcsvc/dbm.h			\
		shadow.h			\
		sys/attr.h			\
		sys/bitypes.h			\
		sys/cdefs.h			\
		sys/dir.h			\
		sys/filedesc.h			\
		sys/ioccom.h			\
		sys/ioctl.h			\
		sys/libkern.h			\
		sys/lkm.h			\
		sys/mman.h			\
		sys/module.h			\
		sys/mount.h			\
		sys/param.h			\
		sys/poll.h			\
		sys/prctl.h			\
		sys/proc.h			\
		sys/queue.h			\
		sys/resource.h			\
		sys/select.h			\
		sys/signalvar.h			\
		sys/socket.h			\
		sys/sockio.h			\
		sys/stat.h			\
		sys/syscallargs.h		\
		sys/sysconfig.h			\
		sys/sysctl.h			\
		sys/sysent.h			\
		sys/sysproto.h			\
		sys/systm.h			\
		sys/time.h			\
		sys/tty.h			\
		sys/types.h			\
		sys/ubc.h			\
		sys/uio.h			\
		sys/user.h			\
		sys/utsname.h			\
		sys/vfs.h			\
		sys/vfs_proto.h			\
		sys/vnode.h			\
		sys/wait.h			\
		syslog.h			\
		termios.h			\
		unistd.h			\
		uvm/uvm_extern.h		\
		vm/vm.h				\
		vm/vm_extern.h			\
		vm/vm_object.h			\
		vm/vm_pager.h			\
		vm/vm_zone.h			\
		vm/vnode_pager.h		\
])

dnl
dnl Check for endian-ness
dnl
KRB_C_BIGENDIAN

dnl
dnl check for const
dnl

AC_C_CONST

dnl
dnl Check for inline
dnl

AC_C_INLINE

dnl
dnl Check for __FUNCTION__
dnl

AC_C___FUNCTION__

dnl
dnl Check for __attribute__
dnl

AC_C___ATTRIBUTE__

dnl
dnl Look for berkeley db, gdbm, and ndbm in that order.
dnl

KRB_FIND_DB("" $berkeley_db gdbm ndbm)

dnl
dnl Check for strange operating systems that you need to handle differently
dnl

AC_KRB_SYS_NEXTSTEP
AC_KRB_SYS_AIX

if test "$krb_cv_sys_aix" = yes ;then
	if test "$aix_dynamic_afs" = yes; then
		AFS_EXTRA_OBJS='$(srcdir)/afsl.exp dlfcn.o'
		AFS_EXTRA_LIBS=afslib.so
		# this works differently in AIX <=3 and 4
		if test `uname -v` = 4 ; then
			AFS_EXTRA_LD="-bnoentry"
		else
			AFS_EXTRA_LD="-e _nostart"
		fi
		AFS_EXTRA_DEFS=
		AIX_EXTRA_KAFS="-lld"
	else
		AFS_EXTRA_OBJS='$(srcdir)/afsl.exp afslib.o'
		AFS_EXTRA_LIBS=
		AFS_EXTRA_DEFS='-DSTATIC_AFS_SYSCALLS'
		AIX_EXTRA_KAFS=
	fi
	AC_SUBST(AFS_EXTRA_OBJS)dnl
	AC_SUBST(AFS_EXTRA_LIBS)dnl
	AC_SUBST(AFS_EXTRA_LD)dnl
	AC_SUBST(AFS_EXTRA_DEFS)dnl
	AC_SUBST(AIX_EXTRA_KAFS)dnl
fi

dnl
dnl Check for struct winsize
dnl

AC_KRB_STRUCT_WINSIZE
 
dnl
dnl Various checks for libraries and their contents
dnl

AC_FIND_FUNC(syslog, syslog)

dnl
dnl System V is have misplaced the socket routines, should really be in libc
dnl

AC_FIND_FUNC(socket, socket)
AC_FIND_FUNC(gethostbyname, nsl)
AC_FIND_FUNC(gethostbyname2, inet6 ip6)

dnl we don't actually use v6 functions in this code, but some generic
dnl functions such as getnameinfo et al can reside in libraries that are
dnl found by this macro

AC_KRB_IPV6

AC_FIND_FUNC(res_search, resolv,
[
#include <stdio.h>
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#ifdef HAVE_ARPA_NAMESER_H
#include <arpa/nameser.h>
#endif
#ifdef HAVE_RESOLV_H
#include <resolv.h>
#endif
],
[0,0,0,0,0])

AC_FIND_FUNC(res_init, resolv,
[
#include <stdio.h>
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#ifdef HAVE_ARPA_NAMESER_H
#include <arpa/nameser.h>
#endif
#ifdef HAVE_RESOLV_H
#include <resolv.h>
#endif
],
[])

AC_FIND_FUNC(dn_expand, resolv,
[
#include <stdio.h>
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#ifdef HAVE_ARPA_NAMESER_H
#include <arpa/nameser.h>
#endif
#ifdef HAVE_RESOLV_H
#include <resolv.h>
#endif
],
[0,0,0,0,0])

AC_BROKEN_SNPRINTF

AC_CHECK_FUNCS(asnprintf asprintf vasprintf vasnprintf vsnprintf)

AC_CHECK_FUNCS(thr_yield)

AC_EGREP_HEADER(sigaction, signal.h,
	AC_DEFINE(HAVE_POSIX_SIGNALS, 1, [define if you have sigaction]))

save_CPPFLAGS="${CPPFLAGS}"
if test "$KRB4_INC_DIR"; then
  CPPFLAGS="-I${KRB4_INC_DIR} $CPPFLAGS"
fi
AC_HAVE_TYPES(int8_t int16_t int32_t int64_t)
AC_HAVE_TYPES(int16 int32)
AC_HAVE_TYPES(u_int8_t u_int16_t u_int32_t u_int64_t)
AC_HAVE_TYPES(u_int16 u_int32)
AC_HAVE_TYPES(bool ssize_t)
AC_HAVE_TYPES(register_t)
AC_HAVE_TYPES(intptr_t)
AC_HAVE_TYPES(off64_t)
AC_CHECK_HEADERS(ktypes.h com_err.h et/com_err.h)
CPPFLAGS="${save_CPPFLAGS}"

AC_TYPE_SIGNAL

dnl
dnl check for old libkafs
dnl

AC_FIND_FUNC_NO_LIBS2(krb_afslog_uid, "", , , [$KAFS_LIBS $KRB4_LIB_FLAGS])

#
# libroken
#

AC_FUNC_GETLOGIN

AC_FIND_IF_NOT_BROKEN(hstrerror, resolv,
[#ifdef HAVE_NETDB_H
#include <netdb.h>
#endif],
17)
AC_NEED_PROTO([
#ifdef HAVE_NETDB_H
#include <netdb.h>
#endif],
hstrerror)
AC_FUNC_HSTRERROR_CONST

AC_BROKEN(chown daemon err errx fchown flock getcwd getdtablesize getopt)
AC_BROKEN(getusershell initgroups lstat localtime_r memmove mkstemp)
AC_BROKEN(putenv rcmd readv recvmsg sendmsg setegid setenv seteuid)
AC_BROKEN(strcasecmp strdup strerror strftime strlcat strlcpy strlwr)
AC_BROKEN(strnlen strsep strsep_copy strptime strtok_r strupr unsetenv)
AC_BROKEN(verr verrx vsyslog vwarn vwarnx warn warnx writev)

AC_BROKEN(getipnodebyname getipnodebyaddr freehostent copyhostent)
AC_BROKEN(gai_strerror freeaddrinfo getaddrinfo getnameinfo)
AC_BROKEN(inet_aton inet_ntop inet_pton)


if test "$ac_cv_func_inet_aton" = "yes"; then
AC_NEED_PROTO([
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#ifdef HAVE_ARPA_INET_H
#include <arpa/inet.h>
#endif],
inet_aton)
fi

AC_CHECK_FUNCS(fcntl getrlimit getrusage getspnam getspuid mktime setregid)
AC_CHECK_FUNCS(setresuid setreuid setsid setsockopt sysconf sysctl)

AC_CHECK_FUNCS(get_progname set_progname warnerr)

AC_CHECK_FUNCS(getitimer)

AC_CHECK_FUNCS(getfh fhopen)

AC_CHECK_VAR([#include <stdlib.h>], optreset)dnl
if test "$ac_cv_var_optreset" = yes; then
	AC_CHECK_DECLARATION([#include <stdlib.h>], optreset)dnl
fi

dnl
dnl Test if hstrerror needs const (like on SunOS 5.6)
dnl

dnl XXX - AC_HSTRERROR_CONST

dnl
dnl Test if we can mmap time, speed hack
dnl

AC_FIND_FUNC(kvm_open, kvm)
AC_FIND_FUNC(kvm_nlist, kvm)
#AC_MMAP_TIME($with_mmap_time)

dnl
dnl prototypes
dnl

AC_NEED_PROTO([
#include <string.h>
],
strtok_r)

AC_NEED_PROTO([
#include <sys/types.h> 
#include <sys/time.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
], 
select)

AC_DIRENT_SYS_DIR_H

AC_HAVE_STRUCT_FIELD(struct dirent, d_type,
[#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#include <dirent.h>
])

dnl
dnl Check for sa_len in sys/socket.h
dnl

AC_HAVE_STRUCT_FIELD(struct sockaddr,
sa_len,
[#include <sys/types.h>
#include <sys/socket.h>])

dnl
dnl Check for sin_len
dnl

AC_HAVE_STRUCT_FIELD(struct sockaddr_in,
sin_len,
[#include <sys/types.h>
#include <sys/socket.h>
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif])

AC_HAVE_TYPE([sa_family_t],[#include <sys/socket.h>])
AC_HAVE_TYPE([socklen_t],[#include <sys/socket.h>])
AC_HAVE_TYPE([struct sockaddr], [#include <sys/socket.h>])
AC_HAVE_TYPE([struct sockaddr_storage], [#include <sys/socket.h>])
AC_HAVE_TYPE([struct addrinfo], [#include <netdb.h>])

dnl
dnl variable checks
dnl

AC_CHECK_VAR([#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_NETDB_H
#include <netdb.h>
#endif],
h_errno)

AC_CHECK_VAR([#ifdef HAVE_NETDB_H
#include <netdb.h>
#endif],
h_errlist)

AC_CHECK_VAR([#ifdef HAVE_NETDB_H
#include <netdb.h>
#endif],
h_nerr)

dnl
dnl check for strange as stuff on solaris
dnl

case "$target_os" in
solaris*)
  AC_CACHE_CHECK(if as supports .register, ac_cv_prog_as_register,[
  cat > conftest.s <<EOF
	.register	%g2, #scratch
	.register	%g3, #scratch
	.register	%g6, #scratch
	.register	%g7, #scratch
EOF
  if $AS conftest.s >/dev/null 2>&1; then
    ac_cv_prog_as_register=yes
  else
    ac_cv_prog_as_register=no
  fi
  rm -f conftest.s a.out
])
  if test "$ac_cv_prog_as_register" = "yes"; then
    AC_DEFINE(AS_UNDERSTANDS_REGISTER, 1,
	[define this if your as understands .register])
  fi
esac

dnl
dnl kernel checks
dnl

dnl
dnl bsd style
dnl

if test "$XFS_SUBDIR" = "bsd"; then


AC_ELF_OBJECT_FORMAT
AC_KERNEL

AC_CHECK_KERNEL_FUNCS(				\
cdevsw_add					\
debuglockmgr					\
lockmgr						\
make_dev					\
vop_revoke					\
genfs_revoke					\
vfs_opv_init					\
vfs_opv_init_default				\
vfs_opv_init_explicit				\
vfs_add_vnodeops				\
vfs_attach					\
vfs_deallocate_syncvnode			\
vfs_register					\
vfs_getvfs					\
vgonel						\
zfreei						\
vfs_cache_lookup				\
vnode_pager_generic_putpages			\
vnode_pager_generic_getpages			\
vnode_pager_setsize				\
devtoname					\
udev2dev					\
snprintf					\
nosys						\
sys_nosys					\
sys_lkmnosys					\
cache_purgevfs					\
vfs_name_hash					\
)
AC_CHECK_KERNEL_FUNC(memcpy, [0,0,0])

AC_BSD_HEADER_VNODE_IF_H

AC_KERNEL_NEED_PROTO([
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#ifdef HAVE_SYS_PROC_H
#include <sys/proc.h>
#endif
#ifdef HAVE_SYS_VNODE_H
#include <sys/vnode.h>
#endif
],
vgonel)

AC_KERNEL_NEED_PROTO([
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#ifdef HAVE_SYS_PROC_H
#include <sys/proc.h>
#endif
#include <sys/signal.h>
#include <sys/signalvar.h>
],
issignal)

AC_KERNEL_NEED_PROTO([
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#ifdef HAVE_SYS_PROC_H
#include <sys/proc.h>
#endif
#ifdef HAVE_SYS_VNODE_H
#include <sys/vnode.h>
#endif
#ifdef HAVE_SYS_VFS_PROTO_H
#include <sys/vfs_proto.h>
#endif
],
vn_writechk)

AC_KERNEL_NEED_PROTO([
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#ifdef HAVE_SYS_PROC_H
#include <sys/proc.h>
#endif
#ifdef HAVE_SYS_VNODE_H
#include <sys/vnode.h>
#endif
#ifdef HAVE_SYS_UBC_H
#include <sys/ubc.h>
#endif
],
ubc_pushdirty)

AC_KERNEL_NEED_PROTO([
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#ifdef HAVE_SYS_LIBKERN_H
#include <sys/libkern.h>
#endif
#ifdef HAVE_SYS_SYSTM_H
#include <sys/systm.h>
#endif
],
strncmp)

AC_CHECK_KERNEL_VAR(doforce, int)
AC_CHECK_KERNEL_VAR(aout_sysent, struct sysent*,[#include <sys/systm.h>])
AC_CHECK_KERNEL_VOP_T
AC_BSD_FUNC_VFS_OBJECT_CREATE
AC_BSD_FUNC_VOP_LOCK
AC_BSD_FUNC_VFS_BUSY
AC_BSD_FUNC_VGET
AC_BSD_FUNC_SUSER
AC_BSD_FUNC_VFS_GETNEWFSID
AC_BSD_FUNC_LOCKMGR
AC_BSD_FUNC_LOCKSTATUS
AC_BSD_FUNC_SELRECORD
case "$target_os" in
osf*)
AC_OSF_FUNC_UBC_LOOKUP 
AC_OSF_FUNC_VFS_NAME_HASH
;;
esac

AC_CHECK_DIRSIZ

dnl
dnl Find out if have have proc.p_sigmask
dnl

AC_HAVE_STRUCT_FIELD(
struct proc,
p_sigmask,
[#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#ifdef HAVE_SYS_PROC_H
#include <sys/proc.h>
#endif])

AC_HAVE_STRUCT_FIELD(
struct proc,
p_sigctx,
[#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#ifdef HAVE_SYS_PROC_H
#include <sys/proc.h>
#endif])

AC_HAVE_KERNEL_STRUCT_FIELD([
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#ifdef HAVE_SYS_PROC_H
#include <sys/proc.h>
#endif
#ifdef HAVE_SYS_VNODE_H
#include <sys/vnode.h>
#endif
#ifdef HAVE_SYS_MOUNT_H
#include <sys/mount.h>
#endif
],
mount,
struct vnode *,
mnt_syncer)

dnl FreeBSD 4.5 and above changed mnt_vnodelist to mnt_nvnodelist

AC_HAVE_KERNEL_STRUCT_FIELD([
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#ifdef HAVE_SYS_PROC_H
#include <sys/proc.h>
#endif
#ifdef HAVE_SYS_VNODE_H
#include <sys/vnode.h>
#endif
#ifdef HAVE_SYS_MOUNT_H
#include <sys/mount.h>
#endif
],
mount,
struct vnodelst,
mnt_nvnodelist)

AC_HAVE_KERNEL_STRUCT_FIELD([
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#ifdef HAVE_SYS_PROC_H
#include <sys/proc.h>
#endif
#ifdef HAVE_SYS_VNODE_H
#include <sys/vnode.h>
#endif
#ifdef HAVE_SYS_MOUNT_H
#include <sys/mount.h>
#endif
],
mount,
qaddr_t,
m_info)

AC_HAVE_KERNEL_STRUCT_FIELD([
#include <sys/types.h>
#include <sys/param.h>
#include <sys/mount.h>
],
vfsconf,
int,
vfc_refcount)

AC_HAVE_KERNEL_STRUCT_FIELD([
#include <sys/types.h>
#include <sys/param.h>
#include <sys/mount.h>
],
vfsconf,
int (*)(void),
vfc_mountroot)

AC_HAVE_KERNEL_STRUCT_FIELD([
#include <sys/types.h>
#ifdef HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
#endif
#include <sys/uio.h>
],
uio,
struct proc *,
uio_procp)

AC_HAVE_KERNEL_STRUCT_FIELD([
#include <sys/types.h>
#include <sys/param.h>
#include <sys/mount.h>
],
vfsops,
struct vnodeopv_desc **,
vfs_opv_descs)

AC_HAVE_KERNEL_STRUCT_FIELD([
#include <sys/types.h>
#include <sys/param.h>
#include <sys/mount.h>
],
vfsops,
char *,
vfs_name)

AC_HAVE_KERNEL_STRUCT_FIELD([
#include <sys/types.h>
#include <sys/param.h>
#include <sys/mount.h>
],
vfsops,
void *,
vfs_uninit)

AC_HAVE_KERNEL_STRUCT_FIELD([
#include <sys/types.h>
#include <sys/param.h>
#include <sys/mount.h>
],
vfsops,
void *,
vfs_reinit)

AC_HAVE_KERNEL_STRUCT_FIELD([
#include <sys/types.h>
#include <sys/param.h>
#include <sys/mount.h>
],
vfsops,
struct sysctl_oid *,
vfs_oid)

AC_HAVE_KERNEL_STRUCT_FIELD([
#include <sys/types.h>
#include <sys/param.h>
#include <sys/mount.h>
],
vfsops,
int,
vfs_done)

AC_HAVE_KERNEL_STRUCT_FIELD([
#include <sys/types.h>
#include <sys/param.h>
#include <sys/mount.h>
],
vfsops,
void *,
vfs_checkexp)

AC_HAVE_KERNEL_STRUCT_FIELD([
#include <sys/types.h>
#include <sys/param.h>
#include <sys/mount.h>
],
vfsops,
void *,
vfs_mountroot)

AC_HAVE_KERNEL_STRUCT_FIELD([
#include <sys/types.h>
#include <sys/param.h>
#include <sys/mount.h>
],
vfsops,
void *,
vfs_swapvp)

AC_HAVE_KERNEL_STRUCT_FIELD([
#include <sys/types.h>
#include <sys/param.h>
#include <sys/mount.h>
],
vfsops,
void *,
vfs_smoothsync)

AC_HAVE_KERNEL_STRUCT_FIELD([
#include <sys/types.h>
#include <sys/systm.h>
],
sysent,
int,
sy_flags)

AC_HAVE_KERNEL_STRUCT_FIELD([
#include <sys/types.h>
#include <sys/systm.h>
],
sysent,
unsigned char,
sy_info)

AC_HAVE_KERNEL_STRUCT_FIELD([
#include <sys/types.h>
#include <sys/param.h>
#include <sys/vnode.h>
],
vop_fsync_args,
int,
a_flags)

AC_HAVE_KERNEL_STRUCT_FIELD([
#include <sys/types.h>
#include <sys/param.h>
#include <sys/vnode.h>
],
vop_putpages_args,
int,
a_sync)

AC_HAVE_KERNEL_STRUCT_FIELD([
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#ifdef HAVE_SYS_PROC_H
#include <sys/proc.h>
#endif
],
proc,
register_t *,
p_retval)

AC_HAVE_KERNEL_DEF([
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#ifdef HAVE_SYS_MOUNT_H
#include <sys/mount.h>
#endif
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#ifdef HAVE_SYS_PROC_H
#include <sys/proc.h>
#endif
#ifdef HAVE_SYS_SYSPROTO_H
#include <sys/sysproto.h>
#endif
#ifdef HAVE_SYS_SYSCALLARGS_H
#include <sys/syscallargs.h>
#endif
],
struct setgroups_args)

AC_HAVE_KERNEL_DEF([
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#ifdef HAVE_SYS_MOUNT_H
#include <sys/mount.h>
#endif
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#ifdef HAVE_SYS_PROC_H
#include <sys/proc.h>
#endif
#ifdef HAVE_SYS_SYSPROTO_H
#include <sys/sysproto.h>
#endif
#ifdef HAVE_SYS_SYSCALLARGS_H
#include <sys/syscallargs.h>
#endif
],
struct sys_setgroups_args)

AC_HAVE_KERNEL_STRUCT_FIELD([
#include <sys/types.h>
#ifdef HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
#endif
#include <sys/conf.h>
],
cdevsw,
d_stop_t *,
d_stop)

AC_HAVE_KERNEL_STRUCT_FIELD([
#include <sys/types.h>
#ifdef HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
#endif
#include <sys/conf.h>
],
cdevsw,
d_reset_t *,
d_reset)

AC_HAVE_KERNEL_STRUCT_FIELD([
#include <sys/types.h>
#ifdef HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
#endif
#include <sys/conf.h>
],
cdevsw,
d_reset_t *,
d_bogoreset)

AC_HAVE_KERNEL_STRUCT_FIELD([
#include <sys/types.h>
#ifdef HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
#endif
#include <sys/conf.h>
],
cdevsw,
d_devtotty_t *,
d_devtotty)

AC_HAVE_KERNEL_STRUCT_FIELD([
#include <sys/types.h>
#ifdef HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
#endif
#include <sys/conf.h>
],
cdevsw,
d_parms_t *,
d_bogoparms)

AC_HAVE_KERNEL_STRUCT_FIELD([
#include <sys/types.h>
#ifdef HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
#endif
#include <sys/conf.h>
],
cdevsw,
void *,
d_spare)

AC_HAVE_KERNEL_STRUCT_FIELD([
#include <sys/types.h>
#ifdef HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
#endif
#include <sys/conf.h>
],
cdevsw,
int,
d_maxio)

AC_HAVE_KERNEL_STRUCT_FIELD([
#include <sys/types.h>
#ifdef HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
#endif
#include <sys/conf.h>
],
cdevsw,
int,
d_bmaj)

AC_HAVE_KERNEL_STRUCT_FIELD([
#include <sys/types.h>
#ifdef HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
#endif
#include <sys/uio.h>
#include <sys/namei.h>
],
componentname,
u_long,
cn_hash)

AC_CHECK_BSD_UVM_ONLY

dnl
dnl linux
dnl

elif test "$XFS_SUBDIR" = "linux"; then

dnl Linux devfs check
AC_CHECK_HEADERS(linux/devfs_fs.h linux/devfs_fs_kernel.h linux/stddef.h)

AC_LINUX_FUNC_D_ALLOC_ROOT_TWO_ARGS
AC_LINUX_FUNC_DEVFS_REGISTER_ELEVEN_ARGS

AC_HAVE_KERNEL_STRUCT_FIELD([
#define __KERNEL__
#include <asm/current.h>
#include <linux/fs.h>
],
ViceIoctl,
caddr_t,
in)

AC_HAVE_LINUX_KERNEL_TYPES(int8_t int16_t int32_t int64_t)
AC_HAVE_LINUX_KERNEL_TYPES(u_int8_t u_int16_t u_int32_t u_int64_t)

AC_HAVE_KERNEL_STRUCT_FIELD([
#include <asm/current.h>
#include <linux/fs.h>
typedef int (*notify_change_type)(struct dentry *, struct iattr *);
],
super_operations,
notify_change_type,
notify_change)

AC_HAVE_KERNEL_STRUCT_FIELD([
#include <asm/current.h>
#include <linux/fs.h>
],
inode_operations,
struct file_operations *,
default_file_ops)

AC_HAVE_KERNEL_STRUCT_FIELD([
#include <asm/current.h>
#include <linux/fs.h>
typedef int (*updatepage_type)(struct file *, struct page *, unsigned long, unsigned int, int);
],
inode_operations,
updatepage_type,
updatepage)

AC_HAVE_KERNEL_STRUCT_FIELD([
#include <asm/current.h>
#include <linux/fs.h>
typedef int (*bmap_type)(struct inode *,int);
],
inode_operations,
bmap_type,
bmap)

AC_HAVE_KERNEL_STRUCT_FIELD([
#include <asm/current.h>
#include <linux/fs.h>
typedef int (*smap_type)(struct inode *,int);
],
inode_operations,
smap_type,
smap)

AC_LINUX_TYPE_WAIT_QUEUE_HEAD_T
AC_LINUX_TYPE_WAIT_QUEUE_TASK_LIST
AC_LINUX_FUNC_INIT_WAITQUEUE_HEAD
AC_LINUX_FUNC_INIT_MUTEX
AC_LINUX_FUNC_LIST_DEL_INIT
AC_LINUX_FILLDIR_DT_TYPE
AC_LINUX_FUNC_DGET_LOCKED

AC_HAVE_KERNEL_STRUCT_FIELD([
#include <asm/current.h>
#include <linux/sched.h>
],
task_struct,
[struct sigpending],
pending)

AC_LINUX_D_DELETE_VOID

elif test "$XFS_SUBDIR" = "solaris"; then

AC_HAVE_KERNEL_STRUCT_FIELD([
#include <sys/types.h>
#include <sys/vfs.h>
typedef void (*freevfs_type)(struct vfs *);
],
vfsops,
freevfs_type,
vfs_freevfs)

fi # end of OS-specific tests

dnl
dnl Global kernel checks
dnl

AC_CHECK_KERNEL_FUNCS(strlcpy)

dnl
dnl
dnl

AC_MSG_CHECKING(for working htonl)
AC_CACHE_VAL(ac_cv_htonl_works, [
AC_TRY_LINK([#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_NETDB_H
#include <netdb.h>
#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
],
[htonl(0);],
ac_cv_htonl_works=yes,
ac_cv_htonl_works=no)])
AC_MSG_RESULT($ac_cv_htonl_works)

if test "$ac_cv_htonl_works" = "no"; then
AC_MSG_CHECKING(if htonl is repairable)
AC_CACHE_VAL(ac_cv_htonl_hack_works, [
AC_TRY_LINK(
[#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_NETDB_H
#include <netdb.h>
#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#define htonl(x) __cpu_to_be32(x)
],
[htonl(0);],
ac_cv_htonl_hack_works=yes,
ac_cv_htonl_hack_works=no)])
AC_MSG_RESULT($ac_cv_htonl_hack_works)

if test "$ac_cv_htonl_hack_works" = "no"; then
AC_MSG_ERROR([Cannot repair htonl])
else
  AC_DEFINE(HAVE_REPAIRABLE_HTONL, 1, [define?])
fi

fi

# Almost done....

AC_OUTPUT(Makefile				\
	include/Makefile			\
	arlad/Makefile				\
	lwp/Makefile				\
	xfs/Makefile				\
	$XFS_SUBDIR_Makefile			\
	$XFS_SUBDIR_BIN_Makefile		\
	rx/Makefile				\
	$RXKAD_MAKEFILE				\
	rxdef/Makefile				\
	appl/Makefile				\
	appl/lib/Makefile			\
	appl/asrvutil/Makefile			\
	appl/kalog/Makefile			\
	appl/afsmgr/Makefile			\
	appl/afsutils/Makefile			\
	appl/amon/Makefile			\
	appl/fs/Makefile			\
	appl/pts/Makefile			\
	appl/udebug/Makefile			\
	appl/vos/Makefile			\
	appl/bos/Makefile			\
	appl/mac/Makefile			\
	appl/mac/Arla_Configuration/Makefile	\
	appl/mac/Arla_Configuration/Info.plist	\
	doc/Makefile				\
	lib/Makefile				\
	lib/roken/Makefile			\
	lib/sl/Makefile				\
	lib/cmd/Makefile			\
	lib/editline/Makefile			\
	lib/ko/Makefile				\
	lib/acl/Makefile			\
	lib/bufdir/Makefile			\
	util/Makefile				\
	ydr/Makefile				\
	conf/Makefile				\
	conf/arla.spec				\
	milko/Makefile 				\
	milko/lib/Makefile 			\
	milko/lib/vstatus/Makefile 		\
	milko/lib/dpart/Makefile		\
	milko/lib/voldb/Makefile		\
	milko/lib/vld/Makefile			\
	milko/lib/ropa/Makefile			\
	milko/lib/msecurity/Makefile		\
	milko/lib/mlog/Makefile			\
	milko/appl/Makefile			\
	milko/appl/sked/Makefile		\
	milko/appl/perf/Makefile		\
	milko/appl/bootstrap/Makefile		\
	milko/fs/Makefile			\
	milko/vldb/Makefile			\
	milko/pts/Makefile			\
	milko/bos/Makefile			\
	tests/Makefile)

AC_KRB_VERSION