Tizen 2.0 Release
[external/tizen-coreutils.git] / m4 / rename.m4
1 #serial 10
2
3 # Copyright (C) 2001, 2003, 2005, 2006 Free Software Foundation, Inc.
4 # This file is free software; the Free Software Foundation
5 # gives unlimited permission to copy and/or distribute it,
6 # with or without modifications, as long as this notice is preserved.
7
8 dnl From Volker Borchert.
9 dnl Determine whether rename works for source file names with a trailing slash.
10 dnl The rename from SunOS 4.1.1_U1 doesn't.
11 dnl
12 dnl If it doesn't, then define RENAME_TRAILING_SLASH_BUG and arrange
13 dnl to compile the wrapper function.
14 dnl
15
16 AC_DEFUN([gl_FUNC_RENAME],
17 [
18  AC_CACHE_CHECK([whether rename is broken],
19   gl_cv_func_rename_trailing_slash_bug,
20   [
21     rm -rf conftest.d1 conftest.d2
22     mkdir conftest.d1 ||
23       AC_MSG_ERROR([cannot create temporary directory])
24     AC_TRY_RUN([
25 #       include <stdio.h>
26 #       include <stdlib.h>
27         int
28         main ()
29         {
30           exit (rename ("conftest.d1/", "conftest.d2") ? 1 : 0);
31         }
32       ],
33       gl_cv_func_rename_trailing_slash_bug=no,
34       gl_cv_func_rename_trailing_slash_bug=yes,
35       dnl When crosscompiling, assume rename is broken.
36       gl_cv_func_rename_trailing_slash_bug=yes)
37
38       rm -rf conftest.d1 conftest.d2
39   ])
40   if test $gl_cv_func_rename_trailing_slash_bug = yes; then
41     AC_LIBOBJ(rename)
42     AC_DEFINE(rename, rpl_rename,
43       [Define to rpl_rename if the replacement function should be used.])
44     AC_DEFINE(RENAME_TRAILING_SLASH_BUG, 1,
45       [Define if rename does not work for source file names with a trailing
46        slash, like the one from SunOS 4.1.1_U1.])
47     gl_PREREQ_RENAME
48   fi
49 ])
50
51 # Prerequisites of lib/rename.c.
52 AC_DEFUN([gl_PREREQ_RENAME], [:])