3 # Copyright (C) 2009, 2010 Free Software Foundation, Inc.
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.
9 AC_DEFUN([gl_FUNC_STAT],
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],
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],
24 mingw*) gl_cv_func_stat_dir_slash="guessing no";;
25 *) gl_cv_func_stat_dir_slash="guessing yes";;
27 dnl AIX 7.1, Solaris 9 mistakenly succeed 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],
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
38 [[#include <sys/stat.h>
41 if (!stat ("conftest.tmp/", &st))
44 if (!stat ("conftest.lnk/", &st))
49 [gl_cv_func_stat_file_slash=yes], [gl_cv_func_stat_file_slash=no],
50 [gl_cv_func_stat_file_slash="guessing no"])
51 rm -f conftest.tmp conftest.lnk])
52 case $gl_cv_func_stat_dir_slash in
54 AC_DEFINE([REPLACE_FUNC_STAT_DIR], [1], [Define to 1 if stat needs
55 help when passed a directory name with a trailing slash]);;
57 case $gl_cv_func_stat_file_slash in
59 AC_DEFINE([REPLACE_FUNC_STAT_FILE], [1], [Define to 1 if stat needs
60 help when passed a file name with a trailing slash]);;
62 if test $REPLACE_STAT = 1; then
64 dnl Prerequisites of lib/stat.c.
65 AC_REQUIRE([AC_C_INLINE])