Link smbd on AIX with -bexpfull instead of -bexpall
[ira/wip.git] / source3 / configure.in
index 919cfc93dc32bfd0da108d86bc5f3405094b5d5b..fcbe56f268a0491eb0c4b384c168cbac9638c07a 100644 (file)
@@ -15,9 +15,20 @@ esac
 SMB_VERSION_STRING=`cat $srcdir/include/version.h | grep 'SAMBA_VERSION_OFFICIAL_STRING' | cut -d '"' -f2`
 echo "SAMBA VERSION: ${SMB_VERSION_STRING}"
 
-SAMBA_VERSION_SVN_REVISION=`cat $srcdir/include/version.h | grep 'SAMBA_VERSION_SVN_REVISION' | cut -d ' ' -f3-`
-if test -n "${SAMBA_VERSION_SVN_REVISION}";then
-       echo "BUILD REVISION: ${SAMBA_VERSION_SVN_REVISION}"
+SAMBA_VERSION_GIT_COMMIT_FULLREV=`cat $srcdir/include/version.h | grep 'SAMBA_VERSION_GIT_COMMIT_FULLREV' | cut -d ' ' -f3- | cut -d '"' -f2`
+if test -n "${SAMBA_VERSION_GIT_COMMIT_FULLREV}";then
+       echo "BUILD COMMIT REVISION: ${SAMBA_VERSION_GIT_COMMIT_FULLREV}"
+fi
+SAMBA_VERSION_GIT_COMMIT_DATE=`cat $srcdir/include/version.h | grep 'SAMBA_VERSION_GIT_COMMIT_DATE' | cut -d ' ' -f3-`
+if test -n "${SAMBA_VERSION_GIT_COMMIT_DATE}";then
+       echo "BUILD COMMIT DATE: ${SAMBA_VERSION_GIT_COMMIT_DATE}"
+fi
+SAMBA_VERSION_GIT_COMMIT_TIME=`cat $srcdir/include/version.h | grep 'SAMBA_VERSION_GIT_COMMIT_TIME' | cut -d ' ' -f3-`
+if test -n "${SAMBA_VERSION_GIT_COMMIT_TIME}";then
+       echo "BUILD COMMIT TIME: ${SAMBA_VERSION_GIT_COMMIT_TIME}"
+
+       # just to keep the build-farm gui happy for now...
+       echo "BUILD REVISION: ${SAMBA_VERSION_GIT_COMMIT_TIME}"
 fi
 
 AC_LIBREPLACE_LOCATION_CHECKS
@@ -41,6 +52,9 @@ test "${libdir}" || libdir="\${prefix}/lib"
 pammodulesdir="\${LIBDIR}/security"
 configdir="\${LIBDIR}"
 swatdir="\${prefix}/swat"
+codepagedir="\${LIBDIR}"
+statedir="\${LOCKDIR}"
+cachedir="\${LOCKDIR}"
 
 AC_ARG_WITH(fhs,
 [  --with-fhs              Use FHS-compliant paths (default=no)],
@@ -51,9 +65,13 @@ AC_ARG_WITH(fhs,
     mandir="\${prefix}/share/man"
     logfilebase="\${VARDIR}/log/samba"
     privatedir="\${CONFIGDIR}/private"
-    libdir="\${prefix}/lib/samba"
+    test "${libdir}" || libdir="\${prefix}/lib/samba"
     configdir="\${sysconfdir}/samba"
     swatdir="\${DATADIR}/samba/swat"
+    codepagedir="\${LIBDIR}"
+    statedir="\${VARDIR}/lib/samba"
+    cachedir="\${VARDIR}/lib/samba"
+    AC_DEFINE(FHS_COMPATIBLE, 1, [Whether to use fully FHS-compatible paths])
     ;;
   esac])
 
@@ -273,6 +291,9 @@ AC_SUBST(privatedir)
 AC_SUBST(swatdir)
 AC_SUBST(bindir)
 AC_SUBST(sbindir)
+AC_SUBST(codepagedir)
+AC_SUBST(statedir)
+AC_SUBST(cachedir)
 AC_SUBST(rootsbindir)
 AC_SUBST(pammodulesdir)
 
@@ -293,14 +314,20 @@ AC_SUBST(INSTALLLIBCMD_SH)
 AC_SUBST(INSTALLLIBCMD_A)
 AC_SUBST(UNINSTALLLIBCMD_SH)
 AC_SUBST(UNINSTALLLIBCMD_A)
-AC_SUBST(INSTALL_LIBMSRPC)
-AC_SUBST(UNINSTALL_LIBMSRPC)
-AC_SUBST(LIBMSRPC_SHARED)
-AC_SUBST(LIBMSRPC)
 AC_SUBST(INSTALL_LIBADDNS)
 AC_SUBST(UNINSTALL_LIBADDNS)
 AC_SUBST(LIBADDNS_SHARED)
 AC_SUBST(LIBADDNS)
+
+AC_SUBST(INSTALL_LIBWBCLIENT)
+AC_SUBST(UNINSTALL_LIBWBCLIENT)
+AC_SUBST(LIBWBCLIENT_SHARED)
+AC_SUBST(LIBWBCLIENT_STATIC)
+AC_SUBST(LIBWBCLIENT)
+AC_SUBST(WINBIND_LIBS)
+
+AC_SUBST(LIBSAMBAUTIL_SHARED)
+
 AC_SUBST(INSTALL_LIBSMBCLIENT)
 AC_SUBST(UNINSTALL_LIBSMBCLIENT)
 AC_SUBST(LIBSMBCLIENT_SHARED)
@@ -309,6 +336,10 @@ AC_SUBST(INSTALL_LIBSMBSHAREMODES)
 AC_SUBST(UNINSTALL_LIBSMBSHAREMODES)
 AC_SUBST(LIBSMBSHAREMODES_SHARED)
 AC_SUBST(LIBSMBSHAREMODES)
+AC_SUBST(INSTALL_LIBNETAPI)
+AC_SUBST(UNINSTALL_LIBNETAPI)
+AC_SUBST(LIBNETAPI_SHARED)
+AC_SUBST(LIBNETAPI)
 AC_SUBST(PRINT_LIBS)
 AC_SUBST(AUTH_LIBS)
 AC_SUBST(ACL_LIBS)
@@ -326,6 +357,9 @@ AC_SUBST(SMBMOUNT_PROGS)
 AC_SUBST(CIFSMOUNT_PROGS)
 AC_SUBST(INSTALL_CIFSMOUNT)
 AC_SUBST(UNINSTALL_CIFSMOUNT)
+AC_SUBST(CIFSSPNEGO_PROGS)
+AC_SUBST(INSTALL_CIFSSPNEGO)
+AC_SUBST(UNINSTALL_CIFSSPNEGO)
 AC_SUBST(EXTRA_SBIN_PROGS)
 AC_SUBST(EXTRA_ALL_TARGETS)
 AC_SUBST(CONFIG_LIBS)
@@ -353,6 +387,7 @@ CFLAGS="${CFLAGS} -D_SAMBA_BUILD_=3"
 AC_LIBREPLACE_CC_CHECKS
 
 m4_include(lib/socket_wrapper/config.m4)
+m4_include(lib/nss_wrapper/config.m4)
 
 SWAT_SBIN_TARGETS='bin/swat$(EXEEXT)'
 SWAT_INSTALL_TARGETS=installswat
@@ -373,10 +408,10 @@ AC_SUBST(SWAT_INSTALL_TARGETS)
 
 #################################################
 # set prefix for 'make test'
-selftest_prefix="./st"
+selftest_prefix="./"
 AC_SUBST(selftest_prefix)
 AC_ARG_WITH(selftest-prefix,
-[  --with-selftest-prefix=DIR    The prefix where make test will be runned ($selftest_prefix)],
+[  --with-selftest-prefix=DIR    The prefix where make test will be run ($selftest_prefix)],
 [ case "$withval" in
   yes|no)
     AC_MSG_WARN([--with-selftest-prefix called without argument - will use default])
@@ -387,49 +422,20 @@ AC_ARG_WITH(selftest-prefix,
   esac
 ])
 
-AC_ARG_ENABLE(launchd,
-[  --enable-launchd        Support running under launchd (default=auto)])
-
-if test x"$enable_launchd" != x"no" ; then
-    AC_CACHE_CHECK([whether to include launchd support],
-       samba_cv_launchd_support,
-       [
-           AC_TRY_COMPILE(
-           [
-#include <launch.h>
-           ],
-           [
-               launchd_msg(NULL);
-               launchd_data_get_fd(NULL);
-           ],
-           samba_cv_launchd_support=yes,
-           samba_cv_launchd_support=no)
-       ])
-
-    if test x"$samba_cv_launchd_support" = x"yes" ; then
-       AC_DEFINE(WITH_LAUNCHD_SUPPORT, 1,
-                   [Whether launchd support should be enabled])
-    else
-       if test x"$enable_launchd" = x"yes" ; then
-           AC_ERROR(launchd support is not available)
-       fi
-    fi
-fi
-
 #################################################
 # set path of samba4's smbtorture
-samba4srcdir=""
-AC_SUBST(samba4srcdir)
-AC_ARG_WITH(samba4srcdir,
-[  --with-samba4srcdir=PATH    The path to a samba4 source directorhy for make test (none)],
+smbtorture4_path=""
+AC_SUBST(smbtorture4_path)
+AC_ARG_WITH(smbtorture4_path,
+[  --with-smbtorture4-path=PATH    The path to a samba4 smbtorture for make test (none)],
 [ case "$withval" in
   yes|no)
-    AC_MSG_ERROR([--with-samba4srcdir should take a path])
+    AC_MSG_ERROR([--with-smbtorture4-path should take a path])
   ;;
   * )
-    samba4srcdir="$withval"
-    if test -z "$samba4srcdir" -a ! -f $samba4srcdir; then
-       AC_MSG_ERROR(['$samba4srcdir' does not  exist!])
+    smbtorture4_path="$withval"
+    if test -z "$smbtorture4_path" -a ! -f $smbtorture4_path; then
+       AC_MSG_ERROR(['$smbtorture_path' does not  exist!])
     fi
   ;;
  esac
@@ -450,7 +456,7 @@ AC_ARG_ENABLE(krb5developer, [  --enable-krb5developer  Turn on developer warnin
 # DEVELOPER_CFLAGS, so that you can turn them on and off with a simple
 # Makefile edit, avoiding the need to re-run configure.
 if test x"$ac_cv_prog_gcc" = x"yes" ; then
-       DEVELOPER_CFLAGS="-gstabs -Wall -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -DDEBUG_PASSWORD -DDEVELOPER"
+       DEVELOPER_CFLAGS="-g -Wall -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -DDEBUG_PASSWORD -DDEVELOPER"
        # Add -Wdeclaration-after-statement if compiler supports it
        AC_CACHE_CHECK(
           [that the C compiler understands -Wdeclaration-after-statement],
@@ -648,41 +654,7 @@ if test x"$SMB_BUILD_CC_NEGATIVE_ENUM_VALUES" != x"yes"; then
        PIDL_ARGS="$PIDL_ARGS --uint-enums"
 fi
 
-############################################
-# Check whether we can do automatic dependency tracking
-
-m4_include(m4/substnot.m4)
-m4_include(m4/cond.m4)
-m4_include(m4/make.m4)
-m4_include(m4/depout.m4)
-m4_include(m4/lead-dot.m4)
-m4_include(m4/check_gnu_make.m4)
-m4_include(m4/depend.m4)
-
-# Using the dependency files requires GNU make until someone adds support
-# for Makefile includes for other make implementations. Note that
-# CHECK_GNU_MAKE() can find a non-default make.
-CHECK_GNU_MAKE()
-if test "x$_cv_gnu_make_command" != "x" -a \
-    x`which make` = x`which "$_cv_gnu_make_command"` ; then
-    AC_SUBST(MAKE, $_cv_gnu_make_command)
-else
-    # If GNU make is not the default, don't enable GNU-isms because we can't
-    # guarantee that GNU make will actually be the make that is invoked.
-    ifGNUmake='#'
-fi
-
-AM_DEP_TRACK()
-_AM_DEPENDENCIES(CC)
-
-# As per vl, disable dependency tracking by default until we don't need
-# to use "make proto' -- jpeach
-if test "x$enable_dependency_tracking" != xyes; then
-    ifGNUmake='#'
-fi
-
-############################################
-# Figure out the flags to support named structure initializers
+dnl Figure out the flags to support named structure initializers
 
 LIBREPLACE_C99_STRUCT_INIT([],[AC_MSG_ERROR([c99 structure initializer are not supported])])
 
@@ -732,10 +704,10 @@ AC_SUBST(DYNEXP)
 
 dnl Add modules that have to be built by default here
 dnl These have to be built static:
-default_static_modules="pdb_smbpasswd pdb_tdbsam rpc_lsa rpc_samr rpc_winreg rpc_initshutdown rpc_lsa_ds rpc_wkssvc rpc_svcctl2 rpc_ntsvcs rpc_net rpc_netdfs rpc_srvsvc rpc_spoolss rpc_eventlog2 rpc_unixinfo rpc_epmapper auth_sam auth_unix auth_winbind auth_server auth_domain auth_builtin vfs_default nss_info_template"
+default_static_modules="pdb_smbpasswd pdb_tdbsam rpc_lsa rpc_samr rpc_winreg rpc_initshutdown rpc_lsa_ds rpc_wkssvc rpc_svcctl2 rpc_ntsvcs rpc_net rpc_netdfs rpc_srvsvc2 rpc_spoolss rpc_eventlog2 auth_sam auth_unix auth_winbind auth_server auth_domain auth_builtin vfs_default nss_info_template"
 
 dnl These are preferably build shared, and static if dlopen() is not available
-default_shared_modules="vfs_recycle vfs_audit vfs_extd_audit vfs_full_audit vfs_netatalk vfs_fake_perms vfs_default_quota vfs_readonly vfs_cap vfs_expand_msdfs vfs_shadow_copy charset_CP850 charset_CP437 auth_script vfs_readahead"
+default_shared_modules="vfs_recycle vfs_audit vfs_extd_audit vfs_full_audit vfs_netatalk vfs_fake_perms vfs_default_quota vfs_readonly vfs_cap vfs_expand_msdfs vfs_shadow_copy vfs_shadow_copy2 charset_CP850 charset_CP437 auth_script vfs_readahead vfs_syncops vfs_xattr_tdb vfs_streams_xattr"
 
 if test "x$developer" = xyes; then
    default_static_modules="$default_static_modules rpc_rpcecho"
@@ -860,11 +832,11 @@ case "$host_os" in
         CPPFLAGS="-D_LARGEFILE64_SOURCE $CPPFLAGS"
         AC_TRY_RUN([
 #include <unistd.h>
-int main () {
+main () {
 #if _LFS64_LARGEFILE == 1
-return 0;
+exit(0);
 #else
-return 1;
+exit(1);
 #endif
 }], [SINIX_LFS_SUPPORT=yes], [SINIX_LFS_SUPPORT=no], [SINIX_LFS_SUPPORT=cross])
         CPPFLAGS="$old_CPPFLAGS"
@@ -879,15 +851,6 @@ return 1;
       fi
     ;;
 
-# Systems with LFS support.
-#
-    gnu* | k*bsd*-gnu)
-       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])
-       ;;
-
 # Tests for linux LFS support. Need kernel 2.4 and glibc2.2 or greater support.
 #
     *linux*)
@@ -899,7 +862,7 @@ return 1;
 #include <sys/utsname.h>
 #include <string.h>
 #include <stdlib.h>
-int main() {
+main() {
 #if _LFS64_LARGEFILE == 1
        struct utsname uts;
        char *release;
@@ -911,9 +874,9 @@ int main() {
        int libc_minor = __GLIBC_MINOR__;
 
        if (libc_major < 2)
-              return 1;
+              exit(1);
        if (libc_minor < 2)
-              return 1;
+              exit(1);
 #endif
 
        /* Ensure this is kernel 2.4 or higher */
@@ -924,10 +887,10 @@ int main() {
        minor = atoi(strsep(&release, "."));
 
        if (major > 2 || (major == 2 && minor > 3))
-               return 0;
-       return 1;
+               exit(0);
+       exit(1);
 #else
-       return 1;
+       exit(1);
 #endif
 }
 ], [LINUX_LFS_SUPPORT=yes], [LINUX_LFS_SUPPORT=no], [LINUX_LFS_SUPPORT=cross])
@@ -948,7 +911,7 @@ int main() {
     *darwin*)
        AC_DEFINE(BROKEN_UNICODE_COMPOSE_CHARACTERS, 1, [Does this system use unicode compose characters])
 
-       # Add a system specific charset module.
+# Add a system specific charset module.
        default_shared_modules="$default_shared_modules charset_macosxfs"
 
        ;;
@@ -960,9 +923,9 @@ int main() {
 #include <unistd.h>
 main () {
 #if _LFS64_LARGEFILE == 1
-return 0;
+exit(0);
 #else
-return 1;
+exit(1);
 #endif
 }], [GLIBC_LFS_SUPPORT=yes], [GLIBC_LFS_SUPPORT=no], [GLIBC_LFS_SUPPORT=cross])
         CPPFLAGS="$old_CPPFLAGS"
@@ -1082,7 +1045,6 @@ 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(socklen_t, int)
 AC_CHECK_TYPE(comparison_fn_t,
 [AC_DEFINE(HAVE_COMPARISON_FN_T, 1,[Whether or not we have comparison_fn_t])])
 
@@ -1202,7 +1164,7 @@ AC_HAVE_DECL(snprintf, [#include <stdio.h>])
 # nothing until kernel 2.1.44! very dumb.
 AC_CACHE_CHECK([for real setresuid],samba_cv_have_setresuid,[
     AC_TRY_RUN([#include <errno.h>
-int main() { setresuid(1,1,1); setresuid(2,2,2); return errno==EPERM?0:1;}],
+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])
@@ -1213,7 +1175,7 @@ fi
 AC_CACHE_CHECK([for real setresgid],samba_cv_have_setresgid,[
     AC_TRY_RUN([#include <unistd.h>
 #include <errno.h>
-int main() { errno = 0; setresgid(1,1,1); return errno != 0 ? (errno==EPERM ? 0 : 1) : 0;}],
+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])
@@ -1347,7 +1309,7 @@ fi
 AC_CHECK_FUNCS(waitpid getcwd strdup strndup strnlen strerror chown fchown lchown chmod fchmod chroot link mknod mknod64)
 AC_CHECK_FUNCS(strtol strtoll strtoul strtoull strtouq __strtoull)
 AC_CHECK_FUNCS(fstat strchr utime utimes chflags)
-AC_CHECK_FUNCS(getrlimit fsync memset strlcpy strlcat setpgid)
+AC_CHECK_FUNCS(getrlimit fsync fdatasync 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 poll rdchk getgrnam getgrent pathconf realpath)
@@ -1362,11 +1324,10 @@ AC_CHECK_FUNCS(syslog vsyslog timegm)
 AC_CHECK_FUNCS(setlocale nl_langinfo)
 AC_CHECK_FUNCS(nanosleep)
 AC_CHECK_FUNCS(mlock munlock mlockall munlockall)
-AC_CHECK_FUNCS(memalign posix_memalign)
+AC_CHECK_FUNCS(memalign posix_memalign hstrerror)
 AC_CHECK_HEADERS(sys/mman.h)
 # setbuffer, shmget, shm_open are needed for smbtorture
 AC_CHECK_FUNCS(setbuffer shmget shm_open)
-AC_CHECK_FUNCS(makecontext getcontext setcontext swapcontext)
 
 # Find a method of generating a stack trace
 AC_CHECK_HEADERS(execinfo.h libexc.h libunwind.h)
@@ -1517,35 +1478,25 @@ AC_DEFINE(HAVE_PRCTL, 1, [Whether prctl is available]),[])
 #
 #
 case "$host_os" in
-    linux*-gnu* | gnu* | k*bsd*-gnu)
+    *linux*)
        # glibc <= 2.3.2 has a broken getgrouplist
-    AC_CACHE_CHECK([for a broken Linux getgrouplist API],
-           linux_getgrouplist_ok,
-           [
-               AC_TRY_RUN([
+       AC_TRY_RUN([
 #include <unistd.h>
 #include <sys/utsname.h>
-
-                   int main() {
-                          /* glibc up to 2.3 has a broken getgrouplist */
+main() {
+       /* glibc up to 2.3 has a broken getgrouplist */
 #if defined(__GLIBC__) && defined(__GLIBC_MINOR__)
-                          int libc_major = __GLIBC__;
-                          int libc_minor = __GLIBC_MINOR__;
+       int libc_major = __GLIBC__;
+       int libc_minor = __GLIBC_MINOR__;
 
-                          if (libc_major < 2)
-                                 return 1;
-                          if ((libc_major == 2) && (libc_minor <= 3))
-                                 return 1;
+       if (libc_major < 2)
+              exit(1);
+       if ((libc_major == 2) && (libc_minor <= 3))
+              exit(1);
 #endif
-                          return 0;
-                   }
-
-               ],
-               [linux_getgrouplist_ok=yes],
-               [linux_getgrouplist_ok=no],
-               [linux_getgrouplist_ok=cross])
-       ])
-
+       exit(0);
+}
+], [linux_getgrouplist_ok=yes], [linux_getgrouplist_ok=no])
        if test x"$linux_getgrouplist_ok" = x"yes"; then
           AC_DEFINE(HAVE_GETGROUPLIST, 1, [Have good getgrouplist])
        fi
@@ -1566,7 +1517,7 @@ if test x$ac_cv_func_stat64 = xno ; then
 #include <unistd.h>
 #endif
 #include <sys/stat.h>
-], [struct stat64 st64; return stat64(".",&st64);], [ac_cv_func_stat64=yes])
+], [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])
@@ -1580,7 +1531,7 @@ if test x$ac_cv_func_lstat64 = xno ; then
 #include <unistd.h>
 #endif
 #include <sys/stat.h>
-], [struct stat64 st64; return lstat64(".",&st64);], [ac_cv_func_lstat64=yes])
+], [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])
@@ -1594,7 +1545,7 @@ if test x$ac_cv_func_fstat64 = xno ; then
 #include <unistd.h>
 #endif
 #include <sys/stat.h>
-], [struct stat64 st64; return fstat64(0,&st64);], [ac_cv_func_fstat64=yes])
+], [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])
@@ -1817,29 +1768,6 @@ EOF
        fi
 fi
 
-#Check if we can enable relro as well
-if test x"${samba_cv_fpie}" = x"yes"
-then
-       AC_CACHE_CHECK(for relro, samba_cv_fpie_relro,
-       [
-               cat > conftest.c <<EOF
-int foo;
-main () { return 0;}
-EOF
-                if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -pie -fPIE -Wl,-z,relro -o conftest conftest.c 1>&AS_MESSAGE_LOG_FD])
-               then
-                       samba_cv_fpie_relro=yes
-               else
-                       samba_cv_fpie_relro=no
-               fi
-               rm -f conftest*
-       ])
-       if test x"${samba_cv_fpie_relro}" = x"yes"
-       then
-               PIE_LDFLAGS="-pie -Wl,-z,relro"
-       fi
-fi
-
 # Assume non-shared by default and override below
 BLDSHARED="false"
 
@@ -1855,16 +1783,13 @@ DSO_EXPORTS=""
 
 # this bit needs to be modified for each OS that supports share libs
 # You need to specify how to create a shared library and
-# how to compile C code to produce PIC object files
+  # 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*-gnu* | gnu* | k*bsd*-gnu)
-                       case "$host_os" in 
-                               linux*)   AC_DEFINE(LINUX,1,[Whether the host os is linux]) ;;
-                       esac
+  # and these are for particular systems
+  case "$host_os" in
+               *linux*)   AC_DEFINE(LINUX,1,[Whether the host os is linux])
                        BLDSHARED="true"
                        if test "${ac_cv_gnu_ld_no_default_allow_shlib_undefined}" = "yes"; then
                                LDSHFLAGS="-shared -Wl,-Bsymbolic -Wl,--allow-shlib-undefined"
@@ -1939,7 +1864,7 @@ case "$host_os" in
                *aix*) AC_DEFINE(AIX,1,[Whether the host os is aix])
                        BLDSHARED="true"
                        LDSHFLAGS="-Wl,-G,-bexpall,-bbigtoc"
-                       DYNEXP="-Wl,-brtl,-bexpall,-bbigtoc"
+                       DYNEXP="-Wl,-brtl,-bexpfull,-bbigtoc"
                        PICFLAG="-O2"
                        # as AIX code is always position independent...
                        # .po will just create compile warnings, use po.o:
@@ -2030,20 +1955,21 @@ case "$host_os" in
                *darwin*)   AC_DEFINE(DARWINOS,1,[Whether the host os is Darwin/MacOSX])
                        BLDSHARED="true"
                        LDSHFLAGS="-bundle -flat_namespace -undefined suppress"
-                       MODULE_EXPORTS="-exported_symbols_list \$(srcdir)/exports/modules-darwin.syms"
                        SHLIBEXT="dylib"
-                       # Since gcc doesn't fail on unrecognised options, the
-                       # PIE test incorrectly succeeds. Darwin gcc does not
-                       # actually support the PIE stuff.
-                       PIE_LDFLAGS=
-                       PIE_CFLAGS=
+                        MODULE_EXPORTS="-exported_symbols_list \$(srcdir)/exports/modules-darwin.syms"
+                        SHLIBEXT="dylib"
+                        # Since gcc doesn't fail on unrecognised options, the
+                        # PIE test incorrectly succeeds. Darwin gcc does not
+                        # actually support the PIE stuff.
+                        PIE_LDFLAGS=
+                        PIE_CFLAGS=
                        AC_DEFINE(STAT_ST_BLOCKSIZE,512)
                        ;;
 
                *)
                        AC_DEFINE(STAT_ST_BLOCKSIZE,512)
                        ;;
-esac
+  esac
 
 if test "$enable_shared" != "yes"; then
        BLDSHARED=false
@@ -2112,11 +2038,13 @@ AC_MSG_RESULT([$PICFLAG])
 
 AC_DEFINE_UNQUOTED(SHLIBEXT, "$SHLIBEXT", [Shared library extension])
 
+AC_LIBREPLACE_RUNTIME_LIB_PATH_VAR
+
 ################
 
 AC_CACHE_CHECK([for long long],samba_cv_have_longlong,[
 AC_TRY_RUN([#include <stdio.h>
-int main() { long long x = 1000000; x *= x; return ((x/1000000) == 1000000)? 0: 1; }],
+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])
@@ -2148,7 +2076,7 @@ fi
 AC_CACHE_CHECK([for 64 bit off_t],samba_cv_SIZEOF_OFF_T,[
 AC_TRY_RUN([#include <stdio.h>
 #include <sys/stat.h>
-int main() { return (sizeof(off_t) == 8) ? 0 : 1; }],
+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])
@@ -2161,7 +2089,7 @@ AC_TRY_RUN([
 #endif
 #include <stdio.h>
 #include <sys/stat.h>
-int main() { struct stat64 st; off64_t s; if (sizeof(off_t) == sizeof(off64_t)) return 1; return (lstat64("/dev/null", &st)==0)?0:1; }],
+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])
@@ -2174,7 +2102,7 @@ AC_TRY_RUN([
 #endif
 #include <stdio.h>
 #include <sys/stat.h>
-int main() { return (sizeof(ino_t) == 8) ? 0 : 1; }],
+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])
@@ -2187,7 +2115,7 @@ AC_TRY_RUN([
 #endif
 #include <stdio.h>
 #include <sys/stat.h>
-int main() { struct stat64 st; ino64_t s; if (sizeof(ino_t) == sizeof(ino64_t)) return 1; return (lstat64("/dev/null", &st)==0)?0:1; }],
+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])
@@ -2200,7 +2128,7 @@ AC_TRY_RUN([
 #endif
 #include <stdio.h>
 #include <sys/stat.h>
-int main() { return (sizeof(dev_t) == 8) ? 0 : 1; }],
+main() { exit((sizeof(dev_t) == 8) ? 0 : 1); }],
 samba_cv_SIZEOF_DEV_T=yes,samba_cv_SIZEOF_DEV_T=no,samba_cv_SIZEOF_DEV_T=cross)])
 if test x"$samba_cv_SIZEOF_DEV_T" = x"yes"; then
     AC_DEFINE(SIZEOF_DEV_T,8,[The size of the 'dev_t' type])
@@ -2213,7 +2141,7 @@ AC_TRY_RUN([
 #endif
 #include <stdio.h>
 #include <sys/stat.h>
-int main() { struct stat64 st; dev64_t s; if (sizeof(dev_t) == sizeof(dev64_t)) return 1; return (lstat64("/dev/null", &st)==0)?0:1; }],
+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])
@@ -2251,7 +2179,7 @@ AC_TRY_RUN([
 #include <unistd.h>
 #endif
 #include <sys/types.h>
-int main() { dev_t dev; int i = major(dev); return 0; }],
+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])
@@ -2263,7 +2191,7 @@ AC_TRY_RUN([
 #include <unistd.h>
 #endif
 #include <sys/types.h>
-int main() { dev_t dev; int i = minor(dev); return 0; }],
+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])
@@ -2275,7 +2203,7 @@ AC_TRY_RUN([
 #include <unistd.h>
 #endif
 #include <sys/types.h>
-int main() { dev_t dev = makedev(1,2); return 0; }],
+main() { dev_t dev = makedev(1,2); return 0; }],
 samba_cv_HAVE_MAKEDEV=yes,samba_cv_HAVE_MAKEDEV=no,samba_cv_HAVE_MAKEDEV=cross)])
 if test x"$samba_cv_HAVE_MAKEDEV" = x"yes"; then
     AC_DEFINE(HAVE_MAKEDEV,1,[Whether the macro for makedev is available])
@@ -2283,7 +2211,7 @@ fi
 
 AC_CACHE_CHECK([for unsigned char],samba_cv_HAVE_UNSIGNED_CHAR,[
 AC_TRY_RUN([#include <stdio.h>
-int main() { char c; c=250; return (c > 0)?0:1; }],
+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])
@@ -2334,12 +2262,12 @@ if test x"$samba_cv_WITH_PROFILE" = x"yes"; then
 
     AC_LIBTESTFUNC(rt, clock_gettime,
            [
-               AC_DEFINE(HAVE_CLOCK_GETTIME, 1,
-                   [Whether clock_gettime is available])
-               SMB_CHECK_CLOCK_ID(CLOCK_MONOTONIC)
-               SMB_CHECK_CLOCK_ID(CLOCK_PROCESS_CPUTIME_ID)
-               SMB_CHECK_CLOCK_ID(CLOCK_REALTIME)
-           ])
+                           AC_DEFINE(HAVE_CLOCK_GETTIME, 1,
+                               [Whether clock_gettime is available])
+                           SMB_CHECK_CLOCK_ID(CLOCK_MONOTONIC)
+                           SMB_CHECK_CLOCK_ID(CLOCK_PROCESS_CPUTIME_ID)
+                           SMB_CHECK_CLOCK_ID(CLOCK_REALTIME)
+                       ])
 
 fi
 
@@ -2373,18 +2301,18 @@ void foo(const char *format, ...) {
        va_start(ap, format);
        len = vsnprintf(buf, 0, format, ap);
        va_end(ap);
-       if (len != 5) return 1;
+       if (len != 5) exit(1);
 
        va_start(ap, format);
        len = vsnprintf(0, 0, format, ap);
        va_end(ap);
-       if (len != 5) return 1;
+       if (len != 5) exit(1);
 
-       if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) return 1;
+       if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
 
-       return 0;
+       exit(0);
 }
-int main() { foo("hello"); }
+main() { foo("hello"); }
 ],
 samba_cv_HAVE_C99_VSNPRINTF=yes,samba_cv_HAVE_C99_VSNPRINTF=no,samba_cv_HAVE_C99_VSNPRINTF=cross)])
 if test x"$samba_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
@@ -2394,9 +2322,9 @@ fi
 AC_CACHE_CHECK([for broken readdir name],samba_cv_HAVE_BROKEN_READDIR_NAME,[
 AC_TRY_RUN([#include <sys/types.h>
 #include <dirent.h>
-int main() { struct dirent *di; DIR *d = opendir("."); di = readdir(d);
+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) return 0; return 1;} ],
+di->d_name[0] == 0) exit(0); exit(1);} ],
 samba_cv_HAVE_BROKEN_READDIR_NAME=yes,samba_cv_HAVE_BROKEN_READDIR_NAME=no,samba_cv_HAVE_BROKEN_READDIR_NAME=cross)])
 if test x"$samba_cv_HAVE_BROKEN_READDIR_NAME" = x"yes"; then
     AC_DEFINE(HAVE_BROKEN_READDIR_NAME,1,[Whether readdir() returns the wrong name offset])
@@ -2405,7 +2333,7 @@ fi
 AC_CACHE_CHECK([for utimbuf],samba_cv_HAVE_UTIMBUF,[
 AC_TRY_COMPILE([#include <sys/types.h>
 #include <utime.h>],
-[struct utimbuf tbuf;  tbuf.actime = 0; tbuf.modtime = 1; return utime("foo.c",&tbuf);],
+[struct utimbuf tbuf;  tbuf.actime = 0; tbuf.modtime = 1; exit(utime("foo.c",&tbuf));],
 samba_cv_HAVE_UTIMBUF=yes,samba_cv_HAVE_UTIMBUF=no,samba_cv_HAVE_UTIMBUF=cross)])
 if test x"$samba_cv_HAVE_UTIMBUF" = x"yes"; then
     AC_DEFINE(HAVE_UTIMBUF,1,[Whether struct utimbuf is available])
@@ -2502,6 +2430,16 @@ if test x"$samba_cv_HAVE_UT_UT_EXIT" = x"yes"; then
     AC_DEFINE(HAVE_UT_UT_EXIT,1,[Whether the utmp struct has a property ut_exit])
 fi
 
+dnl Look for the IPv6 varient by preference. Many systems have both.
+AC_CACHE_CHECK([for ut_addr_v6 in utmp],samba_cv_HAVE_UT_UT_ADDR_V6,[
+AC_TRY_COMPILE([#include <sys/types.h>
+#include <utmp.h>],
+[struct utmp ut;  ut.ut_addr_v6[0] = 0;],
+samba_cv_HAVE_UT_UT_ADDR_V6=yes,samba_cv_HAVE_UT_UT_ADDR_V6=no,samba_cv_HAVE_UT_UT_ADDR_V6=cross)])
+if test x"$samba_cv_HAVE_UT_UT_ADDR_V6" = x"yes"; then
+    AC_DEFINE(HAVE_UT_UT_ADDR_V6,1,[Whether the utmp struct has a property ut_addr_v6])
+fi
+
 AC_CACHE_CHECK([for ut_addr in utmp],samba_cv_HAVE_UT_UT_ADDR,[
 AC_TRY_COMPILE([#include <sys/types.h>
 #include <utmp.h>],
@@ -2727,7 +2665,7 @@ AC_TRY_RUN([
 #ifndef F_GETLEASE
 #define F_GETLEASE     1025
 #endif
-int main() {
+main() {
        int fd = open("/dev/null", O_RDONLY);
        return fcntl(fd, F_GETLEASE, 0) == -1;
 }
@@ -2745,8 +2683,8 @@ AC_TRY_RUN([
 #ifndef F_NOTIFY
 #define F_NOTIFY 1026
 #endif
-int main() {
-               return fcntl(open("/tmp", O_RDONLY), F_NOTIFY, 0) == -1 ?  1 : 0;
+main() {
+               exit(fcntl(open("/tmp", O_RDONLY), F_NOTIFY, 0) == -1 ?  1 : 0);
 }
 ],
 samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=yes,samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=no,samba_cv_HAVE_KERNEL_CHANGE_NOTIFY=cross)])
@@ -2813,6 +2751,12 @@ AC_SUBST(SMB_FAM_LIBS)
 
 SMB_CHECK_DMAPI([], AC_MSG_NOTICE(DMAPI support not present) )
 
+# Add TSM SM VFS module only if there are both GPFS and DMAPI support
+# Theoretically it should work with AIX JFS2 too but this needs testing
+if test x"$samba_cv_HAVE_GPFS" = x"yes" && test x"$samba_dmapi_libs" != x"" ; then
+    default_shared_modules="$default_shared_modules vfs_tsmsm"
+fi
+
 AC_CACHE_CHECK([for kernel share modes],samba_cv_HAVE_KERNEL_SHARE_MODES,[
 AC_TRY_RUN([
 #include <sys/types.h>
@@ -2823,8 +2767,8 @@ AC_TRY_RUN([
 #define LOCK_MAND      32
 #define LOCK_READ      64
 #endif
-int main() {
-               return flock(open("/dev/null", O_RDWR), LOCK_MAND|LOCK_READ) != 0;
+main() {
+               exit(flock(open("/dev/null", O_RDWR), LOCK_MAND|LOCK_READ) != 0);
 }
 ],
 samba_cv_HAVE_KERNEL_SHARE_MODES=yes,samba_cv_HAVE_KERNEL_SHARE_MODES=no,samba_cv_HAVE_KERNEL_SHARE_MODES=cross)])
@@ -2860,15 +2804,15 @@ if test x"$samba_cv_HAVE_SYS_CAPABILITY_H" = x"yes"; then
                AC_TRY_RUN([
 #include <sys/types.h>
 #include <sys/capability.h>
-int main() {
+main() {
  cap_t cap;
  cap_value_t vals[1];
  if (!(cap = cap_get_proc()))
-   return 1;
+   exit(1);
  vals[0] = CAP_CHOWN;
  cap_set_flag(cap, CAP_INHERITABLE, 1, vals, CAP_CLEAR);
  cap_set_proc(cap);
return 0;
exit(0);
 }],
                samba_cv_HAVE_POSIX_CAPABILITIES=yes,
                samba_cv_HAVE_POSIX_CAPABILITIES=no,
@@ -2990,15 +2934,15 @@ AC_TRY_RUN([#include <stdlib.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <unistd.h>
-int main() {
+main() {
   struct stat st;
   char tpl[20]="/tmp/test.XXXXXX";
   int fd = mkstemp(tpl);
-  if (fd == -1) return 1;
+  if (fd == -1) exit(1);
   unlink(tpl);
-  if (fstat(fd, &st) != 0) return 1;
-  if ((st.st_mode & 0777) != 0600) return 1;
-  return 0;
+  if (fstat(fd, &st) != 0) exit(1);
+  if ((st.st_mode & 0777) != 0600) exit(1);
+  exit(0);
 }],
 samba_cv_HAVE_SECURE_MKSTEMP=yes,
 samba_cv_HAVE_SECURE_MKSTEMP=no,
@@ -3008,12 +2952,7 @@ if test x"$samba_cv_HAVE_SECURE_MKSTEMP" = x"yes"; then
 fi
 
 AC_CACHE_CHECK([for broken readdir],samba_cv_HAVE_BROKEN_READDIR,[
-       AC_TRY_RUN([
-#include "${srcdir-.}/lib/replace/test/os2_delete.c"
-int main(void) {
-    return test_readdir_os2_delete();
-}
-],
+       AC_TRY_RUN([#include "${srcdir-.}/tests/os2_delete.c"],
                [samba_cv_HAVE_BROKEN_READDIR=no],
                        [samba_cv_HAVE_BROKEN_READDIR=yes],
                        [samba_cv_HAVE_BROKEN_READDIR="assuming not"])])
@@ -3022,10 +2961,7 @@ if test x"$samba_cv_HAVE_BROKEN_READDIR" = x"yes"; then
 AC_CACHE_CHECK([for replacing readdir],samba_cv_REPLACE_READDIR,[
        AC_TRY_RUN([
 #include "${srcdir-.}/lib/repdir.c"
-#include "${srcdir-.}/lib/replace/test/os2_delete.c"
-int main(void) {
-    return test_readdir_os2_delete();
-],
+#include "${srcdir-.}/tests/os2_delete.c"],
        samba_cv_REPLACE_READDIR=yes,samba_cv_REPLACE_READDIR=no)])
 fi
 
@@ -3039,22 +2975,6 @@ SMB_CHECK_SYSCONF(_SC_NPROCESSORS_ONLN)
 SMB_CHECK_SYSCONF(_SC_PAGESIZE)
 AC_CHECK_FUNCS(getpagesize)
 
-dnl test for sa_family_t
-AC_CACHE_CHECK([for sa_family_t],samba_cv_HAVE_SA_FAMILY_T,[
-AC_TRY_COMPILE([
-#include <sys/socket.h>
-#include <sys/types.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-],
-[
-sa_family_t foo;
-],
-samba_cv_HAVE_SA_FAMILY_T=yes,samba_cv_HAVE_SA_FAMILY_T=no)])
-if test x"$samba_cv_HAVE_SA_FAMILY_T" = x"yes"; then
-    AC_DEFINE(HAVE_SA_FAMILY_T,1,[Whether the system has sa_family_t])
-fi
-
 dnl test for getifaddrs and freeifaddrs
 AC_CACHE_CHECK([for getifaddrs and freeifaddrs],samba_cv_HAVE_GETIFADDRS,[
 AC_TRY_COMPILE([
@@ -3078,33 +2998,19 @@ fi
 ##################
 # look for a method of finding the list of network interfaces
 iface=no;
-AC_CACHE_CHECK([for iface AIX],samba_cv_HAVE_IFACE_AIX,[
-SAVE_CPPFLAGS="$CPPFLAGS"
-CPPFLAGS="$CPPFLAGS ${SAMBA_CONFIGURE_CPPFLAGS}"
-AC_TRY_RUN([
-#define HAVE_IFACE_AIX 1
-#define AUTOCONF_TEST 1
-#undef _XOPEN_SOURCE_EXTENDED
-#include "${srcdir-.}/lib/interfaces.c"],
-           samba_cv_HAVE_IFACE_AIX=yes,samba_cv_HAVE_IFACE_AIX=no,samba_cv_HAVE_IFACE_AIX=cross)])
-CPPFLAGS="$SAVE_CPPFLAGS"
-if test x"$samba_cv_HAVE_IFACE_AIX" = x"yes"; then
-    iface=yes;AC_DEFINE(HAVE_IFACE_AIX,1,[Whether iface AIX is available])
-fi
-
-if test $iface = no; then
-AC_CACHE_CHECK([for iface getifaddrs],samba_cv_HAVE_GETIFADDRS,[
+AC_CACHE_CHECK([for iface getifaddrs],samba_cv_HAVE_IFACE_GETIFADDRS,[
 SAVE_CPPFLAGS="$CPPFLAGS"
 CPPFLAGS="$CPPFLAGS ${SAMBA_CONFIGURE_CPPFLAGS}"
 AC_TRY_RUN([
+#define NO_CONFIG_H 1
 #define HAVE_IFACE_GETIFADDRS 1
 #define AUTOCONF_TEST 1
+#include "${srcdir-.}/lib/replace/replace.c"
 #include "${srcdir-.}/lib/interfaces.c"],
            samba_cv_HAVE_IFACE_GETIFADDRS=yes,samba_cv_HAVE_IFACE_GETIFADDRS=no,samba_cv_HAVE_IFACE_GETIFADDRS=cross)])
 CPPFLAGS="$SAVE_CPPFLAGS"
 if test x"$samba_cv_HAVE_IFACE_GETIFADDRS" = x"yes"; then
-    iface=yes;AC_DEFINE(HAVE_IFACE_GETIFADDRS,1,[Whether iface ifconf is available])
-fi
+    iface=yes;AC_DEFINE(HAVE_IFACE_GETIFADDRS,1,[Whether iface getifaddrs is available])
 fi
 
 if test $iface = no; then
@@ -3112,8 +3018,11 @@ AC_CACHE_CHECK([for iface ifconf],samba_cv_HAVE_IFACE_IFCONF,[
 SAVE_CPPFLAGS="$CPPFLAGS"
 CPPFLAGS="$CPPFLAGS ${SAMBA_CONFIGURE_CPPFLAGS}"
 AC_TRY_RUN([
+#define NO_CONFIG_H 1
 #define HAVE_IFACE_IFCONF 1
 #define AUTOCONF_TEST 1
+#define SOCKET_WRAPPER_NOT_REPLACE
+#include "${srcdir-.}/lib/replace/replace.c"
 #include "${srcdir-.}/lib/interfaces.c"],
            samba_cv_HAVE_IFACE_IFCONF=yes,samba_cv_HAVE_IFACE_IFCONF=no,samba_cv_HAVE_IFACE_IFCONF=cross)])
 CPPFLAGS="$SAVE_CPPFLAGS"
@@ -3127,8 +3036,13 @@ AC_CACHE_CHECK([for iface ifreq],samba_cv_HAVE_IFACE_IFREQ,[
 SAVE_CPPFLAGS="$CPPFLAGS"
 CPPFLAGS="$CPPFLAGS ${SAMBA_CONFIGURE_CPPFLAGS}"
 AC_TRY_RUN([
+#define NO_CONFIG_H 1
 #define HAVE_IFACE_IFREQ 1
 #define AUTOCONF_TEST 1
+#define SOCKET_WRAPPER_NOT_REPLACE
+#include "${srcdir-.}/lib/replace/replace.c"
+#include "${srcdir-.}/lib/replace/getaddrinfo.c"
+#include "${srcdir-.}/lib/replace/snprintf.c"
 #include "${srcdir-.}/lib/interfaces.c"],
            samba_cv_HAVE_IFACE_IFREQ=yes,samba_cv_HAVE_IFACE_IFREQ=no,samba_cv_HAVE_IFACE_IFREQ=cross)])
 CPPFLAGS="$SAVE_CPPFLAGS"
@@ -3137,15 +3051,37 @@ if test x"$samba_cv_HAVE_IFACE_IFREQ" = x"yes"; then
 fi
 fi
 
+if test $iface = no; then
+AC_CACHE_CHECK([for iface AIX],samba_cv_HAVE_IFACE_AIX,[
+SAVE_CPPFLAGS="$CPPFLAGS"
+CPPFLAGS="$CPPFLAGS ${SAMBA_CONFIGURE_CPPFLAGS}"
+AC_TRY_RUN([
+#define NO_CONFIG_H 1
+#define HAVE_IFACE_AIX 1
+#define AUTOCONF_TEST 1
+#undef _XOPEN_SOURCE_EXTENDED
+#define SOCKET_WRAPPER_NOT_REPLACE
+#include "${srcdir-.}/lib/replace/replace.c"
+#include "${srcdir-.}/lib/replace/snprintf.c"
+#include "${srcdir-.}/lib/interfaces.c"],
+           samba_cv_HAVE_IFACE_AIX=yes,samba_cv_HAVE_IFACE_AIX=no,samba_cv_HAVE_IFACE_AIX=cross)])
+CPPFLAGS="$SAVE_CPPFLAGS"
+if test x"$samba_cv_HAVE_IFACE_AIX" = x"yes"; then
+    iface=yes;AC_DEFINE(HAVE_IFACE_AIX,1,[Whether iface AIX is available])
+fi
+fi
+
 dnl test for ipv6
 AC_CACHE_CHECK([for ipv6 support],samba_cv_HAVE_IPV6,[
 AC_TRY_COMPILE([
+#include <stdlib.h> /* for NULL */
 #include <sys/socket.h>
 #include <sys/types.h>
 #include <netdb.h>],
 [
 struct sockaddr_storage sa_store;
 struct addrinfo *ai = NULL;
+struct in6_addr in6addr;
 int s = socket(AF_INET6, SOCK_STREAM, 0);
 int ret = getaddrinfo(NULL, NULL, NULL, &ai);
 if (ret != 0) {
@@ -3272,11 +3208,11 @@ dnl
 #ifdef HAVE_SYS_FCNTL_H
 #include <sys/fcntl.h>
 #endif
-int main() { struct flock64 fl64;
+main() { struct flock64 fl64;
 #if defined(F_SETLKW64) && defined(F_SETLK64) && defined(F_GETLK64)
-return 0;
+exit(0);
 #else
-return 1;
+exit(1);
 #endif
 }],
        samba_cv_HAVE_STRUCT_FLOCK64=yes,samba_cv_HAVE_STRUCT_FLOCK64=no,samba_cv_HAVE_STRUCT_FLOCK64=cross)])
@@ -3323,24 +3259,6 @@ if test x"$samba_cv_HAVE_STAT_ST_FLAGS" = x"yes"; then
                [Whether the stat struct has a st_flags member])
 fi
 
-case "$host_os" in
-*linux*)
-AC_CACHE_CHECK([for broken RedHat 7.2 system header files],samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS,[
-AC_TRY_COMPILE([
-#ifdef HAVE_SYS_VFS_H
-#include <sys/vfs.h>
-#endif
-#ifdef HAVE_SYS_CAPABILITY_H
-#include <sys/capability.h>
-#endif
-],[int i;],
-   samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS=no,samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS=yes)])
-if test x"$samba_cv_BROKEN_REDHAT_7_SYSTEM_HEADERS" = x"yes"; then
-   AC_DEFINE(BROKEN_REDHAT_7_SYSTEM_HEADERS,1,[Broken RedHat 7.2 system header files])
-fi
-;;
-esac
-
 AC_CACHE_CHECK([for broken nisplus include files],samba_cv_BROKEN_NISPLUS_INCLUDE_FILES,[
 AC_TRY_COMPILE([
 #include <sys/types.h>
@@ -3357,11 +3275,10 @@ fi
 AC_CACHE_CHECK([if the realpath function allows a NULL argument],samba_cv_REALPATH_TAKES_NULL,[
 AC_TRY_RUN([
 #include <stdio.h>
-#include <stdlib.h>
 #include <limits.h>
-int main() {
+main() {
        char *newpath = realpath("/tmp", NULL);
-       return (newpath != NULL) ? 0 : 1;
+       exit ((newpath != NULL) ? 0 : 1);
 }
 ],
 samba_cv_REALPATH_TAKES_NULL=yes,samba_cv_REALPATH_TAKES_NULL=no,samba_cv_REALPATH_TAKES_NULL=cross)])
@@ -3600,12 +3517,6 @@ if test x"$with_ldap_support" != x"no"; then
     default_shared_modules="$default_shared_modules";
     SMBLDAP="lib/smbldap.o"
     SMBLDAPUTIL="lib/smbldap_util.o"
-    if test x"$ac_cv_func_ext_ldap_initialize" != x"yes"; then
-      AC_MSG_WARN(Disabling ldb_ldap support (requires ldap_initialize))
-    else
-      AC_DEFINE(HAVE_LDB_LDAP,1,[Whether ldb_ldap is available])
-      LDBLDAP="lib/ldb/ldb_ldap/ldb_ldap.o"
-    fi
     with_ldap_support=yes
     AC_MSG_CHECKING(whether LDAP support is used)
     AC_MSG_RESULT(yes)
@@ -3762,10 +3673,12 @@ if test x"$with_ads_support" != x"no"; then
           KRB5_CFLAGS="-I/usr/include/heimdal"
           KRB5_CPPFLAGS="-I/usr/include/heimdal"
           KRB5_LDFLAGS="-L/usr/lib/heimdal/lib"
+         FOUND_KRB5=yes
           AC_MSG_RESULT(yes)
       else
           KRB5_CFLAGS="-I/usr/include/heimdal"
           KRB5_CPPFLAGS="-I/usr/include/heimdal"
+         FOUND_KRB5=yes
           AC_MSG_RESULT(yes)
       fi
     else
@@ -3781,6 +3694,21 @@ if test x"$with_ads_support" != x"no"; then
       KRB5_LDFLAGS="-L/usr/kerberos/lib"
       KRB5_CFLAGS="-I/usr/kerberos/include"
       KRB5_CPPFLAGS="-I/usr/kerberos/include"
+      FOUND_KRB5=yes
+      AC_MSG_RESULT(yes)
+    else
+      AC_MSG_RESULT(no)
+    fi
+  fi
+
+  if test x$FOUND_KRB5 = x"no"; then
+    #################################################
+    # see if this box has the OpenBSD location for heimdal krb5
+    AC_MSG_CHECKING(for /usr/include/kerberosV)
+    if test -d /usr/include/kerberosV; then
+      KRB5_CPPFLAGS="-I/usr/include/kerberosV"
+      KRB5_LIBS="-lcrypto"
+      FOUND_KRB5=yes
       AC_MSG_RESULT(yes)
     else
       AC_MSG_RESULT(no)
@@ -3823,8 +3751,8 @@ if test x"$with_ads_support" != x"no"; then
   fi
   AC_CHECK_HEADERS(krb5/locate_plugin.h)
   if test x"$ac_cv_header_krb5_locate_plugin_h" = x"yes"; then
-       SMB_KRB5_LOCATOR="bin/smb_krb5_locator.$SHLIBEXT"
-       EXTRA_ALL_TARGETS="$EXTRA_ALL_TARGETS $SMB_KRB5_LOCATOR"
+       WINBIND_KRB5_LOCATOR="bin/winbind_krb5_locator.$SHLIBEXT"
+       EXTRA_ALL_TARGETS="$EXTRA_ALL_TARGETS $WINBIND_KRB5_LOCATOR"
   fi
 fi
 
@@ -4225,7 +4153,7 @@ if test x"$with_ads_support" != x"no"; then
                 samba_cv_HAVE_WRFILE_KEYTAB,[
     AC_TRY_RUN([
 #include<krb5.h>
-  int main()
+  main()
   {
     krb5_context context;
     krb5_keytab keytab;
@@ -4321,6 +4249,30 @@ if test x"$with_ads_support" != x"no"; then
     fi
   fi
 
+  AC_CACHE_CHECK([for krb5_principal_get_realm],
+                samba_cv_HAVE_KRB5_PRINCIPAL_GET_REALM,[
+    AC_TRY_LINK([#include <krb5.h>],
+      [krb5_context ctx = NULL; krb5_principal princ = NULL; const char *str = krb5_principal_get_realm(ctx, princ);],
+      samba_cv_HAVE_KRB5_PRINCIPAL_GET_REALM=yes,
+      samba_cv_HAVE_KRB5_PRINCIPAL_GET_REALM=no)])
+
+  if test x"$samba_cv_HAVE_KRB5_PRINCIPAL_GET_REALM" = x"yes"; then
+    AC_DEFINE(HAVE_KRB5_PRINCIPAL_GET_REALM,1,
+               [Whether the function krb5_principal_get_realm is defined])
+  fi
+
+  AC_CACHE_CHECK([for krb5_princ_realm],
+                samba_cv_HAVE_KRB5_PRINC_REALM,[
+    AC_TRY_LINK([#include <krb5.h>],
+      [krb5_context ctx = NULL; krb5_principal princ = NULL; const char *str = krb5_princ_realm(ctx, princ)->data;],
+      samba_cv_HAVE_KRB5_PRINC_REALM=yes,
+      samba_cv_HAVE_KRB5_PRINC_REALM=no)])
+
+  if test x"$samba_cv_HAVE_KRB5_PRINC_REALM" = x"yes"; then
+    AC_DEFINE(HAVE_KRB5_PRINC_REALM,1,
+               [Whether the macro krb5_princ_realm is defined])
+  fi
+
   #
   #
   # Now the decisions whether we can support krb5
@@ -4561,6 +4513,45 @@ AC_ARG_WITH(cifsmount,
   esac ]
 )
 
+#################################################
+# check for cifs.spnego support
+AC_CHECK_HEADERS([keyutils.h], [HAVE_KEYUTILS_H=1], [HAVE_KEYUTILS_H=0])
+CIFSSPNEGO_PROGS=""
+INSTALL_CIFSSPNEGO=""
+UNINSTALL_CIFSSPNEGO=""
+AC_MSG_CHECKING(whether to build cifs.spnego)
+AC_ARG_WITH(cifsspnego,
+[  --with-cifsspnego       Include cifs.spnego (Linux only) support (default=no)],
+[ case "$withval" in
+  no)
+       AC_MSG_RESULT(no)
+       ;;
+  *)
+       case "$host_os" in
+       *linux*)
+               if test x"$use_ads" != x"yes"; then
+                       AC_MSG_ERROR(ADS support should be enabled for building cifs.spnego)
+               elif test x"$HAVE_KEYUTILS_H" != "x1"; then
+                       AC_MSG_ERROR(keyutils package is required for cifs.spnego)
+               else
+                       AC_MSG_RESULT(yes)
+                       AC_DEFINE(WITH_CIFSSPNEGO,1,[whether to build cifs.spnego])
+                       CIFSSPNEGO_PROGS="bin/cifs.spnego"
+                       INSTALL_CIFSSPNEGO="installcifsspnego"
+                       UNINSTALL_CIFSSPNEGO="uninstallcifsspnego"
+               fi
+               ;;
+       *)
+               AC_MSG_ERROR(not on a linux system!)
+               ;;
+       esac
+    ;;
+  esac ],
+[
+  AC_MSG_RESULT(no)
+  ]
+)
+
 
 #################################################
 # Check for a PAM clear-text auth, accounts, password
@@ -4620,15 +4611,15 @@ if test x"${try_pam}" != x"no";then
                x"$ac_cv_header_pam_pam_modules_h" = x"no" ; then
                if test x"${try_pam}" = x"yes";then
                        AC_MSG_ERROR([--with-pam=yes but pam_modules.h not found])
-               fi
+       fi
                create_pam_modules=no
-       fi
+    fi
 
        if test x"$use_pam" = x"yes"; then
-               AC_DEFINE(WITH_PAM,1,[Whether to include PAM support])
+    AC_DEFINE(WITH_PAM,1,[Whether to include PAM support])
                AC_DEFINE(HAVE_LIBPAM,1,[Whether libpam is available])
                AUTH_LIBS="$AUTH_LIBS $PAM_LIBS"
-               with_pam_for_crypt=yes
+    with_pam_for_crypt=yes
 
                if test x"$create_pam_modules" = x"yes"; then
                        AC_DEFINE(WITH_PAM_MODULES,1,[Whether to include PAM MODULES support])
@@ -5104,37 +5095,50 @@ if test $enable_static = yes; then
 fi
 
 #################################################
-# should we build libmsrpc?
-INSTALL_LIBMSRPC=
-UNINSTALL_LIBMSRPC=
-LIBMSRPC_SHARED=
-LIBMSRPC=
-AC_MSG_CHECKING(whether to build the libmsrpc shared library)
-AC_ARG_WITH(libmsrpc,
-[  --with-libmsrpc         Build the libmsrpc shared library (default=no unmaintained)],
+# should we build libnetapi?
+INSTALL_LIBNETAPI=
+UNINSTALL_LIBNETAPI=
+LIBNETAPI_SHARED=
+LIBNETAPI=
+AC_MSG_CHECKING(whether to build the libnetapi shared library)
+AC_ARG_WITH(libnetapi,
+[  --with-libnetapi        Build the libnetapi shared library (default=yes if shared libs supported)],
 [ case "$withval" in
   *)
      AC_MSG_RESULT(no)
      ;;
   yes)
      if test $BLDSHARED = true; then
-        LIBMSRPC_SHARED=bin/libmsrpc.$SHLIBEXT
-        LIBMSRPC=libmsrpc
+        LIBNETAPI_SHARED=bin/libnetapi.$SHLIBEXT
+        LIBNETAPI=libnetapi
         AC_MSG_RESULT(yes)
      else
        enable_static=yes
         AC_MSG_RESULT(no shared library support -- will supply static library)
      fi
      if test $enable_static = yes; then
-        LIBMSRPC=libmsrpc
+        LIBNETAPI=libnetapi
      fi
-     INSTALL_LIBMSRPC=installlibmsrpc
-     UNINSTALL_LIBMSRPC=uninstalllibmsrpc
+     INSTALL_LIBNETAPI=installlibnetapi
+     UNINSTALL_LIBNETAPI=uninstalllibnetapi
      ;;
-  esac ]
+  esac ],
+[
+# if unspecified, default is to built it if possible.
+  if test $BLDSHARED = true; then
+     LIBNETAPI_SHARED=bin/libnetapi.$SHLIBEXT
+     LIBNETAPI=libnetapi
+     AC_MSG_RESULT(yes)
+   else
+     enable_static=yes
+     AC_MSG_RESULT(no shared library support -- will supply static library)
+   fi
+   if test $enable_static = yes; then
+     LIBNETAPI=libnetapi
+  fi]
+  INSTALL_LIBNETAPI=installlibnetapi
 )
 
-
 #################################################
 # should we build libaddns?
 INSTALL_LIBADDNS=
@@ -5163,11 +5167,13 @@ AC_ARG_WITH(libaddns,
      INSTALL_LIBADDNS=installlibaddns
      UNINSTALL_LIBADDNS=uninstalllibaddns
      ;;
-  esac ]
+  esac ],
+[AC_MSG_RESULT(no)]
 )
 
 #################################################
 # should we build libsmbclient?
+
 INSTALL_LIBSMBCLIENT=
 UNINSTALL_LIBSMBCLIENT=
 LIBSMBCLIENT_SHARED=
@@ -5254,6 +5260,7 @@ AC_ARG_WITH(libsmbsharemodes,
   INSTALL_LIBSMBSHAREMODES=installlibsmbsharemodes
 )
 
+
 #################################################
 # these tests are taken from the GNU fileutils package
 AC_CHECKING(how to get filesystem space usage)
@@ -5272,7 +5279,7 @@ if test $space = no; then
   main ()
   {
     struct statvfs64 fsd;
-    return statvfs64 (".", &fsd);
+    exit (statvfs64 (".", &fsd));
   }],
   fu_cv_sys_stat_statvfs64=yes,
   fu_cv_sys_stat_statvfs64=no,
@@ -5325,7 +5332,7 @@ if test $space = no; then
   {
     struct statfs fsd;
     fsd.f_fsize = 0;
-    return statfs (".", &fsd, sizeof (struct statfs));
+    exit (statfs (".", &fsd, sizeof (struct statfs)));
   }],
   fu_cv_sys_stat_statfs3_osf1=yes,
   fu_cv_sys_stat_statfs3_osf1=no,
@@ -5356,7 +5363,7 @@ member (AIX, 4.3BSD)])
   {
   struct statfs fsd;
   fsd.f_bsize = 0;
-  return statfs (".", &fsd);
+  exit (statfs (".", &fsd));
   }],
   fu_cv_sys_stat_statfs2_bsize=yes,
   fu_cv_sys_stat_statfs2_bsize=no,
@@ -5377,7 +5384,7 @@ if test $space = no; then
   main ()
   {
   struct statfs fsd;
-  return statfs (".", &fsd, sizeof fsd, 0);
+  exit (statfs (".", &fsd, sizeof fsd, 0));
   }],
     fu_cv_sys_stat_statfs4=yes,
     fu_cv_sys_stat_statfs4=no,
@@ -5405,7 +5412,7 @@ member (4.4BSD and NetBSD)])
   {
   struct statfs fsd;
   fsd.f_fsize = 0;
-  return statfs (".", &fsd);
+  exit (statfs (".", &fsd));
   }],
   fu_cv_sys_stat_statfs2_fsize=yes,
   fu_cv_sys_stat_statfs2_fsize=no,
@@ -5436,7 +5443,7 @@ if test $space = no; then
   struct fs_data fsd;
   /* Ultrix's statfs returns 1 for success,
      0 for not mounted, -1 for failure.  */
-  return statfs (".", &fsd) != 1;
+  exit (statfs (".", &fsd) != 1);
   }],
   fu_cv_sys_stat_fs_data=yes,
   fu_cv_sys_stat_fs_data=no,
@@ -5752,7 +5759,7 @@ AC_ARG_WITH(sendfile-support,
        AC_MSG_RESULT(yes);
 
        case "$host_os" in
-       linux*-gnu* | gnu* | k*bsd*-gnu)
+       *linux*)
                AC_CACHE_CHECK([for linux sendfile64 support],samba_cv_HAVE_SENDFILE64,[
                AC_TRY_LINK([#include <sys/sendfile.h>],
 [\
@@ -6001,7 +6008,6 @@ samba_cv_HAVE_SENDFILE=yes,samba_cv_HAVE_SENDFILE=no)])
 
 AC_CACHE_CHECK([for Linux readahead],
                 samba_cv_HAVE_LINUX_READAHEAD,[
-
     AC_TRY_LINK([
 #if defined(HAVE_UNISTD_H)
 #include <unistd.h>
@@ -6059,11 +6065,11 @@ NSSSONAMEVERSIONSUFFIX=""
 WINBIND_NSS_PTHREAD=""
 
 case "$host_os" in
-       linux*-gnu* | gnu* | k*bsd*-gnu)
+       *linux*)
                NSSSONAMEVERSIONSUFFIX=".2"
                WINBIND_NSS_EXTRA_OBJS="nsswitch/winbind_nss_linux.o"
                ;;
-       freebsd5*|*freebsd[[6-9]]*)
+       *freebsd[[5-9]]*)
                # FreeBSD winbind client is implemented as a wrapper around
                # the Linux version.
                NSSSONAMEVERSIONSUFFIX=".1"
@@ -6120,18 +6126,6 @@ case "$host_os" in
                ;;
 esac
 
-AC_CHECK_LIB(pthread, pthread_mutex_lock, [WINBIND_NSS_PTHREAD="-lpthread"
-                       AC_DEFINE(HAVE_PTHREAD, 1, [whether pthread exists])])
-AC_SUBST(WINBIND_NSS_PTHREAD)
-AC_SUBST(WINBIND_NSS)
-AC_SUBST(WINBIND_WINS_NSS)
-AC_SUBST(WINBIND_NSS_LDSHFLAGS)
-AC_SUBST(WINBIND_NSS_EXTRA_OBJS)
-AC_SUBST(WINBIND_NSS_EXTRA_LIBS)
-AC_SUBST(NSSSONAMEVERSIONSUFFIX)
-
-AC_SUBST(SMB_KRB5_LOCATOR)
-
 # Check the setting of --with-winbind
 
 AC_ARG_WITH(winbind,
@@ -6164,8 +6158,26 @@ if test x"$HAVE_WINBIND" = x"no"; then
        WINBIND_WINS_NSS=""
 fi
 
-if test $BLDSHARED = true -a x"$HAVE_WINBIND" = x"yes"; then
+BUILD_LIBWBCLIENT_SHARED=yes
+
+AC_ARG_ENABLE(libwbclient-shared,
+[ --enable-libwbclient-shared  Build libwbclient as shared object (default=yes, \"no\" only for --enable-developer)],
+       [if eval "test x$enable_developer = xyes -a x$enable_libwbclient_shared = xno" ; then
+               BUILD_LIBWBCLIENT_SHARED=no
+       fi])
+
+if test $BLDSHARED = true -a x"$HAVE_WINBIND" = x"yes" -a x"$BUILD_LIBWBCLIENT_SHARED" = x"yes"; then
        NSS_MODULES="${WINBIND_NSS} ${WINBIND_WINS_NSS}"
+       ## Only worry about libwbclient if we have shared library support
+       ## and winbindd
+        LIBWBCLIENT_SHARED=bin/libwbclient.$SHLIBEXT
+        LIBWBCLIENT=libwbclient
+       INSTALL_LIBWBCLIENT=installlibwbclient
+       UNINSTALL_LIBWBCLIENT=uninstalllibwbclient
+       WINBIND_LIBS="-lwbclient"
+       LDFLAGS="$LDFLAGS -L./bin"
+else
+       LIBWBCLIENT_STATIC=bin/libwbclient.a
 fi
 
 if test x"$HAVE_WINBIND" = x"yes"; then
@@ -6183,6 +6195,19 @@ else
         AC_MSG_RESULT(no$winbind_no_reason)
 fi
 
+AC_CHECK_LIB(pthread, pthread_mutex_lock, [WINBIND_NSS_PTHREAD="-lpthread"
+                       AC_DEFINE(HAVE_PTHREAD, 1, [whether pthread exists])])
+
+AC_SUBST(WINBIND_NSS_PTHREAD)
+AC_SUBST(WINBIND_NSS)
+AC_SUBST(WINBIND_WINS_NSS)
+AC_SUBST(WINBIND_NSS_LDSHFLAGS)
+AC_SUBST(WINBIND_NSS_EXTRA_OBJS)
+AC_SUBST(WINBIND_NSS_EXTRA_LIBS)
+AC_SUBST(NSSSONAMEVERSIONSUFFIX)
+
+AC_SUBST(WINBIND_KRB5_LOCATOR)
+
 # Solaris 10 does have new member in nss_XbyY_key
 AC_CHECK_MEMBER(union nss_XbyY_key.ipnode.af_family,
                AC_DEFINE(HAVE_NSS_XBYY_KEY_IPNODE, 1, [Defined if union nss_XbyY_key has ipnode field]),,
@@ -6218,6 +6243,7 @@ if test x"$samba_cv_HAVE_PEERCRED" = x"yes"; then
     AC_DEFINE(HAVE_PEERCRED,1,[Whether we can use SO_PEERCRED to get socket credentials])
 fi
 
+
 #################################################
 # Check to see if we should use the included popt
 
@@ -6246,13 +6272,48 @@ if test x"$INCLUDED_POPT" = x"yes"; then
     FLAGS1="-I\$(srcdir)/popt"
 else
     AC_MSG_RESULT(no)
-    BUILD_POPT=""
+       BUILD_POPT=""
     POPTLIBS="-lpopt"
 fi
 AC_SUBST(BUILD_POPT)
 AC_SUBST(POPTLIBS)
 AC_SUBST(FLAGS1)
 
+#################################################
+# Check if user wants DNS service discovery support
+
+AC_ARG_ENABLE(dnssd,
+[  --enable-dnssd          Enable DNS service discovery support (default=auto)])
+
+AC_SUBST(DNSSD_LIBS)
+if test x"$enable_dnssd" != x"no"; then
+    have_dnssd_support=yes
+
+    AC_CHECK_HEADERS(dns_sd.h)
+    if test x"$ac_cv_header_dns_sd_h" != x"yes"; then
+       have_dnssd_support=no
+    fi
+
+    # On Darwin the DNSSD API is in libc, but on other platforms it's
+    # probably in -ldns_sd
+    AC_CHECK_FUNCS(DNSServiceRegister)
+    AC_CHECK_LIB_EXT(dns_sd, DNSSD_LIBS, DNSServiceRegister)
+    if test x"$ac_cv_func_DNSServiceRegister" != x"yes" -a \
+            x"$ac_cv_lib_ext_DNSServiceRegister" != x"yes"; then
+       have_dnssd_support=no
+    fi
+
+    if test x"$have_dnssd_support" = x"yes"; then
+       AC_DEFINE(WITH_DNSSD_SUPPORT, 1,
+               [Whether to enable DNS service discovery support])
+    else
+       if test x"$enable_dnssd" = x"yes"; then
+           AC_MSG_ERROR(DNS service discovery support not available)
+       fi
+    fi
+
+fi
+
 #################################################
 # Check to see if we should use the included iniparser
 
@@ -6290,35 +6351,6 @@ AC_SUBST(FLAGS1)
 
 
 
-#################################################
-# Check if the user wants Python
-
-# At the moment, you can use this to set which Python binary to link
-# against.  (Libraries built for Python2.2 can't be used by 2.1,
-# though they can coexist in different directories.)  In the future
-# this might make the Python stuff be built by default.
-
-# Defaulting python breaks the clean target if python isn't installed
-
-PYTHON=
-
-AC_ARG_WITH(python,
-[  --with-python=PYTHONNAME  build Python libraries],
-[ case "${withval-python}" in
-  yes)
-       PYTHON=python
-       EXTRA_ALL_TARGETS="$EXTRA_ALL_TARGETS python_ext"
-       ;;
-  no)
-       PYTHON=
-       ;;
-  *)
-       PYTHON=${withval-python}
-       ;;
-  esac ])
-AC_SUBST(PYTHON)
-
-
 # Checks for the vfs_fileid module
 # Start
 AC_CHECK_FUNC(getmntent)
@@ -6367,7 +6399,7 @@ done
 
 dnl Always built these modules static
 MODULE_rpc_spoolss=STATIC
-MODULE_rpc_srvsvc=STATIC
+MODULE_rpc_srvsvc2=STATIC
 MODULE_idmap_tdb=STATIC
 MODULE_idmap_passdb=STATIC
 MODULE_idmap_nss=STATIC
@@ -6408,17 +6440,16 @@ SMB_MODULE(rpc_svcctl2, \$(RPC_SVCCTL_OBJ), "bin/librpc_svcctl2.$SHLIBEXT", RPC)
 SMB_MODULE(rpc_ntsvcs, \$(RPC_NTSVCS_OBJ), "bin/librpc_ntsvcs.$SHLIBEXT", RPC)
 SMB_MODULE(rpc_net, \$(RPC_NETLOG_OBJ), "bin/librpc_NETLOGON.$SHLIBEXT", RPC)
 SMB_MODULE(rpc_netdfs, \$(RPC_DFS_OBJ), "bin/librpc_netdfs.$SHLIBEXT", RPC)
-SMB_MODULE(rpc_srvsvc, \$(RPC_SVC_OBJ), "bin/librpc_srvsvc.$SHLIBEXT", RPC)
+SMB_MODULE(rpc_srvsvc2, \$(RPC_SVC_OBJ), "bin/librpc_svcsvc2.$SHLIBEXT", RPC)
 SMB_MODULE(rpc_spoolss, \$(RPC_SPOOLSS_OBJ), "bin/librpc_spoolss.$SHLIBEXT", RPC)
 SMB_MODULE(rpc_eventlog2, \$(RPC_EVENTLOG_OBJ), "bin/librpc_eventlog2.$SHLIBEXT", RPC)
 SMB_MODULE(rpc_samr, \$(RPC_SAMR_OBJ), "bin/librpc_samr.$SHLIBEXT", RPC)
-SMB_MODULE(rpc_rpcecho, \$(RPC_ECHO_OBJ), "bin/librpc_echo.$SHLIBEXT", RPC)
-SMB_MODULE(rpc_unixinfo, \$(RPC_UNIXINFO_OBJ), "bin/librpc_unixinfo.$SHLIBEXT", RPC)
-SMB_MODULE(rpc_epmapper, \$(RPC_EPMAPPER_OBJ), "bin/librpc_epmapper.$SHLIBEXT", RPC)
+SMB_MODULE(rpc_rpcecho, \$(RPC_ECHO_OBJ), "bin/librpc_rpcecho.$SHLIBEXT", RPC)
 SMB_SUBSYSTEM(RPC,smbd/server.o)
 
 SMB_MODULE(idmap_ldap, winbindd/idmap_ldap.o, "bin/ldap.$SHLIBEXT", IDMAP)
 SMB_MODULE(idmap_tdb, winbindd/idmap_tdb.o, "bin/tdb.$SHLIBEXT", IDMAP)
+SMB_MODULE(idmap_tdb2, winbindd/idmap_tdb2.o, "bin/tdb2.$SHLIBEXT", IDMAP)
 SMB_MODULE(idmap_passdb, winbindd/idmap_passdb.o, "bin/passdb.$SHLIBEXT", IDMAP)
 SMB_MODULE(idmap_nss, winbindd/idmap_nss.o, "bin/nss.$SHLIBEXT", IDMAP)
 SMB_MODULE(idmap_rid, winbindd/idmap_rid.o, "bin/rid.$SHLIBEXT", IDMAP)
@@ -6455,7 +6486,9 @@ SMB_MODULE(vfs_readonly, \$(VFS_READONLY_OBJ), "bin/readonly.$SHLIBEXT", VFS)
 SMB_MODULE(vfs_cap, \$(VFS_CAP_OBJ), "bin/cap.$SHLIBEXT", VFS)
 SMB_MODULE(vfs_expand_msdfs, \$(VFS_EXPAND_MSDFS_OBJ), "bin/expand_msdfs.$SHLIBEXT", VFS)
 SMB_MODULE(vfs_shadow_copy, \$(VFS_SHADOW_COPY_OBJ), "bin/shadow_copy.$SHLIBEXT", VFS)
+SMB_MODULE(vfs_shadow_copy2, \$(VFS_SHADOW_COPY2_OBJ), "bin/shadow_copy2.$SHLIBEXT", VFS)
 SMB_MODULE(vfs_afsacl, \$(VFS_AFSACL_OBJ), "bin/afsacl.$SHLIBEXT", VFS)
+SMB_MODULE(vfs_xattr_tdb, \$(VFS_XATTR_TDB_OBJ), "bin/xattr_tdb.$SHLIBEXT", VFS)
 SMB_MODULE(vfs_posixacl, \$(VFS_POSIXACL_OBJ), "bin/posixacl.$SHLIBEXT", VFS)
 SMB_MODULE(vfs_aixacl, \$(VFS_AIXACL_OBJ), "bin/aixacl.$SHLIBEXT", VFS)
 SMB_MODULE(vfs_aixacl2, \$(VFS_AIXACL2_OBJ), "bin/aixacl2.$SHLIBEXT", VFS)
@@ -6464,13 +6497,19 @@ SMB_MODULE(vfs_irixacl, \$(VFS_IRIXACL_OBJ), "bin/irixacl.$SHLIBEXT", VFS)
 SMB_MODULE(vfs_hpuxacl, \$(VFS_HPUXACL_OBJ), "bin/hpuxacl.$SHLIBEXT", VFS)
 SMB_MODULE(vfs_tru64acl, \$(VFS_TRU64ACL_OBJ), "bin/tru64acl.$SHLIBEXT", VFS)
 SMB_MODULE(vfs_catia, \$(VFS_CATIA_OBJ), "bin/catia.$SHLIBEXT", VFS)
+SMB_MODULE(vfs_streams_xattr, \$(VFS_STREAMS_XATTR_OBJ), "bin/streams_xattr.$SHLIBEXT", VFS)
+SMB_MODULE(vfs_streams_depot, \$(VFS_STREAMS_DEPOT_OBJ), "bin/streams_depot.$SHLIBEXT", VFS)
 SMB_MODULE(vfs_cacheprime, \$(VFS_CACHEPRIME_OBJ), "bin/cacheprime.$SHLIBEXT", VFS)
 SMB_MODULE(vfs_prealloc, \$(VFS_PREALLOC_OBJ), "bin/prealloc.$SHLIBEXT", VFS)
 SMB_MODULE(vfs_commit, \$(VFS_COMMIT_OBJ), "bin/commit.$SHLIBEXT", VFS)
 SMB_MODULE(vfs_gpfs, \$(VFS_GPFS_OBJ), "bin/gpfs.$SHLIBEXT", VFS)
-SMB_MODULE(vfs_notify_fam, \$(VFS_NOTIFY_FAM_OBJ), "bin/notify_fam.$SHLIBEXT", VFS)
 SMB_MODULE(vfs_readahead, \$(VFS_READAHEAD_OBJ), "bin/readahead.$SHLIBEXT", VFS)
+SMB_MODULE(vfs_tsmsm, \$(VFS_TSMSM_OBJ), "bin/tsmsm.$SHLIBEXT", VFS)
 SMB_MODULE(vfs_fileid, \$(VFS_FILEID_OBJ), "bin/fileid.$SHLIBEXT", VFS)
+SMB_MODULE(vfs_syncops, \$(VFS_SYNCOPS_OBJ), "bin/syncops.$SHLIBEXT", VFS)
+SMB_MODULE(vfs_zfsacl, \$(VFS_ZFSACL_OBJ), "bin/zfsacl.$SHLIBEXT", VFS)
+SMB_MODULE(vfs_notify_fam, \$(VFS_NOTIFY_FAM_OBJ), "bin/notify_fam.$SHLIBEXT", VFS)
+
 
 SMB_SUBSYSTEM(VFS,smbd/vfs.o)
 
@@ -6492,9 +6531,7 @@ if test x"$RUN_FROM_BUILD_FARM" = x"yes"; then
        AC_DEFINE(ENABLE_BUILD_FARM_HACKS, 1, [Defined if running in the build farm])
 else
        AC_MSG_RESULT(no)
-       SELFTEST_ARGS="$SELFTEST_ARGS --skip=samba3-skip-nobuildfarm"
 fi
-AC_SUBST(SELFTEST_ARGS)
 
 #################################################
 # check for bad librt/libpthread interactions
@@ -6591,6 +6628,9 @@ fi
 if test x"$with_dnsupdate_support" != x"no"; then
     AC_MSG_RESULT([    UUID_LIBS = $UUID_LIBS])
 fi
+if test x"$have_dnssd_support" != x"no"; then
+    AC_MSG_RESULT([    DNSSD_LIBS = $DNSSD_LIBS])
+fi
 AC_MSG_RESULT([    AUTH_LIBS = $AUTH_LIBS])
 
 #################################################
@@ -6616,7 +6656,14 @@ AC_SUBST(builddir)
 SMBD_LIBS="$samba_dmapi_libs"
 AC_SUBST(SMBD_LIBS)
 
-AC_OUTPUT(Makefile library-versions script/findsmb smbadduser script/gen-8bit-gap.sh script/installbin.sh script/uninstallbin.sh)
+AC_OUTPUT(Makefile library-versions
+         script/findsmb smbadduser script/gen-8bit-gap.sh script/installbin.sh script/uninstallbin.sh
+         lib/netapi/examples/Makefile
+         pkgconfig/smbclient.pc
+         pkgconfig/wbclient.pc
+         pkgconfig/netapi.pc
+         pkgconfig/smbsharemodes.pc
+         )
 
 #################################################
 # Print very concise instructions on building/use