Blame gettext-tools/gnulib-m4/rmdir.m4

Packit Bot 06c835
# rmdir.m4 serial 13
Packit Bot 06c835
dnl Copyright (C) 2002, 2005, 2009-2015 Free Software Foundation, Inc.
Packit Bot 06c835
dnl This file is free software; the Free Software Foundation
Packit Bot 06c835
dnl gives unlimited permission to copy and/or distribute it,
Packit Bot 06c835
dnl with or without modifications, as long as this notice is preserved.
Packit Bot 06c835
Packit Bot 06c835
AC_DEFUN([gl_FUNC_RMDIR],
Packit Bot 06c835
[
Packit Bot 06c835
  AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
Packit Bot 06c835
  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
Packit Bot 06c835
  dnl Detect cygwin 1.5.x bug.
Packit Bot 06c835
  AC_CHECK_HEADERS_ONCE([unistd.h])
Packit Bot 06c835
  AC_CACHE_CHECK([whether rmdir works], [gl_cv_func_rmdir_works],
Packit Bot 06c835
    [mkdir conftest.dir
Packit Bot 06c835
     touch conftest.file
Packit Bot 06c835
     AC_RUN_IFELSE(
Packit Bot 06c835
       [AC_LANG_PROGRAM(
Packit Bot 06c835
         [[#include <stdio.h>
Packit Bot 06c835
           #include <errno.h>
Packit Bot 06c835
           #if HAVE_UNISTD_H
Packit Bot 06c835
           # include <unistd.h>
Packit Bot 06c835
           #else /* on Windows with MSVC */
Packit Bot 06c835
           # include <direct.h>
Packit Bot 06c835
           #endif
Packit Bot 06c835
]], [[int result = 0;
Packit Bot 06c835
      if (!rmdir ("conftest.file/"))
Packit Bot 06c835
        result |= 1;
Packit Bot 06c835
      else if (errno != ENOTDIR)
Packit Bot 06c835
        result |= 2;
Packit Bot 06c835
      if (!rmdir ("conftest.dir/./"))
Packit Bot 06c835
        result |= 4;
Packit Bot 06c835
      return result;
Packit Bot 06c835
    ]])],
Packit Bot 06c835
       [gl_cv_func_rmdir_works=yes], [gl_cv_func_rmdir_works=no],
Packit Bot 06c835
       [case "$host_os" in
Packit Bot 06c835
                  # Guess yes on glibc systems.
Packit Bot 06c835
          *-gnu*) gl_cv_func_rmdir_works="guessing yes" ;;
Packit Bot 06c835
                  # If we don't know, assume the worst.
Packit Bot 06c835
          *)      gl_cv_func_rmdir_works="guessing no" ;;
Packit Bot 06c835
        esac
Packit Bot 06c835
       ])
Packit Bot 06c835
     rm -rf conftest.dir conftest.file])
Packit Bot 06c835
  case "$gl_cv_func_rmdir_works" in
Packit Bot 06c835
    *yes) ;;
Packit Bot 06c835
    *)
Packit Bot 06c835
      REPLACE_RMDIR=1
Packit Bot 06c835
      ;;
Packit Bot 06c835
  esac
Packit Bot 06c835
])