Blame m4/symlink.m4

Packit Service 4684c1
# serial 9
Packit Service 4684c1
# See if we need to provide symlink replacement.
Packit Service 4684c1
Packit Service 4684c1
dnl Copyright (C) 2009-2020 Free Software Foundation, Inc.
Packit Service 4684c1
dnl This file is free software; the Free Software Foundation
Packit Service 4684c1
dnl gives unlimited permission to copy and/or distribute it,
Packit Service 4684c1
dnl with or without modifications, as long as this notice is preserved.
Packit Service 4684c1
Packit Service 4684c1
# Written by Eric Blake.
Packit Service 4684c1
Packit Service 4684c1
AC_DEFUN([gl_FUNC_SYMLINK],
Packit Service 4684c1
[
Packit Service 4684c1
  AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
Packit Service 4684c1
  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
Packit Service 4684c1
  AC_CHECK_FUNCS_ONCE([symlink])
Packit Service 4684c1
  dnl The best we can do on mingw is provide a dummy that always fails, so
Packit Service 4684c1
  dnl that compilation can proceed with fewer ifdefs.  On FreeBSD 7.2, AIX 7.1,
Packit Service 4684c1
  dnl and Solaris 9, we want to fix a bug with trailing slash handling.
Packit Service 4684c1
  if test $ac_cv_func_symlink = no; then
Packit Service 4684c1
    HAVE_SYMLINK=0
Packit Service 4684c1
  else
Packit Service 4684c1
    AC_CACHE_CHECK([whether symlink handles trailing slash correctly],
Packit Service 4684c1
      [gl_cv_func_symlink_works],
Packit Service 4684c1
      [AC_RUN_IFELSE(
Packit Service 4684c1
         [AC_LANG_PROGRAM(
Packit Service 4684c1
           [[#include <unistd.h>
Packit Service 4684c1
           ]],
Packit Service 4684c1
           [[int result = 0;
Packit Service 4684c1
             if (!symlink ("a", "conftest.link/"))
Packit Service 4684c1
               result |= 1;
Packit Service 4684c1
             if (symlink ("conftest.f", "conftest.lnk2"))
Packit Service 4684c1
               result |= 2;
Packit Service 4684c1
             else if (!symlink ("a", "conftest.lnk2/"))
Packit Service 4684c1
               result |= 4;
Packit Service 4684c1
             return result;
Packit Service 4684c1
           ]])],
Packit Service 4684c1
         [gl_cv_func_symlink_works=yes], [gl_cv_func_symlink_works=no],
Packit Service 4684c1
         [case "$host_os" in
Packit Service 4684c1
                             # Guess yes on Linux systems.
Packit Service 4684c1
            linux-* | linux) gl_cv_func_symlink_works="guessing yes" ;;
Packit Service 4684c1
                             # Guess yes on glibc systems.
Packit Service 4684c1
            *-gnu* | gnu*)   gl_cv_func_symlink_works="guessing yes" ;;
Packit Service 4684c1
                             # If we don't know, obey --enable-cross-guesses.
Packit Service 4684c1
            *)               gl_cv_func_symlink_works="$gl_cross_guess_normal" ;;
Packit Service 4684c1
          esac
Packit Service 4684c1
         ])
Packit Service 4684c1
      rm -f conftest.f conftest.link conftest.lnk2])
Packit Service 4684c1
    case "$gl_cv_func_symlink_works" in
Packit Service 4684c1
      *yes) ;;
Packit Service 4684c1
      *)
Packit Service 4684c1
        REPLACE_SYMLINK=1
Packit Service 4684c1
        ;;
Packit Service 4684c1
    esac
Packit Service 4684c1
  fi
Packit Service 4684c1
])