2
2
dnl Run a program to determine whether link(2) follows symlinks.
3
3
dnl Set LINK_FOLLOWS_SYMLINKS accordingly.
5
# Copyright (C) 1999-2001, 2004-2006, 2009-2011 Free Software Foundation, Inc.
5
# Copyright (C) 1999-2001, 2004-2006, 2009-2012 Free Software Foundation, Inc.
6
6
# This file is free software; the Free Software Foundation
7
7
# gives unlimited permission to copy and/or distribute it,
8
8
# with or without modifications, as long as this notice is preserved.
16
16
dnl runtime test. If it is -2, use a generic runtime test.
17
17
AC_DEFUN([gl_FUNC_LINK_FOLLOWS_SYMLINK],
19
AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
19
20
AC_CHECK_FUNCS_ONCE([readlink])
20
21
dnl Mingw lacks link, although gnulib provides a good replacement.
21
22
dnl However, it also lacks symlink, so there's nothing to test in
82
83
[gl_cv_func_link_follows_symlink=no], dnl GNU behavior
83
84
[gl_cv_func_link_follows_symlink=yes], dnl Followed link/compile failed
84
[gl_cv_func_link_follows_symlink=unknown] dnl We're cross compiling.
85
[dnl We're cross compiling.
86
dnl The past results are "yes" on Mac OS X, FreeBSD, NetBSD,
87
dnl OpenBSD, Minix, AIX, HP-UX, OSF/1, and "no" on Linux, Cygwin.
89
# On glibc/Linux we know the result.
90
linux*-gnu*) gl_cv_func_link_follows_symlink="guessing no" ;;
91
# Otherwise, we don't know.
92
*) gl_cv_func_link_follows_symlink=unknown ;;
86
95
rm -f conftest.file conftest.sym conftest.hard
88
case $gl_cv_func_link_follows_symlink in
89
yes) gl_link_follows_symlinks=1 ;;
90
no) ;; # already defaulted to 0
97
case "$gl_cv_func_link_follows_symlink" in
98
*yes) gl_link_follows_symlinks=1 ;;
99
*no) ;; # already defaulted to 0
91
100
*) gl_link_follows_symlinks=-2 ;;
95
104
AC_DEFINE_UNQUOTED([LINK_FOLLOWS_SYMLINKS], [$gl_link_follows_symlinks],
96
[Define to 1 if `link(2)' dereferences symbolic links, 0 if it
105
[Define to 1 if 'link(2)' dereferences symbolic links, 0 if it
97
106
creates hard links to symlinks, -1 if it depends on the variable __xpg4,
98
107
and -2 if unknown.])