r5917: First step in using the new cli_credentials structure. This patch
[bbaumbach/samba-autobuild/.git] / source4 / build / m4 / rewrite.m4
index 08c2019a09185c87085974c599dc042e12e1a964..3361679f2c9e7e9872dbe7aa1ef5efd917ff6bde 100644 (file)
@@ -1,69 +1,15 @@
 dnl Checks for programs.
-AC_PROG_CC
-AC_PROG_INSTALL
-AC_PATH_PROG(PERL, perl)
+dnl Unique-to-Samba variables we'll be playing with.
 
-# compile with optimization and without debugging by default, but
-# allow people to set their own preference.
-if test "x$CFLAGS" = x
-then
-  CFLAGS="-O ${CFLAGS}"
-fi
-
-dnl Check if we use GNU ld
-LD=ld
-AC_PROG_LD_GNU
-
-dnl needed before AC_TRY_COMPILE
-AC_ISC_POSIX
-
-dnl look for executable suffix
-AC_EXEEXT
-
-dnl Check if C compiler understands -c and -o at the same time
-AC_PROG_CC_C_O
-if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" = no"; then
-      BROKEN_CC=
-else
-      BROKEN_CC=#
-fi
-AC_SUBST(BROKEN_CC)
-
-AC_CACHE_CHECK([that the C compiler can precompile header files],samba_cv_precompiled_headers, [
-       dnl Check whether the compiler can generate precompiled headers
-       touch conftest.h
-       if ${CC-cc} conftest.h 2> /dev/null && test -f conftest.h.gch; then
-               samba_cv_precompiled_headers=yes
-       else
-               samba_cv_precompiled_headers=no
-       fi])
-PCH_AVAILABLE="#"
-if test x"$samba_cv_precompiled_headers" = x"yes"; then
-       PCH_AVAILABLE=""
-fi
-AC_SUBST(PCH_AVAILABLE)
-
-
-dnl Check if the C compiler understands volatile (it should, being ANSI).
-AC_CACHE_CHECK([that the C compiler understands volatile],samba_cv_volatile, [
-    AC_TRY_COMPILE([#include <sys/types.h>],[volatile int i = 0],
-       samba_cv_volatile=yes,samba_cv_volatile=no)])
-if test x"$samba_cv_volatile" = x"yes"; then
-   AC_DEFINE(HAVE_VOLATILE, 1, [Whether the C compiler understands volatile])
-fi
-
-
-AC_CANONICAL_SYSTEM
-
-dnl Add #include for broken IRIX header files
-  case "$host_os" in
-       *irix6*) AC_ADD_INCLUDE(<standards.h>)
-       ;;
-esac
+DYNEXP=
 
-AC_VALIDATE_CACHE_SYSTEM_TYPE
+AC_SUBST(SHLIBEXT)
+AC_SUBST(LDSHFLAGS)
+AC_SUBST(SONAMEFLAG)
+AC_SUBST(PICFLAG)
 
-DYNEXP=
+AC_DEFINE([_GNU_SOURCE],[],[Pull in GNU extensions])
+AC_SYS_LARGEFILE
 
 #
 # Config CPPFLAG settings for strange OS's that must be set
@@ -71,228 +17,43 @@ DYNEXP=
 #
 case "$host_os" in
 # Try to work out if this is the native HPUX compiler that uses the -Ae flag.
-    *hpux*)
-    
+    *hpux*)    
       AC_PROG_CC_FLAG(Ae)
       # mmap on HPUX is completely broken...
       AC_DEFINE(MMAP_BLACKLIST, 1, [Whether MMAP is broken])
       if test $ac_cv_prog_cc_Ae = yes; then
         CPPFLAGS="$CPPFLAGS -Ae"
       fi
-#
-# Defines needed for HPUX support.
-# HPUX has bigcrypt but (sometimes?) doesn't use it for
-# password hashing - hence the USE_BOTH_CRYPT_CALLS define.
-#
-      case `uname -r` in
-                       *9*|*10*)
-                               CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE -D_POSIX_SOURCE -D_ALIGNMENT_REQUIRED=1 -D_MAX_ALIGNMENT=4 -DMAX_POSITIVE_LOCK_OFFSET=0x1ffffffffffLL"
-                               AC_DEFINE(USE_BOTH_CRYPT_CALLS, 1, [Whether to use both of HPUX' crypt calls])
-                               AC_DEFINE(_HPUX_SOURCE, 1, [Whether to use HPUX extensions])
-                               AC_DEFINE(_POSIX_SOURCE, 1, [Whether to use POSIX compatible functions])
-                               AC_DEFINE(_ALIGNMENT_REQUIRED,1,[Required alignment])
-                               AC_DEFINE(_MAX_ALIGNMENT,4,[Maximum alignment])
-                               ;;
-                       *11*)
-                               CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE -D_POSIX_SOURCE -D_LARGEFILE64_SOURCE -D_ALIGNMENT_REQUIRED=1 -D_MAX_ALIGNMENT=4 -DMAX_POSITIVE_LOCK_OFFSET=0x1ffffffffffLL"
-                               AC_DEFINE(USE_BOTH_CRYPT_CALLS, 1, [Whether to use both of HPUX' crypt calls])
-                               AC_DEFINE(_HPUX_SOURCE, 1, [Whether to use HPUX extensions])
-                               AC_DEFINE(_POSIX_SOURCE, 1, [Whether to use POSIX compatible functions])
-                               AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to use large file support])
-                               AC_DEFINE(_ALIGNMENT_REQUIRED, 1, [Required alignment])
-                               AC_DEFINE(_MAX_ALIGNMENT, 4, [Maximum alignment])
-                               ;;
-      esac
-      DYNEXP="-Wl,-E"
-      ;;
-
-#
-# CRAY Unicos has broken const handling
-       *unicos*)
-         AC_MSG_RESULT([disabling const])
-         CPPFLAGS="$CPPFLAGS -Dconst="
-         ;;
-       
-#
-# AIX4.x doesn't even admit to having large
-# files *at all* unless the -D_LARGE_FILE or -D_LARGE_FILE_API flags are set.
-#
-    *aix4*)
-         AC_MSG_RESULT([enabling large file support])
-      CPPFLAGS="$CPPFLAGS -D_LARGE_FILES"
-         AC_DEFINE(_LARGE_FILES, 1, [Whether to enable large file support])
-      ;;    
-#
-# Defines needed for Solaris 2.6/2.7 aka 7.0 to make it admit
-# to the existance of large files..
-# Note that -D_LARGEFILE64_SOURCE is different from the Sun
-# recommendations on large file support, however it makes the
-# compile work using gcc 2.7 and 2.8, whereas using the Sun
-# recommendation makes the compile fail on gcc2.7. JRA.
-#
-       *solaris*)
-               case `uname -r` in
-                       5.0*|5.1*|5.2*|5.3*|5.5*)
-                               AC_MSG_RESULT([no large file support])
-                               ;;
-                       5.*)
-                       AC_MSG_RESULT([enabling large file support])
-                       if test "$ac_cv_prog_gcc" = yes; then
-                               ${CC-cc} -v >conftest.c 2>&1
-                               ac_cv_gcc_compiler_version_number=`grep 'gcc version' conftest.c`
-                               rm -fr conftest.c
-                               case "$ac_cv_gcc_compiler_version_number" in
-                                       *"gcc version 2.6"*|*"gcc version 2.7"*)
-                                               CPPFLAGS="$CPPFLAGS -D_LARGEFILE64_SOURCE"
-                                               AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
-                                               ;;
-                                       *)
-                                               CPPFLAGS="$CPPFLAGS -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
-                                               AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
-                                               AC_DEFINE(_FILE_OFFSET_BITS, 64, [File offset bits])
-                                               ;;
-                               esac
-                       else
-                               CPPFLAGS="$CPPFLAGS -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
-                               AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
-                               AC_DEFINE(_FILE_OFFSET_BITS, 64, [File offset bits])
-                       fi
-                       ;;
-               esac
-               ;;
+    ;;
 #
 # VOS may need to have POSIX support and System V compatibility enabled.
 #
     *vos*)
-    case "$CPPFLAGS" in
-         *-D_POSIX_C_SOURCE*)
+          case "$CPPFLAGS" in
+             *-D_POSIX_C_SOURCE*)
                ;;
          *)
-               CPPFLAGS="$CPPFLAGS -D_POSIX_C_SOURCE=199506L"
-               AC_DEFINE(_POSIX_C_SOURCE, 199506L, [Whether to enable POSIX support])
+               CPPFLAGS="$CPPFLAGS -D_POSIX_C_SOURCE=200112L"
+               AC_DEFINE(_POSIX_C_SOURCE, 200112L, [Whether to enable POSIX support])
                ;;
-    esac
-    case "$CPPFLAGS" in
-         *-D_SYSV*|*-D_SVID_SOURCE*)
+          esac
+          case "$CPPFLAGS" in
+            *-D_SYSV*|*-D_SVID_SOURCE*)
                ;;
-         *)
+            *)
                CPPFLAGS="$CPPFLAGS -D_SYSV"
                AC_DEFINE(_SYSV, 1, [Whether to enable System V compatibility])
-    esac
-    ;;
-#
-# Tests needed for SINIX large file support.
-#
-    *sysv4*)
-      if test $host = mips-sni-sysv4 ; then
-        AC_MSG_CHECKING([for LFS support])
-        old_CPPFLAGS="$CPPFLAGS"
-        CPPFLAGS="-D_LARGEFILE64_SOURCE $CPPFLAGS"
-        AC_TRY_RUN([
-#include <unistd.h>
-main () {
-#if _LFS64_LARGEFILE == 1
-exit(0);
-#else
-exit(1);
-#endif
-}], [SINIX_LFS_SUPPORT=yes], [SINIX_LFS_SUPPORT=no], [SINIX_LFS_SUPPORT=cross])
-        CPPFLAGS="$old_CPPFLAGS"
-        if test x$SINIX_LFS_SUPPORT = xyes ; then
-          CPPFLAGS="-D_LARGEFILE64_SOURCE $CPPFLAGS"
-                 AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
-          CFLAGS="`getconf LFS64_CFLAGS` $CFLAGS"
-          LDFLAGS="`getconf LFS64_LDFLAGS` $LDFLAGS"
-          LIBS="`getconf LFS64_LIBS` $LIBS"
-        fi
-      AC_MSG_RESULT([$SINIX_LFS_SUPPORT])
-      fi
-    ;;
-
-# Tests for linux LFS support. Need kernel 2.4 and glibc2.2 or greater support.
-#
-    *linux*)
-        AC_MSG_CHECKING([for LFS support])
-        old_CPPFLAGS="$CPPFLAGS"
-        CPPFLAGS="-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE $CPPFLAGS"
-       AC_TRY_RUN([
-#include <unistd.h>
-#include <sys/utsname.h>
-#include <string.h>
-#include <stdlib.h>
-main() {
-#if _LFS64_LARGEFILE == 1
-       struct utsname uts;
-       char *release;
-       int major, minor;
-
-       /* Ensure this is glibc 2.2 or higher */
-#if defined(__GLIBC__) && defined(__GLIBC_MINOR__)
-       int libc_major = __GLIBC__;
-       int libc_minor = __GLIBC_MINOR__;
-
-       if (libc_major < 2)
-              exit(1);
-       if (libc_minor < 2)
-              exit(1);
-#endif
-
-       /* Ensure this is kernel 2.4 or higher */
-
-       uname(&uts);
-       release = uts.release;
-       major = atoi(strsep(&release, "."));
-       minor = atoi(strsep(&release, "."));
-
-       if (major > 2 || (major == 2 && minor > 3))
-               exit(0);
-       exit(1);
-#else
-       exit(1);
-#endif
-}
-], [LINUX_LFS_SUPPORT=yes], [LINUX_LFS_SUPPORT=no], [LINUX_LFS_SUPPORT=cross])
-        CPPFLAGS="$old_CPPFLAGS"
-        if test x$LINUX_LFS_SUPPORT = xyes ; then
-          CPPFLAGS="-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE $CPPFLAGS"
-                 AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
-          AC_DEFINE(_FILE_OFFSET_BITS, 64, [File offset bits])
-          AC_DEFINE(_GNU_SOURCE, 1, [Whether to use GNU libc extensions])
-        fi
-       AC_MSG_RESULT([$LINUX_LFS_SUPPORT])
-               ;;
-
-    *hurd*)
-        AC_MSG_CHECKING([for LFS support])
-        old_CPPFLAGS="$CPPFLAGS"
-        CPPFLAGS="-D_LARGEFILE64_SOURCE -D_GNU_SOURCE $CPPFLAGS"
-        AC_TRY_RUN([
-#include <unistd.h>
-main () {
-#if _LFS64_LARGEFILE == 1
-exit(0);
-#else
-exit(1);
-#endif
-}], [GLIBC_LFS_SUPPORT=yes], [GLIBC_LFS_SUPPORT=no], [GLIBC_LFS_SUPPORT=cross])
-        CPPFLAGS="$old_CPPFLAGS"
-        if test x$GLIBC_LFS_SUPPORT = xyes ; then
-          CPPFLAGS="-D_LARGEFILE64_SOURCE -D_GNU_SOURCE $CPPFLAGS"
-                 AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Whether to enable large file support])
-          AC_DEFINE(_GNU_SOURCE, 1, [Whether to use GNU libc extensions])
-        fi
-      AC_MSG_RESULT([$GLIBC_LFS_SUPPORT])
+          esac
     ;;
 
 esac
 
-AC_INLINE
-AC_HEADER_STDC
+
 AC_HEADER_DIRENT
 AC_HEADER_TIME
 AC_HEADER_SYS_WAIT
 AC_CHECK_HEADERS(arpa/inet.h sys/select.h fcntl.h sys/fcntl.h sys/time.h)
-AC_CHECK_HEADERS(unistd.h utime.h grp.h sys/id.h limits.h memory.h net/if.h)
+AC_CHECK_HEADERS(utime.h grp.h sys/id.h limits.h memory.h net/if.h)
 AC_CHECK_HEADERS(compat.h)
 AC_CHECK_HEADERS(sys/param.h ctype.h sys/wait.h sys/resource.h sys/ioctl.h sys/ipc.h sys/mode.h)
 AC_CHECK_HEADERS(sys/mman.h sys/filio.h sys/priv.h sys/shm.h string.h strings.h stdlib.h sys/socket.h)
@@ -300,34 +61,13 @@ AC_CHECK_HEADERS(sys/mount.h sys/vfs.h sys/fs/s5param.h sys/filsys.h termios.h t
 AC_CHECK_HEADERS(sys/termio.h sys/statfs.h sys/dustat.h sys/statvfs.h stdarg.h sys/sockio.h)
 AC_CHECK_HEADERS(security/pam_modules.h security/_pam_macros.h dlfcn.h)
 AC_CHECK_HEADERS(sys/syslog.h syslog.h)
-
-#
-# HPUX has a bug in that including shadow.h causes a re-definition of MAXINT.
-# This causes configure to fail to detect it. Check for shadow separately on HPUX.
-#
-case "$host_os" in
-    *hpux*)
-               AC_TRY_COMPILE([#include <shadow.h>],[struct spwd testme],
-                       ac_cv_header_shadow_h=yes,ac_cv_header_shadow_h=no)
-               if test x"$ac_cv_header_shadow_h" = x"yes"; then
-                  AC_DEFINE(HAVE_SHADOW_H,1,[Whether we have shadow.h])
-               fi
-       ;;
-esac
+AC_CHECK_HEADERS(stdint.h locale.h)
 AC_CHECK_HEADERS(shadow.h netinet/ip.h netinet/tcp.h netinet/in_systm.h netinet/in_ip.h)
 AC_CHECK_HEADERS(nss.h nss_common.h ns_api.h sys/security.h security/pam_appl.h security/pam_modules.h)
 AC_CHECK_HEADERS(stropts.h)
 AC_CHECK_HEADERS(sys/capability.h syscall.h sys/syscall.h)
 AC_CHECK_HEADERS(sys/acl.h)
 
-AC_CHECK_SIZEOF(int,cross)
-AC_CHECK_SIZEOF(long,cross)
-AC_CHECK_SIZEOF(short,cross)
-
-AC_C_CONST
-AC_C_INLINE
-AC_C_BIGENDIAN
-AC_C_CHAR_UNSIGNED
 
 AC_TYPE_SIGNAL
 AC_TYPE_UID_T
@@ -341,35 +81,20 @@ AC_CHECK_TYPE(ino_t,unsigned)
 AC_CHECK_TYPE(loff_t,off_t)
 AC_CHECK_TYPE(offset_t,loff_t)
 AC_CHECK_TYPE(ssize_t, int)
-AC_CHECK_TYPE(wchar_t, unsigned short)
-AC_CHECK_TYPE(uint_t, unsigned int)
+AC_CHECK_TYPES(intptr_t)
+
 
 ############################################
 # we need dlopen/dlclose/dlsym/dlerror for PAM, the password database plugins and the plugin loading code
-AC_SEARCH_LIBS(dlopen, [dl])
+AC_SEARCH_LIBS(dlopen, [dl], [
+                          tmp=$ac_cv_search_dlopen
+                          if test "$ac_cv_search_dlopen" = "none required"; then 
+                              tmp=""
+                          fi
+                          SMB_EXT_LIB(DL, [$tmp])]
+                          )
 # dlopen/dlclose/dlsym/dlerror will be checked again later and defines will be set then
 
-############################################
-# check if the compiler can do immediate structures
-AC_CACHE_CHECK([for immediate structures],samba_cv_immediate_structures, [
-    AC_TRY_COMPILE([
-#include <stdio.h>],
-[
-   typedef struct {unsigned x;} FOOBAR;
-   #define X_FOOBAR(x) ((FOOBAR) { x })
-   #define FOO_ONE X_FOOBAR(1)
-   FOOBAR f = FOO_ONE;   
-   static struct {
-       FOOBAR y; 
-       } f2[] = {
-               {FOO_ONE}
-       };   
-],
-       samba_cv_immediate_structures=yes,samba_cv_immediate_structures=no)])
-if test x"$samba_cv_immediate_structures" = x"yes"; then
-   AC_DEFINE(HAVE_IMMEDIATE_STRUCTURES,1,[Whether the compiler supports immediate structures])
-fi
-
 ############################################
 # check for unix domain sockets
 AC_CACHE_CHECK([for unix domain sockets],samba_cv_unixsocket, [
@@ -424,27 +149,6 @@ AC_HAVE_DECL(vasprintf, [#include <stdio.h>])
 AC_HAVE_DECL(vsnprintf, [#include <stdio.h>])
 AC_HAVE_DECL(snprintf, [#include <stdio.h>])
 
-# and glibc has setresuid under linux but the function does
-# nothing until kernel 2.1.44! very dumb.
-AC_CACHE_CHECK([for real setresuid],samba_cv_have_setresuid,[
-    AC_TRY_RUN([#include <errno.h>
-main() { setresuid(1,1,1); setresuid(2,2,2); exit(errno==EPERM?0:1);}],
-       samba_cv_have_setresuid=yes,samba_cv_have_setresuid=no,samba_cv_have_setresuid=cross)])
-if test x"$samba_cv_have_setresuid" = x"yes"; then
-    AC_DEFINE(HAVE_SETRESUID,1,[Whether the system has setresuid])
-fi
-
-# Do the same check for setresguid...
-#
-AC_CACHE_CHECK([for real setresgid],samba_cv_have_setresgid,[
-    AC_TRY_RUN([#include <unistd.h>
-#include <errno.h>
-main() { errno = 0; setresgid(1,1,1); exit(errno != 0 ? (errno==EPERM ? 0 : 1) : 0);}],
-       samba_cv_have_setresgid=yes,samba_cv_have_setresgid=no,samba_cv_have_setresgid=cross)])
-if test x"$samba_cv_have_setresgid" = x"yes"; then
-    AC_DEFINE(HAVE_SETRESGID,1,[Whether the system has setresgid])
-fi
-
 AC_FUNC_MEMCMP
 
 # The following test taken from the cvs sources
@@ -481,122 +185,27 @@ if test x"$ac_cv_func_connect" = x"no"; then
     fi
 fi
 
-###############################################
-# test for where we get yp_get_default_domain() from
-AC_SEARCH_LIBS(yp_get_default_domain, [nsl])
-AC_CHECK_FUNCS(yp_get_default_domain)
-
-# Check if we have execl, if not we need to compile smbrun.
-AC_CHECK_FUNCS(execl)
-if test x"$ac_cv_func_execl" = x"no"; then
-    EXTRA_BIN_PROGS="$EXTRA_BIN_PROGS bin/smbrun\$(EXEEXT)"
-fi
-
-AC_CHECK_FUNCS(dlopen dlclose dlsym dlerror waitpid getcwd strdup strndup strnlen strtoul strerror chown fchown chmod fchmod chroot link mknod mknod64)
+AC_CHECK_FUNCS(dlopen dlclose dlsym dlerror waitpid getcwd strdup strndup strnlen strtoul strtoull strtouq strerror chown fchown chmod fchmod chroot link mknod mknod64)
 AC_CHECK_FUNCS(fstat strchr utime utimes getrlimit fsync bzero memset strlcpy strlcat setpgid)
 AC_CHECK_FUNCS(memmove vsnprintf snprintf asprintf vasprintf setsid glob strpbrk pipe crypt16 getauthuid)
 AC_CHECK_FUNCS(strftime sigprocmask sigblock sigaction sigset innetgr setnetgrent getnetgrent endnetgrent)
 AC_CHECK_FUNCS(initgroups select rdchk getgrnam getgrent pathconf realpath)
-AC_CHECK_FUNCS(setpriv setgidx setuidx setgroups sysconf mktime rename ftruncate stat64 fstat64)
-AC_CHECK_FUNCS(lstat64 fopen64 atexit grantpt dup2 lseek64 ftruncate64 readdir64)
-AC_CHECK_FUNCS(fseek64 fseeko64 ftell64 ftello64 setluid getpwanam setlinebuf)
+AC_CHECK_FUNCS(setpriv setgidx setuidx setgroups sysconf mktime rename ftruncate)
+AC_CHECK_FUNCS(setluid getpwanam setlinebuf)
 AC_CHECK_FUNCS(srandom random srand rand setenv usleep strcasecmp fcvt fcvtl symlink readlink)
-AC_CHECK_FUNCS(syslog vsyslog getgrouplist timegm)
-# setbuffer, shmget, shm_open are needed for smbtorture
-AC_CHECK_FUNCS(setbuffer shmget shm_open)
-
-# syscall() is needed for smbwrapper.
-AC_CHECK_FUNCS(syscall)
-
-AC_CHECK_FUNCS(_dup _dup2 _opendir _readdir _seekdir _telldir _closedir)
-AC_CHECK_FUNCS(__dup __dup2 __opendir __readdir __seekdir __telldir __closedir)
-AC_CHECK_FUNCS(__getcwd _getcwd)
-AC_CHECK_FUNCS(__xstat __fxstat __lxstat)
-AC_CHECK_FUNCS(_stat _lstat _fstat __stat __lstat __fstat)
-AC_CHECK_FUNCS(_acl __acl _facl __facl _open __open _chdir __chdir)
-AC_CHECK_FUNCS(_close __close _fchdir __fchdir _fcntl __fcntl)
-AC_CHECK_FUNCS(getdents _getdents __getdents _lseek __lseek _read __read)
-AC_CHECK_FUNCS(getdirentries _write __write _fork __fork)
-AC_CHECK_FUNCS(_stat64 __stat64 _fstat64 __fstat64 _lstat64 __lstat64)
-AC_CHECK_FUNCS(__sys_llseek llseek _llseek __llseek readdir64 _readdir64 __readdir64)
-AC_CHECK_FUNCS(pread _pread __pread pread64 _pread64 __pread64)
-AC_CHECK_FUNCS(pwrite _pwrite __pwrite pwrite64 _pwrite64 __pwrite64)
-AC_CHECK_FUNCS(open64 _open64 __open64 creat64)
+AC_CHECK_FUNCS(syslog vsyslog getgrouplist timegm backtrace)
+AC_CHECK_FUNCS(setbuffer)
 
-#
-# stat64 family may need <sys/stat.h> on some systems, notably ReliantUNIX
-#
-
-if test x$ac_cv_func_stat64 = xno ; then
-  AC_MSG_CHECKING([for stat64 in <sys/stat.h>])
-  AC_TRY_LINK([
-#if defined(HAVE_UNISTD_H)
-#include <unistd.h>
-#endif
-#include <sys/stat.h>
-], [struct stat64 st64; exit(stat64(".",&st64));], [ac_cv_func_stat64=yes])
-  AC_MSG_RESULT([$ac_cv_func_stat64])
-  if test x$ac_cv_func_stat64 = xyes ; then
-    AC_DEFINE(HAVE_STAT64,1,[Whether stat64() is available])
-  fi
-fi
+AC_CHECK_FUNCS(getdents)
+AC_CHECK_FUNCS(pread pwrite)
 
-if test x$ac_cv_func_lstat64 = xno ; then
-  AC_MSG_CHECKING([for lstat64 in <sys/stat.h>])
-  AC_TRY_LINK([
-#if defined(HAVE_UNISTD_H)
-#include <unistd.h>
-#endif
-#include <sys/stat.h>
-], [struct stat64 st64; exit(lstat64(".",&st64));], [ac_cv_func_lstat64=yes])
-  AC_MSG_RESULT([$ac_cv_func_lstat64])
-  if test x$ac_cv_func_lstat64 = xyes ; then
-    AC_DEFINE(HAVE_LSTAT64,[Whether lstat64() is available])
-  fi
-fi
-
-if test x$ac_cv_func_fstat64 = xno ; then
-  AC_MSG_CHECKING([for fstat64 in <sys/stat.h>])
-  AC_TRY_LINK([
-#if defined(HAVE_UNISTD_H)
-#include <unistd.h>
-#endif
-#include <sys/stat.h>
-], [struct stat64 st64; exit(fstat64(0,&st64));], [ac_cv_func_fstat64=yes])
-  AC_MSG_RESULT([$ac_cv_func_fstat64])
-  if test x$ac_cv_func_fstat64 = xyes ; then
-    AC_DEFINE(HAVE_FSTAT64,1,[Whether fstat64() is available])
-  fi
-fi
+# needed for lib/charcnv.c
+AC_CHECK_FUNCS(setlocale)
 
 #####################################
 # we might need the resolv library on some systems
 AC_CHECK_LIB(resolv, dn_expand)
 
-#
-# Check for the functions putprpwnam, set_auth_parameters,
-# getspnam, bigcrypt and getprpwnam in -lsec and -lsecurity
-# Needed for OSF1 and HPUX.
-#
-
-AC_LIBTESTFUNC(security, putprpwnam)
-AC_LIBTESTFUNC(sec, putprpwnam)
-
-AC_LIBTESTFUNC(security, set_auth_parameters)
-AC_LIBTESTFUNC(sec, set_auth_parameters)
-
-# UnixWare 7.x has its getspnam in -lgen
-AC_LIBTESTFUNC(gen, getspnam)
-
-AC_LIBTESTFUNC(security, getspnam)
-AC_LIBTESTFUNC(sec, getspnam)
-
-AC_LIBTESTFUNC(security, bigcrypt)
-AC_LIBTESTFUNC(sec, bigcrypt)
-
-AC_LIBTESTFUNC(security, getprpwnam)
-AC_LIBTESTFUNC(sec, getprpwnam)
-
 # Assume non-shared by default and override below
 BLDSHARED="false"
 
@@ -610,166 +219,159 @@ PICSUFFIX="po"
 POBAD_CC="#"
 SHLIBEXT="so"
 
-if test "$enable_shared" = "yes"; then
-  # this bit needs to be modified for each OS that is suported by
-  # smbwrapper. You need to specify how to created a shared library and
-  # how to compile C code to produce PIC object files
-
-  AC_MSG_CHECKING([ability to build shared libraries])
+AC_MSG_CHECKING([ability to build shared libraries])
 
-  # and these are for particular systems
-  case "$host_os" in
-               *linux*)   AC_DEFINE(LINUX,1,[Whether the host os is linux])
-                       BLDSHARED="true"
-                       LDSHFLAGS="-shared" 
-                       DYNEXP="-Wl,--export-dynamic"
+# and these are for particular systems
+case "$host_os" in
+       *linux*)   AC_DEFINE(LINUX,1,[Whether the host os is linux])
+               BLDSHARED="true"
+               LDSHFLAGS="-shared" 
+               DYNEXP="-Wl,--export-dynamic"
+               PICFLAG="-fPIC"
+               SONAMEFLAG="-Wl,-soname="
+               AC_DEFINE(STAT_ST_BLOCKSIZE,512)
+               ;;
+       *solaris*) AC_DEFINE(SUNOS5,1,[Whether the host os is solaris])
+               BLDSHARED="true"
+               LDSHFLAGS="-G"
+               SONAMEFLAG="-h "
+               if test "${GCC}" = "yes"; then
                        PICFLAG="-fPIC"
-                       SONAMEFLAG="-Wl,-soname="
-                       AC_DEFINE(STAT_ST_BLOCKSIZE,512)
-                       ;;
-               *solaris*) AC_DEFINE(SUNOS5,1,[Whether the host os is solaris])
-                       BLDSHARED="true"
-                       LDSHFLAGS="-G"
-                       SONAMEFLAG="-h "
-                       if test "${GCC}" = "yes"; then
-                               PICFLAG="-fPIC"
-                               if test "${ac_cv_prog_gnu_ld}" = "yes"; then
-                                       DYNEXP="-Wl,-E"
-                               fi
-                       else
-                               PICFLAG="-KPIC"
-                               ## ${CFLAGS} added for building 64-bit shared 
-                               ## libs using Sun's Compiler
-                               LDSHFLAGS="-G \${CFLAGS}"
-                               POBAD_CC=""
-                               PICSUFFIX="po.o"
+                       if test "${ac_cv_prog_gnu_ld}" = "yes"; then
+                               DYNEXP="-Wl,-E"
                        fi
-                       AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block])
-                       ;;
-               *sunos*) AC_DEFINE(SUNOS4,1,[Whether the host os is sunos4])
-                       BLDSHARED="true"
-                       LDSHFLAGS="-G"
-                       SONAMEFLAG="-Wl,-h,"
-                       PICFLAG="-KPIC"   # Is this correct for SunOS
-                       AC_DEFINE(STAT_ST_BLOCKSIZE,512)
-                       ;;
-               *netbsd* | *freebsd*)  BLDSHARED="true"
-                       LDSHFLAGS="-shared"
-                       DYNEXP="-Wl,--export-dynamic"
-                       SONAMEFLAG="-Wl,-soname,"
-                       PICFLAG="-fPIC -DPIC"
-                       AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block])
-                       ;;
-               *openbsd*)  BLDSHARED="true"
-                       LDSHFLAGS="-shared"
-                       DYNEXP="-Wl,-Bdynamic"
-                       SONAMEFLAG="-Wl,-soname,"
+               else
+                       PICFLAG="-KPIC"
+                       ## ${CFLAGS} added for building 64-bit shared 
+                       ## libs using Sun's Compiler
+                       LDSHFLAGS="-G \${CFLAGS}"
+                       POBAD_CC=""
+                       PICSUFFIX="po.o"
+               fi
+               AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block])
+               ;;
+       *sunos*) AC_DEFINE(SUNOS4,1,[Whether the host os is sunos4])
+               BLDSHARED="true"
+               LDSHFLAGS="-G"
+               SONAMEFLAG="-Wl,-h,"
+               PICFLAG="-KPIC"   # Is this correct for SunOS
+               AC_DEFINE(STAT_ST_BLOCKSIZE,512)
+               ;;
+       *netbsd* | *freebsd*)  BLDSHARED="true"
+               LDSHFLAGS="-shared"
+               DYNEXP="-Wl,--export-dynamic"
+               SONAMEFLAG="-Wl,-soname,"
+               PICFLAG="-fPIC -DPIC"
+               AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block])
+               ;;
+       *openbsd*)  BLDSHARED="true"
+               LDSHFLAGS="-shared"
+               DYNEXP="-Wl,-Bdynamic"
+               SONAMEFLAG="-Wl,-soname,"
+               PICFLAG="-fPIC"
+               AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block])
+               ;;
+       *irix*) AC_DEFINE(IRIX,1,[Whether the host os is irix])
+               case "$host_os" in
+               *irix6*) AC_DEFINE(IRIX6,1,[Whether the host os is irix6])
+               ;;
+               esac
+               ATTEMPT_WRAP32_BUILD=yes
+               BLDSHARED="true"
+               LDSHFLAGS="-set_version sgi1.0 -shared"
+               SONAMEFLAG="-soname "
+               SHLD="\${LD}"
+               if test "${GCC}" = "yes"; then
                        PICFLAG="-fPIC"
-                       AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block])
-                       ;;
-               *irix*) AC_DEFINE(IRIX,1,[Whether the host os is irix])
-                       case "$host_os" in
-                       *irix6*) AC_DEFINE(IRIX6,1,[Whether the host os is irix6])
-                       ;;
-                       esac
-                       ATTEMPT_WRAP32_BUILD=yes
-                       BLDSHARED="true"
-                       LDSHFLAGS="-set_version sgi1.0 -shared"
-                       SONAMEFLAG="-soname "
-                       SHLD="\${LD}"
-                       if test "${GCC}" = "yes"; then
-                               PICFLAG="-fPIC"
-                       else 
-                               PICFLAG="-KPIC"
-                       fi
-                       AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block])
-                       ;;
-               *aix*) AC_DEFINE(AIX,1,[Whether the host os is aix])
-                       BLDSHARED="true"
-                       LDSHFLAGS="-Wl,-bexpall,-bM:SRE,-bnoentry"
-                       DYNEXP="-Wl,-brtl,-bexpall"
-                       PICFLAG="-O2"
-                       if test "${GCC}" != "yes"; then
-                               ## for funky AIX compiler using strncpy()
-                               CFLAGS="$CFLAGS -D_LINUX_SOURCE_COMPAT -qmaxmem=32000"
-                       fi
+               else 
+                       PICFLAG="-KPIC"
+               fi
+               AC_DEFINE(STAT_ST_BLOCKSIZE,512,[The size of a block])
+               ;;
+       *aix*) AC_DEFINE(AIX,1,[Whether the host os is aix])
+               BLDSHARED="true"
+               LDSHFLAGS="-Wl,-bexpall,-bM:SRE,-bnoentry"
+               DYNEXP="-Wl,-brtl,-bexpall"
+               PICFLAG="-O2"
+               if test "${GCC}" != "yes"; then
+                       ## for funky AIX compiler using strncpy()
+                       CFLAGS="$CFLAGS -D_LINUX_SOURCE_COMPAT -qmaxmem=32000"
+               fi
 
-                       AC_DEFINE(STAT_ST_BLOCKSIZE,DEV_BSIZE,[The size of a block])
-                       ;;
-               *hpux*) AC_DEFINE(HPUX,1,[Whether the host os is HPUX])
-                       SHLIBEXT="sl"
-                       # Use special PIC flags for the native HP-UX compiler.
-                       if test $ac_cv_prog_cc_Ae = yes; then
-                               BLDSHARED="true"
-                               SHLD="/usr/bin/ld"
-                               LDSHFLAGS="-B symbolic -b -z"
-                               SONAMEFLAG="+h "
-                               PICFLAG="+z"
-                       fi
-                       DYNEXP="-Wl,-E"
-                       AC_DEFINE(STAT_ST_BLOCKSIZE,8192,[The size of a block])
-                       ;;
-               *qnx*) AC_DEFINE(QNX,1,[Whether the host os is qnx])
-                       AC_DEFINE(STAT_ST_BLOCKSIZE,512)
-                       ;;
-               *osf*) AC_DEFINE(OSF1,1,[Whether the host os is osf1])
-                       BLDSHARED="true"
-                       LDSHFLAGS="-shared"
-                       SONAMEFLAG="-Wl,-soname,"
-                       PICFLAG="-fPIC"
-                       AC_DEFINE(STAT_ST_BLOCKSIZE,512)
-                       ;;
-               *sco*) AC_DEFINE(SCO,1,[Whether the host os is sco unix])
-                       AC_DEFINE(STAT_ST_BLOCKSIZE,512)
-                       ;;
-               *unixware*) AC_DEFINE(UNIXWARE,1,[Whether the host os is unixware])
+               AC_DEFINE(STAT_ST_BLOCKSIZE,DEV_BSIZE,[The size of a block])
+               ;;
+       *hpux*) AC_DEFINE(HPUX,1,[Whether the host os is HPUX])
+               SHLIBEXT="sl"
+               # Use special PIC flags for the native HP-UX compiler.
+               if test $ac_cv_prog_cc_Ae = yes; then
                        BLDSHARED="true"
-                       LDSHFLAGS="-shared"
-                       SONAMEFLAG="-Wl,-soname,"
-                       PICFLAG="-KPIC"
-                       AC_DEFINE(STAT_ST_BLOCKSIZE,512)
-                       ;;
-               *next2*) AC_DEFINE(NEXT2,1,[Whether the host os is NeXT v2])
-                       AC_DEFINE(STAT_ST_BLOCKSIZE,512)
-                       ;;
-               *dgux*) AC_CHECK_PROG( ROFF, groff, [groff -etpsR -Tascii -man])
-                       AC_DEFINE(STAT_ST_BLOCKSIZE,512)
-                       ;;
-               *sysv4*) AC_DEFINE(SYSV,1,[Whether this is a system V system])
-                       case "$host" in
-                               *-univel-*)     if [ test "$GCC" != yes ]; then
-                                               AC_DEFINE(HAVE_MEMSET,1,[Whether memset() is available])
-                                       fi
-                                       LDSHFLAGS="-G"
-                                       DYNEXP="-Bexport"
-                               ;;
-                               *mips-sni-sysv4*) AC_DEFINE(RELIANTUNIX,1,[Whether the host os is reliantunix]);;
-                       esac
-                       AC_DEFINE(STAT_ST_BLOCKSIZE,512)
+                       SHLD="/usr/bin/ld"
+                       LDSHFLAGS="-B symbolic -b -z"
+                       SONAMEFLAG="+h "
+                       PICFLAG="+z"
+               fi
+               DYNEXP="-Wl,-E"
+               AC_DEFINE(STAT_ST_BLOCKSIZE,8192,[The size of a block])
+               ;;
+       *qnx*) AC_DEFINE(QNX,1,[Whether the host os is qnx])
+               AC_DEFINE(STAT_ST_BLOCKSIZE,512)
+               ;;
+       *osf*) AC_DEFINE(OSF1,1,[Whether the host os is osf1])
+               BLDSHARED="true"
+               LDSHFLAGS="-shared"
+               SONAMEFLAG="-Wl,-soname,"
+               PICFLAG="-fPIC"
+               AC_DEFINE(STAT_ST_BLOCKSIZE,512)
+               ;;
+       *sco*) AC_DEFINE(SCO,1,[Whether the host os is sco unix])
+               AC_DEFINE(STAT_ST_BLOCKSIZE,512)
+               ;;
+       *unixware*) AC_DEFINE(UNIXWARE,1,[Whether the host os is unixware])
+               BLDSHARED="true"
+               LDSHFLAGS="-shared"
+               SONAMEFLAG="-Wl,-soname,"
+               PICFLAG="-KPIC"
+               AC_DEFINE(STAT_ST_BLOCKSIZE,512)
+               ;;
+       *next2*) AC_DEFINE(NEXT2,1,[Whether the host os is NeXT v2])
+               AC_DEFINE(STAT_ST_BLOCKSIZE,512)
+               ;;
+       *dgux*) AC_CHECK_PROG( ROFF, groff, [groff -etpsR -Tascii -man])
+               AC_DEFINE(STAT_ST_BLOCKSIZE,512)
+               ;;
+       *sysv4*) AC_DEFINE(SYSV,1,[Whether this is a system V system])
+               case "$host" in
+                       *-univel-*)     if [ test "$GCC" != yes ]; then
+                                       AC_DEFINE(HAVE_MEMSET,1,[Whether memset() is available])
+                               fi
+                               LDSHFLAGS="-G"
+                                       DYNEXP="-Bexport"
                        ;;
+                       *mips-sni-sysv4*) AC_DEFINE(RELIANTUNIX,1,[Whether the host os is reliantunix]);;
+               esac
+               AC_DEFINE(STAT_ST_BLOCKSIZE,512)
+               ;;
 
-               *sysv5*) AC_DEFINE(SYSV,1,[Whether this is a system V system])
-                       if [ test "$GCC" != yes ]; then
-                               AC_DEFINE(HAVE_MEMSET,1,[Whether memset() is available])
-                       fi
-                       LDSHFLAGS="-G"
-                       AC_DEFINE(STAT_ST_BLOCKSIZE,512)
-                       ;;
-               *vos*) AC_DEFINE(STAT_ST_BLOCKSIZE,4096)
-                       BLDSHARED="false"
-                       LDSHFLAGS=""
-                       ;;
-               *)
-                       AC_DEFINE(STAT_ST_BLOCKSIZE,512)
-                       ;;
-  esac
-  AC_SUBST(DYNEXP)
-  AC_MSG_RESULT($BLDSHARED)
-  AC_MSG_CHECKING([linker flags for shared libraries])
-  AC_MSG_RESULT([$LDSHFLAGS])
-  AC_MSG_CHECKING([compiler flags for position-independent code])
-  AC_MSG_RESULT([$PICFLAGS])
-fi
+       *sysv5*) AC_DEFINE(SYSV,1,[Whether this is a system V system])
+               if [ test "$GCC" != yes ]; then
+                       AC_DEFINE(HAVE_MEMSET,1,[Whether memset() is available])
+               fi
+               LDSHFLAGS="-G"
+               AC_DEFINE(STAT_ST_BLOCKSIZE,512)
+               ;;
+       *vos*) AC_DEFINE(STAT_ST_BLOCKSIZE,4096)
+               BLDSHARED="false"
+               LDSHFLAGS=""
+               ;;
+       *)
+               AC_DEFINE(STAT_ST_BLOCKSIZE,512)
+               ;;
+esac
+AC_MSG_RESULT($BLDSHARED)
+AC_MSG_CHECKING([linker flags for shared libraries])
+AC_MSG_RESULT([$LDSHFLAGS])
+AC_MSG_CHECKING([compiler flags for position-independent code])
+AC_MSG_RESULT([$PICFLAGS])
 
 #######################################################
 # test whether building a shared library actually works
@@ -795,130 +397,6 @@ if test $ac_cv_shlib_works = no; then
 fi
 fi
 
-################
-
-AC_CACHE_CHECK([for long long],samba_cv_have_longlong,[
-AC_TRY_RUN([#include <stdio.h>
-main() { long long x = 1000000; x *= x; exit(((x/1000000) == 1000000)? 0: 1); }],
-samba_cv_have_longlong=yes,samba_cv_have_longlong=no,samba_cv_have_longlong=cross)])
-if test x"$samba_cv_have_longlong" = x"yes"; then
-    AC_DEFINE(HAVE_LONGLONG,1,[Whether the host supports long long's])
-fi
-
-#
-# Check if the compiler supports the LL prefix on long long integers.
-# AIX needs this.
-
-AC_CACHE_CHECK([for LL suffix on long long integers],samba_cv_compiler_supports_ll, [
-    AC_TRY_COMPILE([#include <stdio.h>],[long long i = 0x8000000000LL],
-       samba_cv_compiler_supports_ll=yes,samba_cv_compiler_supports_ll=no)])
-if test x"$samba_cv_compiler_supports_ll" = x"yes"; then
-   AC_DEFINE(COMPILER_SUPPORTS_LL,1,[Whether the compiler supports the LL prefix on long long integers])
-fi
-
-  
-AC_CACHE_CHECK([for 64 bit off_t],samba_cv_SIZEOF_OFF_T,[
-AC_TRY_RUN([#include <stdio.h>
-#include <sys/stat.h>
-main() { exit((sizeof(off_t) == 8) ? 0 : 1); }],
-samba_cv_SIZEOF_OFF_T=yes,samba_cv_SIZEOF_OFF_T=no,samba_cv_SIZEOF_OFF_T=cross)])
-if test x"$samba_cv_SIZEOF_OFF_T" = x"yes"; then
-    AC_DEFINE(SIZEOF_OFF_T,8,[The size of the 'off_t' type])
-fi
-
-AC_CACHE_CHECK([for off64_t],samba_cv_HAVE_OFF64_T,[
-AC_TRY_RUN([
-#if defined(HAVE_UNISTD_H)
-#include <unistd.h>
-#endif
-#include <stdio.h>
-#include <sys/stat.h>
-main() { struct stat64 st; off64_t s; if (sizeof(off_t) == sizeof(off64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
-samba_cv_HAVE_OFF64_T=yes,samba_cv_HAVE_OFF64_T=no,samba_cv_HAVE_OFF64_T=cross)])
-if test x"$samba_cv_HAVE_OFF64_T" = x"yes"; then
-    AC_DEFINE(HAVE_OFF64_T,1,[Whether off64_t is available])
-fi
-
-AC_CACHE_CHECK([for 64 bit ino_t],samba_cv_SIZEOF_INO_T,[
-AC_TRY_RUN([#include <stdio.h>
-#include <sys/stat.h>
-main() { exit((sizeof(ino_t) == 8) ? 0 : 1); }],
-samba_cv_SIZEOF_INO_T=yes,samba_cv_SIZEOF_INO_T=no,samba_cv_SIZEOF_INO_T=cross)])
-if test x"$samba_cv_SIZEOF_INO_T" = x"yes"; then
-    AC_DEFINE(SIZEOF_INO_T,8,[The size of the 'ino_t' type])
-fi
-
-AC_CACHE_CHECK([for ino64_t],samba_cv_HAVE_INO64_T,[
-AC_TRY_RUN([
-#if defined(HAVE_UNISTD_H)
-#include <unistd.h>
-#endif
-#include <stdio.h>
-#include <sys/stat.h>
-main() { struct stat64 st; ino64_t s; if (sizeof(ino_t) == sizeof(ino64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
-samba_cv_HAVE_INO64_T=yes,samba_cv_HAVE_INO64_T=no,samba_cv_HAVE_INO64_T=cross)])
-if test x"$samba_cv_HAVE_INO64_T" = x"yes"; then
-    AC_DEFINE(HAVE_INO64_T,1,[Whether the 'ino64_t' type is available])
-fi
-
-AC_CACHE_CHECK([for dev64_t],samba_cv_HAVE_DEV64_T,[
-AC_TRY_RUN([
-#if defined(HAVE_UNISTD_H)
-#include <unistd.h>
-#endif
-#include <stdio.h>
-#include <sys/stat.h>
-main() { struct stat64 st; dev64_t s; if (sizeof(dev_t) == sizeof(dev64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
-samba_cv_HAVE_DEV64_T=yes,samba_cv_HAVE_DEV64_T=no,samba_cv_HAVE_DEV64_T=cross)])
-if test x"$samba_cv_HAVE_DEV64_T" = x"yes"; then
-    AC_DEFINE(HAVE_DEV64_T,1,[Whether the 'dev64_t' type is available])
-fi
-
-AC_CACHE_CHECK([for struct dirent64],samba_cv_HAVE_STRUCT_DIRENT64,[
-AC_TRY_COMPILE([
-#if defined(HAVE_UNISTD_H)
-#include <unistd.h>
-#endif
-#include <sys/types.h>
-#include <dirent.h>],
-[struct dirent64 de;],
-samba_cv_HAVE_STRUCT_DIRENT64=yes,samba_cv_HAVE_STRUCT_DIRENT64=no)])
-if test x"$samba_cv_HAVE_STRUCT_DIRENT64" = x"yes" && test x"$ac_cv_func_readdir64" = x"yes"; then
-    AC_DEFINE(HAVE_STRUCT_DIRENT64,1,[Whether the 'dirent64' struct is available])
-fi
-
-AC_CACHE_CHECK([for major macro],samba_cv_HAVE_DEVICE_MAJOR_FN,[
-AC_TRY_RUN([
-#if defined(HAVE_UNISTD_H)
-#include <unistd.h>
-#endif
-#include <sys/types.h>
-main() { dev_t dev; int i = major(dev); return 0; }],
-samba_cv_HAVE_DEVICE_MAJOR_FN=yes,samba_cv_HAVE_DEVICE_MAJOR_FN=no,samba_cv_HAVE_DEVICE_MAJOR_FN=cross)])
-if test x"$samba_cv_HAVE_DEVICE_MAJOR_FN" = x"yes"; then
-    AC_DEFINE(HAVE_DEVICE_MAJOR_FN,1,[Whether the major macro for dev_t is available])
-fi
-
-AC_CACHE_CHECK([for minor macro],samba_cv_HAVE_DEVICE_MINOR_FN,[
-AC_TRY_RUN([
-#if defined(HAVE_UNISTD_H)
-#include <unistd.h>
-#endif
-#include <sys/types.h>
-main() { dev_t dev; int i = minor(dev); return 0; }],
-samba_cv_HAVE_DEVICE_MINOR_FN=yes,samba_cv_HAVE_DEVICE_MINOR_FN=no,samba_cv_HAVE_DEVICE_MINOR_FN=cross)])
-if test x"$samba_cv_HAVE_DEVICE_MINOR_FN" = x"yes"; then
-    AC_DEFINE(HAVE_DEVICE_MINOR_FN,1,[Whether the minor macro for dev_t is available])
-fi
-
-AC_CACHE_CHECK([for unsigned char],samba_cv_HAVE_UNSIGNED_CHAR,[
-AC_TRY_RUN([#include <stdio.h>
-main() { char c; c=250; exit((c > 0)?0:1); }],
-samba_cv_HAVE_UNSIGNED_CHAR=yes,samba_cv_HAVE_UNSIGNED_CHAR=no,samba_cv_HAVE_UNSIGNED_CHAR=cross)])
-if test x"$samba_cv_HAVE_UNSIGNED_CHAR" = x"yes"; then
-    AC_DEFINE(HAVE_UNSIGNED_CHAR,1,[Whether the 'unsigned char' type is available])
-fi
-
 AC_CACHE_CHECK([for sin_len in sock],samba_cv_HAVE_SOCK_SIN_LEN,[
 AC_TRY_COMPILE([#include <sys/types.h>
 #include <sys/socket.h>
@@ -929,15 +407,6 @@ if test x"$samba_cv_HAVE_SOCK_SIN_LEN" = x"yes"; then
     AC_DEFINE(HAVE_SOCK_SIN_LEN,1,[Whether the sockaddr_in struct has a sin_len property])
 fi
 
-AC_CACHE_CHECK([whether seekdir returns void],samba_cv_SEEKDIR_RETURNS_VOID,[
-AC_TRY_COMPILE([#include <sys/types.h>
-#include <dirent.h>
-void seekdir(DIR *d, long loc) { return; }],[return 0;],
-samba_cv_SEEKDIR_RETURNS_VOID=yes,samba_cv_SEEKDIR_RETURNS_VOID=no)])
-if test x"$samba_cv_SEEKDIR_RETURNS_VOID" = x"yes"; then
-    AC_DEFINE(SEEKDIR_RETURNS_VOID,1,[Whether seekdir returns void])
-fi
-
 AC_CACHE_CHECK([for __FUNCTION__ macro],samba_cv_HAVE_FUNCTION_MACRO,[
 AC_TRY_COMPILE([#include <stdio.h>], [printf("%s\n", __FUNCTION__);],
 samba_cv_HAVE_FUNCTION_MACRO=yes,samba_cv_HAVE_FUNCTION_MACRO=no)])
@@ -955,12 +424,22 @@ if test x"$samba_cv_HAVE_GETTIMEOFDAY_TZ" = x"yes"; then
     AC_DEFINE(HAVE_GETTIMEOFDAY_TZ,1,[Whether gettimeofday() is available])
 fi
 
-AC_CACHE_CHECK([for __va_copy],samba_cv_HAVE_VA_COPY,[
+AC_CACHE_CHECK([for va_copy],samba_cv_HAVE_VA_COPY,[
 AC_TRY_LINK([#include <stdarg.h>
-va_list ap1,ap2;], [__va_copy(ap1,ap2);],
+va_list ap1,ap2;], [va_copy(ap1,ap2);],
 samba_cv_HAVE_VA_COPY=yes,samba_cv_HAVE_VA_COPY=no)])
 if test x"$samba_cv_HAVE_VA_COPY" = x"yes"; then
-    AC_DEFINE(HAVE_VA_COPY,1,[Whether __va_copy() is available])
+    AC_DEFINE(HAVE_VA_COPY,1,[Whether va_copy() is available])
+fi
+
+if test x"$samba_cv_HAVE_VA_COPY" != x"yes"; then
+AC_CACHE_CHECK([for __va_copy],samba_cv_HAVE___VA_COPY,[
+AC_TRY_LINK([#include <stdarg.h>
+va_list ap1,ap2;], [__va_copy(ap1,ap2);],
+samba_cv_HAVE___VA_COPY=yes,samba_cv_HAVE___VA_COPY=no)])
+if test x"$samba_cv_HAVE___VA_COPY" = x"yes"; then
+    AC_DEFINE(HAVE___VA_COPY,1,[Whether __va_copy() is available])
+fi
 fi
 
 AC_CACHE_CHECK([for C99 vsnprintf],samba_cv_HAVE_C99_VSNPRINTF,[
@@ -993,17 +472,6 @@ if test x"$samba_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
     AC_DEFINE(HAVE_C99_VSNPRINTF,1,[Whether there is a C99 compliant vsnprintf])
 fi
 
-AC_CACHE_CHECK([for broken readdir],samba_cv_HAVE_BROKEN_READDIR,[
-AC_TRY_RUN([#include <sys/types.h>
-#include <dirent.h>
-main() { struct dirent *di; DIR *d = opendir("."); di = readdir(d);
-if (di && di->d_name[-2] == '.' && di->d_name[-1] == 0 &&
-di->d_name[0] == 0) exit(0); exit(1);} ],
-samba_cv_HAVE_BROKEN_READDIR=yes,samba_cv_HAVE_BROKEN_READDIR=no,samba_cv_HAVE_BROKEN_READDIR=cross)])
-if test x"$samba_cv_HAVE_BROKEN_READDIR" = x"yes"; then
-    AC_DEFINE(HAVE_BROKEN_READDIR,1,[Whether readdir() is broken])
-fi
-
 AC_CACHE_CHECK([for utimbuf],samba_cv_HAVE_UTIMBUF,[
 AC_TRY_COMPILE([#include <sys/types.h>
 #include <utime.h>],
@@ -1096,11 +564,6 @@ if test x"$samba_cv_HAVE_IRIX_SPECIFIC_CAPABILITIES" = x"yes"; then
     AC_DEFINE(HAVE_IRIX_SPECIFIC_CAPABILITIES,1,[Whether IRIX specific capabilities are available])
 fi
 
-AC_MSG_CHECKING([for test routines])
-AC_TRY_RUN([#include "${srcdir-.}/build/tests/trivial.c"],
-           AC_MSG_RESULT(yes),
-          AC_MSG_ERROR([cant find test code. Aborting config]),
-          AC_MSG_WARN([cannot run when cross-compiling]))
 
 AC_CACHE_CHECK([for ftruncate extend],samba_cv_HAVE_FTRUNCATE_EXTEND,[
 AC_TRY_RUN([#include "${srcdir-.}/build/tests/ftruncate.c"],
@@ -1126,22 +589,6 @@ if test x"$samba_cv_HAVE_BROKEN_GETGROUPS" = x"yes"; then
     AC_DEFINE(HAVE_BROKEN_GETGROUPS,1,[Whether getgroups is broken])
 fi
 
-AC_CACHE_CHECK([whether getpass should be replaced],samba_cv_REPLACE_GETPASS,[
-SAVE_CPPFLAGS="$CPPFLAGS"
-CPPFLAGS="$CPPFLAGS -I${srcdir-.}/ -I${srcdir-.}/include -I${srcdir-.}/ubiqx -I${srcdir-.}/popt  -I${srcdir-.}/smbwrapper"
-AC_TRY_COMPILE([
-#define REPLACE_GETPASS 1
-#define NO_CONFIG_H 1
-#define main dont_declare_main
-#include "${srcdir-.}/lib/getsmbpass.c"
-#undef main
-],[],samba_cv_REPLACE_GETPASS=yes,samba_cv_REPLACE_GETPASS=no)
-CPPFLAGS="$SAVE_CPPFLAGS"
-])
-if test x"$samba_cv_REPLACE_GETPASS" = x"yes"; then
-       AC_DEFINE(REPLACE_GETPASS,1,[Whether getpass should be replaced])
-fi
-
 AC_CACHE_CHECK([for broken inet_ntoa],samba_cv_REPLACE_INET_NTOA,[
 AC_TRY_RUN([
 #include <stdio.h>
@@ -1189,15 +636,6 @@ if test x"$samba_cv_SYSCONF_SC_NGROUPS_MAX" = x"yes"; then
     AC_DEFINE(SYSCONF_SC_NGROUPS_MAX,1,[Whether sysconf(_SC_NGROUPS_MAX) is available])
 fi
 
-AC_CACHE_CHECK([for root],samba_cv_HAVE_ROOT,[
-AC_TRY_RUN([main() { exit(getuid() != 0); }],
-           samba_cv_HAVE_ROOT=yes,samba_cv_HAVE_ROOT=no,samba_cv_HAVE_ROOT=cross)])
-if test x"$samba_cv_HAVE_ROOT" = x"yes"; then
-    AC_DEFINE(HAVE_ROOT,1,[Whether current user is root])
-else
-    AC_MSG_WARN(running as non-root will disable some tests)
-fi
-
 ##################
 # look for a method of finding the list of network interfaces
 iface=no;
@@ -1206,7 +644,8 @@ AC_TRY_RUN([
 #define HAVE_IFACE_AIX 1
 #define AUTOCONF_TEST 1
 #include "confdefs.h"
-#include "${srcdir-.}/lib/interfaces.c"],
+#include "${srcdir-.}/lib/netif/netif.h"
+#include "${srcdir-.}/lib/netif/netif.c"],
            samba_cv_HAVE_IFACE_AIX=yes,samba_cv_HAVE_IFACE_AIX=no,samba_cv_HAVE_IFACE_AIX=cross)])
 if test x"$samba_cv_HAVE_IFACE_AIX" = x"yes"; then
     iface=yes;AC_DEFINE(HAVE_IFACE_AIX,1,[Whether iface AIX is available])
@@ -1218,7 +657,8 @@ AC_TRY_RUN([
 #define HAVE_IFACE_IFCONF 1
 #define AUTOCONF_TEST 1
 #include "confdefs.h"
-#include "${srcdir-.}/lib/interfaces.c"],
+#include "${srcdir-.}/lib/netif/netif.h"
+#include "${srcdir-.}/lib/netif/netif.c"],
            samba_cv_HAVE_IFACE_IFCONF=yes,samba_cv_HAVE_IFACE_IFCONF=no,samba_cv_HAVE_IFACE_IFCONF=cross)])
 if test x"$samba_cv_HAVE_IFACE_IFCONF" = x"yes"; then
     iface=yes;AC_DEFINE(HAVE_IFACE_IFCONF,1,[Whether iface ifconf is available])
@@ -1231,71 +671,14 @@ AC_TRY_RUN([
 #define HAVE_IFACE_IFREQ 1
 #define AUTOCONF_TEST 1
 #include "confdefs.h"
-#include "${srcdir-.}/lib/interfaces.c"],
+#include "${srcdir-.}/lib/netif/netif.h"
+#include "${srcdir-.}/lib/netif/netif.c"],
            samba_cv_HAVE_IFACE_IFREQ=yes,samba_cv_HAVE_IFACE_IFREQ=no,samba_cv_HAVE_IFACE_IFREQ=cross)])
 if test x"$samba_cv_HAVE_IFACE_IFREQ" = x"yes"; then
     iface=yes;AC_DEFINE(HAVE_IFACE_IFREQ,1,[Whether iface ifreq is available])
 fi
 fi
 
-
-################################################
-# look for a method of setting the effective uid
-seteuid=no;
-if test $seteuid = no; then
-AC_CACHE_CHECK([for setresuid],samba_cv_USE_SETRESUID,[
-AC_TRY_RUN([
-#define AUTOCONF_TEST 1
-#define USE_SETRESUID 1
-#include "confdefs.h"
-#include "${srcdir-.}/lib/util_sec.c"],
-           samba_cv_USE_SETRESUID=yes,samba_cv_USE_SETRESUID=no,samba_cv_USE_SETRESUID=cross)])
-if test x"$samba_cv_USE_SETRESUID" = x"yes"; then
-    seteuid=yes;AC_DEFINE(USE_SETRESUID,1,[Whether setresuid() is available])
-fi
-fi
-
-
-if test $seteuid = no; then
-AC_CACHE_CHECK([for setreuid],samba_cv_USE_SETREUID,[
-AC_TRY_RUN([
-#define AUTOCONF_TEST 1
-#define USE_SETREUID 1
-#include "confdefs.h"
-#include "${srcdir-.}/lib/util_sec.c"],
-           samba_cv_USE_SETREUID=yes,samba_cv_USE_SETREUID=no,samba_cv_USE_SETREUID=cross)])
-if test x"$samba_cv_USE_SETREUID" = x"yes"; then
-    seteuid=yes;AC_DEFINE(USE_SETREUID,1,[Whether setreuid() is available])
-fi
-fi
-
-if test $seteuid = no; then
-AC_CACHE_CHECK([for seteuid],samba_cv_USE_SETEUID,[
-AC_TRY_RUN([
-#define AUTOCONF_TEST 1
-#define USE_SETEUID 1
-#include "confdefs.h"
-#include "${srcdir-.}/lib/util_sec.c"],
-           samba_cv_USE_SETEUID=yes,samba_cv_USE_SETEUID=no,samba_cv_USE_SETEUID=cross)])
-if test x"$samba_cv_USE_SETEUID" = x"yes"; then
-    seteuid=yes;AC_DEFINE(USE_SETEUID,1,[Whether seteuid() is available])
-fi
-fi
-
-if test $seteuid = no; then
-AC_CACHE_CHECK([for setuidx],samba_cv_USE_SETUIDX,[
-AC_TRY_RUN([
-#define AUTOCONF_TEST 1
-#define USE_SETUIDX 1
-#include "confdefs.h"
-#include "${srcdir-.}/lib/util_sec.c"],
-           samba_cv_USE_SETUIDX=yes,samba_cv_USE_SETUIDX=no,samba_cv_USE_SETUIDX=cross)])
-if test x"$samba_cv_USE_SETUIDX" = x"yes"; then
-    seteuid=yes;AC_DEFINE(USE_SETUIDX,1,[Whether setuidx() is available])
-fi
-fi
-
-
 AC_CACHE_CHECK([for working mmap],samba_cv_HAVE_MMAP,[
 AC_TRY_RUN([#include "${srcdir-.}/build/tests/shared_mmap.c"],
            samba_cv_HAVE_MMAP=yes,samba_cv_HAVE_MMAP=no,samba_cv_HAVE_MMAP=cross)])
@@ -1310,55 +693,6 @@ if test x"$samba_cv_FTRUNCATE_NEEDS_ROOT" = x"yes"; then
     AC_DEFINE(FTRUNCATE_NEEDS_ROOT,1,[Whether ftruncate() needs root])
 fi
 
-AC_CACHE_CHECK([for fcntl locking],samba_cv_HAVE_FCNTL_LOCK,[
-AC_TRY_RUN([#include "${srcdir-.}/build/tests/fcntl_lock.c"],
-           samba_cv_HAVE_FCNTL_LOCK=yes,samba_cv_HAVE_FCNTL_LOCK=no,samba_cv_HAVE_FCNTL_LOCK=cross)])
-if test x"$samba_cv_HAVE_FCNTL_LOCK" = x"yes"; then
-    AC_DEFINE(HAVE_FCNTL_LOCK,1,[Whether fcntl locking is available])
-fi
-
-AC_CACHE_CHECK([for broken (glibc2.1/x86) 64 bit fcntl locking],samba_cv_HAVE_BROKEN_FCNTL64_LOCKS,[
-AC_TRY_RUN([#include "${srcdir-.}/build/tests/fcntl_lock64.c"],
-           samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=yes,samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=no,samba_cv_HAVE_BROKEN_FCNTL64_LOCKS=cross)])
-if test x"$samba_cv_HAVE_BROKEN_FCNTL64_LOCKS" = x"yes"; then
-    AC_DEFINE(HAVE_BROKEN_FCNTL64_LOCKS,1,[Whether fcntl64 locks are broken])
-
-else
-
-dnl
-dnl Don't check for 64 bit fcntl locking if we know that the
-dnl glibc2.1 broken check has succeeded.
-dnl 
-
-  AC_CACHE_CHECK([for 64 bit fcntl locking],samba_cv_HAVE_STRUCT_FLOCK64,[
-  AC_TRY_RUN([
-#if defined(HAVE_UNISTD_H)
-#include <unistd.h>
-#endif
-#include <stdio.h>
-#include <stdlib.h>
-
-#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
-
-#ifdef HAVE_SYS_FCNTL_H
-#include <sys/fcntl.h>
-#endif
-main() { struct flock64 fl64;
-#if defined(F_SETLKW64) && defined(F_SETLK64) && defined(F_GETLK64)
-exit(0);
-#else
-exit(1);
-#endif
-}],
-       samba_cv_HAVE_STRUCT_FLOCK64=yes,samba_cv_HAVE_STRUCT_FLOCK64=no,samba_cv_HAVE_STRUCT_FLOCK64=cross)])
-
-  if test x"$samba_cv_HAVE_STRUCT_FLOCK64" = x"yes"; then
-      AC_DEFINE(HAVE_STRUCT_FLOCK64,1,[Whether the flock64 struct is available])
-  fi
-fi
-
 AC_CACHE_CHECK([for st_blocks in struct stat],samba_cv_HAVE_STAT_ST_BLOCKS,[
 AC_TRY_COMPILE([#include <sys/types.h>
 #include <sys/stat.h>
@@ -1400,7 +734,7 @@ esac
 AC_SUBST(SMBD_EXTRA_OBJS)
 AC_SUBST(SMBD_EXTRA_LIBS)
 
-sinclude(libads/config.m4)
+SMB_INCLUDE_M4(libads/config.m4)
 
 ###############################################
 # test for where we get crypt() from
@@ -1610,28 +944,7 @@ if test $space = no; then
   fi
 fi
 
-#
-# As a gating factor for large file support, in order to
-# use <4GB files we must have the following minimal support
-# available.
-# long long, and a 64 bit off_t or off64_t.
-# If we don't have all of these then disable large
-# file support.
-#
-AC_MSG_CHECKING([if large file support can be enabled])
-AC_TRY_COMPILE([
-#if defined(HAVE_LONGLONG) && (defined(HAVE_OFF64_T) || (defined(SIZEOF_OFF_T) && (SIZEOF_OFF_T == 8)))
-#include <sys/types.h>
-#else
-__COMPILE_ERROR_
-#endif
-],
-[int i],
-samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT=yes,samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT=no)
-if test x"$samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT" = x"yes"; then
-       AC_DEFINE(HAVE_EXPLICIT_LARGEFILE_SUPPORT,1,[Whether large file support can be enabled])
-fi
-AC_MSG_RESULT([$samba_cv_HAVE_EXPLICIT_LARGEFILE_SUPPORT])
+
 
 #######################################
 # Check for comparison_fn_t
@@ -1649,3 +962,4 @@ samba_cv_HAVE_COMPARISON_FN_T=yes,samba_cv_HAVE_COMPARISON_FN_T=no)
 if test x"$samba_cv_HAVE_COMPARISON_FN_T" = x"yes"; then
        AC_DEFINE(HAVE_COMPARISON_FN_T,1,[Whether or not we have comparison_fn_t])
 fi
+