re-mark 1.29b-2 as not yet uploaded (merge madness!)
[debian/tar] / m4 / mkfifo.m4
1 # serial 4
2 # See if we need to provide mkfifo replacement.
3
4 dnl Copyright (C) 2009-2015 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   AC_CHECK_FUNCS_ONCE([mkfifo])
16   if test $ac_cv_func_mkfifo = no; then
17     HAVE_MKFIFO=0
18   else
19     dnl Check for Solaris 9 and FreeBSD bug with trailing slash.
20     AC_CHECK_FUNCS_ONCE([lstat])
21     AC_CACHE_CHECK([whether mkfifo rejects trailing slashes],
22       [gl_cv_func_mkfifo_works],
23       [# Assume that if we have lstat, we can also check symlinks.
24        if test $ac_cv_func_lstat = yes; then
25          ln -s conftest.tmp conftest.lnk
26        fi
27        AC_RUN_IFELSE(
28          [AC_LANG_PROGRAM(
29            [[#include <sys/stat.h>
30            ]],
31            [[int result = 0;
32              if (!mkfifo ("conftest.tmp/", 0600))
33                result |= 1;
34 #if HAVE_LSTAT
35              if (!mkfifo ("conftest.lnk/", 0600))
36                result |= 2;
37 #endif
38              return result;
39            ]])],
40          [gl_cv_func_mkfifo_works=yes], [gl_cv_func_mkfifo_works=no],
41          [case "$host_os" in
42                     # Guess yes on glibc systems.
43             *-gnu*) gl_cv_func_mkfifo_works="guessing yes" ;;
44                     # If we don't know, assume the worst.
45             *)      gl_cv_func_mkfifo_works="guessing no" ;;
46           esac
47          ])
48        rm -f conftest.tmp conftest.lnk])
49     case "$gl_cv_func_mkfifo_works" in
50       *yes) ;;
51       *)
52         AC_DEFINE([MKFIFO_TRAILING_SLASH_BUG], [1], [Define to 1 if mkfifo
53           does not reject trailing slash])
54         REPLACE_MKFIFO=1
55         ;;
56     esac
57   fi
58 ])