xref: /illumos-gate/usr/src/tools/quick/make-nfs (revision ac2f5fbefc05314fcd97b03f2338b39e6efe643f)
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 2019 Nexenta 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
193}
194
195# Build the MDB modules, WITH the linktest
196# Not yet.  See https://www.illumos.org/issues/3409
197
198# end do_cmds()
199
200
201################################################################
202# This builds $SRC/TAGS (and cscope.files) in a helpful order.
203
204do_tags() {
205	(cd $SRC ;
206	find uts/common/sys -name '*.[ch]' -print |sort
207	find uts/common/net -name '*.[ch]' -print |sort
208	find uts/common/netinet -name '*.[ch]' -print |sort
209	find uts/common/nfs -name '*.[ch]' -print |sort
210	find uts/common/rpc -name '*.[ch]' -print |sort
211	find uts/common/klm -name '*.[ch]' -print |sort
212	find uts/common/fs/nfs -name '*.[ch]' -print |sort
213	find uts/common/gssapi -name '*.[ch]' -print |sort
214	find head -name '*.h' -print |sort
215	find cmd/fs.d/nfs -name '*.[ch]' -print |sort
216	) > $SRC/cscope.files
217
218	(cd $SRC ;
219	exctags -e --langmap=c:+.ndl -h ndl -L - < cscope.files
220	cscope -b )
221}
222
223#end do_tags()
224
225
226################################################################
227# This creates tarfiles one can use to update a test machine.
228
229do_tar() {
230	git_rev=`git rev-parse --short=8 HEAD`
231
232# NFS (everything)
233	files="
234kernel/misc/$arch64/klmmod
235kernel/misc/$arch64/klmops
236kernel/misc/$arch64/nfs_dlboot
237kernel/misc/$arch64/nfssrv
238kernel/fs/$arch64/nfs
239kernel/sys/$arch64/nfs
240lib/svc/manifest/network/nfs/cbd.xml
241lib/svc/manifest/network/nfs/client.xml
242lib/svc/manifest/network/nfs/mapid.xml
243lib/svc/manifest/network/nfs/nfslogd.xml
244lib/svc/manifest/network/nfs/nlockmgr.xml
245lib/svc/manifest/network/nfs/rquota.xml
246lib/svc/manifest/network/nfs/server.xml
247lib/svc/manifest/network/nfs/status.xml
248lib/svc/method/nfs-client
249lib/svc/method/nfs-server
250lib/svc/method/nlockmgr
251usr/bin/nfsstat
252usr/lib/fs/nfs/$arch64/libshare_nfs.so.1
253usr/lib/fs/nfs/libshare_nfs.so.1
254usr/lib/fs/nfs/dfmounts
255usr/lib/fs/nfs/dfshares
256usr/lib/fs/nfs/nfsfind
257usr/lib/fs/nfs/showmount
258usr/lib/fs/nfs/umount
259usr/lib/nfs/libmapid.so.1
260usr/lib/nfs/lockd
261usr/lib/nfs/mountd
262usr/lib/nfs/nfs4cbd
263usr/lib/nfs/nfsd
264usr/lib/nfs/nfslogd
265usr/lib/nfs/nfsmapid
266usr/lib/nfs/rquotad
267usr/lib/nfs/statd
268usr/lib/reparse/$arch64/libnfs_basic.so.1
269usr/lib/reparse/libnfs_basic.so.1
270usr/sbin/clear_locks
271usr/sbin/exportfs
272usr/sbin/nfsref
273"
274	(cd $ROOT && tar cfj ../../nfs-${git_rev}.tar.bz2 $files)
275
276# KLM kmod
277	files="
278kernel/misc/$arch64/klmmod
279kernel/misc/$arch64/klmops
280"
281	(cd $ROOT && tar cfj ../../klm-${git_rev}.tar.bz2 $files)
282}
283
284# end do_tar()
285
286
287################################################################
288
289if [ "$1" = "" ]; then
290  set '?' # force usage
291fi
292
293set -x
294
295for arg
296do
297  case "$arg" in
298  install)
299    build_tools
300    set -e
301    do_hdrs $arg
302    do_kern $arg
303    do_lib1 $arg
304    do_lib2 $arg
305    do_cmds $arg
306    ;;
307  clean)
308    # intentionally skip: lib1, hdrs, tools
309    do_cmds $arg
310    do_lib2 $arg
311    do_kern $arg
312    ;;
313  clobber)
314    do_cmds $arg
315    do_lib2 $arg
316    do_lib1 $arg
317    do_kern $arg
318    do_hdrs $arg
319    clobber_tools
320    ;;
321  tags)
322    do_tags
323    ;;
324  tar)
325    do_tar
326    ;;
327  *)
328    echo "Usage: $0 {install|clean|clobber|tags|tar}";
329    exit 1;
330    ;;
331  esac
332done
333