hasmntopt: Add tests.
[gnulib.git] / m4 / rmdir.m4
blob8ac675f8686c6b20877c693ead6a5e6c157f05b0
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.
8 AC_DEFUN([gl_FUNC_RMDIR],
10   AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
11   AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
12   dnl Detect cygwin 1.5.x bug.
13   AC_CHECK_HEADERS_ONCE([unistd.h])
14   AC_CACHE_CHECK([whether rmdir works], [gl_cv_func_rmdir_works],
15     [mkdir conftest.dir
16      touch conftest.file
17      AC_RUN_IFELSE(
18        [AC_LANG_PROGRAM(
19          [[#include <stdio.h>
20            #include <errno.h>
21            #if HAVE_UNISTD_H
22            # include <unistd.h>
23            #else /* on Windows with MSVC */
24            # include <direct.h>
25            #endif
26          ]GL_MDA_DEFINES],
27          [[int result = 0;
28            if (!rmdir ("conftest.file/"))
29              result |= 1;
30            else if (errno != ENOTDIR)
31              result |= 2;
32            if (!rmdir ("conftest.dir/./"))
33              result |= 4;
34            return result;
35          ]])],
36        [gl_cv_func_rmdir_works=yes], [gl_cv_func_rmdir_works=no],
37        [case "$host_os" in
38                              # Guess yes on Linux systems.
39           linux-* | linux)   gl_cv_func_rmdir_works="guessing yes" ;;
40                              # Guess yes on systems that emulate the Linux system calls.
41           midipix*)          gl_cv_func_rmdir_works="guessing yes" ;;
42                              # Guess yes on glibc systems.
43           *-gnu* | gnu*)     gl_cv_func_rmdir_works="guessing yes" ;;
44                              # Guess no on native Windows.
45           mingw* | windows*) gl_cv_func_rmdir_works="guessing no" ;;
46                              # If we don't know, obey --enable-cross-guesses.
47           *)                 gl_cv_func_rmdir_works="$gl_cross_guess_normal" ;;
48         esac
49        ])
50      rm -rf conftest.dir conftest.file])
51   case "$gl_cv_func_rmdir_works" in
52     *yes) ;;
53     *)
54       REPLACE_RMDIR=1
55       ;;
56   esac