Debian Codegraph @

m4/symlinkat.m4

raw
1 # symlinkat.m4
2 # serial 13
3 dnl Copyright (C) 2009-2025 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 symlinkat replacement.
10
11 # Written by Eric Blake.
12
13 AC_DEFUN([gl_FUNC_SYMLINKAT],
14 [
15 AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
16 AC_REQUIRE([gl_FUNC_OPENAT])
17 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
18 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
19 gl_CHECK_FUNCS_ANDROID([symlinkat], [[#include <unistd.h>]])
20 if test $ac_cv_func_symlinkat = no; then
21 HAVE_SYMLINKAT=0
22 case "$gl_cv_onwards_func_symlinkat" in
23 future*) REPLACE_SYMLINKAT=1 ;;
24 esac
25 else
26 AC_CACHE_CHECK([whether symlinkat handles trailing slash correctly],
27 [gl_cv_func_symlinkat_works],
28 [AC_RUN_IFELSE(
29 [AC_LANG_PROGRAM(
30 [[#include <fcntl.h>
31 #include <unistd.h>
32 ]],
33 [[int result = 0;
34 if (!symlinkat ("a", AT_FDCWD, "conftest.link/"))
35 result |= 1;
36 if (symlinkat ("conftest.f", AT_FDCWD, "conftest.lnk2"))
37 result |= 2;
38 else if (!symlinkat ("a", AT_FDCWD, "conftest.lnk2/"))
39 result |= 4;
40 return result;
41 ]])],
42 [gl_cv_func_symlinkat_works=yes],
43 [gl_cv_func_symlinkat_works=no],
44 [case "$host_os" in
45 # Guess yes on Linux systems.
46 linux-* | linux) gl_cv_func_symlinkat_works="guessing yes" ;;
47 # Guess yes on systems that emulate the Linux system calls.
48 midipix*) gl_cv_func_symlinkat_works="guessing yes" ;;
49 # Guess yes on glibc systems.
50 *-gnu* | gnu*) gl_cv_func_symlinkat_works="guessing yes" ;;
51 # If we don't know, obey --enable-cross-guesses.
52 *) gl_cv_func_symlinkat_works="$gl_cross_guess_normal" ;;
53 esac
54 ])
55 rm -f conftest.f conftest.link conftest.lnk2])
56 case "$gl_cv_func_symlinkat_works" in
57 *yes) ;;
58 *)
59 REPLACE_SYMLINKAT=1
60 ;;
61 esac
62 fi
63 ])