log2-ieee: Work around test failure on NetBSD 5.1 and Solaris 10.
[gnulib.git] / m4 / rename.m4
index 6648542..59cc5c7 100644 (file)
@@ -1,6 +1,6 @@
-# serial 23
+# serial 25
 
 
-# Copyright (C) 2001, 2003, 2005-2006, 2009-2011 Free Software Foundation, Inc.
+# Copyright (C) 2001, 2003, 2005-2006, 2009-2012 Free Software Foundation, Inc.
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -58,7 +58,6 @@ AC_DEFUN([gl_FUNC_RENAME],
     rm -rf conftest.f conftest.f1 conftest.f2 conftest.d1 conftest.d2 conftest.lnk
   ])
   if test "x$gl_cv_func_rename_slash_dst_works" != xyes; then
     rm -rf conftest.f conftest.f1 conftest.f2 conftest.d1 conftest.d2 conftest.lnk
   ])
   if test "x$gl_cv_func_rename_slash_dst_works" != xyes; then
-    AC_LIBOBJ([rename])
     REPLACE_RENAME=1
     AC_DEFINE([RENAME_TRAILING_SLASH_DEST_BUG], [1],
       [Define if rename does not correctly handle slashes on the destination
     REPLACE_RENAME=1
     AC_DEFINE([RENAME_TRAILING_SLASH_DEST_BUG], [1],
       [Define if rename does not correctly handle slashes on the destination
@@ -102,7 +101,6 @@ AC_DEFUN([gl_FUNC_RENAME],
     rm -rf conftest.f conftest.f1 conftest.d1 conftest.d2 conftest.d3 conftest.lnk
   ])
   if test "x$gl_cv_func_rename_slash_src_works" != xyes; then
     rm -rf conftest.f conftest.f1 conftest.d1 conftest.d2 conftest.d3 conftest.lnk
   ])
   if test "x$gl_cv_func_rename_slash_src_works" != xyes; then
-    AC_LIBOBJ([rename])
     REPLACE_RENAME=1
     AC_DEFINE([RENAME_TRAILING_SLASH_SOURCE_BUG], [1],
       [Define if rename does not correctly handle slashes on the source
     REPLACE_RENAME=1
     AC_DEFINE([RENAME_TRAILING_SLASH_SOURCE_BUG], [1],
       [Define if rename does not correctly handle slashes on the source
@@ -112,39 +110,43 @@ AC_DEFUN([gl_FUNC_RENAME],
   dnl NetBSD 1.6 and cygwin 1.5.x mistakenly reduce hard link count
   dnl on rename("h1","h2").
   dnl This bug requires stat'ting targets prior to attempting rename.
   dnl NetBSD 1.6 and cygwin 1.5.x mistakenly reduce hard link count
   dnl on rename("h1","h2").
   dnl This bug requires stat'ting targets prior to attempting rename.
+  AC_CHECK_FUNCS_ONCE([link])
   AC_CACHE_CHECK([whether rename manages hard links correctly],
     [gl_cv_func_rename_link_works],
   AC_CACHE_CHECK([whether rename manages hard links correctly],
     [gl_cv_func_rename_link_works],
-    [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.
-        [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 $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.
+           [gl_cv_func_rename_link_works="guessing no"])
+       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
+    ])
   if test "x$gl_cv_func_rename_link_works" != xyes; then
   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
     REPLACE_RENAME=1
     AC_DEFINE([RENAME_HARD_LINK_BUG], [1],
       [Define if rename fails to leave hard links alone, as on NetBSD 1.6
@@ -179,7 +181,6 @@ AC_DEFUN([gl_FUNC_RENAME],
     rm -rf conftest.f conftest.d1 conftest.d2
   ])
   if test "x$gl_cv_func_rename_dest_works" != xyes; then
     rm -rf conftest.f conftest.d1 conftest.d2
   ])
   if test "x$gl_cv_func_rename_dest_works" != xyes; then
-    AC_LIBOBJ([rename])
     REPLACE_RENAME=1
     AC_DEFINE([RENAME_DEST_EXISTS_BUG], [1],
       [Define if rename does not work when the destination file exists,
     REPLACE_RENAME=1
     AC_DEFINE([RENAME_DEST_EXISTS_BUG], [1],
       [Define if rename does not work when the destination file exists,