3
# Copyright (C) 1997-2001, 2003-2010 Free Software Foundation, Inc.
3
# Copyright (C) 1997-2001, 2003-2012 Free Software Foundation, Inc.
5
5
# This file is free software; the Free Software Foundation
6
6
# gives unlimited permission to copy and/or distribute it,
15
15
dnl "#define lstat stat", and lstat.c is a no-op.
16
16
AC_CHECK_FUNCS_ONCE([lstat])
17
17
if test $ac_cv_func_lstat = yes; then
18
AC_REQUIRE([AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK])
19
if test $ac_cv_func_lstat_dereferences_slashed_symlink = no; then
20
dnl Note: AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK does AC_LIBOBJ([lstat]).
18
AC_REQUIRE([gl_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK])
19
if test $gl_cv_func_lstat_dereferences_slashed_symlink = no; then
23
# Prerequisites of lib/lstat.c.
24
AC_REQUIRE([AC_C_INLINE])
27
# Prerequisites of lib/lstat.c.
28
AC_DEFUN([gl_PREREQ_LSTAT],
30
AC_REQUIRE([AC_C_INLINE])
34
AC_DEFUN([gl_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK],
36
dnl We don't use AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK any more, because it
37
dnl is no longer maintained in Autoconf and because it invokes AC_LIBOBJ.
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
42
if test "$as_ln_s" = "ln -s" && ln -s conftest.file conftest.sym; then
45
[AC_INCLUDES_DEFAULT],
47
/* Linux will dereference the symlink and fail, as required by
48
POSIX. That is better in the sense that it means we will not
49
have to compile and use the lstat wrapper. */
50
return lstat ("conftest.sym/", &sbuf) == 0;
52
[gl_cv_func_lstat_dereferences_slashed_symlink=yes],
53
[gl_cv_func_lstat_dereferences_slashed_symlink=no],
54
[# When cross-compiling, be pessimistic so we will end up using the
55
# replacement version of lstat that checks for trailing slashes and
56
# calls lstat a second time when necessary.
57
gl_cv_func_lstat_dereferences_slashed_symlink=no
60
# If the 'ln -s' command failed, then we probably don't even
61
# have an lstat function.
62
gl_cv_func_lstat_dereferences_slashed_symlink=no
64
rm -f conftest.sym conftest.file
66
test $gl_cv_func_lstat_dereferences_slashed_symlink = yes &&
67
AC_DEFINE_UNQUOTED([LSTAT_FOLLOWS_SLASHED_SYMLINK], [1],
68
[Define to 1 if 'lstat' dereferences a symlink specified
69
with a trailing slash.])