2 # m4-rename.m4 -- Test the abilities of rename.
3 # Written by Eric Blake <ebb9@byu.net>
5 # Copyright (C) 2008, 2010, 2013-2014, 2017 Free Software Foundation,
8 # This file is part of GNU M4.
10 # GNU M4 is free software: you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation, either version 3 of the License, or
13 # (at your option) any later version.
15 # GNU M4 is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with this program. If not, see <http://www.gnu.org/licenses/>.
27 # Detect platforms like mingw where rename can't move open files.
29 [AC_CACHE_CHECK([whether an open file can be renamed],
30 [M4_cv_func_rename_open_file_works],
31 [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
32 [FILE *f = fopen ("conftest.1", "w+");
33 int result = rename ("conftest.1", "conftest.2");
34 fclose (f); remove ("conftest.1"); remove ("conftest.2");
36 [M4_cv_func_rename_open_file_works=yes],
37 [M4_cv_func_rename_open_file_works=no],
38 [M4_cv_func_rename_open_file_works='guessing no'])])
39 if test "$M4_cv_func_rename_open_file_works" = yes ; then
40 M4_rename_open_works=1
42 M4_rename_open_works=0
44 AC_DEFINE_UNQUOTED([RENAME_OPEN_FILE_WORKS], [$M4_rename_open_works],
45 [Define to 1 if a file can be renamed while open, or to 0 if not.])