From: Bruno Haible <bruno@clisp.org>
Date: Sun, 16 Feb 2020 18:51:25 +0000 (+0100)
Subject: lchmod: Improve cross-compilation guess.
X-Git-Tag: v1.0~4247
X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=c7cc0deae47dad9f68ba56fd569e1eb793f61b81;p=gnulib.git

lchmod: Improve cross-compilation guess.

* m4/lchmod.m4 (gl_FUNC_LCHMOD): Require AC_CANONICAL_HOST. When
cross-compiling, guess depending on the platform.
---

diff --git a/ChangeLog b/ChangeLog
index 288bae705f..beacc09263 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2020-02-16  Bruno Haible  <bruno@clisp.org>
+
+	lchmod: Improve cross-compilation guess.
+	* m4/lchmod.m4 (gl_FUNC_LCHMOD): Require AC_CANONICAL_HOST. When
+	cross-compiling, guess depending on the platform.
+
 2020-02-16  Bruno Haible  <bruno@clisp.org>
 
 	fstrcmp: Add API to clean up resources.
diff --git a/m4/lchmod.m4 b/m4/lchmod.m4
index 68dab7a4ac..1646bd7db3 100644
--- a/m4/lchmod.m4
+++ b/m4/lchmod.m4
@@ -1,4 +1,4 @@
-#serial 4
+#serial 5
 
 dnl Copyright (C) 2005-2006, 2008-2020 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
@@ -15,6 +15,8 @@ AC_DEFUN([gl_FUNC_LCHMOD],
   dnl Persuade glibc <sys/stat.h> to declare lchmod().
   AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
 
+  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+
   AC_CHECK_FUNCS_ONCE([fchmodat lchmod lstat])
   if test "$ac_cv_func_lchmod" = no; then
     HAVE_LCHMOD=0
@@ -56,7 +58,12 @@ AC_DEFUN([gl_FUNC_LCHMOD],
             ]])],
          [gl_cv_func_lchmod_works=yes],
          [gl_cv_func_lchmod_works=no],
-         [gl_cv_func_lchmod_works=$gl_cross_guess_normal])
+         [case "$host_os" in
+            dnl Guess no on Linux with glibc, yes otherwise.
+            linux-gnu*) gl_cv_func_lchmod_works="guessing no" ;;
+            *)          gl_cv_func_lchmod_works="$gl_cross_guess_normal" ;;
+          esac
+         ])
        rm -f conftest.lchmod])
     case $gl_cv_func_lchmod_works in
       *yes) ;;