Tizen 2.0 Release
[external/tizen-coreutils.git] / m4 / rename-dest-slash.m4
1 #serial 2
2
3 # Copyright (C) 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 # Derived from rename.m4.
9
10 # A rename wrapper to make tools like mv -- that would normally
11 # rely on the underlying rename syscall -- work more consistently.
12
13 AC_DEFUN([gl_FUNC_RENAME_TRAILING_DEST_SLASH],
14 [
15  AC_CACHE_CHECK([whether rename is broken with respect to destination slashes],
16   gl_cv_func_rename_trailing_dest_slash_bug,
17   [
18     rm -rf conftest.d1 conftest.d2
19     mkdir conftest.d1 ||
20       AC_MSG_ERROR([cannot create temporary directory])
21     AC_TRY_RUN([
22 #       include <stdio.h>
23         int
24         main ()
25         {
26           return (rename ("conftest.d1", "conftest.d2/") ? 1 : 0);
27         }
28       ],
29       gl_cv_func_rename_trailing_dest_slash_bug=no,
30       gl_cv_func_rename_trailing_dest_slash_bug=yes,
31       dnl When crosscompiling, assume rename is broken.
32       gl_cv_func_rename_trailing_dest_slash_bug=yes)
33
34       rm -rf conftest.d1 conftest.d2
35   ])
36   if test $gl_cv_func_rename_trailing_dest_slash_bug = yes; then
37     AC_LIBOBJ(rename-dest-slash)
38     AC_DEFINE(rename, rpl_rename_dest_slash,
39       [Define to rpl_rename_dest_slash if the replacement function should be used.])
40   fi
41 ])