Debian Codegraph @

m4/access.m4

raw
1 # access.m4
2 # serial 3
3 dnl Copyright (C) 2019-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 AC_DEFUN([gl_FUNC_ACCESS],
10 [
11 AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
12 AC_REQUIRE([AC_CANONICAL_HOST])
13 dnl On native Windows, access (= _access) does not support the X_OK mode.
14 dnl It works by chance on some versions of mingw.
15 case "$host_os" in
16 mingw* | windows*)
17 REPLACE_ACCESS=1
18 ;;
19 *)
20 dnl Mac OS X 10.5 mistakenly allows access("link-to-file/",amode).
21 AC_CHECK_FUNCS_ONCE([lstat])
22 AC_CACHE_CHECK([whether access honors trailing slash],
23 [gl_cv_func_access_slash_works],
24 [# Assume that if we have lstat, we can also check symlinks.
25 if test $ac_cv_func_lstat = yes; then
26 rm -rf conftest.f conftest.lnk
27 touch conftest.f || AC_MSG_ERROR([cannot create temporary files])
28 ln -s conftest.f conftest.lnk
29 AC_RUN_IFELSE(
30 [AC_LANG_PROGRAM([[
31 #include <unistd.h>
32 ]],
33 [[int result = 0;
34 if (access ("conftest.lnk/", R_OK) == 0)
35 result |= 1;
36 return result;
37 ]])],
38 [gl_cv_func_access_slash_works=yes],
39 [gl_cv_func_access_slash_works=no],
40 dnl When crosscompiling, assume access is broken.
41 [case "$host_os" in
42 # Guess yes on Linux systems.
43 linux-* | linux) gl_cv_func_access_slash_works="guessing yes" ;;
44 # Guess yes on systems that emulate the Linux system calls.
45 midipix*) gl_cv_func_access_slash_works="guessing yes" ;;
46 # Guess yes on glibc systems.
47 *-gnu*) gl_cv_func_access_slash_works="guessing yes" ;;
48 # If we don't know, obey --enable-cross-guesses.
49 *) gl_cv_func_access_slash_works="$gl_cross_guess_normal" ;;
50 esac
51 ])
52 rm -rf conftest.f conftest.lnk
53 else
54 gl_cv_func_access_slash_works="guessing yes"
55 fi
56 ])
57 case "$gl_cv_func_access_slash_works" in
58 *yes) ;;
59 *)
60 REPLACE_ACCESS=1
61 AC_DEFINE([ACCESS_TRAILING_SLASH_BUG], [1],
62 [Define if access does not correctly handle trailing slashes.])
63 ;;
64 esac
65 ;;
66 esac
67 ])