Blame m4/d-ino.m4

Packit 709fb3
# serial 16
Packit 709fb3
Packit 709fb3
dnl From Jim Meyering.
Packit 709fb3
dnl
Packit 709fb3
dnl Check whether struct dirent has a member named d_ino.
Packit 709fb3
dnl
Packit 709fb3
Packit 709fb3
# Copyright (C) 1997, 1999-2001, 2003-2004, 2006-2007, 2009-2017 Free Software
Packit 709fb3
# Foundation, Inc.
Packit 709fb3
Packit 709fb3
# This file is free software; the Free Software Foundation
Packit 709fb3
# gives unlimited permission to copy and/or distribute it,
Packit 709fb3
# with or without modifications, as long as this notice is preserved.
Packit 709fb3
Packit 709fb3
AC_DEFUN([gl_CHECK_TYPE_STRUCT_DIRENT_D_INO],
Packit 709fb3
  [AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
Packit 709fb3
   AC_CACHE_CHECK([for d_ino member in directory struct],
Packit 709fb3
                  gl_cv_struct_dirent_d_ino,
Packit 709fb3
     [AC_RUN_IFELSE(
Packit 709fb3
        [AC_LANG_PROGRAM(
Packit 709fb3
           [[#include <sys/types.h>
Packit 709fb3
             #include <sys/stat.h>
Packit 709fb3
             #include <dirent.h>
Packit 709fb3
           ]],
Packit 709fb3
           [[DIR *dp = opendir (".");
Packit 709fb3
             struct dirent *e;
Packit 709fb3
             struct stat st;
Packit 709fb3
             if (! dp)
Packit 709fb3
               return 1;
Packit 709fb3
             e = readdir (dp);
Packit 709fb3
             if (! e)
Packit 709fb3
               { closedir (dp); return 2; }
Packit 709fb3
             if (lstat (e->d_name, &st) != 0)
Packit 709fb3
               { closedir (dp); return 3; }
Packit 709fb3
             if (e->d_ino != st.st_ino)
Packit 709fb3
               { closedir (dp); return 4; }
Packit 709fb3
             closedir (dp);
Packit 709fb3
             return 0;
Packit 709fb3
           ]])],
Packit 709fb3
           [gl_cv_struct_dirent_d_ino=yes],
Packit 709fb3
           [gl_cv_struct_dirent_d_ino=no],
Packit 709fb3
           [case "$host_os" in
Packit 709fb3
                           # Guess yes on glibc systems with Linux kernel.
Packit 709fb3
              linux*-gnu*) gl_cv_struct_dirent_d_ino="guessing yes" ;;
Packit 709fb3
                           # If we don't know, assume the worst.
Packit 709fb3
              *)           gl_cv_struct_dirent_d_ino="guessing no" ;;
Packit 709fb3
            esac
Packit 709fb3
           ])])
Packit 709fb3
   case "$gl_cv_struct_dirent_d_ino" in
Packit 709fb3
     *yes)
Packit 709fb3
       AC_DEFINE([D_INO_IN_DIRENT], [1],
Packit 709fb3
         [Define if struct dirent has a member d_ino that actually works.])
Packit 709fb3
       ;;
Packit 709fb3
   esac
Packit 709fb3
  ]
Packit 709fb3
)