Import upstream version 1.26
[debian/tar] / m4 / rmdir.m4
1 # rmdir.m4 serial 10
2 dnl Copyright (C) 2002, 2005, 2009-2011 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
6
7 AC_DEFUN([gl_FUNC_RMDIR],
8 [
9   AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
10   dnl Detect cygwin 1.5.x bug.
11   AC_CACHE_CHECK([whether rmdir works], [gl_cv_func_rmdir_works],
12     [mkdir conftest.dir
13      touch conftest.file
14      AC_RUN_IFELSE(
15        [AC_LANG_PROGRAM(
16          [[#include <stdio.h>
17            #include <errno.h>
18            #include <unistd.h>
19 ]], [[int result = 0;
20       if (!rmdir ("conftest.file/"))
21         result |= 1;
22       else if (errno != ENOTDIR)
23         result |= 2;
24       if (!rmdir ("conftest.dir/./"))
25         result |= 4;
26       return result;
27     ]])],
28        [gl_cv_func_rmdir_works=yes], [gl_cv_func_rmdir_works=no],
29        [gl_cv_func_rmdir_works="guessing no"])
30      rm -rf conftest.dir conftest.file])
31   if test x"$gl_cv_func_rmdir_works" != xyes; then
32     REPLACE_RMDIR=1
33     AC_LIBOBJ([rmdir])
34   fi
35 ])