gnulib update
[bpt/guile.git] / m4 / stat.m4
CommitLineData
3d458a81 1# serial 8
8912421c 2
49114fd4 3# Copyright (C) 2009-2011 Free Software Foundation, Inc.
8912421c
LC
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
8912421c 12 AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS])
f29ded4b 13 AC_CHECK_FUNCS_ONCE([lstat])
8912421c
LC
14 dnl mingw is the only known platform where stat(".") and stat("./") differ
15 AC_CACHE_CHECK([whether stat handles trailing slashes on directories],
16 [gl_cv_func_stat_dir_slash],
17 [AC_RUN_IFELSE(
18 [AC_LANG_PROGRAM(
19 [[#include <sys/stat.h>
20]], [[struct stat st; return stat (".", &st) != stat ("./", &st);]])],
21 [gl_cv_func_stat_dir_slash=yes], [gl_cv_func_stat_dir_slash=no],
22 [case $host_os in
23 mingw*) gl_cv_func_stat_dir_slash="guessing no";;
24 *) gl_cv_func_stat_dir_slash="guessing yes";;
25 esac])])
9157d901 26 dnl AIX 7.1, Solaris 9 mistakenly succeed on stat("file/")
f29ded4b 27 dnl FreeBSD 7.2 mistakenly succeeds on stat("link-to-file/")
8912421c
LC
28 AC_CACHE_CHECK([whether stat handles trailing slashes on files],
29 [gl_cv_func_stat_file_slash],
30 [touch conftest.tmp
f29ded4b
LC
31 # Assume that if we have lstat, we can also check symlinks.
32 if test $ac_cv_func_lstat = yes; then
33 ln -s conftest.tmp conftest.lnk
34 fi
8912421c
LC
35 AC_RUN_IFELSE(
36 [AC_LANG_PROGRAM(
37 [[#include <sys/stat.h>
0f00f2c3
LC
38]], [[int result = 0;
39 struct stat st;
40 if (!stat ("conftest.tmp/", &st))
41 result |= 1;
f29ded4b 42#if HAVE_LSTAT
0f00f2c3
LC
43 if (!stat ("conftest.lnk/", &st))
44 result |= 2;
f29ded4b 45#endif
0f00f2c3 46 return result;
f29ded4b 47 ]])],
8912421c 48 [gl_cv_func_stat_file_slash=yes], [gl_cv_func_stat_file_slash=no],
f29ded4b
LC
49 [gl_cv_func_stat_file_slash="guessing no"])
50 rm -f conftest.tmp conftest.lnk])
8912421c
LC
51 case $gl_cv_func_stat_dir_slash in
52 *no) REPLACE_STAT=1
53 AC_DEFINE([REPLACE_FUNC_STAT_DIR], [1], [Define to 1 if stat needs
54 help when passed a directory name with a trailing slash]);;
55 esac
56 case $gl_cv_func_stat_file_slash in
57 *no) REPLACE_STAT=1
58 AC_DEFINE([REPLACE_FUNC_STAT_FILE], [1], [Define to 1 if stat needs
59 help when passed a file name with a trailing slash]);;
60 esac
3d458a81
AW
61])
62
63# Prerequisites of lib/stat.c.
64AC_DEFUN([gl_PREREQ_STAT],
65[
66 AC_REQUIRE([AC_C_INLINE])
67 :
8912421c 68])