immutable: Add tests.
[gnulib.git] / m4 / unlinkat.m4
blob8bad505806b8ca971bd8140c13c1561f4ef66bf2
1 # unlinkat.m4 serial 2
2 dnl Copyright (C) 2004-2021 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
7 # Written by Jim Meyering.
9 AC_DEFUN([gl_FUNC_UNLINKAT],
11   AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
12   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
13   AC_CHECK_FUNCS_ONCE([unlinkat])
14   AC_REQUIRE([gl_FUNC_UNLINK])
15   AC_REQUIRE([gl_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK])
16   if test $ac_cv_func_unlinkat = no; then
17     HAVE_UNLINKAT=0
18   else
19     case "$gl_cv_func_lstat_dereferences_slashed_symlink" in
20       *no)
21         # Solaris 9 has *at functions, but uniformly mishandles trailing
22         # slash in all of them.
23         REPLACE_UNLINKAT=1
24         ;;
25       *)
26         # GNU/Hurd has unlinkat, but it has the same bug as unlink.
27         # Darwin has unlinkat, but it has the same UNLINK_PARENT_BUG.
28         if test $REPLACE_UNLINK = 1; then
29           REPLACE_UNLINKAT=1
30         fi
31         ;;
32     esac
33   fi