symlink.m4 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. # serial 5
  2. # See if we need to provide symlink replacement.
  3. dnl Copyright (C) 2009-2011 Free Software Foundation, Inc.
  4. dnl This file is free software; the Free Software Foundation
  5. dnl gives unlimited permission to copy and/or distribute it,
  6. dnl with or without modifications, as long as this notice is preserved.
  7. # Written by Eric Blake.
  8. AC_DEFUN([gl_FUNC_SYMLINK],
  9. [
  10. AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
  11. AC_CHECK_FUNCS_ONCE([symlink])
  12. dnl The best we can do on mingw is provide a dummy that always fails, so
  13. dnl that compilation can proceed with fewer ifdefs. On FreeBSD 7.2, AIX 7.1,
  14. dnl and Solaris 9, we want to fix a bug with trailing slash handling.
  15. if test $ac_cv_func_symlink = no; then
  16. HAVE_SYMLINK=0
  17. else
  18. AC_CACHE_CHECK([whether symlink handles trailing slash correctly],
  19. [gl_cv_func_symlink_works],
  20. [AC_RUN_IFELSE(
  21. [AC_LANG_PROGRAM(
  22. [[#include <unistd.h>
  23. ]],
  24. [[int result = 0;
  25. if (!symlink ("a", "conftest.link/"))
  26. result |= 1;
  27. if (symlink ("conftest.f", "conftest.lnk2"))
  28. result |= 2;
  29. else if (!symlink ("a", "conftest.lnk2/"))
  30. result |= 4;
  31. return result;
  32. ]])],
  33. [gl_cv_func_symlink_works=yes], [gl_cv_func_symlink_works=no],
  34. [gl_cv_func_symlink_works="guessing no"])
  35. rm -f conftest.f conftest.link conftest.lnk2])
  36. if test "$gl_cv_func_symlink_works" != yes; then
  37. REPLACE_SYMLINK=1
  38. fi
  39. fi
  40. ])