Add script for determining the set of symbols to export from a library.
[gnulib.git] / m4 / rmdir-errno.m4
blobd1ab74f1dc6bd5e5919858856cf0e9658299f509
1 # serial 13
3 # Copyright (C) 2000-2001, 2005-2006, 2009-2019 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.
8 # When rmdir fails because the specified directory is not empty, it sets
9 # errno to some value, usually ENOTEMPTY.  However, on some AIX systems,
10 # ENOTEMPTY is mistakenly defined to be EEXIST.  To work around this, and
11 # in general, to avoid depending on the use of any particular symbol, this
12 # test runs a test to determine the actual numeric value.
13 AC_DEFUN([gl_FUNC_RMDIR_NOTEMPTY],
14 [dnl
15   AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
16   AC_CHECK_HEADERS_ONCE([unistd.h])
17   AC_CACHE_CHECK([for rmdir-not-empty errno value],
18     [gl_cv_func_rmdir_errno_not_empty],
19     [
20       # Arrange for deletion of the temporary directory this test creates.
21       ac_clean_files="$ac_clean_files confdir2"
22       mkdir confdir2; : > confdir2/file
23       AC_RUN_IFELSE([AC_LANG_SOURCE([[
24 #include <stdio.h>
25 #include <errno.h>
26 #ifdef HAVE_UNISTD_H
27 # include <unistd.h>
28 #endif
29         int main ()
30         {
31           FILE *s;
32           int val;
33           rmdir ("confdir2");
34           val = errno;
35           s = fopen ("confdir2/errno", "w");
36           fprintf (s, "%d\n", val);
37           fclose (s);
38           return 0;
39         }
40         ]])],
41         [gl_cv_func_rmdir_errno_not_empty=`cat confdir2/errno`],
42         [gl_cv_func_rmdir_errno_not_empty='configure error in rmdir-errno.m4'],
43         [case "$host_os" in
44                    # Guess ENOTEMPTY = 41 on native Windows.
45            mingw*) gl_cv_func_rmdir_errno_not_empty=ENOTEMPTY ;;
46            *)      gl_cv_func_rmdir_errno_not_empty=ENOTEMPTY ;;
47          esac
48         ])
49     ]
50   )
52   AC_DEFINE_UNQUOTED([RMDIR_ERRNO_NOT_EMPTY],
53     [$gl_cv_func_rmdir_errno_not_empty],
54     [the value to which errno is set when rmdir fails on a nonempty directory])