634a33fc6f7670aabca1922a364e589ec2217ed9
[gnulib.git] / m4 / sys_stat_h.m4
1 # sys_stat_h.m4 serial 12   -*- Autoconf -*-
2 dnl Copyright (C) 2006-2009 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
6
7 dnl From Eric Blake.
8 dnl Test whether <sys/stat.h> contains lstat and mkdir or must be substituted.
9
10 AC_DEFUN([gl_HEADER_SYS_STAT_H],
11 [
12   AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS])
13
14   dnl Check for lstat.  Systems that lack it (mingw) also lack symlinks, so
15   dnl stat is a good replacement.
16   AC_CHECK_FUNCS_ONCE([lstat])
17   if test $ac_cv_func_lstat = yes; then
18     HAVE_LSTAT=1
19   else
20     HAVE_LSTAT=0
21   fi
22   AC_SUBST([HAVE_LSTAT])
23
24   dnl For the mkdir substitute.
25   AC_REQUIRE([AC_C_INLINE])
26
27   dnl Check for broken stat macros.
28   AC_REQUIRE([AC_HEADER_STAT])
29
30   gl_CHECK_NEXT_HEADERS([sys/stat.h])
31
32   dnl Define types that are supposed to be defined in <sys/types.h> or
33   dnl <sys/stat.h>.
34   AC_CHECK_TYPE([nlink_t], [],
35     [AC_DEFINE([nlink_t], [int],
36        [Define to the type of st_nlink in struct stat, or a supertype.])],
37     [#include <sys/types.h>
38      #include <sys/stat.h>])
39
40 ]) # gl_HEADER_SYS_STAT_H
41
42 AC_DEFUN([gl_SYS_STAT_MODULE_INDICATOR],
43 [
44   dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
45   AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS])
46   GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1
47 ])
48
49 AC_DEFUN([gl_SYS_STAT_H_DEFAULTS],
50 [
51   AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) dnl for REPLACE_FCHDIR
52   AC_REQUIRE([gl_OPENAT_DEFAULTS]) dnl for GNULIB_OPENAT
53   GNULIB_LCHMOD=0; AC_SUBST([GNULIB_LCHMOD])
54   GNULIB_LSTAT=0;  AC_SUBST([GNULIB_LSTAT])
55   dnl Assume proper GNU behavior unless another module says otherwise.
56   HAVE_LCHMOD=1;   AC_SUBST([HAVE_LCHMOD])
57   REPLACE_LSTAT=0; AC_SUBST([REPLACE_LSTAT])
58   REPLACE_MKDIR=0; AC_SUBST([REPLACE_MKDIR])
59 ])