Debian Codegraph @

m4/symlink.m4

raw
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.
7 dnl This file is offered as-is, without any warranty.
8
9 # See if we need to provide symlink replacement.
10
11 # Written by Eric Blake.
12
13 AC_DEFUN([gl_FUNC_SYMLINK],
14 [
15 AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
16 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
17 AC_CHECK_FUNCS_ONCE([symlink])
18 dnl The best we can do on mingw is provide a dummy that always fails, so
19 dnl that compilation can proceed with fewer ifdefs. On FreeBSD 7.2, AIX 7.1,
20 dnl and Solaris 9, we want to fix a bug with trailing slash handling.
21 if test $ac_cv_func_symlink = no; then
22 HAVE_SYMLINK=0
23 else
24 AC_CACHE_CHECK([whether symlink handles trailing slash correctly],
25 [gl_cv_func_symlink_works],
26 [AC_RUN_IFELSE(
27 [AC_LANG_PROGRAM(
28 [[#include <unistd.h>
29 ]],
30 [[int result = 0;
31 if (!symlink ("a", "conftest.link/"))
32 result |= 1;
33 if (symlink ("conftest.f", "conftest.lnk2"))
34 result |= 2;
35 else if (!symlink ("a", "conftest.lnk2/"))
36 result |= 4;
37 return result;
38 ]])],
39 [gl_cv_func_symlink_works=yes], [gl_cv_func_symlink_works=no],
40 [case "$host_os" in
41 # Guess yes on Linux systems.
42 linux-* | linux) gl_cv_func_symlink_works="guessing yes" ;;
43 # Guess yes on systems that emulate the Linux system calls.
44 midipix*) gl_cv_func_symlink_works="guessing yes" ;;
45 # Guess yes on glibc systems.
46 *-gnu* | gnu*) gl_cv_func_symlink_works="guessing yes" ;;
47 # If we don't know, obey --enable-cross-guesses.
48 *) gl_cv_func_symlink_works="$gl_cross_guess_normal" ;;
49 esac
50 ])
51 rm -f conftest.f conftest.link conftest.lnk2])
52 case "$gl_cv_func_symlink_works" in
53 *yes) ;;
54 *)
55 REPLACE_SYMLINK=1
56 ;;
57 esac
58 fi
59 ])