rmdir.m4 1.9 KB

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