Debian Codegraph @

m4/symlinkat.m4

raw
1 # serial 13
2 # See if we need to provide symlinkat replacement.
3
4 dnl Copyright (C) 2009-2023 Free Software Foundation, Inc.
5 dnl This file is free software; the Free Software Foundation
6 dnl gives unlimited permission to copy and/or distribute it,
7 dnl with or without modifications, as long as this notice is preserved.
8
9 # Written by Eric Blake.
10
11 AC_DEFUN([gl_FUNC_SYMLINKAT],
12 [
13 AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
14 AC_REQUIRE([gl_FUNC_OPENAT])
15 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
16 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
17 gl_CHECK_FUNCS_ANDROID([symlinkat], [[#include <unistd.h>]])
18 if test $ac_cv_func_symlinkat = no; then
19 HAVE_SYMLINKAT=0
20 case "$gl_cv_onwards_func_symlinkat" in
21 future*) REPLACE_SYMLINKAT=1 ;;
22 esac
23 else
24 AC_CACHE_CHECK([whether symlinkat handles trailing slash correctly],
25 [gl_cv_func_symlinkat_works],
26 [AC_RUN_IFELSE(
27 [AC_LANG_PROGRAM(
28 [[#include <fcntl.h>
29 #include <unistd.h>
30 ]],
31 [[int result = 0;
32 if (!symlinkat ("a", AT_FDCWD, "conftest.link/"))
33 result |= 1;
34 if (symlinkat ("conftest.f", AT_FDCWD, "conftest.lnk2"))
35 result |= 2;
36 else if (!symlinkat ("a", AT_FDCWD, "conftest.lnk2/"))
37 result |= 4;
38 return result;
39 ]])],
40 [gl_cv_func_symlinkat_works=yes],
41 [gl_cv_func_symlinkat_works=no],
42 [case "$host_os" in
43 # Guess yes on Linux systems.
44 linux-* | linux) gl_cv_func_symlinkat_works="guessing yes" ;;
45 # Guess yes on systems that emulate the Linux system calls.
46 midipix*) gl_cv_func_symlinkat_works="guessing yes" ;;
47 # Guess yes on glibc systems.
48 *-gnu* | gnu*) gl_cv_func_symlinkat_works="guessing yes" ;;
49 # If we don't know, obey --enable-cross-guesses.
50 *) gl_cv_func_symlinkat_works="$gl_cross_guess_normal" ;;
51 esac
52 ])
53 rm -f conftest.f conftest.link conftest.lnk2])
54 case "$gl_cv_func_symlinkat_works" in
55 *yes) ;;
56 *)
57 REPLACE_SYMLINKAT=1
58 ;;
59 esac
60 fi
61 ])