mkfifo: Respect rules for use of AC_LIBOBJ.
[gnulib.git] / m4 / mkfifo.m4
1 # serial 3
2 # See if we need to provide mkfifo replacement.
3
4 dnl Copyright (C) 2009-2011 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   else
18     dnl Check for Solaris 9 and FreeBSD bug with trailing slash.
19     AC_CHECK_FUNCS_ONCE([lstat])
20     AC_CACHE_CHECK([whether mkfifo rejects trailing slashes],
21       [gl_cv_func_mkfifo_works],
22       [# Assume that if we have lstat, we can also check symlinks.
23        if test $ac_cv_func_lstat = yes; then
24          ln -s conftest.tmp conftest.lnk
25        fi
26        AC_RUN_IFELSE(
27          [AC_LANG_PROGRAM(
28            [[#include <sys/stat.h>
29            ]],
30            [[int result = 0;
31              if (!mkfifo ("conftest.tmp/", 0600))
32                result |= 1;
33 #if HAVE_LSTAT
34              if (!mkfifo ("conftest.lnk/", 0600))
35                result |= 2;
36 #endif
37              return result;
38            ]])],
39          [gl_cv_func_mkfifo_works=yes], [gl_cv_func_mkfifo_works=no],
40          [gl_cv_func_mkfifo_works="guessing no"])
41        rm -f conftest.tmp conftest.lnk])
42     if test "$gl_cv_func_mkfifo_works" != yes; then
43       AC_DEFINE([MKFIFO_TRAILING_SLASH_BUG], [1], [Define to 1 if mkfifo
44         does not reject trailing slash])
45       REPLACE_MKFIFO=1
46     fi
47   fi
48 ])