dnl @(#)configure.in	1.201 09/11/29 Copyright 1998-2009 J. Schilling
dnl Process this file with autoconf to produce a configure script.
AC_REVISION(1.201)dnl

dnl AC_INIT(xconfig.h.in)
AC_INIT(config.guess)
AC_CONFIG_HEADER(xconfig.h)
AC_CANONICAL_HOST

dnl Checks for programs.
AC_SHELL_BASH
AC_BIN_SHELL_BASH
AC_SHELL_CE_BROKEN
AC_BIN_SHELL_CE_BROKEN
AC_BIN_SHELL_BOSH
AC_OPT_SCHILY_BIN_SHELL_BOSH
dnl CC=${CC-cc}
dnl AC_PROG_CC
AC_OBJEXT
AC_EXEEXT
AC_PROG_CPP
AC_SUN_CC64_OPT
AC_HP_CC_ANSI_OPT
AC_HP_CC_OPT_OPT
AC_HP_CC_GPROF_OPT
dnl AC_PROG_INSTALL
AC_PROG_RANLIB
AC_PROG_MAKE_SET

dnl Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS(stdarg.h stdlib.h string.h float.h)	dnl AC_HEADER_STDC in particular
AC_HEADER_INTTYPES
AC_HEADER_STDINT
ac_xsave_LIBS="$LIBS"
LIBS=""
AC_HEADER_DIRENT
lib_dir="$LIBS"
LIBS="$ac_xsave_LIBS"
AC_HEADER_STAT
AC_HEADER_TIME
AC_HEADER_SYS_WAIT
dnl check whether select() needs sys/select.h
AC_HEADER_SYS_SELECT
dnl check whether select() needs sys/socket.h (BeOS)
AC_HEADER_SELECT2
AC_CHECK_HEADERS(assert.h)
AC_CHECK_HEADERS(stdio.h varargs.h stdarg.h stdlib.h stddef.h string.h strings.h unistd.h fcntl.h sys/file.h)
AC_CHECK_HEADERS(getopt.h)
AC_CHECK_HEADERS(limits.h)
AC_CHECK_HEADERS(a.out.h aouthdr.h elf.h)
AC_CHECK_HEADERS(sysexits.h)
AC_CHECK_HEADERS(malloc.h sgtty.h termios.h termio.h)
AC_CHECK_HEADERS(pwd.h grp.h sys/acl.h acllib.h acl/libacl.h)
AC_CHECK_HEADERS(signal.h siginfo.h sys/siginfo.h ucontext.h)
AC_CHECK_HEADERS(shadow.h syslog.h)
AC_CHECK_HEADERS(sys/time.h sys/times.h utime.h sys/utime.h sys/ioctl.h sys/filio.h sys/param.h sys/systeminfo.h sys/sysctl.h)
AC_CHECK_HEADERS(sys/syscall.h)
AC_CHECK_HEADERS(mach/machine.h)
AC_CHECK_HEADERS(mntent.h sys/mntent.h sys/mnttab.h sys/mount.h)
AC_CHECK_HEADERS(sys/fork.h vfork.h wait.h sys/wait.h sys/resource.h procfs.h sys/procfs.h)
AC_CHECK_HEADERS(sys/utsname.h sys/priocntl.h sys/rtpriocntl.h sys/procset.h)
AC_CHECK_HEADERS(sys/mtio.h sys/tape.h sys/mman.h linux/pg.h camlib.h)
AC_CHECK_HEADERS(sys/shm.h sys/sem.h sys/ipc.h)
AC_CHECK_HEADERS(sys/dkio.h sys/dklabel.h sun/dkio.h sun/dklabel.h)
AC_CHECK_HEADERS(sys/types.h sys/stat.h types.h stat.h)
AC_CHECK_HEADERS(sys/stypes.h sys/filedesc.h)
AC_CHECK_HEADERS(sys/acct.h)
AC_CHECK_HEADERS(poll.h sys/poll.h sys/select.h)
AC_CHECK_HEADERS(netdb.h sys/socket.h netinet/in.h stropts.h)
AC_CHECK_HEADERS(ieeefp.h fp.h)
AC_CHECK_HEADERS(values.h float.h math.h)
AC_CHECK_HEADERS(arpa/inet.h)
AC_CHECK_HEADERS(bsd/dev/scsireg.h)
dnl Check for HP-UX sys/bsdtty.h (needed for TIOCGPGRP)
AC_CHECK_HEADERS(sys/bsdtty.h)
dnl Check for Linux kernel definitions
AC_CHECK_HEADERS(linux/types.h linux/gfp.h asm/types.h)
dnl Check for BeOS kernel definitions (e.g. B_PAGE_SIZE)
AC_CHECK_HEADERS(OS.h)
dnl needed for newer OS/2 versions of EMX
AC_CHECK_HEADERS(os2.h)
AC_CHECK_HEADERS(os2me.h)
dnl Check for MS-Win's junkyard
AC_CHECK_HEADERS(windows.h)
dnl Check for moving Linux targets caused by missing concepts
AC_CHECK_HEADERS(ext2fs/ext2_fs.h)
dnl Check for Linux Extended File Attributes definitions
AC_CHECK_HEADERS(attr/xattr.h)
dnl Check for Mas OS X ac, av, env delarations
AC_CHECK_HEADERS(crt_externs.h)
AC_CHECK_HEADERS(fnmatch.h)
AC_CHECK_HEADERS(libintl.h locale.h langinfo.h nl_types.h)
AC_CHECK_HEADERS(ctype.h wctype.h wchar.h iconv.h)
AC_CHECK_HEADERS(priv.h sys/priv.h)
AC_CHECK_HEADERS(exec_attr.h secdb.h)
AC_CHECK_HEADERS(direct.h)
AC_CHECK_HEADERS(pthread.h thread.h)
AC_CHECK_HEADERS(libgen.h)
AC_CHECK_HEADERS(dlfcn.h link.h dl.h)

dnl from aclocal.m4 (uses AC_TRY_COMPILE)
AC_HEADER_MAKEDEV

dnl don't use GNU original
dnl from GNU acspecific.m4 (uses AC_CHECK_HEADER)
dnl AC_HEADER_MAJOR

AC_CHECK_MINOR_BITS
AC_CHECK_MINOR_NONCONTIG

AC_HEADER_USG_STDIO
AC_HEADER_ERRNO_DEF
AC_HEADER_ENVIRON_DEF
AC_HEADER_SYS_SIGLIST_DEF

dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_C_BIGENDIAN
AC_C_BITFIELDS
AC_C_STRINGIZE
AC_C_INLINE
AC_TYPE_SIGNAL
AC_TYPE_GETGROUPS
AC_TYPE_LONGLONG
AC_TYPE___INT64
AC_TYPE_LONGDOUBLE
AC_TYPE_PROTOTYPES
dnl AC_USER_MALLOC must be past AC_CHECK_FUNCS(strdup)
AC_DYN_ARRAYS
AC_PRAGMA_WEAK

AC_TYPE_UID_T
AC_TYPE_SIZE_T
AC_CHECK_TYPE(ssize_t, int)
AC_CHECK_TYPE(ptrdiff_t, int)
AC_TYPE_PID_T
AC_TYPE_OFF_T
AC_TYPE_MODE_T
AC_TYPE_TIME_T
AC_CHECK_TYPE(caddr_t, char *)
AC_CHECK_TYPE(daddr_t, long)
AC_CHECK_TYPE(dev_t, unsigned short)
AC_CHECK_TYPE(major_t, dev_t)
AC_CHECK_TYPE(minor_t, dev_t)
AC_CHECK_TYPE(ino_t, unsigned long)
AC_CHECK_TYPE(nlink_t, unsigned long)
AC_CHECK_TYPE(blksize_t, long)
AC_CHECK_TYPE(blkcnt_t, Intmax_t)
AC_TYPE_CLOCK_T
AC_TYPE_SOCKLEN_T
AC_HAVE_TYPE([#include <sys/frame.h>], greg_t)
AC_TYPE_STACK_T
AC_TYPE_SIGINFO_T

dnl These types are present on all UNIX systems but should be avoided
dnl for portability.
dnl On Apollo/Domain OS we don't have them....
dnl Better include <utypes.h> and use Uchar, Uint & Ulong
AC_CHECK_TYPE(u_char, unsigned char)
AC_CHECK_TYPE(u_short, unsigned short)
AC_CHECK_TYPE(u_int, unsigned int)
AC_CHECK_TYPE(u_long, unsigned long)

AC_CHECK_SIZEOF(char)
AC_CHECK_SIZEOF(short int)
AC_CHECK_SIZEOF(int)
AC_CHECK_SIZEOF(long int)
AC_CHECK_SIZEOF(long long)
AC_CHECK_SIZEOF(__int64)
AC_CHECK_SIZEOF(char *)

AC_CHECK_SIZEOF(unsigned char)
AC_CHECK_SIZEOF(unsigned short int)
AC_CHECK_SIZEOF(unsigned int)
AC_CHECK_SIZEOF(unsigned long int)
AC_CHECK_SIZEOF(unsigned long long)
AC_CHECK_SIZEOF(unsigned __int64)
AC_CHECK_SIZEOF(unsigned char *)
AC_CHECK_SIZEOF(float)
AC_CHECK_SIZEOF(double)
AC_CHECK_SIZEOF(long double)

AC_CHECK_SIZEOF(size_t)
AC_CHECK_SIZEOF(ssize_t)
AC_CHECK_SIZEOF(ptrdiff_t)

dnl This call must be past AC_CHECK_SIZEOF(long int)
AC_CHECK_SIZE_TIME_T
AC_CHECK_SIZE_WCHAR
AC_CHECK_SIZE_WCHAR_T

dnl # AC_TYPE_SIZE_T_		# Defines HAVE_SIZE_T / NO_SIZE_T
AC_TYPE_CHAR
AC_TYPE_VA_LIST
AC_STRUCT_TIMEVAL
AC_STRUCT_TIMEZONE
AC_STRUCT_MTGET_TYPE
AC_STRUCT_MTGET_MODEL
AC_STRUCT_MTGET_DSREG
AC_STRUCT_MTGET_DSREG1
AC_STRUCT_MTGET_DSREG2
AC_STRUCT_MTGET_GSTAT
AC_STRUCT_MTGET_ERREG
AC_STRUCT_MTGET_RESID
AC_STRUCT_MTGET_FILENO
AC_STRUCT_MTGET_BLKNO
AC_STRUCT_MTGET_FLAGS
AC_STRUCT_MTGET_BF
AC_STRUCT_RUSAGE
AC_STRUCT_SI_UTIME
AC_STRUCT_SOCKADDR_STORAGE
AC_STRUCT_UNION_SEMUN
AC_STRUCT_UNION_WAIT
AC_USE_STRUCT_UNION_WAIT
AC_STRUCT_ST_SPARE1
AC_STRUCT_ST_ATIMENSEC
AC_STRUCT_ST_NSEC
AC_STRUCT_ST__TIM
AC_STRUCT_ST_ATIMESPEC
AC_STRUCT_ST_BLKSIZE
AC_STRUCT_ST_BLOCKS
AC_STRUCT_ST_FSTYPE
AC_STRUCT_ST_ACLCNT
AC_STRUCT_ST_RDEV
AC_STRUCT_ST_FLAGS
AC_STRUCT_DIRENT_D_INO
AC_STRUCT_DIR_DD_FD
AC_STRUCT_UTSNAME_ARCH
AC_STRUCT_UTSNAME_PROCESSOR
AC_STRUCT_UTSNAME_SYSNAME_HOST
AC_STRUCT_UTSNAME_RELEASE_HOST
AC_STRUCT_UTSNAME_VERSION_HOST

dnl Check whether iconv() uses const char ** arguments
AC_ICONV_CONST

dnl Check whether we are able to get the address of a function
dnl or whether the symbol is declared and usable as rhs
AC_CHECK_DECLARE([
#include <sys/types.h>
#include <sys/stat.h>], stat)
AC_CHECK_DECLARE([
#include <sys/types.h>
#include <sys/stat.h>], lstat)

dnl Checks for library functions.
AC_FUNC_WAIT3
AC_FUNC_MLOCK
AC_FUNC_MLOCKALL
AC_FUNC_VA_COPY
AC_FUNC__VA_COPY
AC_FUNC_ECVT
AC_FUNC_FCVT
AC_FUNC_GCVT
AC_FUNC_DTOA
AC_FUNC_DTOA_R
jsAC_FUNC_MMAP
AC_MMAP_SIZEP
AC_FUNC_SMMAP
AC_FUNC_SHMGET
AC_FUNC_ALLOCA
AC_FUNC_QUOTAIOCTL
AC_FUNC_FCNTL_LOCKF
AC_FUNC_UNAME
AC_CHECK_FUNCS(execl)
AC_FUNC_VFORK
AC_FUNC_SYS_SIGLIST
AC_FUNC_BSD_GETPGRP
AC_FUNC_BSD_SETPGRP
AC_FUNC_C99_ISINF
AC_FUNC_C99_ISNAN
AC_FUNC_SIGSETJMP
AC_FUNC_SIGLONGJMP
AC_CHECK_FUNCS(access eaccess euidaccess)
AC_CHECK_FUNCS(memchr memcpy memmove memset)
AC_CHECK_FUNCS(brk sbrk strerror nice flock lockf fchdir statvfs quotactl)
AC_CHECK_FUNCS(realpath resolvepath)
AC_CHECK_FUNCS(dup dup2)
AC_CHECK_FUNCS(getcwd shmat semget)
AC_CHECK_FUNCS(lstat readlink symlink link rename mkfifo mknod)
AC_CHECK_FUNCS(setreuid setresuid seteuid setuid)
AC_CHECK_FUNCS(setregid setresgid setegid setgid)
AC_CHECK_FUNCS(getuid geteuid getgid getegid)
AC_CHECK_FUNCS(getpid getppid)
AC_CHECK_FUNCS(getpgid setpgid getsid setsid)
AC_CHECK_FUNCS(getpgrp setpgrp)
dnl			getspwnam() on HP-UX is in libsec.a
AC_CHECK_FUNCS(getspnam getspwnam)
AC_CHECK_FUNCS(sync fsync fork forkx vforkx forkall forkallx wait wait4 waitid waitpid getrusage getrlimit setrlimit ulimit)
AC_CHECK_FUNCS(execl execle execlp execv execve execvp)
AC_CHECK_FUNCS(getexecname)
AC_CHECK_FUNCS(getprogname setprogname)
AC_CHECK_FUNCS(gethostid gethostname getdomainname getpagesize getdtablesize)
AC_CHECK_FUNCS(gettimeofday settimeofday time stime gethrtime)
AC_CHECK_FUNCS(ftime tzset mktime gmtime localtime timegm timelocal)
AC_CHECK_FUNCS(ctime cftime ascftime strftime)
AC_CHECK_FUNCS(poll select isastream)
AC_CHECK_FUNCS(chown fchown lchown chmod fchmod lchmod times utime utimes futimes lutimes)
AC_CHECK_FUNCS(futimens utimensat)
dnl AC_CHECK_FUNCS(ecvt fcvt gcvt)
AC_CHECK_FUNCS(ecvt_r fcvt_r gcvt_r)
AC_CHECK_FUNCS(econvert fconvert gconvert)
AC_CHECK_FUNCS(isinf isnan)
AC_CHECK_FUNCS(rand drand48)
AC_CHECK_FUNCS(strtol strtoll strtoul strtoull strtod)
AC_CHECK_FUNCS(setpriority DosSetPriority)
AC_CHECK_FUNCS(DosAllocSharedMem)
AC_CHECK_FUNCS(seekdir fdopendir)
dnl These are POSIX.1 functions (syscalls on Solaris)
AC_CHECK_FUNCS(openat fstatat fchownat futimesat renameat unlinkat)
dnl This is a library function for the Solaris extended attr interface
AC_CHECK_FUNCS(attropen)
dnl This appeared on Solaris 11 Build 63
AC_CHECK_FUNCS(__accessat)
dnl This appeared not yet in POSIX
AC_CHECK_FUNCS(accessat)
dnl This are POSIX extensions not found on Solaris 10
AC_CHECK_FUNCS(mkdirat faccessat fchmodat linkat mkfifoat mknodat readlinkat symlinkat)
AC_CHECK_FUNCS(popen pclose _popen _pclose)
AC_CHECK_FUNCS(strsignal str2sig sig2str)
AC_CHECK_FUNCS(kill killpg)
AC_CHECK_FUNCS(signal sigrelse sigprocmask sigsetmask sigset sigaltstack)
AC_CHECK_FUNCS(sleep usleep yield)
AC_CHECK_FUNCS(tcgetattr tcsetattr tcgetpgrp tcsetpgrp)
AC_CHECK_FUNCS(getenv putenv setenv unsetenv)
AC_CHECK_FUNCS(snprintf strcasecmp)
AC_CHECK_FUNCS(strcat strncat strcmp strncmp strcpy strlcpy strncpy strdup strlen strchr strrchr)
AC_CHECK_FUNCS(wcscat wcsncat wcscmp wcsncmp wcscpy wcslcpy wcsncpy wcsdup wcslen wcschr wcsrchr)
AC_CHECK_FUNCS(wcwidth wcswidth wctype iswctype)
AC_CHECK_FUNCS(malloc calloc valloc realloc memalign posix_memalign)
AC_CHECK_FUNCS(madvise)
AC_CHECK_FUNCS(mktemp mkstemp)
AC_CHECK_FUNCS(chflags fchflags fflagstostr strtofflags)
AC_CHECK_FUNCS(fnmatch)
AC_CHECK_FUNCS(truncate ftruncate)
AC_CHECK_FUNCS(getppriv setppriv priv_set)
AC_CHECK_FUNCS(getroles privbit_set)
AC_CHECK_FUNCS(setlocale localeconv nl_langinfo)
AC_CHECK_FUNCS(setbuf setvbuf)
AC_CHECK_FUNCS(clone_area create_area delete_area)

dnl The official POSIX rule is not to define "new" interfaces that
dnl are in conflict with older interfaces of the same name.
dnl Our interfaces fexec*() have been defined and published in 1982.
dnl The new POSIX interfaces define a different interface and the
dnl new POSIX interfaces even use names that are not compatible with
dnl POSIX rules. The new POSIX interfaces in question should be called
dnl fdexec*() to follow the rules of other similar POSIX functions.
dnl
dnl We use AC_RCHECK_FUNCS() because some Linux distros define a
dnl fexecve() that returns ENOSYS an AC_CHECK_FUNCS() would return FALSE
dnl
echo Checking for POSIX violations by the POSIX.1-2008 standard:
AC_RCHECK_FUNCS(fexecl fexecle fexecv fexecve)
AC_RCHECK_FUNCS(fspawnv fspawnl fspawnv_nowait)

dnl A similar problem exists with the new POSIX.1-2008 interfaces 
dnl getline() and fgetline(). These interfaces are also incompatible
dnl with our interfaces defined in 1982.
AC_RCHECK_FUNCS(getline fgetline)
echo End of tests for POSIX violations by the POSIX.1-2008 standard.

dnl Check whether a symbol is either defined in an include file or
dnl otherwise usable (e.g. as function)
AC_CHECK_DFUNC([#include <dirent.h>], dirfd)

AC_CHECK_DFUNC([
#ifdef	HAVE_WCHAR_H
#include <wchar.h>
#endif
#ifdef	HAVE_WCTYPE_H
#include <wctype.h>
#endif
], iswprint)

AC_CHECK_DFUNC([#include <ieeefp.h>], finite)
AC_CHECK_DFUNC([#include <ieeefp.h>], isnand)

dnl Checks for typedefs, structures, and compiler characteristics.
dnl that need results from the AC_CHECK_FUNCS() calls.
AC_USER_MALLOC
dnl AC_USER_XCVT test macro does not yet work
AC_VAR_TIMEZONE
AC_VAR_TIMEZONE_DEF

dnl Checks for OS characteristics.
AC_HARD_SYMLINKS
AC_LINK_NOFOLLOW
AC_ACCESS_E_OK

dnl Need to check this in default compilation mode to find out
dnl whether this platform supports both functions by default too.
dnl We cannot use the standard tests because they would find
dnl that fseeko()/ftello() are present in small file mode on
dnl Limnux while there is no prototype for these functions.
AC_SMALL_FSEEKO
AC_SMALL_FTELLO

AC_CHECK_LIB(c, dlopen, lib_dl="",
  [AC_CHECK_LIB(dl, dlopen, lib_dl="-ldl")])
ac_save_LIBS="$LIBS"
LIBS="$LIBS $lib_dl"
AC_CHECK_FUNCS(dlopen dlclose dlsym dlerror)
AC_CHECK_FUNCS(shl_load shl_unload shl_gethandle)
AC_CHECK_FUNCS(LoadLibrary FreeLibrary GetProcAddress)
LIBS="$ac_save_LIBS"

dnl ??? AC_CHECK_LIB(socket, socket, lib_socket="-lsocket")
dnl
AC_CHECK_LIB(socket, rcmd, lib_socket="-lsocket")
ac_save_LIBS="$LIBS"
LIBS="$LIBS $lib_socket"
AC_CHECK_LIB(nsl, inet_ntoa, lib_nsl="-lnsl")
LIBS="$LIBS $lib_nsl"
AC_CHECK_FUNCS(rcmd socket socketpair)
AC_CHECK_FUNCS(getservbyname inet_ntoa)
AC_CHECK_FUNCS(getaddrinfo getnameinfo)
LIBS="$ac_save_LIBS"

ac_save_LIBS="$LIBS"
AC_CHECK_LIB(c, res_init, lib_resolv="",
  [AC_CHECK_LIB(resolv, res_init, lib_resolv="-lresolv")])
LIBS="$ac_save_LIBS"

dnl Check for largefile support
dnl Do this last to make sure that no large file definition
dnl in confdefs.h will modify our results
AC_SYS_LARGEFILE
dnl Warning do not run this test. it interferes with the test
dnl AC_CHECK_FUNCS(fseeko ftello) from above.
dnl The test AC_HAVE_LARGEFILES will check whether ftello/fseeko
dnl are available in Large File mode
dnl AC_FUNC_FSEEKO
AC_HAVE_LARGEFILES

AC_DEFINE_UNQUOTED_STRING(HOST_ALIAS,$host_alias)
AC_DEFINE_UNQUOTED_STRING(HOST_SUB,$host)
AC_DEFINE_UNQUOTED_STRING(HOST_CPU,$host_cpu)
AC_DEFINE_UNQUOTED_STRING(HOST_VENDOR,$host_vendor)
AC_DEFINE_UNQUOTED_STRING(HOST_OS,$host_os)

dnl AC_CHECK_LIB(crypt, crypt, lib_crypt="-lcrypt")

AC_CHECK_LIB(c, crypt, lib_crypt="",
  [AC_CHECK_LIB(crypt, crypt, lib_crypt="-lcrypt")])

ac_save_LIBS="$LIBS"
LIBS="$LIBS $lib_crypt"
AC_CHECK_FUNCS(crypt)
LIBS="$ac_save_LIBS"

AC_CHECK_ILIB([#include <libintl.h>], c, gettext, lib_intl="",
  [AC_CHECK_ILIB([#include <libintl.h>], intl, gettext, lib_intl="-lintl")])

ac_save_LIBS="$LIBS"
LIBS="$LIBS $lib_intl"
AC_CHECK_DFUNC([#include <libintl.h>], gettext)
LIBS="$ac_save_LIBS"

AC_CHECK_ILIB([#include <iconv.h>], c, iconv_open, lib_iconv="",
    [AC_CHECK_ILIB([#include <iconv.h>], iconv, iconv_open, lib_iconv="-liconv")])

ac_save_LIBS="$LIBS"
LIBS="$LIBS $lib_iconv"
AC_CHECK_DFUNC([#include <iconv.h>], iconv)
AC_CHECK_DFUNC([#include <iconv.h>], iconv_open)
AC_CHECK_DFUNC([#include <iconv.h>], iconv_close)
dnl GNU libiconv on Linux and Cygwin may make "configure" fail :-(
AC_CHECK_DFUNC([#include <iconv.h>], libiconv)
AC_CHECK_DFUNC([#include <iconv.h>], libiconv_open)
AC_CHECK_DFUNC([#include <iconv.h>], libiconv_close)
LIBS="$ac_save_LIBS"

if test $ac_cv_header_camlib_h = yes; then
  scsi_lib=-lcam
  lib_scsi=-lcam
fi

if test "$ac_cv_header_sys_acl_h" = yes; then

  AC_CHECKING(for Posix Access Control List support)
  AC_CHECK_LIB(acl, acl_get_file, lib_acl="-lacl")
  AC_CHECK_LIB(pacl, acl_get_file, lib_acl="-lpacl")

	dnl If $lib_acl is nonempty, save it in $lib_acl_test
	
	if test ".$lib_acl" != .; then
		lib_acl_test="$lib_acl"
	fi

  ac_save_LIBS="$LIBS"
  LIBS="$LIBS $lib_acl"
  AC_CHECK_FUNCS(acl_get_file acl_set_file acl_from_text acl_to_text acl_free acl_delete_def_file)
  AC_CHECK_FUNCS(acl_extended_file)
  AC_CHECK_FUNCS(acl_get_entry)
  LIBS="$ac_save_LIBS"

  AC_CHECKING(for Solaris Access Control List support)
  AC_CHECK_LIB(sec, acltotext, lib_acl="-lsec")
  ac_save_LIBS="$LIBS"
  LIBS="$LIBS $lib_acl"
  AC_CHECK_FUNCS(acl facl aclfromtext acltotext)
  LIBS="$ac_save_LIBS"

  dnl On Solaris, there is no need for lib_acl_test as acl(2) is in -libc

  AC_CHECKING(for HP-UX Access Control List support)
  AC_CHECK_FUNCS(getacl fgetacl setacl fsetacl strtoacl acltostr cpacl fcpacl chownacl setaclentry fsetaclentry)

  dnl XXX lib_acl_test: How do we test for ACLs on HP-UX?

fi

if test "$ac_cv_header_attr_xattr_h" = yes; then
  AC_CHECKING(for Linux flavor Extended Attribute support)
  AC_CHECK_LIB(attr, getxattr, lib_attr="-lattr")
  ac_save_LIBS="$LIBS"
  LIBS="$LIBS $lib_attr"
  AC_CHECK_FUNCS(getxattr setxattr listxattr lgetxattr lsetxattr llistxattr)
  LIBS="$ac_save_LIBS"
fi

AC_CHECKING(for RBAC support)
AC_CHECK_LIB(secdb, getuserattr, lib_secdb="-lsecdb")
ac_save_LIBS="$LIBS"
LIBS="$LIBS $lib_secdb"
AC_CHECK_FUNCS(getauthattr getuserattr getexecattr getprofattr)
LIBS="$ac_save_LIBS"

AC_CHECKING(for gmatch() support)
AC_CHECK_LIB(gen, gmatch, lib_gen="-lgen")
ac_save_LIBS="$LIBS"
LIBS="$LIBS $lib_gen"
AC_CHECK_FUNCS(gmatch)
LIBS="$ac_save_LIBS"

AC_CHECK_FUNCS(thr_yield)

AC_CHECK_LIB(pthread, pthread_create, lib_pthread="-lpthread",
  [AC_CHECK_LIB(c, pthread_create, lib_pthread="")])

ac_save_LIBS="$LIBS"
LIBS="$LIBS $lib_pthread"
AC_CHECK_FUNCS(pthread_create pthread_kill)
AC_CHECK_FUNCS(pthread_mutex_lock pthread_cond_wait pthread_spin_lock)
LIBS="$ac_save_LIBS"

AC_CHECK_LIB(c, clock_gettime, lib_rt="",
  [AC_CHECK_LIB(rt, clock_gettime, lib_rt="-lrt",
  [AC_CHECK_LIB(posix4, clock_gettime, lib_rt="-lposix4")])])

ac_save_LIBS="$LIBS"
LIBS="$LIBS $lib_rt"
AC_CHECK_FUNCS(clock_gettime clock_settime clock_getres)
AC_CHECK_FUNCS(sched_getparam sched_setparam sched_getscheduler sched_setscheduler)
AC_CHECK_FUNCS(sched_yield)
AC_CHECK_FUNCS(nanosleep)
LIBS="$ac_save_LIBS"

dnl Misc OS checks.
AC_MSG_CHECKING(for /dev/tty)
if test -r /dev/tty; then
	echo yes
	AC_DEFINE(HAVE_DEV_TTY)
else
	echo no
fi
AC_MSG_CHECKING(for /dev/null)
if test -r /dev/null; then
	echo yes
	AC_DEFINE(HAVE_DEV_NULL)
else
	echo no
fi
AC_MSG_CHECKING(for /dev/zero)
if test -r /dev/zero; then
	echo yes
	AC_DEFINE(HAVE_DEV_ZERO)
else
	echo no
fi

dnl Checks for OS madness.
UNAME=`uname || true`

if test ."$UNAME" = .Linux; then

dnl Linux madness tests:

AC_BROKEN_LINUX_EXT2_FS_H
AC_BROKEN_SRC_LINUX_EXT2_FS_H
if test .$ac_cv_broken_linux_ext2_fs_h = .no -o .$ac_cv_broken_src_linux_ext2_fs_h = .no; then
	#
	# If either /usr/include/linux/ex2_fs.h works or
	# /usr/src/linux/include/linux/ex2_fs.h works, we will
	# #define HAVE_USABLE_LINUX_EXT2_FS_H
	#
	# If HAVE_USABLE_LINUX_EXT2_FS_H is defined, a simple
	# #include <linux/ex2_fs.h> will work.
	#
	ac_cv_usable_linux_ext2_fs_h=yes
	AC_DEFINE(HAVE_USABLE_LINUX_EXT2_FS_H)
else
	ac_cv_usable_linux_ext2_fs_h=no
fi
AC_BROKEN_SCSI_SCSI_H
AC_BROKEN_SRC_SCSI_SCSI_H
AC_BROKEN_SCSI_SG_H
AC_BROKEN_SRC_SCSI_SG_H

if test .$ac_cv_broken_src_scsi_scsi_h = .yes; then
	may_linux_src_include=no
fi
if test .$ac_cv_broken_src_linux_ext2_fs_h = .yes; then
	may_linux_src_include=no
fi
if test .$may_linux_src_include = .no; then
	echo
	echo "Warning: *** /usr/src/linux/include contains broken include files ***"
	echo "Warning: *** /usr/src/linux/include is not used this reason ***"
	echo "Warning: This may result in the inability to use recent Linux kernel interfaces" 
	echo
fi
if test .$ac_cv_usable_linux_ext2_fs_h = .no; then
	echo
	echo "Warning: *** linux/ext2_fs.h is not usable at all ***"
	echo "Warning: *** This makes it impossible to support Linux file flags ***"
	echo "You may try to compile using 'make COPTX=-DTRY_EXT2_FS'"
	echo
	sleep 10
fi
fi	# Linux only tests

AC_SUBST(may_linux_src_include)

AC_SUBST(largefile_cc_opt)
AC_SUBST(sun_cc64_opt)
AC_SUBST(hp_cc_ansi_opt)
AC_SUBST(hp_cc_opt_opt)
AC_SUBST(hp_cc_gprof_opt)

AC_SUBST(lib_crypt)
AC_SUBST(lib_resolv)
AC_SUBST(lib_intl)
AC_SUBST(lib_iconv)
AC_SUBST(scsi_lib)
AC_SUBST(lib_scsi)
AC_SUBST(lib_acl)
AC_SUBST(lib_acl_test)
AC_SUBST(lib_attr)
AC_SUBST(lib_secdb)
AC_SUBST(lib_gen)
AC_SUBST(lib_pthread)
AC_SUBST(lib_rt)
AC_SUBST(lib_dl)
AC_SUBST(lib_dir)

AC_OUTPUT(rules.cnf)
