summaryrefslogtreecommitdiffstats
path: root/gl/m4/stat.m4
diff options
context:
space:
mode:
authorThomas Guyot-Sionnest <dermoth@aei.ca>2010-04-08 01:11:46 (GMT)
committerThomas Guyot-Sionnest <dermoth@aei.ca>2010-04-13 01:26:35 (GMT)
commit74da141e618ef99959d509cb2e7be35a348a39db (patch)
tree88ebc38b381a1021fc2d74864a71e230ae591c3d /gl/m4/stat.m4
parentc63a4f726a0b6ad8cf6040f947754a81fd4683bb (diff)
downloadmonitoring-plugins-74da141e618ef99959d509cb2e7be35a348a39db.tar.gz
Sync with the latest Gnulib code (177f525)
Signed-off-by: Thomas Guyot-Sionnest <dermoth@aei.ca>
Diffstat (limited to 'gl/m4/stat.m4')
-rw-r--r--gl/m4/stat.m463
1 files changed, 63 insertions, 0 deletions
diff --git a/gl/m4/stat.m4 b/gl/m4/stat.m4
new file mode 100644
index 0000000..acd32d8
--- /dev/null
+++ b/gl/m4/stat.m4
@@ -0,0 +1,63 @@
1# serial 4
2
3# Copyright (C) 2009, 2010 Free Software Foundation, Inc.
4#
5# This file is free software; the Free Software Foundation
6# gives unlimited permission to copy and/or distribute it,
7# with or without modifications, as long as this notice is preserved.
8
9AC_DEFUN([gl_FUNC_STAT],
10[
11 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
12 AC_REQUIRE([gl_AC_DOS])
13 AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS])
14 AC_CHECK_FUNCS_ONCE([lstat])
15 dnl mingw is the only known platform where stat(".") and stat("./") differ
16 AC_CACHE_CHECK([whether stat handles trailing slashes on directories],
17 [gl_cv_func_stat_dir_slash],
18 [AC_RUN_IFELSE(
19 [AC_LANG_PROGRAM(
20 [[#include <sys/stat.h>
21]], [[struct stat st; return stat (".", &st) != stat ("./", &st);]])],
22 [gl_cv_func_stat_dir_slash=yes], [gl_cv_func_stat_dir_slash=no],
23 [case $host_os in
24 mingw*) gl_cv_func_stat_dir_slash="guessing no";;
25 *) gl_cv_func_stat_dir_slash="guessing yes";;
26 esac])])
27 dnl Solaris 9 mistakenly succeeds on stat("file/")
28 dnl FreeBSD 7.2 mistakenly succeeds on stat("link-to-file/")
29 AC_CACHE_CHECK([whether stat handles trailing slashes on files],
30 [gl_cv_func_stat_file_slash],
31 [touch conftest.tmp
32 # Assume that if we have lstat, we can also check symlinks.
33 if test $ac_cv_func_lstat = yes; then
34 ln -s conftest.tmp conftest.lnk
35 fi
36 AC_RUN_IFELSE(
37 [AC_LANG_PROGRAM(
38 [[#include <sys/stat.h>
39]], [[struct stat st;
40 if (!stat ("conftest.tmp/", &st)) return 1;
41#if HAVE_LSTAT
42 if (!stat ("conftest.lnk/", &st)) return 2;
43#endif
44 ]])],
45 [gl_cv_func_stat_file_slash=yes], [gl_cv_func_stat_file_slash=no],
46 [gl_cv_func_stat_file_slash="guessing no"])
47 rm -f conftest.tmp conftest.lnk])
48 case $gl_cv_func_stat_dir_slash in
49 *no) REPLACE_STAT=1
50 AC_DEFINE([REPLACE_FUNC_STAT_DIR], [1], [Define to 1 if stat needs
51 help when passed a directory name with a trailing slash]);;
52 esac
53 case $gl_cv_func_stat_file_slash in
54 *no) REPLACE_STAT=1
55 AC_DEFINE([REPLACE_FUNC_STAT_FILE], [1], [Define to 1 if stat needs
56 help when passed a file name with a trailing slash]);;
57 esac
58 if test $REPLACE_STAT = 1; then
59 AC_LIBOBJ([stat])
60 dnl Prerequisites of lib/stat.c.
61 AC_REQUIRE([AC_C_INLINE])
62 fi
63])