| | |
| | |
| | dnl Copyright (C) 2019-2025 Free Software Foundation, Inc. |
| | dnl This file is free software; the Free Software Foundation |
| | dnl gives unlimited permission to copy and/or distribute it, |
| | dnl with or without modifications, as long as this notice is preserved. |
| | dnl This file is offered as-is, without any warranty. |
| |
|
| | AC_DEFUN([gl_FUNC_ACCESS], |
| | [ |
| | AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) |
| | AC_REQUIRE([AC_CANONICAL_HOST]) |
| | dnl On native Windows, access (= _access) does not support the X_OK mode. |
| | dnl It works by chance on some versions of mingw. |
| | case "$host_os" in |
| | mingw* | windows*) |
| | REPLACE_ACCESS=1 |
| | ;; |
| | *) |
| | dnl Mac OS X 10.5 mistakenly allows access("link-to-file/",amode). |
| | AC_CHECK_FUNCS_ONCE([lstat]) |
| | AC_CACHE_CHECK([whether access honors trailing slash], |
| | [gl_cv_func_access_slash_works], |
| | [ |
| | if test $ac_cv_func_lstat = yes; then |
| | rm -rf conftest.f conftest.lnk |
| | touch conftest.f || AC_MSG_ERROR([cannot create temporary files]) |
| | ln -s conftest.f conftest.lnk |
| | AC_RUN_IFELSE( |
| | [AC_LANG_PROGRAM([[ |
| | |
| | ]], |
| | [[int result = 0; |
| | if (access ("conftest.lnk/", R_OK) == 0) |
| | result |= 1; |
| | return result; |
| | ]])], |
| | [gl_cv_func_access_slash_works=yes], |
| | [gl_cv_func_access_slash_works=no], |
| | dnl When crosscompiling, assume access is broken. |
| | [case "$host_os" in |
| | |
| | linux-* | linux) gl_cv_func_access_slash_works="guessing yes" ;; |
| | |
| | midipix*) gl_cv_func_access_slash_works="guessing yes" ;; |
| | |
| | *-gnu*) gl_cv_func_access_slash_works="guessing yes" ;; |
| | |
| | *) gl_cv_func_access_slash_works="$gl_cross_guess_normal" ;; |
| | esac |
| | ]) |
| | rm -rf conftest.f conftest.lnk |
| | else |
| | gl_cv_func_access_slash_works="guessing yes" |
| | fi |
| | ]) |
| | case "$gl_cv_func_access_slash_works" in |
| | *yes) ;; |
| | *) |
| | REPLACE_ACCESS=1 |
| | AC_DEFINE([ACCESS_TRAILING_SLASH_BUG], [1], |
| | [Define if access does not correctly handle trailing slashes.]) |
| | ;; |
| | esac |
| | ;; |
| | esac |
| | ]) |
| |
|