Tizen 2.0 Release
[external/tizen-coreutils.git] / m4 / stat-prog.m4
1 # stat-prog.m4 serial 5
2 # Record the prerequisites of src/stat.c from the coreutils package.
3
4 # Copyright (C) 2002, 2003, 2004, 2006 Free Software Foundation, Inc.
5
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 2, or (at your option)
9 # any later version.
10
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.
15
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software Foundation,
18 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
20 # Written by Jim Meyering.
21
22 AC_DEFUN([cu_PREREQ_STAT_PROG],
23 [
24   AC_REQUIRE([gl_FSUSAGE])
25   AC_REQUIRE([gl_FSTYPENAME])
26   AC_CHECK_HEADERS_ONCE([OS.h netinet/in.h sys/param.h sys/vfs.h])
27
28   dnl Check for vfs.h first, since this avoids a warning with nfs_client.h
29   dnl on Solaris 8.
30   test $ac_cv_header_sys_param_h = yes &&
31   test $ac_cv_header_sys_mount_h = yes &&
32   AC_CHECK_HEADERS([nfs/vfs.h],
33     [AC_CHECK_HEADERS([nfs/nfs_client.h])])
34
35   statvfs_includes="\
36 AC_INCLUDES_DEFAULT
37 #include <sys/statvfs.h>
38 "
39   statfs_includes="\
40 AC_INCLUDES_DEFAULT
41 #if HAVE_SYS_VFS_H
42 # include <sys/vfs.h>
43 #elif HAVE_SYS_MOUNT_H && HAVE_SYS_PARAM_H
44 # include <sys/param.h>
45 # include <sys/mount.h>
46 # if HAVE_NETINET_IN_H && HAVE_NFS_NFS_CLNT_H && HAVE_NFS_VFS_H
47 #  include <netinet/in.h>
48 #  include <nfs/nfs_clnt.h>
49 #  include <nfs/vfs.h>
50 # endif
51 #elif HAVE_OS_H
52 # include <fs_info.h>
53 #endif
54 "
55   dnl Keep this long conditional in sync with the USE_STATVFS conditional
56   dnl in ../src/stat.c.
57   if test "$fu_cv_sys_stat_statvfs" = yes &&
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_type],,,
76       [$statfs_includes])
77     if test $ac_cv_header_OS_h != yes; then
78       AC_COMPILE_IFELSE(
79         [AC_LANG_PROGRAM(
80            [$statfs_includes],
81            [static statfs s;
82             return (s.s_fsid ^ 0) == 0;])],
83         [AC_DEFINE([STRUCT_STATFS_F_FSID_IS_INTEGER], 1,
84            [Define to 1 if the f_fsid member of struct statfs is an integer.])])
85     fi
86   fi
87 ])