Add files from 'copysign' and 'isfinite' Gnulib modules.
[bpt/guile.git] / m4 / stat.m4
CommitLineData
af07e104 1# serial 11
8912421c 2
af07e104 3# Copyright (C) 2009-2013 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])])
005de2e8
LC
26 dnl AIX 7.1, Solaris 9, mingw64 mistakenly succeed on stat("file/").
27 dnl (For mingw, this is due to a broken stat() override in libmingwex.a.)
28 dnl FreeBSD 7.2 mistakenly succeeds on stat("link-to-file/").
8912421c
LC
29 AC_CACHE_CHECK([whether stat handles trailing slashes on files],
30 [gl_cv_func_stat_file_slash],
31 [touch conftest.tmp
f29ded4b
LC
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
8912421c
LC
36 AC_RUN_IFELSE(
37 [AC_LANG_PROGRAM(
38 [[#include <sys/stat.h>
0f00f2c3
LC
39]], [[int result = 0;
40 struct stat st;
41 if (!stat ("conftest.tmp/", &st))
42 result |= 1;
f29ded4b 43#if HAVE_LSTAT
0f00f2c3
LC
44 if (!stat ("conftest.lnk/", &st))
45 result |= 2;
f29ded4b 46#endif
0f00f2c3 47 return result;
f29ded4b 48 ]])],
8912421c 49 [gl_cv_func_stat_file_slash=yes], [gl_cv_func_stat_file_slash=no],
005de2e8
LC
50 [case "$host_os" in
51 # Guess yes on glibc systems.
52 *-gnu*) gl_cv_func_stat_file_slash="guessing yes" ;;
53 # If we don't know, assume the worst.
54 *) gl_cv_func_stat_file_slash="guessing no" ;;
55 esac
56 ])
f29ded4b 57 rm -f conftest.tmp conftest.lnk])
8912421c
LC
58 case $gl_cv_func_stat_dir_slash in
59 *no) REPLACE_STAT=1
60 AC_DEFINE([REPLACE_FUNC_STAT_DIR], [1], [Define to 1 if stat needs
61 help when passed a directory name with a trailing slash]);;
62 esac
63 case $gl_cv_func_stat_file_slash in
64 *no) REPLACE_STAT=1
65 AC_DEFINE([REPLACE_FUNC_STAT_FILE], [1], [Define to 1 if stat needs
66 help when passed a file name with a trailing slash]);;
67 esac
3d458a81
AW
68])
69
70# Prerequisites of lib/stat.c.
af07e104 71AC_DEFUN([gl_PREREQ_STAT], [:])