- [rm -rf conftest.f conftest.f1
- if touch conftest.f && ln conftest.f conftest.f1 &&
- set x `ls -i conftest.f conftest.f1` && test "$2" = "$4"; then
- AC_RUN_IFELSE([AC_LANG_PROGRAM([[
-# include <stdio.h>
-# include <stdlib.h>
-# include <unistd.h>
-]], [if (rename ("conftest.f", "conftest.f1")) return 1;
- if (unlink ("conftest.f1")) return 2;
- if (rename ("conftest.f", "conftest.f")) return 3;
- if (rename ("conftest.f1", "conftest.f1") == 0) return 4;])],
- [gl_cv_func_rename_link_works=yes],
- [gl_cv_func_rename_link_works=no],
- dnl When crosscompiling, assume rename is broken.
- [gl_cv_func_rename_link_works="guessing no"])
- else
- gl_cv_func_rename_link_works="guessing no"
- fi
- rm -rf conftest.f conftest.f1
- ])
- if test "x$gl_cv_func_rename_link_works" != xyes; then
- AC_LIBOBJ([rename])
- REPLACE_RENAME=1
- AC_DEFINE([RENAME_HARD_LINK_BUG], [1],
- [Define if rename fails to leave hard links alone, as on NetBSD 1.6
- or Cygwin 1.5.])
- fi
+ [if test $ac_cv_func_link = yes; then
+ rm -rf conftest.f conftest.f1
+ if touch conftest.f && ln conftest.f conftest.f1 &&
+ set x `ls -i conftest.f conftest.f1` && test "$2" = "$4"; then
+ AC_RUN_IFELSE(
+ [AC_LANG_PROGRAM([[
+# include <stdio.h>
+# include <stdlib.h>
+# include <unistd.h>
+ ]],
+ [[int result = 0;
+ if (rename ("conftest.f", "conftest.f1"))
+ result |= 1;
+ if (unlink ("conftest.f1"))
+ result |= 2;
+ if (rename ("conftest.f", "conftest.f"))
+ result |= 4;
+ if (rename ("conftest.f1", "conftest.f1") == 0)
+ result |= 8;
+ return result;
+ ]])],
+ [gl_cv_func_rename_link_works=yes],
+ [gl_cv_func_rename_link_works=no],
+ dnl When crosscompiling, assume rename is broken.
+ [case "$host_os" in
+ # Guess yes on glibc systems.
+ *-gnu*) gl_cv_func_rename_link_works="guessing yes" ;;
+ # If we don't know, assume the worst.
+ *) gl_cv_func_rename_link_works="guessing no" ;;
+ esac
+ ])
+ else
+ gl_cv_func_rename_link_works="guessing no"
+ fi
+ rm -rf conftest.f conftest.f1
+ else
+ gl_cv_func_rename_link_works=yes
+ fi
+ ])
+ case "$gl_cv_func_rename_link_works" in
+ *yes) ;;
+ *)
+ REPLACE_RENAME=1
+ AC_DEFINE([RENAME_HARD_LINK_BUG], [1],
+ [Define if rename fails to leave hard links alone, as on NetBSD 1.6
+ or Cygwin 1.5.])
+ ;;
+ esac