summaryrefslogtreecommitdiff
path: root/m4/canonicalize.m4
diff options
context:
space:
mode:
Diffstat (limited to 'm4/canonicalize.m4')
-rw-r--r--m4/canonicalize.m431
1 files changed, 24 insertions, 7 deletions
diff --git a/m4/canonicalize.m4 b/m4/canonicalize.m4
index 6821c70e6..0dfb2da9a 100644
--- a/m4/canonicalize.m4
+++ b/m4/canonicalize.m4
@@ -1,4 +1,4 @@
-# canonicalize.m4 serial 36
+# canonicalize.m4 serial 37
dnl Copyright (C) 2003-2007, 2009-2021 Free Software Foundation, Inc.
@@ -78,15 +78,20 @@ AC_DEFUN([gl_CANONICALIZE_LGPL_SEPARATE],
# so is the latter.
AC_DEFUN([gl_FUNC_REALPATH_WORKS],
[
- AC_CHECK_FUNCS_ONCE([realpath])
+ AC_CHECK_FUNCS_ONCE([realpath lstat])
AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
AC_CACHE_CHECK([whether realpath works], [gl_cv_func_realpath_works], [
rm -rf conftest.a conftest.d
touch conftest.a
+ # Assume that if we have lstat, we can also check symlinks.
+ if test $ac_cv_func_lstat = yes; then
+ ln -s conftest.a conftest.l
+ fi
mkdir conftest.d
AC_RUN_IFELSE([
AC_LANG_PROGRAM([[
]GL_NOCRASH[
+ #include <errno.h>
#include <stdlib.h>
#include <string.h>
]], [[
@@ -98,17 +103,27 @@ AC_DEFUN([gl_FUNC_REALPATH_WORKS],
result |= 1;
free (name);
}
+ /* This test fails on older versions of Cygwin. */
{
char *name = realpath ("conftest.b/../conftest.a", NULL);
if (name != NULL)
result |= 2;
free (name);
}
+ /* This test fails on Cygwin 2.9. */
+ #if HAVE_LSTAT
+ {
+ char *name = realpath ("conftest.l/../conftest.a", NULL);
+ if (name != NULL || errno != ENOTDIR)
+ result |= 4;
+ free (name);
+ }
+ #endif
/* This test fails on Mac OS X 10.13, OpenBSD 6.0. */
{
char *name = realpath ("conftest.a/", NULL);
if (name != NULL)
- result |= 4;
+ result |= 8;
free (name);
}
/* This test fails on AIX 7, Solaris 10. */
@@ -116,7 +131,7 @@ AC_DEFUN([gl_FUNC_REALPATH_WORKS],
char *name1 = realpath (".", NULL);
char *name2 = realpath ("conftest.d//./..", NULL);
if (! name1 || ! name2 || strcmp (name1, name2))
- result |= 8;
+ result |= 16;
free (name1);
free (name2);
}
@@ -127,7 +142,7 @@ AC_DEFUN([gl_FUNC_REALPATH_WORKS],
{
char *name = realpath ("//", NULL);
if (! name || strcmp (name, "/"))
- result |= 16;
+ result |= 32;
free (name);
}
#endif
@@ -136,7 +151,7 @@ AC_DEFUN([gl_FUNC_REALPATH_WORKS],
],
[gl_cv_func_realpath_works=yes],
[case $? in
- 16) gl_cv_func_realpath_works=nearly ;;
+ 32) gl_cv_func_realpath_works=nearly ;;
*) gl_cv_func_realpath_works=no ;;
esac
],
@@ -145,13 +160,15 @@ AC_DEFUN([gl_FUNC_REALPATH_WORKS],
*-gnu* | gnu*) gl_cv_func_realpath_works="guessing yes" ;;
# Guess 'nearly' on musl systems.
*-musl*) gl_cv_func_realpath_works="guessing nearly" ;;
+ # Guess no on Cygwin.
+ cygwin*) gl_cv_func_realpath_works="guessing no" ;;
# Guess no on native Windows.
mingw*) gl_cv_func_realpath_works="guessing no" ;;
# If we don't know, obey --enable-cross-guesses.
*) gl_cv_func_realpath_works="$gl_cross_guess_normal" ;;
esac
])
- rm -rf conftest.a conftest.d
+ rm -rf conftest.a conftest.l conftest.d
])
case "$gl_cv_func_realpath_works" in
*yes)