autoconf: fix --with(out)-sendfile-support option handling
[samba.git] / source3 / configure.in
index 4528cbf341ff3b3612b2620d748eb8d50d4b1458..9d7fb5ddeb3982515685a546939a2eb4d5cea9c5 100644 (file)
@@ -215,7 +215,7 @@ dnl Certain versions of GNU ld the default is not to have the
 dnl --allow-shlib-undefined flag defined.  This causes a stackload of
 dnl warnings when building modules.
 if test "$ac_cv_prog_gnu_ld" = "yes"; then
-       ac_cv_gnu_ld_version=`$CC -Wl,-v /dev/null 2>/dev/null | head -1`
+       ac_cv_gnu_ld_version=`$CC -Wl,-v /dev/null 2>&1 < /dev/null | grep "GNU ld"`
        AC_MSG_CHECKING(GNU ld release date)
        changequote(,)dnl
        ac_cv_gnu_ld_date=`echo $ac_cv_gnu_ld_version | sed -n 's,^.*\([2-9][0-9][0-9][0-9]\)[-]*\([01][0-9]\)[-]*\([0-3][0-9]\).*$,\1\2\3,p'`
@@ -1023,6 +1023,7 @@ AC_CHECK_FUNCS(getrlimit fsync fdatasync setpgid)
 AC_CHECK_FUNCS(setsid glob strpbrk crypt16 getauthuid)
 AC_CHECK_FUNCS(sigprocmask sigblock sigaction sigset innetgr setnetgrent getnetgrent endnetgrent)
 AC_CHECK_FUNCS(initgroups select poll rdchk getgrnam getgrent pathconf)
+AC_CHECK_FUNCS(getgrset)
 AC_CHECK_FUNCS(setpriv setgidx setuidx setgroups sysconf stat64 fstat64)
 AC_CHECK_FUNCS(lstat64 fopen64 atexit grantpt lseek64 ftruncate64 posix_fallocate posix_fallocate64)
 AC_CHECK_FUNCS(fseek64 fseeko64 ftell64 ftello64 setluid getpwanam)
@@ -1330,6 +1331,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)
@@ -5679,16 +5696,23 @@ fi
 #################################################
 # check for sendfile support
 
-with_sendfile_support=yes
-AC_MSG_CHECKING(whether to check to support sendfile)
+AC_MSG_CHECKING(whether sendfile support should be built in)
 AC_ARG_WITH(sendfile-support,
-[AS_HELP_STRING([--with-sendfile-support], [Check for sendfile support (default=yes)])],
+[AS_HELP_STRING([--with-sendfile-support], [Whether sendfile support should be built in (default=auto)])],
 [ case "$withval" in
-  yes)
-
-       AC_MSG_RESULT(yes);
+  yes|no)
+       AC_MSG_RESULT($withval);
+       with_sendfile_support=$withval
+       ;;
+  *)
+       AC_MSG_RESULT(yes)
+       with_sendfile_support=auto
+       ;;
+  esac ],
+)
 
-       case "$host_os" in
+if test x$with_sendfile_support != xno ; then
+    case "$host_os" in
        *linux* | gnu* | k*bsd*-gnu | kopensolaris*-gnu)
                AC_CACHE_CHECK([for linux sendfile64 support],samba_cv_HAVE_SENDFILE64,[
                AC_TRY_LINK([#include <sys/sendfile.h>],
@@ -5924,14 +5948,12 @@ samba_cv_HAVE_SENDFILE=yes,samba_cv_HAVE_SENDFILE=no)])
        ;;
        *)
        ;;
-        esac
-        ;;
-  *)
-    AC_MSG_RESULT(no)
-    ;;
-  esac ],
-  AC_MSG_RESULT(yes)
-)
+    esac
+fi
+
+if test x$with_sendfile_support = xyes -a x"$samba_cv_HAVE_SENDFILE" != xyes ; then
+       AC_MSG_ERROR(sendfile support requested but sendfile not available )
+fi
 
 ############################################
 # See if we have the Linux readahead syscall.