shuf: tiny simplification
[coreutils.git] / m4 / stat-prog.m4
blob735c9aafa53e25fc485262bdb3d0e5510135790f
1 # stat-prog.m4 serial 7
2 # Record the prerequisites of src/stat.c from the coreutils package.
4 # Copyright (C) 2002-2024 Free Software Foundation, Inc.
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
19 # Written by Jim Meyering.
21 AC_DEFUN([cu_PREREQ_STAT_PROG],
23   AC_REQUIRE([gl_FSUSAGE])
24   AC_REQUIRE([gl_FSTYPENAME])
25   AC_CHECK_HEADERS_ONCE([OS.h netinet/in.h sys/param.h sys/vfs.h])
27   dnl Check for vfs.h first, since this avoids a warning with nfs_client.h
28   dnl on Solaris 8.
29   test $ac_cv_header_sys_param_h = yes &&
30   test $ac_cv_header_sys_mount_h = yes &&
31   AC_CHECK_HEADERS([nfs/vfs.h],
32     [AC_CHECK_HEADERS([nfs/nfs_client.h])])
34   statvfs_includes="\
35 AC_INCLUDES_DEFAULT
36 #include <sys/statvfs.h>
38   statfs_includes="\
39 AC_INCLUDES_DEFAULT
40 #if HAVE_SYS_VFS_H
41 # include <sys/vfs.h>
42 #elif HAVE_SYS_MOUNT_H && HAVE_SYS_PARAM_H
43 # include <sys/param.h>
44 # include <sys/mount.h>
45 # if HAVE_NETINET_IN_H && HAVE_NFS_NFS_CLNT_H && HAVE_NFS_VFS_H
46 #  include <netinet/in.h>
47 #  include <nfs/nfs_clnt.h>
48 #  include <nfs/vfs.h>
49 # endif
50 #elif HAVE_OS_H
51 # include <fs_info.h>
52 #endif
54   dnl Keep this long conditional in sync with the USE_STATVFS conditional
55   dnl in ../src/stat.c.
56   if case "$fu_cv_sys_stat_statvfs$fu_cv_sys_stat_statvfs64" in
57        *yes*) ;; *) false;; esac &&
58      { AC_CHECK_MEMBERS([struct statvfs.f_basetype],,, [$statvfs_includes])
59        test $ac_cv_member_struct_statvfs_f_basetype = yes ||
60        { AC_CHECK_MEMBERS([struct statvfs.f_fstypename],,, [$statvfs_includes])
61          test $ac_cv_member_struct_statvfs_f_fstypename = yes ||
62          { test $ac_cv_member_struct_statfs_f_fstypename != yes &&
63            { AC_CHECK_MEMBERS([struct statvfs.f_type],,, [$statvfs_includes])
64              test $ac_cv_member_struct_statvfs_f_type = yes; }; }; }; }
65   then
66     AC_CHECK_MEMBERS([struct statvfs.f_namemax],,, [$statvfs_includes])
67     AC_COMPILE_IFELSE(
68       [AC_LANG_PROGRAM(
69          [$statvfs_includes],
70          [static statvfs s;
71           return (s.s_fsid ^ 0) == 0;])],
72       [AC_DEFINE([STRUCT_STATVFS_F_FSID_IS_INTEGER], [1],
73          [Define to 1 if the f_fsid member of struct statvfs is an integer.])])
74   else
75     AC_CHECK_MEMBERS([struct statfs.f_namelen, struct statfs.f_namemax,
76                       struct statfs.f_type, struct statfs.f_frsize],,,
77                      [$statfs_includes])
78     if test $ac_cv_header_OS_h != yes; then
79       AC_COMPILE_IFELSE(
80         [AC_LANG_PROGRAM(
81            [$statfs_includes],
82            [static statfs s;
83             return (s.s_fsid ^ 0) == 0;])],
84         [AC_DEFINE([STRUCT_STATFS_F_FSID_IS_INTEGER], [1],
85            [Define to 1 if the f_fsid member of struct statfs is an integer.])])
86     fi
87   fi