s3:smbd: add a nfs backend for sysquotas.
[amitay/samba.git] / source3 / configure.in
index 050c16a0248270a02fa49d9dc282d53681290b71..d8bf5543876a6f06b3943f70e1ba4fbe3fb5a0df 100644 (file)
@@ -23,6 +23,7 @@ m4_include(m4/check_path.m4)
 m4_include(pkg.m4)
 
 AC_LIBREPLACE_CC_CHECKS
+AC_LIBREPLACE_RUNTIME_LIB_PATH_VAR
 
 m4_include(../lib/tevent/libtevent.m4)
 
@@ -124,11 +125,13 @@ m4_include(../lib/util/time.m4)
 
 m4_include(m4/swat.m4)
 
+DEVELOPER_CFLAGS="-DDEBUG_PASSWORD -DDEVELOPER"
+
 # Probe the gcc version for extra CFLAGS. We always stash these in
 # 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="-g -Wall -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -DDEBUG_PASSWORD -DDEVELOPER"
+       DEVELOPER_CFLAGS="${DEVELOPER_CFLAGS} -g -Wall -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings"
        # Add -Wdeclaration-after-statement if compiler supports it
        AC_CACHE_CHECK(
           [that the C compiler understands -Wdeclaration-after-statement],
@@ -201,12 +204,16 @@ AC_PROG_INSTALL
 AC_PROG_AWK
 # Check for GNU make
 m4_include(../m4/check_make.m4)
-AC_SAMBA_GNU_MAKE([true], [merged_build_possible=no])
+AC_SAMBA_GNU_MAKE([true], [true])
 
 # Check for perl
 m4_include(../m4/check_perl.m4)
 AC_SAMBA_PERL([true], [merged_build_possible=no])
 
+# Check for python
+m4_include(../m4/check_python.m4)
+AC_SAMBA_PYTHON_DEVEL([true], [merged_build_possible=no])
+
 AC_CHECK_TOOL(AR, ar)
 
 dnl Check if we (actually our C compiler!) use GNU ld
@@ -262,7 +269,7 @@ else
 fi
 AC_SUBST(BROKEN_CC)
 
-dnl Check if the C compiler understands -Werror
+dnl Check if the C compiler understands -Werror (GNU)
 AC_CACHE_CHECK([that the C compiler understands -Werror],samba_cv_HAVE_Werror, [
  AC_TRY_RUN_STRICT([
   int main(void)
@@ -284,7 +291,7 @@ AC_CACHE_CHECK([that the C compiler understands -w2],samba_cv_HAVE_w2, [
 if test x"$samba_cv_HAVE_w2" = x"yes"; then
    Werror_FLAGS="-w2"
 else
-dnl Check if the C compiler understands -errwarn
+dnl Check if the C compiler understands -errwarn (Sun)
 AC_CACHE_CHECK([that the C compiler understands -errwarn],samba_cv_HAVE_errwarn, [
   AC_TRY_RUN_STRICT([
    int main(void)
@@ -294,6 +301,18 @@ AC_CACHE_CHECK([that the C compiler understands -errwarn],samba_cv_HAVE_errwarn,
    samba_cv_HAVE_errwarn=yes,samba_cv_HAVE_errwarn=no,samba_cv_HAVE_errwarn=cross)])
 if test x"$samba_cv_HAVE_errwarn" = x"yes"; then
    Werror_FLAGS="-errwarn=%all"
+else
+dnl Check if the C compiler understands -qhalt (IBM)
+AC_CACHE_CHECK([that the C compiler understands -qhalt],samba_cv_HAVE_qhalt, [
+  AC_TRY_RUN_STRICT([
+   int main(void)
+   {
+       return 0;
+   }],[$CFLAGS -qhalt=w],[$CPPFLAGS],[$LDFLAGS],
+   samba_cv_HAVE_qhalt=yes,samba_cv_HAVE_qhalt=no,samba_cv_HAVE_qhalt=cross)])
+if test x"$samba_cv_HAVE_qhalt" = x"yes"; then
+   Werror_FLAGS="-qhalt=w"
+fi
 fi
 fi
 fi
@@ -324,7 +343,7 @@ AC_CACHE_CHECK([that the C compiler understands negative enum values],samba_cv_C
                return 0;
        }
 ],
-       samba_cv_CC_NEGATIVE_ENUM_VALUES=yes,samba_cv__CC_NEGATIVE_ENUM_VALUES=no)])
+       samba_cv_CC_NEGATIVE_ENUM_VALUES=yes,samba_cv_CC_NEGATIVE_ENUM_VALUES=no)])
 if test x"$samba_cv_CC_NEGATIVE_ENUM_VALUES" != x"yes"; then
        AC_MSG_WARN([using --uint-enums for pidl])
        PIDL_ARGS="$PIDL_ARGS --uint-enums"
@@ -440,6 +459,7 @@ default_shared_modules="$default_shared_modules vfs_preopen"
 default_shared_modules="$default_shared_modules vfs_catia"
 default_shared_modules="$default_shared_modules vfs_scannedonly"
 default_shared_modules="$default_shared_modules vfs_crossrename"
+default_shared_modules="$default_shared_modules vfs_linux_xfs_sgid"
 
 if test "x$developer" = xyes; then
    default_static_modules="$default_static_modules rpc_rpcecho pdb_ads"
@@ -797,15 +817,21 @@ if test x$enable_cups != xno; then
 
         if test "x$CUPS_CONFIG" != x; then
 
-               ac_save_CFLAGS=$CFLAGS
                ac_save_LDFLAGS=$LDFLAGS
                ac_save_PRINT_LIBS=$PRINT_LIBS
-               CFLAGS="$CFLAGS `$CUPS_CONFIG --cflags`"
-               LDFLAGS="$LDFLAGS `$CUPS_CONFIG --ldflags`"
-               PRINT_LIBS="$PRINT_LIBS -lcups"
                AC_CHECK_HEADERS(cups/cups.h cups/language.h)
+
                if test x"$ac_cv_header_cups_cups_h" = xyes -a \
                        x"$ac_cv_header_cups_language_h" = xyes; then
+                       # try linking with -lcups alone first. That should work unless libcups is
+                       # underlinked. With cups-config --libs we pull in unwanted and unneeded
+                       # dendencies including thread libraries - use cups-config only if really
+                       # required. 
+                       AC_CHECK_LIB_EXT(cups, ac_save_PRINT_LIBS , httpConnect,
+                               [PRINT_LIBS"$ac_save_PRINT_LIBS -lcups"],
+                               [AC_MSG_WARN([your cups library doesn't link with -lcups alone, it might be underlinked.]) ;
+                                PRINT_LIBS="$ac_save_PRINT_LIBS `$CUPS_CONFIG --libs`"])
+
                        AC_DEFINE(HAVE_CUPS,1,[Whether we have CUPS])
                        samba_cv_HAVE_CUPS=yes
                        AC_CHECK_LIB_EXT(cups, PRINT_LIBS, httpConnectEncrypt)
@@ -1089,6 +1115,15 @@ AC_CHECK_LIB(exc, trace_back_stack)
 # check for sysctlbyname for BSD systems
 AC_CHECK_FUNCS(sysctlbyname)
 
+#################################################
+# Check to see if core dump directory is defined in linux
+# with /proc/sys/kernel/core_pattern
+
+AC_CHECK_FILE([/proc/sys/kernel/core_pattern],
+       AC_DEFINE(HAVE_SYS_KERNEL_PROC_CORE_PATTERN, 1,
+       [Whether Linux kernel uses core_pattern for core files]),
+        [])
+
 #############################
 # check if building with gpfs
 AC_CHECK_HEADERS(gpfs_gpl.h)
@@ -1366,6 +1401,22 @@ if test x"$samba_cv_stat_dos_flags" = x"yes" ; then
     AC_DEFINE(HAVE_STAT_DOS_FLAGS, 1, [whether there is DOS flags support in the stat struct])
 fi
 
+AC_CACHE_CHECK([whether we can compile with __attribute__((destructor))],
+              samba_cv_function_attribute_destructor,
+              [
+                AC_COMPILE_IFELSE(
+                       [
+                               __attribute__((destructor))
+                               static void cleanup(void) { }
+                       ],
+                       samba_cv_function_attribute_destructor=yes)
+               ])
+
+if test x"$samba_cv_function_attribute_destructor" = xyes ; then
+   AC_DEFINE(HAVE_FUNCTION_ATTRIBUTE_DESTRUCTOR, 1,
+            [whether we can compile with __attribute__((destructor))])
+fi
+
 #####################################
 # needed for SRV lookups
 AC_CHECK_LIB(resolv, dn_expand)
@@ -1468,9 +1519,9 @@ then
        [
                cat > conftest.c <<EOF
 int foo;
-main () { return 0;}
+int main () { return 0;}
 EOF
-               if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -pie -fPIE -o conftest conftest.c 1>&AS_MESSAGE_LOG_FD])
+               if AC_TRY_COMMAND_NO_STDERR([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS -pie -fPIE -o conftest conftest.c])
                then
                        samba_cv_fpie=yes
                else
@@ -1559,13 +1610,10 @@ DSO_EXPORTS=""
                                if test "${ac_cv_prog_gnu_ld}" = "yes"; then
                                        DYNEXP="-Wl,-E"
                                fi
-                               # TODO: need to add $CFLAGS here for explicit 64-bit builds?
                                LDSHFLAGS="-shared"
                        else
                                PICFLAG="-KPIC"
-                               ## ${CFLAGS} added for building 64-bit shared
-                               ## libs using Sun's Compiler
-                               LDSHFLAGS="-G \${CFLAGS}"
+                               LDSHFLAGS="-G"
                        fi
                        if test "$ac_cv_prog_gnu_ld" = "yes"; then
                                SONAMEFLAG="-Wl,-soname="
@@ -1606,9 +1654,8 @@ DSO_EXPORTS=""
                        ;;
                        esac
                        BLDSHARED="true"
-                       LDSHFLAGS="-set_version sgi1.0 -shared"
-                       SONAMEFLAG="-soname "
-                       SHLD="\${LD}"
+                       LDSHFLAGS="-Wl,-set_version,sgi1.0 -shared"
+                       SONAMEFLAG="-Wl,-soname,"
                        if test "${GCC}" = "yes"; then
                                PICFLAG="-fPIC"
                        else
@@ -1627,7 +1674,7 @@ DSO_EXPORTS=""
                        # .po will just create compile warnings, use po.o:
                        if test "${GCC}" != "yes"; then
                                ## for funky AIX compiler using strncpy()
-                               CFLAGS="$CFLAGS -D_LINUX_SOURCE_COMPAT -qmaxmem=32000"
+                               CFLAGS="$CFLAGS -D_LINUX_SOURCE_COMPAT -qmaxmem=32000 -qhalt=e"
                        fi
 
                        AC_DEFINE(STAT_ST_BLOCKSIZE,DEV_BSIZE,[The size of a block])
@@ -1635,25 +1682,45 @@ DSO_EXPORTS=""
                        AC_DEFINE(BROKEN_STRNDUP,1,[Does strndup work correctly])
                        ;;
                *hpux*) AC_DEFINE(HPUX,1,[Whether the host os is HPUX])
-                       # Use special PIC flags for the native HP-UX compiler.
-                               BLDSHARED="true"
-                               SHLD="cc"
-                               LDSHFLAGS="-b -Wl,-B,symbolic,-b,-z"
-                               SONAMEFLAG="-Wl,+h "
-                               PICFLAG="+z"
+                       # ia64: 64bit build using gcc with CFLAGS="-mpl64"
+                       #       64bit build using HP's cc with CFLAGS="+DD64"
+                       # hppa: 64bit build unsupported by gcc
+                       #       64bit build using HP's cc with CFLAGS="+DA2.0w"
+                       # HP-UX 11.00 ld needs PHSS_33034
+                       BLDSHARED="true"
                        if test "${GCC}" = "yes"; then
                                PICFLAG="-fPIC"
+                               LDSHFLAGS="-shared"
                        else
-                               PICFLAG="+z +ESnolit"
+                               PICFLAG="+z"
+                               LDSHFLAGS="-b"
+                               # "Uses depth-first symbol resolution"
+                               LDSHFLAGS="$LDSHFLAGS -Wl,-B,symbolic,-b"
+                               if test "$host_cpu" != "ia64"; then
+                                       # "don't store literals in read-only memory" (?):
+                                       PICFLAG="$PICFLAG +ESnolit"
+                               fi
                        fi
                        if test "$host_cpu" = "ia64"; then
                                SHLIBEXT="so"
-                             PICFLAG="+z"
-                               DYNEXP="-Wl,-E,+b/usr/local/lib/hpux32:/usr/lib/hpux32"
+                               # TODO: does the linker find the right 32/64 bit version of the libs? :
+                               DYNEXP="-Wl,-E,+b/usr/local/lib/hpux32:/usr/lib/hpux32:/usr/local/lib/hpux64:/usr/lib/hpux64"
                        else
                                SHLIBEXT="sl"
                                DYNEXP="-Wl,-E,+b/usr/local/lib:/usr/lib"
                        fi
+                       if test "$ac_cv_prog_gnu_ld" = "yes"; then
+                               SONAMEFLAG="-Wl,-soname="
+                       else
+                               SONAMEFLAG="-Wl,+h,"
+                       fi
+                       # PIE/PIC flags at link time are required on HP-UX because
+                       # linking requires a temporary source file, which is being
+                       # compiled with the indicated flags - which need to contain
+                       # PIC flags when we don't support PIE flags:
+                       if test "$PIE_LDFLAGS" = "" ; then
+                               PIE_LDFLAGS=\${PICFLAG}
+                       fi
                        AC_DEFINE(STAT_ST_BLOCKSIZE,8192,[The size of a block])
                        AC_DEFINE(POSIX_ACL_NEEDS_MASK,1,[Does a POSIX ACL need a mask element])
                        ;;
@@ -1752,7 +1819,19 @@ fi
 
 AC_MSG_RESULT($BLDSHARED)
 
-for flags in "-Wl,--as-needed" "-Wl,-z,ignore" "-z ignore" ; do
+if test x"$enable_developer" = x"yes" ; then
+       default_as_needed=auto
+else
+       default_as_needed=no
+fi
+AC_ARG_ENABLE(as-needed,
+       AS_HELP_STRING([--enable-as-needed],
+       [Turn on as-needed support if available (default=no)]),
+       [enable_as_needed=$enableval],
+       [enable_as_needed=$default_as_needed])
+if test "x$enable_as_needed" != xno; then
+    saved_before_as_needed_ldflags="$LDFLAGS"
+    for flags in "-Wl,--as-needed" "-Wl,-z,ignore" "-z ignore" ; do
        saved_ldflags="$LDFLAGS"
        AC_MSG_CHECKING([if $flags works])
        LDFLAGS="$flags $saved_ldflags"
@@ -1763,7 +1842,65 @@ for flags in "-Wl,--as-needed" "-Wl,-z,ignore" "-z ignore" ; do
                AC_MSG_RESULT([no]))
        LDFLAGS="$LD_AS_NEEDED_FLAG $saved_ldflags"
        test x"$ld_as_needed_flag_found" = xyes && break
-done
+    done
+fi
+
+if test x$ld_as_needed_flag_found = xyes -a x$enable_as_needed = xauto ; then
+# check if ld has bug described in https://bugzilla.samba.org/show_bug.cgi?id=7209#c17
+       AC_MSG_CHECKING([if $LD_AS_NEEDED_FLAG has explicit external libs bug])
+cat > conftest_shb.c <<END
+void b() {}
+END
+cat > conftest_sha.c <<END
+extern void b();
+void a() {
+       b();
+}
+END
+cat > conftest.c <<END
+extern void a();
+int main() {
+       a();
+       return 0;
+}
+END
+
+       rm -fr conftest
+       AC_TRY_COMMAND([$CC $CPPFLAGS $CFLAGS $PICFLAG -c -o conftest_sha.o conftest_sha.c 1>&AS_MESSAGE_LOG_FD 2>&1])
+       AC_TRY_COMMAND([$CC $CPPFLAGS $CFLAGS $PICFLAG -c -o conftest_shb.o conftest_shb.c 1>&AS_MESSAGE_LOG_FD 2>&1])
+       TESTCMD="`eval echo \"$SHLD $LDSHFLAGS $PICFLAG\"`"
+       AC_TRY_COMMAND([$TESTCMD -o libconftest_shb.$SHLIBEXT conftest_shb.o 1>&AS_MESSAGE_LOG_FD 2>&1])
+       AC_TRY_COMMAND([$TESTCMD -o libconftest_sha.$SHLIBEXT conftest_sha.o 1>&AS_MESSAGE_LOG_FD 2>&1])
+       AC_TRY_COMMAND([$CC -o conftest conftest.c $LDFLAGS -L. -lconftest_sha -lconftest_shb 1>&AS_MESSAGE_LOG_FD 2>&1])
+       if AC_TRY_COMMAND([eval "$LIB_PATH_VAR=. ./conftest 1>&AS_MESSAGE_LOG_FD 2>&1"])
+       then
+               AC_MSG_RESULT([no])
+       else
+               ld_as_needed_flag_found=no
+               LDFLAGS="$saved_before_as_needed_ldflags"
+               AC_MSG_RESULT([yes])
+       fi
+       rm conftest* libconftest*
+fi
+
+# check if we have to disable LD_AS_NEEDED_FLAG:
+# On some systems for a veriety of reasons linking with
+# -Wl,--as-needed -lreadline -lncurses fails
+# we have to retest, if these combination is detected before.
+# Bugzilla #7209
+
+if test x$ac_cv_lib_readline_rl_callback_handler_install = xyes ; then
+       if test x$ld_as_needed_flag_found = xyes ; then
+               AC_MSG_CHECKING([if $LD_AS_NEEDED_FLAG works with readline])
+               # try if check no fails
+               save_LIBS=$LIBS
+               LIBS="$LIBS $TERMLIBS"
+               AC_TRY_LINK([], [rl_callback_handler_install();], [AC_MSG_RESULT([yes])],[ AC_MSG_RESULT([no]); LDFLAGS="$saved_before_as_needed_ldflags"])
+               LIBS="$save_LIBS"
+        fi
+fi
+
+
 
 # for historical reasons almost all linkers don't complain about unresolved
 # symbols in shared libs. Except for the internal samba modules we want to get
@@ -1817,10 +1954,15 @@ AC_CACHE_CHECK([whether building shared libraries actually works],
    ac_cv_shlib_works=no
    # The $SHLD and $LDSHFLAGS variables may contain references to other
    # variables so they need to be eval'ed.
-   $CC $CPPFLAGS $CFLAGS $PICFLAG -c -o \
-       shlib.o ${srcdir-.}/../tests/shlib.c && \
-   `eval echo $SHLD` `eval echo $LDSHFLAGS` -o "shlib.$SHLIBEXT" \
-        shlib.o && ac_cv_shlib_works=yes
+   if AC_TRY_COMMAND([$CC $CPPFLAGS $CFLAGS $PICFLAG -c -o shlib.o ${srcdir-.}/../tests/shlib.c 1>&AS_MESSAGE_LOG_FD])
+   then
+     TESTCMD="`eval echo \"$SHLD $LDSHFLAGS $PICFLAG\"`"
+     TESTCMD="$TESTCMD -o \"shlib.$SHLIBEXT\" shlib.o"
+     if AC_TRY_COMMAND([eval $TESTCMD 1>&AS_MESSAGE_LOG_FD 2>&1])
+     then
+       ac_cv_shlib_works=yes
+     fi
+   fi
    rm -f "shlib.$SHLIBEXT" shlib.o
 
 ])
@@ -1844,7 +1986,6 @@ AC_MSG_RESULT([$PICFLAG])
 
 AC_DEFINE_UNQUOTED(SHLIBEXT, "$SHLIBEXT", [Shared library extension])
 
-AC_LIBREPLACE_RUNTIME_LIB_PATH_VAR
 
 
 ###########################################################
@@ -2000,6 +2141,7 @@ then
        LINK_LIBTDB=STATIC
        SMB_LIBRARY(tdb, 1)
        LIBTDB_OBJ0=""
+       LIBTDB_LIBS="$LIBTDB_LIBS $TDB_DEPS"
        for obj in ${TDB_OBJ}; do
                LIBTDB_OBJ0="${LIBTDB_OBJ0} ${tdbdir}/${obj}"
        done
@@ -3618,7 +3760,7 @@ if test x"$with_ads_support" != x"no"; then
 
   # now check for gssapi headers.  This is also done here to allow for
   # different kerberos include paths
-  AC_CHECK_HEADERS(gssapi.h gssapi/gssapi_generic.h gssapi/gssapi.h com_err.h)
+  AC_CHECK_HEADERS(gssapi.h gssapi/gssapi_generic.h gssapi/gssapi.h gssapi/gssapi_ext.h com_err.h)
 
   ##################################################################
   # we might need the k5crypto and com_err libraries on some systems
@@ -3643,6 +3785,7 @@ if test x"$with_ads_support" != x"no"; then
   # now see if we can find the gssapi libs in standard paths
   if test x"$have_gssapi" != x"yes"; then
      AC_CHECK_LIB_EXT(gssapi_krb5, KRB5_LIBS,gss_display_status,[],[],have_gssapi=yes)
+     AC_CHECK_FUNC_EXT(gss_wrap_iov, $KRB5_LIBS)
   fi
 
   AC_CHECK_FUNC_EXT(krb5_set_real_time, $KRB5_LIBS)
@@ -3901,6 +4044,7 @@ if test x"$with_ads_support" != x"no"; then
               [Whether the krb5_keyblock struct has a keyvalue property])
   fi
 
+  found_arcfour_hmac=no
   AC_CACHE_CHECK([for ENCTYPE_ARCFOUR_HMAC_MD5],
                  samba_cv_HAVE_ENCTYPE_ARCFOUR_HMAC_MD5,[
     AC_TRY_COMPILE([#include <krb5.h>],
@@ -3918,7 +4062,19 @@ if test x"$with_ads_support" != x"no"; then
   if test x"$samba_cv_HAVE_ENCTYPE_ARCFOUR_HMAC_MD5" = x"yes" -a\
           x"$samba_cv_HAVE_KEYTYPE_ARCFOUR_56" = x"yes"; then
     AC_DEFINE(HAVE_ENCTYPE_ARCFOUR_HMAC_MD5,1,
-              [Whether the ENCTYPE_ARCFOUR_HMAC_MD5 key type is available])
+              [Whether the ENCTYPE_ARCFOUR_HMAC_MD5 key type definition is available])
+    found_arcfour_hmac=yes
+  fi
+  AC_CACHE_CHECK([for ENCTYPE_ARCFOUR_HMAC],
+                 samba_cv_HAVE_ENCTYPE_ARCFOUR_HMAC,[
+    AC_TRY_COMPILE([#include <krb5.h>],
+      [krb5_enctype enctype; enctype = ENCTYPE_ARCFOUR_HMAC;],
+      samba_cv_HAVE_ENCTYPE_ARCFOUR_HMAC=yes,
+      samba_cv_HAVE_ENCTYPE_ARCFOUR_HMAC=no)])
+  if test x"$samba_cv_HAVE_ENCTYPE_ARCFOUR_HMAC" = x"yes"; then
+    AC_DEFINE(HAVE_ENCTYPE_ARCFOUR_HMAC,1,
+              [Whether the ENCTYPE_ARCFOUR_HMAC key type definition is available])
+    found_arcfour_hmac=yes
   fi
 
   AC_CACHE_CHECK([for AP_OPTS_USE_SUBKEY],
@@ -4161,6 +4317,11 @@ if test x"$with_ads_support" != x"no"; then
   # NOTE: all tests should be done before this block!
   #
   #
+  if test x"$found_arcfour_hmac" != x"yes"; then
+    AC_MSG_WARN(arcfour-hmac-md5 encryption type not found in -lkrb5)
+    use_ads=no
+  fi
+
   if test x"$ac_cv_lib_ext_krb5_krb5_mk_req_extended" != x"yes"; then
     AC_MSG_WARN(krb5_mk_req_extended not found in -lkrb5)
     use_ads=no
@@ -4425,6 +4586,29 @@ if test x"${try_pam}" != x"no";then
 
        AC_MSG_CHECKING(whether to have PAM MODULES support)
        AC_MSG_RESULT([$create_pam_modules])
+
+       AC_TRY_COMPILE([
+               #if defined(HAVE_SECURITY_PAM_APPL_H)
+               #include <security/pam_appl.h>
+               #elif defined(HAVE_PAM_PAM_APPL_H)
+               #include <pam/pam_appl.h>
+               #endif],[
+               pam_set_item(0, PAM_RHOST, 0);
+               ],
+               AC_DEFINE(HAVE_PAM_RHOST, 1,
+                         [Define to 1 if PAM_RHOST is available]),[])
+
+       AC_TRY_COMPILE([
+               #if defined(HAVE_SECURITY_PAM_APPL_H)
+               #include <security/pam_appl.h>
+               #elif defined(HAVE_PAM_PAM_APPL_H)
+               #include <pam/pam_appl.h>
+               #endif],[
+               pam_set_item(0, PAM_TTY, 0);
+               ],
+               AC_DEFINE(HAVE_PAM_TTY, 1,
+                         [Define to 1 if PAM_TTY is available]),[])
+
 fi # try_pam != no
 
 #################################################
@@ -4841,6 +5025,27 @@ AC_MSG_CHECKING(whether to use the new lib/sysquotas.c interface)
 fi
 fi
 
+if test x"$samba_cv_SYSQUOTA_FOUND" != x"no"; then
+AC_CACHE_CHECK([whether the sys_quota interface works with NFS],samba_cv_SYSQUOTA_WORKS_NFS,[
+SAVE_CPPFLAGS="$CPPFLAGS"
+CPPFLAGS="$CPPFLAGS ${SAMBA_CONFIGURE_CPPFLAGS}"
+AC_TRY_COMPILE([
+#include "confdefs.h"
+#define NO_PROTO_H 1
+#define NO_CONFIG_H 1
+#define HAVE_SYS_QUOTAS 1
+#define HAVE_NFS_QUOTAS 1
+#include "${srcdir-.}/lib/sysquotas_nfs.c"
+],[],samba_cv_SYSQUOTA_WORKS_NFS=yes,samba_cv_SYSQUOTA_WORKS_NFS=no)
+CPPFLAGS="$SAVE_CPPFLAGS"
+])
+if test x"$samba_cv_SYSQUOTA_WORKS_NFS" = x"yes"; then
+    if test x"$samba_cv_WE_USE_SYS_QUOTAS" = x"yes"; then
+       AC_DEFINE(HAVE_NFS_QUOTAS,1,[Whether nfs quota support is available])
+    fi
+fi
+fi
+
 if test x"$samba_cv_SYSQUOTA_FOUND" != x"no" -a x"$samba_cv_found_xfs_header" = x"yes"; then
 AC_CACHE_CHECK([whether the sys_quota interface works with XFS],samba_cv_SYSQUOTA_WORKS_XFS,[
 SAVE_CPPFLAGS="$CPPFLAGS"
@@ -5424,7 +5629,9 @@ AC_ARG_WITH(aio-support,
        case "$host_os" in
        *)
                AIO_LIBS=$LIBS
+               no_rt_LIBS=$LIBS
                AC_CHECK_LIB(rt,aio_read,[AIO_LIBS="$LIBS -lrt"])
+               LIBS=$no_rt_LIBS
                AC_CHECK_LIB(aio,aio_read,[AIO_LIBS="$LIBS -laio"])
                AC_CACHE_CHECK([for asynchronous io support],samba_cv_HAVE_AIO,[
                aio_LIBS=$LIBS
@@ -6299,7 +6506,7 @@ AC_ARG_ENABLE(pthreadpool,
 [AS_HELP_STRING([--enable-pthreadpool], [Enable pthreads pool helper support (default=no)])])
 
 if test x"$enable_pthreadpool" = xyes -a x"$samba_cv_HAVE_PTHREAD" != x"yes"; then
-       AC_MSG_ERROR([pthreadpool support cannot be enabled when pthread support was found])
+       AC_MSG_ERROR([pthreadpool support cannot be enabled when pthread support was not found])
 fi
 
 if test x"$enable_pthreadpool" = x"yes" -a x"$samba_cv_HAVE_PTHREAD" = x"yes"; then
@@ -6344,7 +6551,41 @@ AC_SUBST(BUILD_INIPARSER)
 AC_SUBST(INIPARSERLIBS)
 AC_SUBST(FLAGS1)
 
-
+###################################################
+# Check for different/missing (set|get|end)netgrent prototypes
+CFLAGS_SAVE=$CFLAGS
+if test x"$samba_cv_HAVE_Wdeclaration_after_statement" = x"yes"; then
+       CFLAGS="$CFLAGS -Werror-implicit-function-declaration"
+fi
+AC_CACHE_CHECK([for setnetgrent prototype],samba_cv_setnetgrent_prototype, [
+    AC_TRY_COMPILE([#include<netdb.h>
+                    #ifdef HAVE_NETGROUP_H
+                    #include<netgroup.h>
+                    #endif],[setnetgrent("foo")],
+                    samba_cv_setnetgrent_prototype=yes, samba_cv_setnetgrent_prototype=no)])
+if test x"$samba_cv_setnetgrent_prototype" = x"yes"; then
+    AC_DEFINE(HAVE_SETNETGRENT_PROTOTYPE, 1, [If setnetgrent prototype is defined])
+fi
+AC_CACHE_CHECK([for getnetgrent prototype],samba_cv_getnetgrent_prototype, [
+    AC_TRY_COMPILE([#include<netdb.h>
+                    #ifdef HAVE_NETGROUP_H
+                    #include<netgroup.h>
+                    #endif],[char *dom, *user,*host; getnetgrent(&dom,&user,&host)],
+                    samba_cv_getnetgrent_prototype=yes, samba_cv_getnetgrent_prototype=no)])
+if test x"$samba_cv_getnetgrent_prototype" = x"yes"; then
+    AC_DEFINE(HAVE_GETNETGRENT_PROTOTYPE, 1, [If getnetgrent prototype is defined])
+fi
+AC_CACHE_CHECK([for endnetgrent prototype],samba_cv_endnetgrent_prototype, [
+    AC_TRY_COMPILE([#include<netdb.h>
+                    #ifdef HAVE_NETGROUP_H
+                    #include<netgroup.h>
+                    #endif],[endnetgrent()],
+                    samba_cv_endnetgrent_prototype=yes, samba_cv_endnetgrent_prototype=no)])
+if test x"$samba_cv_endnetgrent_prototype" = x"yes"; then
+    AC_DEFINE(HAVE_ENDNETGRENT_PROTOTYPE, 1, [If endnetgrent prototype is defined])
+fi
+
+CFLAGS=$CFLAGS_SAVE
 
 # Checks for the vfs_fileid module
 # Start
@@ -6526,6 +6767,7 @@ SMB_MODULE(vfs_onefs_shadow_copy, \$(VFS_ONEFS_SHADOW_COPY), "bin/onefs_shadow_c
 SMB_MODULE(vfs_dirsort, \$(VFS_DIRSORT_OBJ), "bin/dirsort.$SHLIBEXT", VFS)
 SMB_MODULE(vfs_scannedonly, \$(VFS_SCANNEDONLY_OBJ), "bin/scannedonly.$SHLIBEXT", VFS)
 SMB_MODULE(vfs_crossrename, \$(VFS_CROSSRENAME_OBJ), "bin/crossrename.$SHLIBEXT", VFS)
+SMB_MODULE(vfs_linux_xfs_sgid, \$(VFS_LINUX_XFS_SGID_OBJ), "bin/linux_xfs_sgid.$SHLIBEXT", VFS)
 
 SMB_SUBSYSTEM(VFS,smbd/vfs.o)
 
@@ -6642,9 +6884,6 @@ fi
 m4_include(../lib/zlib/zlib.m4)
 
 if test x$enable_merged_build = xauto; then
-       # Check for python
-       m4_include(../m4/check_python.m4)
-       AC_SAMBA_PYTHON_DEVEL([true], [merged_build_possible=no])
 
        AC_MSG_CHECKING([whether it would be possible to do a merged build])
        AC_MSG_RESULT([$merged_build_possible])
@@ -6659,8 +6898,13 @@ if test x$enable_merged_build = xyes; then
        MERGED_BUILD=1
        saved_USESHARED="$USESHARED"
        USESHARED="false"
-       m4_include(samba4.m4)
+       smbtorture4_path="bin/smbtorture4"
+       smbtorture4_option="-t bin/smbtorture4"
+       AC_SUBST(smbtorture4_path)
+       AC_SUBST(smbtorture4_option)
        USESHARED="$saved_USESHARED"
+       SMBTORTURE4="bin/smbtorture4"
+       AC_SUBST(SMBTORTURE4)
 fi
 
 AC_SUBST(ZLIB_LIBS)
@@ -6734,26 +6978,16 @@ SMBD_LIBS="$samba_dmapi_libs"
 AC_SUBST(SMBD_LIBS)
 
 CFLAGS="${CFLAGS} \$(FLAGS)"
+CFLAGS="${CFLAGS} -D_SAMBA_BUILD_=3"
 
-if test x$MERGED_BUILD != x1; then
-       CFLAGS="${CFLAGS} -D_SAMBA_BUILD_=3"
-else
-       if test x"$BLDSHARED" = x"true" ; then
-               LDFLAGS="$LDFLAGS -L./bin"
-       fi
+# If we had to expand the includes, make tsure the output file is moved back
+AC_OUTPUT_COMMANDS([
+if test -f Makefile-noincludes -a ! -f Makefile -a ! -h Makefile ; then
+       ln -s Makefile-noincludes Makefile
 fi
+])
 
-AC_SUBST(MAKEFILE)
-if test x$samba_cv_gnu_make = xyes; then
-       MAKEFILE=Makefile
-else
-       # When we don't have GNU Make, generate a copy of Makefile.in 
-       # that doesn't have the "include " statements but just includes 
-       # the files verbatim.
-       MAKEFILE=Makefile-noincludes
-       $PERL ./script/expand-includes.pl Makefile.in > $MAKEFILE.in
-fi
-AC_OUTPUT($MAKEFILE
+AC_OUTPUT(Makefile
          script/findsmb smbadduser script/gen-8bit-gap.sh script/installbin.sh script/uninstallbin.sh
          lib/netapi/examples/Makefile
          lib/netapi/tests/Makefile
@@ -6763,12 +6997,6 @@ AC_OUTPUT($MAKEFILE
          pkgconfig/smbsharemodes.pc
          ../examples/libsmbclient/Makefile.internal
          )
-dnl If we had to expand the includes, make tsure the output file is moved back
-AC_OUTPUT_COMMANDS([
-if test x$MAKEFILE != Makefile; then
-       mv $MAKEFILE Makefile
-fi
-])
 
 #################################################
 # Print very concise instructions on building/use