|
Packit |
8f70b4 |
# serial 32
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
# Copyright (C) 1997-2001, 2003-2018 Free Software Foundation, Inc.
|
|
Packit |
8f70b4 |
#
|
|
Packit |
8f70b4 |
# This file is free software; the Free Software Foundation
|
|
Packit |
8f70b4 |
# gives unlimited permission to copy and/or distribute it,
|
|
Packit |
8f70b4 |
# with or without modifications, as long as this notice is preserved.
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
dnl From Jim Meyering.
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
AC_DEFUN([gl_FUNC_LSTAT],
|
|
Packit |
8f70b4 |
[
|
|
Packit |
8f70b4 |
AC_REQUIRE([AC_CANONICAL_HOST])
|
|
Packit |
8f70b4 |
AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS])
|
|
Packit |
8f70b4 |
dnl If lstat does not exist, the replacement <sys/stat.h> does
|
|
Packit |
8f70b4 |
dnl "#define lstat stat", and lstat.c is a no-op.
|
|
Packit |
8f70b4 |
AC_CHECK_FUNCS_ONCE([lstat])
|
|
Packit |
8f70b4 |
if test $ac_cv_func_lstat = yes; then
|
|
Packit |
8f70b4 |
AC_REQUIRE([gl_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK])
|
|
Packit |
8f70b4 |
case $host_os,$gl_cv_func_lstat_dereferences_slashed_symlink in
|
|
Packit |
8f70b4 |
solaris* | *no)
|
|
Packit |
8f70b4 |
REPLACE_LSTAT=1
|
|
Packit |
8f70b4 |
;;
|
|
Packit |
8f70b4 |
esac
|
|
Packit |
8f70b4 |
else
|
|
Packit |
8f70b4 |
HAVE_LSTAT=0
|
|
Packit |
8f70b4 |
fi
|
|
Packit |
8f70b4 |
])
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
# Prerequisites of lib/lstat.c.
|
|
Packit |
8f70b4 |
AC_DEFUN([gl_PREREQ_LSTAT], [:])
|
|
Packit |
8f70b4 |
|
|
Packit |
8f70b4 |
AC_DEFUN([gl_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK],
|
|
Packit |
8f70b4 |
[
|
|
Packit |
8f70b4 |
dnl We don't use AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK any more, because it
|
|
Packit |
8f70b4 |
dnl is no longer maintained in Autoconf and because it invokes AC_LIBOBJ.
|
|
Packit |
8f70b4 |
AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
|
|
Packit |
8f70b4 |
AC_CACHE_CHECK([whether lstat correctly handles trailing slash],
|
|
Packit |
8f70b4 |
[gl_cv_func_lstat_dereferences_slashed_symlink],
|
|
Packit |
8f70b4 |
[rm -f conftest.sym conftest.file
|
|
Packit |
8f70b4 |
echo >conftest.file
|
|
Packit |
8f70b4 |
AC_RUN_IFELSE(
|
|
Packit |
8f70b4 |
[AC_LANG_PROGRAM(
|
|
Packit |
8f70b4 |
[AC_INCLUDES_DEFAULT],
|
|
Packit |
8f70b4 |
[[struct stat sbuf;
|
|
Packit |
8f70b4 |
if (symlink ("conftest.file", "conftest.sym") != 0)
|
|
Packit |
8f70b4 |
return 1;
|
|
Packit |
8f70b4 |
/* Linux will dereference the symlink and fail, as required by
|
|
Packit |
8f70b4 |
POSIX. That is better in the sense that it means we will not
|
|
Packit |
8f70b4 |
have to compile and use the lstat wrapper. */
|
|
Packit |
8f70b4 |
return lstat ("conftest.sym/", &sbuf) == 0;
|
|
Packit |
8f70b4 |
]])],
|
|
Packit |
8f70b4 |
[gl_cv_func_lstat_dereferences_slashed_symlink=yes],
|
|
Packit |
8f70b4 |
[gl_cv_func_lstat_dereferences_slashed_symlink=no],
|
|
Packit |
8f70b4 |
[case "$host_os" in
|
|
Packit |
8f70b4 |
linux-* | linux)
|
|
Packit |
8f70b4 |
# Guess yes on Linux systems.
|
|
Packit |
8f70b4 |
gl_cv_func_lstat_dereferences_slashed_symlink="guessing yes" ;;
|
|
Packit |
8f70b4 |
*-gnu* | gnu*)
|
|
Packit |
8f70b4 |
# Guess yes on glibc systems.
|
|
Packit |
8f70b4 |
gl_cv_func_lstat_dereferences_slashed_symlink="guessing yes" ;;
|
|
Packit |
8f70b4 |
mingw*)
|
|
Packit |
8f70b4 |
# Guess no on native Windows.
|
|
Packit |
8f70b4 |
gl_cv_func_lstat_dereferences_slashed_symlink="guessing no" ;;
|
|
Packit |
8f70b4 |
*)
|
|
Packit |
8f70b4 |
# If we don't know, assume the worst.
|
|
Packit |
8f70b4 |
gl_cv_func_lstat_dereferences_slashed_symlink="guessing no" ;;
|
|
Packit |
8f70b4 |
esac
|
|
Packit |
8f70b4 |
])
|
|
Packit |
8f70b4 |
rm -f conftest.sym conftest.file
|
|
Packit |
8f70b4 |
])
|
|
Packit |
8f70b4 |
case "$gl_cv_func_lstat_dereferences_slashed_symlink" in
|
|
Packit |
8f70b4 |
*yes)
|
|
Packit |
8f70b4 |
AC_DEFINE_UNQUOTED([LSTAT_FOLLOWS_SLASHED_SYMLINK], [1],
|
|
Packit |
8f70b4 |
[Define to 1 if 'lstat' dereferences a symlink specified
|
|
Packit |
8f70b4 |
with a trailing slash.])
|
|
Packit |
8f70b4 |
;;
|
|
Packit |
8f70b4 |
esac
|
|
Packit |
8f70b4 |
])
|