xref: /netbsd-src/external/bsd/am-utils/dist/m4/macros/check_fs_mntent.m4 (revision a53f50b9b44dc9467ccc9c464999b1d1c509cb0c)
1*a53f50b9Schristosdnl ######################################################################
2*a53f50b9Schristosdnl check if a filesystem type exists (if its header files exist)
3*a53f50b9Schristosdnl Usage: AC_CHECK_FS_MNTENT(<filesystem>, [<fssymbol>])
4*a53f50b9Schristosdnl
5*a53f50b9Schristosdnl Check in some headers for MNTTYPE_<filesystem> macro.  If that exist,
6*a53f50b9Schristosdnl then define HAVE_FS_<filesystem>.  If <fssymbol> exits, then define
7*a53f50b9Schristosdnl HAVE_FS_<fssymbol> instead...
8*a53f50b9SchristosAC_DEFUN([AMU_CHECK_FS_MNTENT],
9*a53f50b9Schristos[
10*a53f50b9Schristos# find what name to give to the fs
11*a53f50b9Schristosif test -n "$2"
12*a53f50b9Schristosthen
13*a53f50b9Schristos  ac_fs_name=$2
14*a53f50b9Schristos  ac_fs_as_name=" (from: $1)"
15*a53f50b9Schristoselse
16*a53f50b9Schristos  ac_fs_name=$1
17*a53f50b9Schristos  ac_fs_as_name=""
18*a53f50b9Schristosfi
19*a53f50b9Schristos# store variable name of filesystem
20*a53f50b9Schristosac_upcase_fs_name=`echo $ac_fs_name | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
21*a53f50b9Schristosac_safe=HAVE_FS_$ac_upcase_fs_name
22*a53f50b9Schristos# check for cache and set it if needed
23*a53f50b9SchristosAMU_CACHE_CHECK_DYNAMIC(for $ac_fs_name$ac_fs_as_name mntent definition,
24*a53f50b9Schristosac_cv_fs_$ac_fs_name,
25*a53f50b9Schristos[
26*a53f50b9Schristos# assume not found
27*a53f50b9Schristoseval "ac_cv_fs_$ac_fs_name=no"
28*a53f50b9Schristosfor ac_fs_tmp in $1
29*a53f50b9Schristosdo
30*a53f50b9Schristos  ac_upcase_fs_symbol=`echo $ac_fs_tmp | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
31*a53f50b9Schristos
32*a53f50b9Schristos  # first look for MNTTYPE_*
33*a53f50b9Schristos  AC_EGREP_CPP(yes,
34*a53f50b9Schristos  AMU_MOUNT_HEADERS(
35*a53f50b9Schristos  [
36*a53f50b9Schristos#ifdef MNTTYPE_$ac_upcase_fs_symbol
37*a53f50b9Schristos    yes
38*a53f50b9Schristos#endif /* MNTTYPE_$ac_upcase_fs_symbol */
39*a53f50b9Schristos  ]), [eval "ac_cv_fs_$ac_fs_name=yes"], [eval "ac_cv_fs_$ac_fs_name=no"] )
40*a53f50b9Schristos  # check if need to terminate "for" loop
41*a53f50b9Schristos  if test "`eval echo '$''{ac_cv_fs_'$ac_fs_name'}'`" != no
42*a53f50b9Schristos  then
43*a53f50b9Schristos    break
44*a53f50b9Schristos  fi
45*a53f50b9Schristos
46*a53f50b9Schristos  # now try to look for MOUNT_ macro
47*a53f50b9Schristos  AC_EGREP_CPP(yes,
48*a53f50b9Schristos  AMU_MOUNT_HEADERS(
49*a53f50b9Schristos  [
50*a53f50b9Schristos#ifdef MOUNT_$ac_upcase_fs_symbol
51*a53f50b9Schristos    yes
52*a53f50b9Schristos#endif /* MOUNT_$ac_upcase_fs_symbol */
53*a53f50b9Schristos  ]), [eval "ac_cv_fs_$ac_fs_name=yes"], [eval "ac_cv_fs_$ac_fs_name=no"] )
54*a53f50b9Schristos  # check if need to terminate "for" loop
55*a53f50b9Schristos  if test "`eval echo '$''{ac_cv_fs_'$ac_fs_name'}'`" != no
56*a53f50b9Schristos  then
57*a53f50b9Schristos    break
58*a53f50b9Schristos  fi
59*a53f50b9Schristos
60*a53f50b9Schristos  # now try to look for MNT_ macro
61*a53f50b9Schristos  AC_EGREP_CPP(yes,
62*a53f50b9Schristos  AMU_MOUNT_HEADERS(
63*a53f50b9Schristos  [
64*a53f50b9Schristos#ifdef MNT_$ac_upcase_fs_symbol
65*a53f50b9Schristos    yes
66*a53f50b9Schristos#endif /* MNT_$ac_upcase_fs_symbol */
67*a53f50b9Schristos  ]), [eval "ac_cv_fs_$ac_fs_name=yes"], [eval "ac_cv_fs_$ac_fs_name=no"] )
68*a53f50b9Schristos  # check if need to terminate "for" loop
69*a53f50b9Schristos  if test "`eval echo '$''{ac_cv_fs_'$ac_fs_name'}'`" != no
70*a53f50b9Schristos  then
71*a53f50b9Schristos    break
72*a53f50b9Schristos  fi
73*a53f50b9Schristos
74*a53f50b9Schristos  # now try to look for GT_ macro (ultrix)
75*a53f50b9Schristos  AC_EGREP_CPP(yes,
76*a53f50b9Schristos  AMU_MOUNT_HEADERS(
77*a53f50b9Schristos  [
78*a53f50b9Schristos#ifdef GT_$ac_upcase_fs_symbol
79*a53f50b9Schristos    yes
80*a53f50b9Schristos#endif /* GT_$ac_upcase_fs_symbol */
81*a53f50b9Schristos  ]), [eval "ac_cv_fs_$ac_fs_name=yes"], [eval "ac_cv_fs_$ac_fs_name=no"] )
82*a53f50b9Schristos  # check if need to terminate "for" loop
83*a53f50b9Schristos  if test "`eval echo '$''{ac_cv_fs_'$ac_fs_name'}'`" != no
84*a53f50b9Schristos  then
85*a53f50b9Schristos    break
86*a53f50b9Schristos  fi
87*a53f50b9Schristos
88*a53f50b9Schristos  # look for a loadable filesystem module (linux)
89*a53f50b9Schristos  if test -f /lib/modules/$host_os_version/fs/$ac_fs_tmp.ko
90*a53f50b9Schristos  then
91*a53f50b9Schristos    eval "ac_cv_fs_$ac_fs_name=yes"
92*a53f50b9Schristos    break
93*a53f50b9Schristos  fi
94*a53f50b9Schristos  if test -f /lib/modules/$host_os_version/fs/$ac_fs_tmp.o
95*a53f50b9Schristos  then
96*a53f50b9Schristos    eval "ac_cv_fs_$ac_fs_name=yes"
97*a53f50b9Schristos    break
98*a53f50b9Schristos  fi
99*a53f50b9Schristos
100*a53f50b9Schristos  # look for a loadable filesystem module (linux 2.4+)
101*a53f50b9Schristos  if test -f /lib/modules/$host_os_version/kernel/fs/$ac_fs_tmp/$ac_fs_tmp.ko
102*a53f50b9Schristos  then
103*a53f50b9Schristos    eval "ac_cv_fs_$ac_fs_name=yes"
104*a53f50b9Schristos    break
105*a53f50b9Schristos  fi
106*a53f50b9Schristos  if test -f /lib/modules/$host_os_version/kernel/fs/$ac_fs_tmp/$ac_fs_tmp.o
107*a53f50b9Schristos  then
108*a53f50b9Schristos    eval "ac_cv_fs_$ac_fs_name=yes"
109*a53f50b9Schristos    break
110*a53f50b9Schristos  fi
111*a53f50b9Schristos
112*a53f50b9Schristos  # look for a loadable filesystem module (linux redhat-5.1)
113*a53f50b9Schristos  if test -f /lib/modules/preferred/fs/$ac_fs_tmp.ko
114*a53f50b9Schristos  then
115*a53f50b9Schristos    eval "ac_cv_fs_$ac_fs_name=yes"
116*a53f50b9Schristos    break
117*a53f50b9Schristos  fi
118*a53f50b9Schristos  if test -f /lib/modules/preferred/fs/$ac_fs_tmp.o
119*a53f50b9Schristos  then
120*a53f50b9Schristos    eval "ac_cv_fs_$ac_fs_name=yes"
121*a53f50b9Schristos    break
122*a53f50b9Schristos  fi
123*a53f50b9Schristos
124*a53f50b9Schristos  # in addition look for statically compiled filesystem (linux)
125*a53f50b9Schristos  if egrep "[[^a-zA-Z0-9_]]$ac_fs_tmp$" /proc/filesystems >/dev/null 2>&1
126*a53f50b9Schristos  then
127*a53f50b9Schristos    eval "ac_cv_fs_$ac_fs_name=yes"
128*a53f50b9Schristos    break
129*a53f50b9Schristos  fi
130*a53f50b9Schristos
131*a53f50b9Schristos  if test "$ac_fs_tmp" = "nfs3" -a "$ac_cv_header_linux_nfs_mount_h" = "yes"
132*a53f50b9Schristos  then
133*a53f50b9Schristos    # hack hack hack
134*a53f50b9Schristos    # in 6.1, which has fallback to v2/udp, we might want
135*a53f50b9Schristos    # to always use version 4.
136*a53f50b9Schristos    # in 6.0 we do not have much choice
137*a53f50b9Schristos    #
138*a53f50b9Schristos    let nfs_mount_version="`grep NFS_MOUNT_VERSION /usr/include/linux/nfs_mount.h | awk '{print $''3;}'`"
139*a53f50b9Schristos    if test $nfs_mount_version -ge 4
140*a53f50b9Schristos    then
141*a53f50b9Schristos      eval "ac_cv_fs_$ac_fs_name=yes"
142*a53f50b9Schristos      break
143*a53f50b9Schristos    fi
144*a53f50b9Schristos  fi
145*a53f50b9Schristos
146*a53f50b9Schristos  # run a test program for bsdi3
147*a53f50b9Schristos  AC_TRY_RUN(
148*a53f50b9Schristos  [
149*a53f50b9Schristos#include <sys/param.h>
150*a53f50b9Schristos#include <sys/mount.h>
151*a53f50b9Schristosmain()
152*a53f50b9Schristos{
153*a53f50b9Schristos  int i;
154*a53f50b9Schristos  struct vfsconf vf;
155*a53f50b9Schristos  i = getvfsbyname("$ac_fs_tmp", &vf);
156*a53f50b9Schristos  if (i < 0)
157*a53f50b9Schristos    exit(1);
158*a53f50b9Schristos  else
159*a53f50b9Schristos    exit(0);
160*a53f50b9Schristos}
161*a53f50b9Schristos  ], [eval "ac_cv_fs_$ac_fs_name=yes"
162*a53f50b9Schristos      break
163*a53f50b9Schristos     ]
164*a53f50b9Schristos  )
165*a53f50b9Schristos
166*a53f50b9Schristosdone
167*a53f50b9Schristos])
168*a53f50b9Schristos# check if need to define variable
169*a53f50b9Schristosif test "`eval echo '$''{ac_cv_fs_'$ac_fs_name'}'`" = yes
170*a53f50b9Schristosthen
171*a53f50b9Schristos  AC_DEFINE_UNQUOTED($ac_safe)
172*a53f50b9Schristos# append ops_<fs>.o object to AMD_FS_OBJS for automatic compilation
173*a53f50b9Schristos# if first time we add something to this list, then also tell autoconf
174*a53f50b9Schristos# to replace instances of it in Makefiles.
175*a53f50b9Schristos  if test -z "$AMD_FS_OBJS"
176*a53f50b9Schristos  then
177*a53f50b9Schristos    AMD_FS_OBJS="ops_${ac_fs_name}.o"
178*a53f50b9Schristos    AC_SUBST(AMD_FS_OBJS)
179*a53f50b9Schristos  else
180*a53f50b9Schristos    # since this object file could have already been added before
181*a53f50b9Schristos    # we need to ensure we do not add it twice.
182*a53f50b9Schristos    case "${AMD_FS_OBJS}" in
183*a53f50b9Schristos      *ops_${ac_fs_name}.o* ) ;;
184*a53f50b9Schristos      * )
185*a53f50b9Schristos        AMD_FS_OBJS="$AMD_FS_OBJS ops_${ac_fs_name}.o"
186*a53f50b9Schristos      ;;
187*a53f50b9Schristos    esac
188*a53f50b9Schristos  fi
189*a53f50b9Schristosfi
190*a53f50b9Schristos])
191*a53f50b9Schristosdnl ======================================================================
192