Home | History | Annotate | Download | only in m4
      1 # serial 13
      2 
      3 # Copyright (C) 2001, 2003, 2005, 2006, 2009 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_REQUIRE([AC_CANONICAL_HOST])
     19  AC_CACHE_CHECK([whether rename is broken with a trailing slash],
     20   gl_cv_func_rename_trailing_slash_bug,
     21   [
     22     rm -rf conftest.d1 conftest.d2
     23     mkdir conftest.d1 ||
     24       AC_MSG_ERROR([cannot create temporary directory])
     25     AC_TRY_RUN([
     26 #       include <stdio.h>
     27 #       include <stdlib.h>
     28         int
     29         main ()
     30         {
     31           exit (rename ("conftest.d1/", "conftest.d2") ? 1 : 0);
     32         }
     33       ],
     34       gl_cv_func_rename_trailing_slash_bug=no,
     35       gl_cv_func_rename_trailing_slash_bug=yes,
     36       dnl When crosscompiling, assume rename is broken.
     37       gl_cv_func_rename_trailing_slash_bug=yes)
     38 
     39       rm -rf conftest.d1 conftest.d2
     40   ])
     41  AC_CACHE_CHECK([whether rename is broken when the destination exists],
     42   gl_cv_func_rename_dest_exists_bug,
     43   [
     44     case "$host_os" in
     45       mingw*) gl_cv_func_rename_dest_exists_bug=yes ;;
     46       *) gl_cv_func_rename_dest_exists_bug=no ;;
     47     esac
     48   ])
     49   if test $gl_cv_func_rename_trailing_slash_bug = yes ||
     50      test $gl_cv_func_rename_dest_exists_bug = yes; then
     51     AC_LIBOBJ([rename])
     52     AC_DEFINE([rename], [rpl_rename],
     53       [Define to rpl_rename if the replacement function should be used.])
     54     if test $gl_cv_func_rename_trailing_slash_bug = yes; then
     55       AC_DEFINE([RENAME_TRAILING_SLASH_BUG], [1],
     56 	[Define if rename does not work for source file names with a trailing
     57 	 slash, like the one from SunOS 4.1.1_U1.])
     58     fi
     59     if test $gl_cv_func_rename_dest_exists_bug = yes; then
     60       AC_DEFINE([RENAME_DEST_EXISTS_BUG], [1],
     61 	[Define if rename does not work when the destination file exists,
     62 	 as on Windows.])
     63     fi
     64     gl_PREREQ_RENAME
     65   fi
     66 ])
     67 
     68 # Prerequisites of lib/rename.c.
     69 AC_DEFUN([gl_PREREQ_RENAME], [:])
     70