Merge branch 'stable'
[gnulib.git] / m4 / unlinkat.m4
1 # unlinkat.m4 serial 1
2 dnl Copyright (C) 2004-2011 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.
6
7 # Written by Jim Meyering.
8
9 AC_DEFUN([gl_FUNC_UNLINKAT],
10 [
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     if test $gl_cv_func_lstat_dereferences_slashed_symlink != yes; then
20       # Solaris 9 has *at functions, but uniformly mishandles trailing
21       # slash in all of them.
22       REPLACE_UNLINKAT=1
23     else
24       # GNU/Hurd has unlinkat, but it has the same bug as unlink.
25       if test $REPLACE_UNLINK = 1; then
26         REPLACE_UNLINKAT=1
27       fi
28     fi
29   fi
30 ])