Debian Codegraph @

m4/rmdir.m4

raw
1 # rmdir.m4
2 # serial 19
3 dnl Copyright (C) 2002, 2005, 2009-2024 Free Software Foundation, Inc.
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
7 dnl This file is offered as-is, without any warranty.
8
9 AC_DEFUN([gl_FUNC_RMDIR],
10 [
11 AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
12 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
13 dnl Detect cygwin 1.5.x bug.
14 AC_CHECK_HEADERS_ONCE([unistd.h])
15 AC_CACHE_CHECK([whether rmdir works], [gl_cv_func_rmdir_works],
16 [mkdir conftest.dir
17 touch conftest.file
18 AC_RUN_IFELSE(
19 [AC_LANG_PROGRAM(
20 [[#include <stdio.h>
21 #include <errno.h>
22 #if HAVE_UNISTD_H
23 # include <unistd.h>
24 #else /* on Windows with MSVC */
25 # include <direct.h>
26 #endif
27 ]GL_MDA_DEFINES],
28 [[int result = 0;
29 if (!rmdir ("conftest.file/"))
30 result |= 1;
31 else if (errno != ENOTDIR)
32 result |= 2;
33 if (!rmdir ("conftest.dir/./"))
34 result |= 4;
35 return result;
36 ]])],
37 [gl_cv_func_rmdir_works=yes], [gl_cv_func_rmdir_works=no],
38 [case "$host_os" in
39 # Guess yes on Linux systems.
40 linux-* | linux) gl_cv_func_rmdir_works="guessing yes" ;;
41 # Guess yes on systems that emulate the Linux system calls.
42 midipix*) gl_cv_func_rmdir_works="guessing yes" ;;
43 # Guess yes on glibc systems.
44 *-gnu* | gnu*) gl_cv_func_rmdir_works="guessing yes" ;;
45 # Guess no on native Windows.
46 mingw* | windows*) gl_cv_func_rmdir_works="guessing no" ;;
47 # If we don't know, obey --enable-cross-guesses.
48 *) gl_cv_func_rmdir_works="$gl_cross_guess_normal" ;;
49 esac
50 ])
51 rm -rf conftest.dir conftest.file])
52 case "$gl_cv_func_rmdir_works" in
53 *yes) ;;
54 *)
55 REPLACE_RMDIR=1
56 ;;
57 esac
58 ])