>From f6f709a5d37fa5b8309bfd7d88f2b7f3daeeac1c Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Mon, 21 Dec 2020 11:13:17 +0100 Subject: [PATCH 1/6] Port AC_FUNC_CHOWN fixes from Gnulib. * lib/autoconf/functions.m4 (AC_FUNC_CHOWN): Support compiling without -loldnames on native Windows. Improve cross-compilation guesses. When cross-compiling, say "guessing ...". --- lib/autoconf/functions.m4 | 82 ++++++++++++++++++++++++++++------------------- 1 file changed, 49 insertions(+), 33 deletions(-) diff --git a/lib/autoconf/functions.m4 b/lib/autoconf/functions.m4 index 12f60b9..a86048f 100644 --- a/lib/autoconf/functions.m4 +++ b/lib/autoconf/functions.m4 @@ -470,39 +470,55 @@ AU_ALIAS([AC_ALLOCA], [AC_FUNC_ALLOCA]) # Determine whether chown accepts arguments of -1 for uid and gid. AN_FUNCTION([chown], [AC_FUNC_CHOWN]) AC_DEFUN([AC_FUNC_CHOWN], -[AC_REQUIRE([AC_TYPE_UID_T])dnl -AC_REQUIRE([AC_CANONICAL_HOST])dnl for cross-compiles -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_REQUIRE([AC_TYPE_UID_T])dnl + AC_REQUIRE([AC_CANONICAL_HOST])dnl for cross-compiles + AC_CACHE_CHECK([for working chown], + [ac_cv_func_chown_works], + [AC_RUN_IFELSE( + [AC_LANG_PROGRAM( + [AC_INCLUDES_DEFAULT + [#include + #if defined _WIN32 && !defined __CYGWIN__ + #define creat _creat + #endif + ]], + [[ + 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 Linux systems. + linux-* | linux) ac_cv_func_chown_works="guessing yes" ;; + # Guess yes on glibc systems. + *-gnu* | gnu*) ac_cv_func_chown_works="guessing yes" ;; + # Guess no on native Windows. + mingw*) ac_cv_func_chown_works="guessing no" ;; + # If we don't know, assume the worst. + *) ac_cv_func_chown_works="guessing no" ;; + esac + ]) + rm -f conftest.chown + ]) + case "$ac_cv_func_chown_works" in + *yes) + AC_DEFINE([HAVE_CHOWN], [1], + [Define to 1 if your system has a working `chown' function.]) + ;; + esac ])# AC_FUNC_CHOWN -- 2.7.4