3 # Copyright (C) 1997-2001, 2003-2018 Free Software Foundation, Inc.
5 # This file is free software; the Free Software Foundation
6 # gives unlimited permission to copy and/or distribute it,
7 # with or without modifications, as long as this notice is preserved.
11 AC_DEFUN([gl_FUNC_LSTAT],
13 AC_REQUIRE([AC_CANONICAL_HOST])
14 AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS])
15 dnl If lstat does not exist, the replacement <sys/stat.h> does
16 dnl "#define lstat stat", and lstat.c is a no-op.
17 AC_CHECK_FUNCS_ONCE([lstat])
18 if test $ac_cv_func_lstat = yes; then
19 AC_REQUIRE([gl_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK])
20 case $host_os,$gl_cv_func_lstat_dereferences_slashed_symlink in
30 # Prerequisites of lib/lstat.c.
31 AC_DEFUN([gl_PREREQ_LSTAT], [:])
33 AC_DEFUN([gl_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK],
35 dnl We don't use AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK any more, because it
36 dnl is no longer maintained in Autoconf and because it invokes AC_LIBOBJ.
37 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
38 AC_CACHE_CHECK([whether lstat correctly handles trailing slash],
39 [gl_cv_func_lstat_dereferences_slashed_symlink],
40 [rm -f conftest.sym conftest.file
44 [AC_INCLUDES_DEFAULT],
46 if (symlink ("conftest.file", "conftest.sym") != 0)
48 /* Linux will dereference the symlink and fail, as required by
49 POSIX. That is better in the sense that it means we will not
50 have to compile and use the lstat wrapper. */
51 return lstat ("conftest.sym/", &sbuf) == 0;
53 [gl_cv_func_lstat_dereferences_slashed_symlink=yes],
54 [gl_cv_func_lstat_dereferences_slashed_symlink=no],
57 # Guess yes on glibc systems.
58 gl_cv_func_lstat_dereferences_slashed_symlink="guessing yes" ;;
60 # Guess no on native Windows.
61 gl_cv_func_lstat_dereferences_slashed_symlink="guessing no" ;;
63 # If we don't know, assume the worst.
64 gl_cv_func_lstat_dereferences_slashed_symlink="guessing no" ;;
67 rm -f conftest.sym conftest.file
69 case "$gl_cv_func_lstat_dereferences_slashed_symlink" in
71 AC_DEFINE_UNQUOTED([LSTAT_FOLLOWS_SLASHED_SYMLINK], [1],
72 [Define to 1 if 'lstat' dereferences a symlink specified
73 with a trailing slash.])