1 | # serial 9
|
---|
2 | # See if we need to provide symlink replacement.
|
---|
3 |
|
---|
4 | dnl Copyright (C) 2009-2021 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_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
|
---|
15 | AC_CHECK_FUNCS_ONCE([symlink])
|
---|
16 | dnl The best we can do on mingw is provide a dummy that always fails, so
|
---|
17 | dnl that compilation can proceed with fewer ifdefs. On FreeBSD 7.2, AIX 7.1,
|
---|
18 | dnl and Solaris 9, we want to fix a bug with trailing slash handling.
|
---|
19 | if test $ac_cv_func_symlink = no; then
|
---|
20 | HAVE_SYMLINK=0
|
---|
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 | ]],
|
---|
28 | [[int result = 0;
|
---|
29 | if (!symlink ("a", "conftest.link/"))
|
---|
30 | result |= 1;
|
---|
31 | if (symlink ("conftest.f", "conftest.lnk2"))
|
---|
32 | result |= 2;
|
---|
33 | else if (!symlink ("a", "conftest.lnk2/"))
|
---|
34 | result |= 4;
|
---|
35 | return result;
|
---|
36 | ]])],
|
---|
37 | [gl_cv_func_symlink_works=yes], [gl_cv_func_symlink_works=no],
|
---|
38 | [case "$host_os" in
|
---|
39 | # Guess yes on Linux systems.
|
---|
40 | linux-* | linux) gl_cv_func_symlink_works="guessing yes" ;;
|
---|
41 | # Guess yes on glibc systems.
|
---|
42 | *-gnu* | gnu*) gl_cv_func_symlink_works="guessing yes" ;;
|
---|
43 | # If we don't know, obey --enable-cross-guesses.
|
---|
44 | *) gl_cv_func_symlink_works="$gl_cross_guess_normal" ;;
|
---|
45 | esac
|
---|
46 | ])
|
---|
47 | rm -f conftest.f conftest.link conftest.lnk2])
|
---|
48 | case "$gl_cv_func_symlink_works" in
|
---|
49 | *yes) ;;
|
---|
50 | *)
|
---|
51 | REPLACE_SYMLINK=1
|
---|
52 | ;;
|
---|
53 | esac
|
---|
54 | fi
|
---|
55 | ])
|
---|