]> git.cworth.org Git - tar/blob - m4/mkfifo.m4
Imported Upstream version 1.24
[tar] / m4 / mkfifo.m4
1 # serial 1
2 # See if we need to provide mkfifo replacement.
3
4 dnl Copyright (C) 2009, 2010 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_CHECK_FUNCS_ONCE([mkfifo])
15   if test $ac_cv_func_mkfifo = no; then
16     HAVE_MKFIFO=0
17     AC_LIBOBJ([mkfifo])
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 ]], [[if (!mkfifo ("conftest.tmp/", 0600)) return 1;
31 #if HAVE_LSTAT
32       if (!mkfifo ("conftest.lnk/", 0600)) return 2;
33 #endif
34            ]])],
35          [gl_cv_func_mkfifo_works=yes], [gl_cv_func_mkfifo_works=no],
36          [gl_cv_func_mkfifo_works="guessing no"])
37        rm -f conftest.tmp conftest.lnk])
38     if test "$gl_cv_func_mkfifo_works" != yes; then
39       AC_DEFINE([MKFIFO_TRAILING_SLASH_BUG], [1], [Define to 1 if mkfifo
40         does not reject trailing slash])
41       REPLACE_MKFIFO=1
42       AC_LIBOBJ([mkfifo])
43     fi
44   fi
45 ])