Blame m4/stat.m4

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