]> git.cworth.org Git - tar/blob - m4/symlink.m4
Imported Upstream version 1.24
[tar] / m4 / symlink.m4
1 # serial 3
2 # See if we need to provide symlink replacement.
3
4 dnl Copyright (C) 2009, 2010 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_SYMLINK],
12 [
13   AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
14   AC_CHECK_FUNCS_ONCE([symlink])
15   dnl The best we can do on mingw is provide a dummy that always fails, so
16   dnl that compilation can proceed with fewer ifdefs.  On FreeBSD 7.2, AIX 7.1,
17   dnl and Solaris 9, we want to fix a bug with trailing slash handling.
18   if test $ac_cv_func_symlink = no; then
19     HAVE_SYMLINK=0
20     AC_LIBOBJ([symlink])
21   else
22     AC_CACHE_CHECK([whether symlink handles trailing slash correctly],
23       [gl_cv_func_symlink_works],
24       [AC_RUN_IFELSE(
25          [AC_LANG_PROGRAM(
26            [[#include <unistd.h>
27 ]], [[if (!symlink ("a", "conftest.link/")) return 1;
28       if (symlink ("conftest.f", "conftest.lnk2")) return 2;
29       if (!symlink ("a", "conftest.lnk2/")) return 3;]])],
30          [gl_cv_func_symlink_works=yes], [gl_cv_func_symlink_works=no],
31          [gl_cv_func_symlink_works="guessing no"])
32       rm -f conftest.f conftest.link conftest.lnk2])
33     if test "$gl_cv_func_symlink_works" != yes; then
34       REPLACE_SYMLINK=1
35       AC_LIBOBJ([symlink])
36     fi
37   fi
38 ])