immutable: Add tests.
[gnulib.git] / m4 / unlink-busy.m4
blobf45d173c1ae1c9e8a0d33057d2e2287c1886b70c
1 #serial 15
3 dnl From J. David Anglin.
5 dnl HPUX and other systems can't unlink shared text that is being executed.
7 # Copyright (C) 2000-2001, 2004, 2007, 2009-2021 Free Software Foundation, Inc.
8 # This file is free software; the Free Software Foundation
9 # gives unlimited permission to copy and/or distribute it,
10 # with or without modifications, as long as this notice is preserved.
12 AC_DEFUN([gl_FUNC_UNLINK_BUSY_TEXT],
13 [dnl
14   AC_CACHE_CHECK([whether a running program can be unlinked],
15     [gl_cv_func_unlink_busy_text],
16     [
17       AC_RUN_IFELSE(
18         [AC_LANG_SOURCE(
19            [AC_INCLUDES_DEFAULT
20             GL_MDA_DEFINES[
21             int
22             main (int argc, char **argv)
23             {
24               int result = 0;
25               if (argc == 0)
26                 result |= 1;
27               else if (unlink (argv[0]) != 0)
28                 result |= 2;
29               return result;
30             }]])],
31         [gl_cv_func_unlink_busy_text=yes],
32         [gl_cv_func_unlink_busy_text=no],
33         [case "$host_os" in
34                    # Guess no on native Windows.
35            mingw*) gl_cv_func_unlink_busy_text="guessing no" ;;
36            *)      gl_cv_func_unlink_busy_text="guessing no" ;;
37          esac
38         ]
39       )
40     ]
41   )
43   case "$gl_cv_func_unlink_busy_text" in
44     *no) INSTALL=$ac_install_sh ;;
45   esac