check for SunOS4.1.1U bug in rename
[pspp] / m4 / rename.m4
1 #serial 1
2
3 dnl From Volker Borchert.
4 dnl Determine whether rename works for source paths with a trailing slash.
5 dnl The rename from SunOS 4.1.1_U1 doesn't.
6 dnl
7 dnl If it doesn't, then define RENAME_TRAILING_SLASH_BUG and arrange
8 dnl to compile the wrapper function.
9 dnl
10
11 AC_DEFUN(vb_FUNC_RENAME,
12 [
13  AC_CACHE_CHECK([whether rename is broken],
14   vb_cv_func_rename_trailing_slash_bug,
15   [AC_TRY_RUN([
16 #   include <stdio.h>
17
18     int
19     main ()
20     {
21       if (mkdir ("foo") < 0)
22         exit (1);
23       if (rename ("foo/", "bar") < 0)
24         { rmdir ("foo"); exit (1); }
25       else
26         { rmdir ("bar"); exit (0); }
27     }
28           ],
29          vb_cv_func_rename_trailing_slash_bug=no,
30          vb_cv_func_rename_trailing_slash_bug=yes,
31          dnl When crosscompiling, assume rename is broken.
32          vb_cv_func_rename_trailing_slash_bug=yes)
33   ])
34   if test $vb_cv_func_rename_trailing_slash_bug = yes; then
35     AC_LIBOBJ(rename)
36     AC_DEFINE_UNQUOTED(RENAME_TRAILING_SLASH_BUG, 1,
37 [Define if rename does not work for source paths with a trailing slash,
38    like the one from SunOS 4.1.1_U1. ])
39   fi
40 ])