From 6cac66ccfc09978e5807201bdb40f1f0d882e80f Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Fri, 4 May 2012 04:10:40 +0200 Subject: [PATCH] chown: Avoid "guessing no" when cross-compiling to glibc systems. * m4/chown.m4 (AC_FUNC_CHOWN): Override in autoconf < 2.70. --- ChangeLog | 5 +++++ m4/chown.m4 | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 8fafa5c33..a9787b4bd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2012-05-03 Bruno Haible + chown: Avoid "guessing no" when cross-compiling to glibc systems. + * m4/chown.m4 (AC_FUNC_CHOWN): Override in autoconf < 2.70. + +2012-05-03 Bruno Haible + Avoid "guessing no" guesses when cross-compiling to glibc systems. * m4/cbrtl.m4 (gl_FUNC_CBRTL): Require AC_CANONICAL_HOST. When cross- compiling to glibc systems, set gl_cv_func_cbrtl_ieee to "guessing yes". diff --git a/m4/chown.m4 b/m4/chown.m4 index bb7b29598..b35092a22 100644 --- a/m4/chown.m4 +++ b/m4/chown.m4 @@ -1,4 +1,4 @@ -# serial 26 +# serial 27 # Determine whether we need the chown wrapper. dnl Copyright (C) 1997-2001, 2003-2005, 2007, 2009-2012 Free Software @@ -14,6 +14,56 @@ dnl with or without modifications, as long as this notice is preserved. # From Jim Meyering. +m4_version_prereq([2.70], [] ,[ + +# This is taken from the following Autoconf patch: +# http://git.savannah.gnu.org/gitweb/?p=autoconf.git;a=commitdiff;h=7fbb553727ed7e0e689a17594b58559ecf3ea6e9 +AC_DEFUN([AC_FUNC_CHOWN], +[ + AC_REQUIRE([AC_TYPE_UID_T])dnl + AC_REQUIRE([AC_CANONICAL_HOST])dnl for cross-compiles + AC_CHECK_HEADERS([unistd.h]) + AC_CACHE_CHECK([for working chown], + [ac_cv_func_chown_works], + [AC_RUN_IFELSE( + [AC_LANG_PROGRAM( + [AC_INCLUDES_DEFAULT + [#include + ]], + [[ + char *f = "conftest.chown"; + struct stat before, after; + + if (creat (f, 0600) < 0) + return 1; + if (stat (f, &before) < 0) + return 1; + if (chown (f, (uid_t) -1, (gid_t) -1) == -1) + return 1; + if (stat (f, &after) < 0) + return 1; + return ! (before.st_uid == after.st_uid && before.st_gid == after.st_gid); + ]]) + ], + [ac_cv_func_chown_works=yes], + [ac_cv_func_chown_works=no], + [case "$host_os" in # (( + # Guess yes on glibc systems. + *-gnu*) ac_cv_func_chown_works=yes ;; + # If we don't know, assume the worst. + *) ac_cv_func_chown_works=no ;; + esac + ]) + rm -f conftest.chown + ]) + if test $ac_cv_func_chown_works = yes; then + AC_DEFINE([HAVE_CHOWN], [1], + [Define to 1 if your system has a working `chown' function.]) + fi +])# AC_FUNC_CHOWN + +]) + AC_DEFUN_ONCE([gl_FUNC_CHOWN], [ AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) -- 2.11.0