9197 tools/quick scripts broken after 8685
[unleashed.git] / usr / src / tools / quick / make-zfs
blobf88deeff35ea6cdff7df5b26580cdac250f31ccb
1 #!/bin/ksh
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.
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.
14 # Copyright 2018 Nexenta Systems, Inc. All rights reserved.
17 # Use distributed make (dmake) by default.
18 make=${MAKE:-dmake}
20 CLOSED_IS_PRESENT=no
21 export CLOSED_IS_PRESENT
23 [ -n "$SRC" ] || {
24 echo "SRC not set. Run 'ws' or 'bldenv' first."
25 exit 1
28 cpu=`uname -p`
29 case $cpu in
30 i386)
31 x=intel
32 kmdb_arch="amd64"
33 mdb_arch="ia32 amd64"
34 arch32=i86
35 arch64=amd64
37 sparc)
38 x=sparc
39 kmdb_arch=v9
40 mdb_arch="v7 v9"
41 arch32=sparc
42 arch64=sparcv9
44 *) echo "Huh?" ; exit 1;;
45 esac
47 ################################################################
49 build_tools() {
50 test -f $SRC/tools/proto/root_i386-nd/opt/onbld/bin/genoffsets ||
51 (cd $SRC/tools && $make install)
52 (cd $SRC/common/mapfiles; $make install)
55 clobber_tools() {
56 (cd $SRC/tools && $make clobber)
57 (cd $SRC/common/mapfiles; $make clobber)
60 ################################################################
62 do_hdrs() {
64 targ=$1
65 if [ "$targ" = clobber ]
66 then
67 (cd $SRC/uts && $make -k clobber_h)
68 (cd $SRC/head && $make clobber)
71 if [ "$targ" = install ]
72 then
73 targ=install_h
75 # Just the parts of "make sgs" we need, and
76 # skip them if they appear to be done.
77 # ... stuff under $SRC
78 test -f $SRC/uts/common/sys/priv_names.h ||
79 (cd $SRC/uts && $make -k all_h)
81 test -f $SRC/head/rpcsvc/nispasswd.h ||
82 (cd $SRC/head && $make -k install_h)
84 # ... stuff under $ROOT (proto area)
85 test -d $ROOT/usr/include/sys ||
86 (cd $SRC && $make rootdirs)
87 test -f $ROOT/usr/include/sys/types.h ||
88 (cd $SRC/uts && $make -k install_h)
89 test -f $ROOT/usr/include/rpcsvc/daemon_utils.h ||
90 (cd $SRC/head && $make install_h)
92 # always update the sys headers to be safe
93 (cd $SRC/uts/common/sys && $make -k install_h)
97 # Need some library headers too...
98 for lib in \
99 libbsm \
100 libcmdutils \
101 libcryptoutil \
102 libdevid \
103 libdiskmgt \
104 libidmap \
105 libpam \
106 libsec \
107 libscf \
108 libshare \
109 libuutil \
110 libzpool \
111 libzfs_core \
112 libzfs \
113 libzfs_jni
115 (cd $SRC/lib/$lib && $make $targ)
116 done
117 # Should fix the Makefile here so all_h or install_h works.
118 (cd $SRC/lib/libzpool/$cpu && $make ../common/zfs.h)
121 ################################################################
123 do_kern() {
124 case $1 in
125 lint) targ=modlintlib ;;
126 *) targ=$1 ;;
127 esac
128 (cd $SRC/uts/$x/zfs && $make $targ)
131 ################################################################
133 # Build all libraries used by the other targets in here.
135 # Run this once (at least) in each new workspace where you
136 # will run "make-zfs install", if you want to avoid linking
137 # against the libraries from your build host.
139 do_deplibs() {
141 # install all the lib headers
142 if [ "$1" = install ] ; then
143 (cd $SRC/lib && $make install_h)
146 # Wow, building libc takes a while. Really want that?
147 for lib in \
148 libc \
149 libavl \
150 libnvpair \
151 libsec \
152 libcmdutils \
153 libdevinfo \
154 libuutil \
155 libbrand \
156 libzonecfg \
157 libinetutil \
158 libdladm \
159 libdlpi \
160 libdiskmgt \
161 libumem \
162 libdisasm \
163 libidmap \
164 libdevid \
165 libsaveargs
167 (cd $SRC/lib/$lib && $make $1)
168 done
171 ################################################################
173 do_libs() {
175 for lib in \
176 libavl \
177 libcmdutils \
178 libuutil \
179 libzpool \
180 libzfs_core \
181 libzfs \
182 libzfs_jni \
183 pyzfs
185 (cd $SRC/lib/$lib && $make $1)
186 done
187 (cd $SRC/lib/libshare && $make $1 PLUGINS=)
190 ################################################################
192 do_cmds() {
194 for cmd in \
195 availdevs \
196 isaexec \
197 fstyp \
198 zdb \
199 zfs \
200 zhack \
201 zinject \
202 zpool \
203 ztest \
204 zstreamdump \
205 pyzfs
207 (cd $SRC/cmd/$cmd && $make $1)
208 done
210 case $1 in
211 install)
212 # mount programs need fslib.o
213 (cd $SRC/cmd/fs.d/zfs && $make $1)
214 # Build just the ZFS devfsadm module
215 (cd $SRC/cmd/devfsadm/$cpu && $make SUNW_zfs_link.so \
216 ${ROOT}/usr/lib/devfsadm/linkmod \
217 ${ROOT}/usr/lib/devfsadm/linkmod/SUNW_zfs_link.so )
219 clean|clobber)
220 (cd $SRC/cmd/fs.d/zfs && $make clobber)
221 (cd $SRC/cmd/fs.d && $make ${1}_local)
222 (cd $SRC/cmd/devfsadm && $make $1)
224 esac
226 (cd $SRC/cmd/syseventd/modules/zfs_mod && $make $1)
228 # Build the MDB modules, WITH the linktest
229 (cd $SRC/cmd/mdb/tools && $make $1)
231 # kmdb_arch is 64-bit only
232 for a in $kmdb_arch
234 case $1 in
235 install|lint)
236 (cd $SRC/cmd/mdb/$x/$a/kmdb &&
237 $make kmdb_modlinktest.o )
239 clean|clobber)
240 (cd $SRC/cmd/mdb/$x/$a/kmdb &&
241 $make -k $1 )
243 esac
245 (cd $SRC/cmd/mdb/$x/$a/zfs &&
246 $make $1 KMDB_LINKTEST_ENABLE= )
248 done
250 # mdb_arch is both 32-bit & 64-bit
251 for a in $mdb_arch
253 (cd $SRC/cmd/mdb/$x/$a/libzpool &&
254 $make $1 )
256 done
259 ################################################################
261 do_mans() {
263 case "$1" in
264 install)
265 (cd $SRC/man/man1m && make \
266 $ROOT/usr/share/man/man1m/zdb.1m \
267 $ROOT/usr/share/man/man1m/zfs.1m \
268 $ROOT/usr/share/man/man1m/zfs-program.1m \
269 $ROOT/usr/share/man/man1m/zpool.1m )
270 (cd $SRC/man/man5 && make \
271 $ROOT/usr/share/man/man5/zpool-features.5 )
273 lint)
274 (cd $SRC/man/man1m && make zdb.1m.check zfs.1m.check zfs-program.1m.check \
275 zpool.1m.check)
276 (cd $SRC/man/man5 && make zpool-features.5.check)
279 (cd $SRC/man/man1m && make $1)
280 (cd $SRC/man/man5 && make $)
282 esac
285 ################################################################
286 # This builds $SRC/TAGS (and cscope.files) in a helpful order.
288 do_tags() {
289 (cd $SRC ;
290 find uts/common/sys -name '*.[ch]' -print |sort
291 find uts/common/fs/zfs -name '*.[ch]' -print |sort
292 find lib/libzpool -name '*.[ch]' -print |sort
293 find lib/libzfs -name '*.[ch]' -print |sort
294 find cmd/zpool -name '*.[ch]' -print |sort
295 find cmd/zfs -name '*.[ch]' -print |sort
296 find cmd/zdb -name '*.[ch]' -print |sort
297 find cmd/zhack -name '*.[ch]' -print |sort
298 find cmd/zinject -name '*.[ch]' -print |sort
299 find cmd/ztest -name '*.[ch]' -print |sort
300 find common/zfs -name '*.[ch]' -print |sort
301 echo cmd/mdb/common/modules/zfs/zfs.c
302 ) > $SRC/cscope.files
304 (cd $SRC ;
305 exctags -e --langmap=c:+.ndl -h ndl -L - < cscope.files
306 cscope -b )
309 ################################################################
310 # This creates a tarfile one can use to update a test machine.
312 do_tar() {
313 git_rev=`git rev-parse --short=8 HEAD`
314 files="
315 kernel/drv/$arch64/zfs
316 kernel/fs/$arch64/zfs
317 kernel/kmdb/$arch64/zfs
318 lib/$arch64/libzfs.so.1
319 lib/$arch64/libzfs_core.so.1
320 lib/libzfs.so.1
321 lib/libzfs_core.so.1
322 usr/bin/$arch32/ztest
323 usr/bin/$arch64/ztest
324 usr/lib/$arch64/libzfs_jni.so.1
325 usr/lib/$arch64/libzpool.so.1
326 usr/lib/devfsadm/linkmod/SUNW_zfs_link.so
327 usr/lib/fs/zfs/bootinstall
328 usr/lib/fs/zfs/fstyp.so.1
329 usr/lib/libzfs_jni.so.1
330 usr/lib/libzpool.so.1
331 usr/lib/mdb/kvm/$arch64/zfs.so
332 usr/lib/mdb/proc/$arch64/libzpool.so
333 usr/lib/mdb/proc/libzpool.so
334 sbin/zfs
335 sbin/zpool
336 usr/lib/sysevent/modules/zfs_mod.so
337 usr/lib/zfs/availdevs
338 usr/lib/zfs/pyzfs.py
339 usr/lib/zfs/pyzfs.pyc
340 usr/sbin/$arch32/zdb
341 usr/sbin/$arch64/zdb
342 usr/sbin/$arch32/zhack
343 usr/sbin/$arch64/zhack
344 usr/sbin/$arch32/zinject
345 usr/sbin/$arch64/zinject
346 usr/sbin/zstreamdump
347 usr/share/man/man1m/zdb.1m
348 usr/share/man/man1m/zfs.1m
349 usr/share/man/man1m/zfs-program.1m
350 usr/share/man/man1m/zpool.1m
351 usr/share/man/man5/zpool-features.5
353 (cd $ROOT && tar cfj ../../zfs-${git_rev}.tar.bz2 $files)
356 ################################################################
358 if [ "$1" = "" ]; then
359 set '?' # force usage
362 set -x
364 for arg
366 case "$arg" in
367 install)
368 build_tools
369 set -e
370 do_hdrs $arg
371 do_kern $arg
372 do_libs $arg
373 do_cmds $arg
374 do_mans $arg
376 lint)
377 do_kern $arg
378 do_libs $arg
379 do_cmds $arg
380 do_mans $arg
382 clean)
383 do_mans $arg
384 do_cmds $arg
385 do_libs $arg
386 do_kern $arg
388 clobber)
389 do_mans $arg
390 do_cmds $arg
391 do_libs $arg
392 do_kern $arg
393 do_hdrs $arg
394 clobber_tools
396 deplibs)
397 build_tools
398 set -e
399 do_hdrs install
400 do_deplibs install
402 tags)
403 do_tags
405 tar)
406 do_tar
409 echo "Usage: $0 {install|lint|clean|clobber|deplibs|tags|tar}";
410 exit 1;
412 esac
413 done