* ChangeLog: Fix misspelling
[gnulib.git] / m4 / mkfifoat.m4
blob763f8700066b949597ed020d7ddc4fb205a956bd
1 # mkfifoat.m4
2 # serial 11
3 dnl Copyright (C) 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 # See if we need to provide mkfifoat/mknodat replacement.
10 # Written by Eric Blake.
12 AC_DEFUN([gl_FUNC_MKFIFOAT],
14   AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS])
15   AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
17   dnl Persuade glibc <sys/stat.h> to declare mkfifoat() and mknodat().
18   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
20   AC_REQUIRE([gl_FUNC_OPENAT])
22   gl_CHECK_FUNCS_ANDROID_MACOS([mknodat], [[#include <sys/stat.h>]])
23   gl_CHECK_FUNCS_ANDROID_MACOS([mkfifoat], [[#include <sys/stat.h>]])
24   if test $ac_cv_func_mkfifoat = yes; then
25     dnl Check for AIX 7.2 bug and macOS 14 bugs with trailing slash.
26     AC_CACHE_CHECK([whether mkfifoat rejects trailing slashes],
27       [gl_cv_func_mkfifoat_works],
28       [rm -f conftest.tmp
29        AC_RUN_IFELSE(
30          [AC_LANG_PROGRAM(
31             [[#include <fcntl.h>
32               #include <sys/stat.h>
33               #include <unistd.h>
34             ]],
35             [[int result = 0;
36               /* This test fails on AIX 7.2.  */
37               if (!mkfifoat (AT_FDCWD, "conftest.tmp/", 0600))
38                 result |= 1;
39               /* This test fails on macOS 14.  */
40               if (!symlink ("conftest.fifo", "conftest.tmp")
41                   && !mkfifoat (AT_FDCWD, "conftest.tmp/", 0600))
42                 result |= 2;
43               return result;
44             ]])
45          ],
46          [gl_cv_func_mkfifoat_works=yes],
47          [gl_cv_func_mkfifoat_works=no],
48          [case "$host_os" in
49                              # Guess yes on Linux systems.
50             linux-* | linux) gl_cv_func_mkfifoat_works="guessing yes" ;;
51                              # Guess yes on glibc systems.
52             *-gnu* | gnu*)   gl_cv_func_mkfifoat_works="guessing yes" ;;
53                              # Guess no on macOS systems.
54             darwin*)         gl_cv_func_mkfifoat_works="guessing no" ;;
55                              # Guess no on AIX systems.
56             aix*)            gl_cv_func_mkfifoat_works="guessing no" ;;
57                              # If we don't know, obey --enable-cross-guesses.
58             *)               gl_cv_func_mkfifoat_works="$gl_cross_guess_normal" ;;
59           esac
60          ])
61        rm -f conftest.tmp
62       ])
63     case "$gl_cv_func_mkfifoat_works" in
64       *yes) ;;
65       *)
66         REPLACE_MKFIFOAT=1
67         dnl mknodat() has the same bug as mkfifoat().
68         REPLACE_MKNODAT=1
69         ;;
70     esac
71   else
72     # No known system has mkfifoat but not mknodat
73     HAVE_MKFIFOAT=0
74     case "$gl_cv_onwards_func_mkfifoat" in
75       future*) REPLACE_MKFIFOAT=1 ;;
76     esac
77     HAVE_MKNODAT=0
78     case "$gl_cv_onwards_func_mknodat" in
79       future*) REPLACE_MKNODAT=1 ;;
80     esac
81   fi