; Improve recent change to deferred evaluation in Eshell
[emacs.git] / m4 / symlink.m4
blob47968a1d33f65f5372228a960d585428a73ed815
1 # symlink.m4
2 # serial 10
3 dnl Copyright (C) 2009-2024 Free Software Foundation, Inc.
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
8 # See if we need to provide symlink replacement.
10 # Written by Eric Blake.
12 AC_DEFUN([gl_FUNC_SYMLINK],
14   AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
15   AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
16   AC_CHECK_FUNCS_ONCE([symlink])
17   dnl The best we can do on mingw is provide a dummy that always fails, so
18   dnl that compilation can proceed with fewer ifdefs.  On FreeBSD 7.2, AIX 7.1,
19   dnl and Solaris 9, we want to fix a bug with trailing slash handling.
20   if test $ac_cv_func_symlink = no; then
21     HAVE_SYMLINK=0
22   else
23     AC_CACHE_CHECK([whether symlink handles trailing slash correctly],
24       [gl_cv_func_symlink_works],
25       [AC_RUN_IFELSE(
26          [AC_LANG_PROGRAM(
27            [[#include <unistd.h>
28            ]],
29            [[int result = 0;
30              if (!symlink ("a", "conftest.link/"))
31                result |= 1;
32              if (symlink ("conftest.f", "conftest.lnk2"))
33                result |= 2;
34              else if (!symlink ("a", "conftest.lnk2/"))
35                result |= 4;
36              return result;
37            ]])],
38          [gl_cv_func_symlink_works=yes], [gl_cv_func_symlink_works=no],
39          [case "$host_os" in
40                              # Guess yes on Linux systems.
41             linux-* | linux) gl_cv_func_symlink_works="guessing yes" ;;
42                              # Guess yes on systems that emulate the Linux system calls.
43             midipix*)        gl_cv_func_symlink_works="guessing yes" ;;
44                              # Guess yes on glibc systems.
45             *-gnu* | gnu*)   gl_cv_func_symlink_works="guessing yes" ;;
46                              # If we don't know, obey --enable-cross-guesses.
47             *)               gl_cv_func_symlink_works="$gl_cross_guess_normal" ;;
48           esac
49          ])
50       rm -f conftest.f conftest.link conftest.lnk2])
51     case "$gl_cv_func_symlink_works" in
52       *yes) ;;
53       *)
54         REPLACE_SYMLINK=1
55         ;;
56     esac
57   fi