Debian Codegraph @

m4/mkfifo.m4

raw
1 # serial 9
2 # See if we need to provide mkfifo replacement.
3
4 dnl Copyright (C) 2009-2023 Free Software Foundation, Inc.
5 dnl This file is free software; the Free Software Foundation
6 dnl gives unlimited permission to copy and/or distribute it,
7 dnl with or without modifications, as long as this notice is preserved.
8
9 # Written by Eric Blake.
10
11 AC_DEFUN([gl_FUNC_MKFIFO],
12 [
13 AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS])
14 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
15
16 dnl We can't use AC_CHECK_FUNC here, because mkfifo() is defined as a
17 dnl static inline function when compiling for Android 4.4 or older.
18 AC_CACHE_CHECK([for mkfifo], [gl_cv_func_mkfifo],
19 [AC_LINK_IFELSE(
20 [AC_LANG_PROGRAM(
21 [[#include <sys/stat.h>]],
22 [[return mkfifo("/",0);]])
23 ],
24 [gl_cv_func_mkfifo=yes],
25 [gl_cv_func_mkfifo=no])
26 ])
27 if test $gl_cv_func_mkfifo = no; then
28 HAVE_MKFIFO=0
29 else
30 AC_DEFINE([HAVE_MKFIFO], [1],
31 [Define to 1 if you have a 'mkfifo' function.])
32 dnl Check for Solaris 9 and FreeBSD bug with trailing slash.
33 AC_CHECK_FUNCS_ONCE([lstat])
34 AC_CACHE_CHECK([whether mkfifo rejects trailing slashes],
35 [gl_cv_func_mkfifo_works],
36 [# Assume that if we have lstat, we can also check symlinks.
37 if test $ac_cv_func_lstat = yes; then
38 ln -s conftest.tmp conftest.lnk
39 fi
40 AC_RUN_IFELSE(
41 [AC_LANG_PROGRAM(
42 [[#include <sys/stat.h>
43 ]],
44 [[int result = 0;
45 if (!mkfifo ("conftest.tmp/", 0600))
46 result |= 1;
47 #if HAVE_LSTAT
48 if (!mkfifo ("conftest.lnk/", 0600))
49 result |= 2;
50 #endif
51 return result;
52 ]])],
53 [gl_cv_func_mkfifo_works=yes], [gl_cv_func_mkfifo_works=no],
54 [case "$host_os" in
55 # Guess yes on Linux systems.
56 linux-* | linux) gl_cv_func_mkfifo_works="guessing yes" ;;
57 # Guess yes on glibc systems.
58 *-gnu* | gnu*) gl_cv_func_mkfifo_works="guessing yes" ;;
59 # If we don't know, obey --enable-cross-guesses.
60 *) gl_cv_func_mkfifo_works="$gl_cross_guess_normal" ;;
61 esac
62 ])
63 rm -f conftest.tmp conftest.lnk])
64 case "$gl_cv_func_mkfifo_works" in
65 *yes) ;;
66 *)
67 AC_DEFINE([MKFIFO_TRAILING_SLASH_BUG], [1], [Define to 1 if mkfifo
68 does not reject trailing slash])
69 REPLACE_MKFIFO=1
70 ;;
71 esac
72 fi
73 ])