Blame m4/stat.m4

Packit 8f70b4
# serial 15
Packit 8f70b4
Packit 8f70b4
# Copyright (C) 2009-2018 Free Software Foundation, Inc.
Packit 8f70b4
#
Packit 8f70b4
# This file is free software; the Free Software Foundation
Packit 8f70b4
# gives unlimited permission to copy and/or distribute it,
Packit 8f70b4
# with or without modifications, as long as this notice is preserved.
Packit 8f70b4
Packit 8f70b4
AC_DEFUN([gl_FUNC_STAT],
Packit 8f70b4
[
Packit 8f70b4
  AC_REQUIRE([AC_CANONICAL_HOST])
Packit 8f70b4
  AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS])
Packit 8f70b4
  AC_CHECK_FUNCS_ONCE([lstat])
Packit 8f70b4
  case "$host_os" in
Packit 8f70b4
    mingw*)
Packit 8f70b4
      dnl On this platform, the original stat() returns st_atime, st_mtime,
Packit 8f70b4
      dnl st_ctime values that are affected by the time zone.
Packit 8f70b4
      REPLACE_STAT=1
Packit 8f70b4
      ;;
Packit 8f70b4
    *)
Packit 8f70b4
      dnl AIX 7.1, Solaris 9, mingw64 mistakenly succeed on stat("file/").
Packit 8f70b4
      dnl (For mingw, this is due to a broken stat() override in libmingwex.a.)
Packit 8f70b4
      dnl FreeBSD 7.2 mistakenly succeeds on stat("link-to-file/").
Packit 8f70b4
      AC_CACHE_CHECK([whether stat handles trailing slashes on files],
Packit 8f70b4
        [gl_cv_func_stat_file_slash],
Packit 8f70b4
        [touch conftest.tmp
Packit 8f70b4
         # Assume that if we have lstat, we can also check symlinks.
Packit 8f70b4
         if test $ac_cv_func_lstat = yes; then
Packit 8f70b4
           ln -s conftest.tmp conftest.lnk
Packit 8f70b4
         fi
Packit 8f70b4
         AC_RUN_IFELSE(
Packit 8f70b4
           [AC_LANG_PROGRAM(
Packit 8f70b4
             [[#include <sys/stat.h>
Packit 8f70b4
]], [[int result = 0;
Packit 8f70b4
               struct stat st;
Packit 8f70b4
               if (!stat ("conftest.tmp/", &st))
Packit 8f70b4
                 result |= 1;
Packit 8f70b4
#if HAVE_LSTAT
Packit 8f70b4
               if (!stat ("conftest.lnk/", &st))
Packit 8f70b4
                 result |= 2;
Packit 8f70b4
#endif
Packit 8f70b4
               return result;
Packit 8f70b4
             ]])],
Packit 8f70b4
           [gl_cv_func_stat_file_slash=yes], [gl_cv_func_stat_file_slash=no],
Packit 8f70b4
           [case "$host_os" in
Packit 8f70b4
                               # Guess yes on Linux systems.
Packit 8f70b4
              linux-* | linux) gl_cv_func_stat_file_slash="guessing yes" ;;
Packit 8f70b4
                               # Guess yes on glibc systems.
Packit 8f70b4
              *-gnu* | gnu*)   gl_cv_func_stat_file_slash="guessing yes" ;;
Packit 8f70b4
                               # If we don't know, assume the worst.
Packit 8f70b4
              *)               gl_cv_func_stat_file_slash="guessing no" ;;
Packit 8f70b4
            esac
Packit 8f70b4
           ])
Packit 8f70b4
         rm -f conftest.tmp conftest.lnk])
Packit 8f70b4
      case $gl_cv_func_stat_file_slash in
Packit 8f70b4
        *no)
Packit 8f70b4
          REPLACE_STAT=1
Packit 8f70b4
          AC_DEFINE([REPLACE_FUNC_STAT_FILE], [1], [Define to 1 if stat needs
Packit 8f70b4
            help when passed a file name with a trailing slash]);;
Packit 8f70b4
      esac
Packit 8f70b4
      case $host_os in
Packit 8f70b4
        dnl Solaris stat can return a negative tv_nsec.
Packit 8f70b4
        solaris*)
Packit 8f70b4
          REPLACE_FSTAT=1 ;;
Packit 8f70b4
      esac
Packit 8f70b4
      ;;
Packit 8f70b4
  esac
Packit 8f70b4
])
Packit 8f70b4
Packit 8f70b4
# Prerequisites of lib/stat.c and lib/stat-w32.c.
Packit 8f70b4
AC_DEFUN([gl_PREREQ_STAT], [
Packit 8f70b4
  AC_REQUIRE([gl_HEADER_SYS_STAT_H])
Packit 8f70b4
  :
Packit 8f70b4
])