summaryrefslogtreecommitdiff
path: root/m4/stat-prog.m4
blob: 8d29232122a1eb2583b26bd5a96bfb67e5a36e0f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# stat-prog.m4 serial 7
# Record the prerequisites of src/stat.c from the coreutils package.

# Copyright (C) 2002-2017 Free Software Foundation, Inc.

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

# Written by Jim Meyering.

AC_DEFUN([cu_PREREQ_STAT_PROG],
[
  AC_REQUIRE([gl_FSUSAGE])
  AC_REQUIRE([gl_FSTYPENAME])
  AC_CHECK_HEADERS_ONCE([OS.h netinet/in.h sys/param.h sys/vfs.h])

  dnl Check for vfs.h first, since this avoids a warning with nfs_client.h
  dnl on Solaris 8.
  test $ac_cv_header_sys_param_h = yes &&
  test $ac_cv_header_sys_mount_h = yes &&
  AC_CHECK_HEADERS([nfs/vfs.h],
    [AC_CHECK_HEADERS([nfs/nfs_client.h])])

  statvfs_includes="\
AC_INCLUDES_DEFAULT
#include <sys/statvfs.h>
"
  statfs_includes="\
AC_INCLUDES_DEFAULT
#if HAVE_SYS_VFS_H
# include <sys/vfs.h>
#elif HAVE_SYS_MOUNT_H && HAVE_SYS_PARAM_H
# include <sys/param.h>
# include <sys/mount.h>
# if HAVE_NETINET_IN_H && HAVE_NFS_NFS_CLNT_H && HAVE_NFS_VFS_H
#  include <netinet/in.h>
#  include <nfs/nfs_clnt.h>
#  include <nfs/vfs.h>
# endif
#elif HAVE_OS_H
# include <fs_info.h>
#endif
"
  dnl Keep this long conditional in sync with the USE_STATVFS conditional
  dnl in ../src/stat.c.
  if case "$fu_cv_sys_stat_statvfs$fu_cv_sys_stat_statvfs64" in
       *yes*) ;; *) false;; esac &&
     { AC_CHECK_MEMBERS([struct statvfs.f_basetype],,, [$statvfs_includes])
       test $ac_cv_member_struct_statvfs_f_basetype = yes ||
       { AC_CHECK_MEMBERS([struct statvfs.f_fstypename],,, [$statvfs_includes])
         test $ac_cv_member_struct_statvfs_f_fstypename = yes ||
         { test $ac_cv_member_struct_statfs_f_fstypename != yes &&
           { AC_CHECK_MEMBERS([struct statvfs.f_type],,, [$statvfs_includes])
             test $ac_cv_member_struct_statvfs_f_type = yes; }; }; }; }
  then
    AC_CHECK_MEMBERS([struct statvfs.f_namemax],,, [$statvfs_includes])
    AC_COMPILE_IFELSE(
      [AC_LANG_PROGRAM(
         [$statvfs_includes],
         [static statvfs s;
          return (s.s_fsid ^ 0) == 0;])],
      [AC_DEFINE([STRUCT_STATVFS_F_FSID_IS_INTEGER], [1],
         [Define to 1 if the f_fsid member of struct statvfs is an integer.])])
  else
    AC_CHECK_MEMBERS([struct statfs.f_namelen, struct statfs.f_type,
                     struct statfs.f_frsize],,, [$statfs_includes])
    if test $ac_cv_header_OS_h != yes; then
      AC_COMPILE_IFELSE(
        [AC_LANG_PROGRAM(
           [$statfs_includes],
           [static statfs s;
            return (s.s_fsid ^ 0) == 0;])],
        [AC_DEFINE([STRUCT_STATFS_F_FSID_IS_INTEGER], [1],
           [Define to 1 if the f_fsid member of struct statfs is an integer.])])
    fi
  fi
])