re-mark 1.29b-2 as not yet uploaded (merge madness!)
[debian/tar] / m4 / symlinkat.m4
1 # serial 6
2 # See if we need to provide symlinkat replacement.
3
4 dnl Copyright (C) 2009-2015 Free Software Foundation, Inc.
5 dnl This file is free software; the Free Software Foundation
6 dnl gives unlimited permission to copy and/or distribute it,
7 dnl with or without modifications, as long as this notice is preserved.
8
9 # Written by Eric Blake.
10
11 AC_DEFUN([gl_FUNC_SYMLINKAT],
12 [
13   AC_REQUIRE([gl_FUNC_OPENAT])
14   AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
15   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
16   AC_CHECK_FUNCS_ONCE([symlinkat])
17   if test $ac_cv_func_symlinkat = no; then
18     HAVE_SYMLINKAT=0
19   else
20     AC_CACHE_CHECK([whether symlinkat handles trailing slash correctly],
21       [gl_cv_func_symlinkat_works],
22       [AC_RUN_IFELSE(
23          [AC_LANG_PROGRAM(
24            [[#include <fcntl.h>
25              #include <unistd.h>
26            ]],
27            [[int result = 0;
28              if (!symlinkat ("a", AT_FDCWD, "conftest.link/"))
29                result |= 1;
30              if (symlinkat ("conftest.f", AT_FDCWD, "conftest.lnk2"))
31                result |= 2;
32              else if (!symlinkat ("a", AT_FDCWD, "conftest.lnk2/"))
33                result |= 4;
34              return result;
35            ]])],
36          [gl_cv_func_symlinkat_works=yes],
37          [gl_cv_func_symlinkat_works=no],
38          [case "$host_os" in
39                     # Guess yes on glibc systems.
40             *-gnu*) gl_cv_func_symlinkat_works="guessing yes" ;;
41                     # If we don't know, assume the worst.
42             *)      gl_cv_func_symlinkat_works="guessing no" ;;
43           esac
44          ])
45       rm -f conftest.f conftest.link conftest.lnk2])
46     case "$gl_cv_func_symlinkat_works" in
47       *yes) ;;
48       *)
49         REPLACE_SYMLINKAT=1
50         ;;
51     esac
52   fi
53 ])