xref: /illumos-gate/usr/src/tools/quick/make-nfs (revision 86d949f9)
1#!/bin/ksh
2#
3# This file and its contents are supplied under the terms of the
4# Common Development and Distribution License ("CDDL"), version 1.0.
5# You may only use this file in accordance with the terms of version
6# 1.0 of the CDDL.
7#
8# A full copy of the text of the CDDL should have accompanied this
9# source.  A copy of the CDDL is also available via the Internet at
10# http://www.illumos.org/license/CDDL.
11#
12
13#
14# Copyright 2021 Tintri by DDN, Inc. All rights reserved.
15#
16
17# Use normal make (not dmake) by default.
18make=${MAKE:-make}
19
20# Set this if you want to use dbx or gdb:
21# export SOURCEDEBUG=yes
22
23[ -n "$SRC" ] || {
24  echo "SRC not set.  Run 'ws' or 'bldenv' first."
25  exit 1
26}
27
28cpu=`uname -p`
29case $cpu in
30i386)
31	x=intel
32	kmdb_arch="amd64"
33	mdb_arch="ia32 amd64"
34	arch64=amd64
35	;;
36sparc)
37	x=sparc
38	kmdb_arch=v9
39	mdb_arch="v7 v9"
40	arch64=sparcv9
41	;;
42*)  echo "Unknown architecture" ; exit 1;;
43esac
44
45################################################################
46
47build_tools() {
48  test -f $SRC/tools/proto/root_i386-nd/opt/onbld/bin/genoffsets ||
49    (cd $SRC/tools && $make install)
50  (cd $SRC/common/mapfiles; $make install)
51}
52
53clobber_tools() {
54  (cd $SRC/tools && $make clobber)
55  (cd $SRC/common/mapfiles; $make clobber)
56}
57
58# end build_tools()
59
60
61################################################################
62
63do_hdrs() {
64
65targ=$1
66if [ "$targ" = clobber ]
67then
68  (cd $SRC/uts && $make -k clobber_h)
69  (cd $SRC/head && $make clobber)
70fi
71
72if [ "$targ" = install ]
73then
74  targ=install_h
75
76  # Just the parts of "make sgs" we need, and
77  # skip them if they appear to be done.
78  # ... stuff under $SRC
79  test -f $SRC/uts/common/sys/priv_names.h ||
80    (cd $SRC/uts && $make -k all_h)
81
82  test -f $SRC/head/rpcsvc/nispasswd.h ||
83    (cd $SRC/head && $make -k $targ)
84
85  # ... stuff under $ROOT (proto area)
86  test -d $ROOT/usr/include/sys ||
87    (cd $SRC && $make rootdirs)
88  test -f $ROOT/usr/include/sys/types.h ||
89    (cd $SRC/uts && $make -k $targ)
90  test -f $ROOT/usr/include/rpcsvc/daemon_utils.h ||
91    (cd $SRC/head && $make $targ)
92
93  # always update the NFS (kernel) headers to be safe
94  (cd $SRC/uts/common/gssapi && $make -k $targ)
95  (cd $SRC/uts/common/sys && $make -k $targ)
96  (cd $SRC/uts/common/nfs && $make -k $targ)
97fi
98
99# Need some library headers too...
100for lib in \
101  libcmdutils \
102  libcryptoutil \
103  libidmap \
104  libpam \
105  libsec \
106  libzfs_core \
107  libzfs \
108  libshare \
109  libuutil \
110  librpcsvc \
111  libmapid
112do
113  (cd $SRC/lib/$lib && $make $targ)
114done
115}
116
117# end do_hdrs()
118
119
120################################################################
121
122do_kern() {
123  case $1 in
124  *) targ=$1 ;;
125  esac
126  ( unset SOURCEDEBUG ;
127  (cd $SRC/uts/$x/nfs && $make $targ) ;
128  (cd $SRC/uts/$x/nfs_dlboot && $make $targ) ;
129  (cd $SRC/uts/$x/nfssrv && $make $targ) ;
130  (cd $SRC/uts/$x/klmmod && $make $targ) ;
131  (cd $SRC/uts/$x/klmops && $make $targ) )
132}
133
134# end do_kern()
135
136
137################################################################
138
139# Note lib1 builds prerequisite libraries not delivered by the
140# tar file we create below.  To accelerate clean/install, we
141# skip these on clean (but still nuke them for clobber)
142
143do_lib1() {
144
145for lib in \
146  libavl \
147  libuutil \
148  libcmdutils \
149  libidmap \
150  libzfs_core \
151  libzfs
152do
153  (cd $SRC/lib/$lib && $make $1)
154done
155}
156
157# lib2 builds stuff we include in the tar file,
158# or that we don't mind rebuilding after clean.
159
160do_lib2() {
161
162for lib in \
163  librpcsvc \
164  libmapid
165do
166  (cd $SRC/lib/$lib && $make $1)
167done
168
169(cd $SRC/lib/libshare && $make $1 PLUGINS=nfs)
170
171}
172
173# end do_lib1() and do_lib2()
174
175
176################################################################
177
178do_cmds() {
179
180case $1 in
181install)
182  # mount programs need fslib.o
183  (cd $SRC/cmd/fs.d && $make fslib.o)
184  (cd $SRC/cmd/fs.d/nfs && $make $1 catalog)
185  ;;
186clean|clobber)
187  (cd $SRC/cmd/fs.d/nfs && $make $1)
188  (cd $SRC/cmd/fs.d && $make ${1}_local)
189  ;;
190esac
191
192# Build the MDB modules, WITH the linktest
193(cd $SRC/cmd/mdb/tools && $make $1)
194
195# kmdb_arch is 64-bit only
196for a in $kmdb_arch
197do
198  case $1 in
199  install|lint)
200    (cd $SRC/cmd/mdb/$x/$a/kmdb &&
201	$make kmdb_modlinktest.o )
202    ;;
203  clean|clobber)
204    (cd $SRC/cmd/mdb/$x/$a/kmdb &&
205	$make -k $1 )
206    ;;
207  esac
208  (cd $SRC/cmd/mdb/$x/$a/nfs &&
209	$make $1 KMDB_LINKTEST_ENABLE= )
210  (cd $SRC/cmd/mdb/$x/$a/klmmod &&
211	$make $1 KMDB_LINKTEST_ENABLE= )
212done
213}
214
215# end do_cmds()
216
217
218################################################################
219# This builds $SRC/TAGS (and cscope.files) in a helpful order.
220
221do_tags() {
222	(cd $SRC ;
223	find uts/common/sys -name '*.[ch]' -print |sort
224	find uts/common/net -name '*.[ch]' -print |sort
225	find uts/common/netinet -name '*.[ch]' -print |sort
226	find uts/common/nfs -name '*.[ch]' -print |sort
227	find uts/common/rpc -name '*.[ch]' -print |sort
228	find uts/common/klm -name '*.[ch]' -print |sort
229	find uts/common/fs/nfs -name '*.[ch]' -print |sort
230	find uts/common/gssapi -name '*.[ch]' -print |sort
231	find head -name '*.h' -print |sort
232	find cmd/fs.d/nfs -name '*.[ch]' -print |sort
233	) > $SRC/cscope.files
234
235	(cd $SRC ;
236	exctags -e --langmap=c:+.ndl -h ndl -L - < cscope.files
237	cscope -b )
238}
239
240#end do_tags()
241
242
243################################################################
244# This creates tarfiles one can use to update a test machine.
245
246do_tar() {
247	git_rev=`git rev-parse --short=8 HEAD`
248
249# NFS (everything)
250	files="
251kernel/kmdb/$arch64/klmmod
252kernel/kmdb/$arch64/nfs
253kernel/misc/$arch64/klmmod
254kernel/misc/$arch64/klmops
255kernel/misc/$arch64/nfs_dlboot
256kernel/misc/$arch64/nfssrv
257kernel/fs/$arch64/nfs
258kernel/sys/$arch64/nfs
259lib/svc/manifest/network/nfs/cbd.xml
260lib/svc/manifest/network/nfs/client.xml
261lib/svc/manifest/network/nfs/mapid.xml
262lib/svc/manifest/network/nfs/nfslogd.xml
263lib/svc/manifest/network/nfs/nlockmgr.xml
264lib/svc/manifest/network/nfs/rquota.xml
265lib/svc/manifest/network/nfs/server.xml
266lib/svc/manifest/network/nfs/status.xml
267lib/svc/method/nfs-client
268lib/svc/method/nfs-server
269lib/svc/method/nlockmgr
270usr/bin/nfsstat
271usr/lib/fs/nfs/$arch64/libshare_nfs.so.1
272usr/lib/fs/nfs/libshare_nfs.so.1
273usr/lib/fs/nfs/dfmounts
274usr/lib/fs/nfs/dfshares
275usr/lib/fs/nfs/nfsfind
276usr/lib/fs/nfs/showmount
277usr/lib/fs/nfs/umount
278usr/lib/mdb/kvm/$arch64/klmmod.so
279usr/lib/mdb/kvm/$arch64/nfs.so
280usr/lib/nfs/libmapid.so.1
281usr/lib/nfs/lockd
282usr/lib/nfs/mountd
283usr/lib/nfs/nfs4cbd
284usr/lib/nfs/nfsd
285usr/lib/nfs/nfslogd
286usr/lib/nfs/nfsmapid
287usr/lib/nfs/rquotad
288usr/lib/nfs/statd
289usr/lib/reparse/$arch64/libnfs_basic.so.1
290usr/lib/reparse/libnfs_basic.so.1
291usr/sbin/clear_locks
292usr/sbin/exportfs
293usr/sbin/nfsref
294"
295	(cd $ROOT && tar cfj ../../nfs-${git_rev}.tar.bz2 $files)
296
297# KLM kmod
298	files="
299kernel/misc/$arch64/klmmod
300kernel/misc/$arch64/klmops
301"
302	(cd $ROOT && tar cfj ../../klm-${git_rev}.tar.bz2 $files)
303}
304
305# end do_tar()
306
307
308################################################################
309
310if [ "$1" = "" ]; then
311  set '?' # force usage
312fi
313
314set -x
315
316for arg
317do
318  case "$arg" in
319  install)
320    build_tools
321    set -e
322    do_hdrs $arg
323    do_kern $arg
324    do_lib1 $arg
325    do_lib2 $arg
326    do_cmds $arg
327    ;;
328  clean)
329    # intentionally skip: lib1, hdrs, tools
330    do_cmds $arg
331    do_lib2 $arg
332    do_kern $arg
333    ;;
334  clobber)
335    do_cmds $arg
336    do_lib2 $arg
337    do_lib1 $arg
338    do_kern $arg
339    do_hdrs $arg
340    clobber_tools
341    ;;
342  tags)
343    do_tags
344    ;;
345  tar)
346    do_tar
347    ;;
348  *)
349    echo "Usage: $0 {install|clean|clobber|tags|tar}";
350    exit 1;
351    ;;
352  esac
353done
354