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