dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / usr / src / tools / quick / make-zfs
blob787bb2bf3e87dd90b7540b1993d7b96e283b4a7b
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 2014 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 mdb_arch="ia32 amd64"
33 arch32=i86
34 arch64=amd64
36 sparc)
37 x=sparc
38 mdb_arch=v9
39 arch32=sparc
40 arch64=sparcv9
42 *) echo "Huh?" ; exit 1;;
43 esac
45 ################################################################
47 build_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)
53 clobber_tools() {
54 (cd $SRC/tools && $make clobber)
55 (cd $SRC/common/mapfiles; $make clobber)
58 ################################################################
60 do_hdrs() {
62 targ=$1
63 if [ "$targ" = clobber ]
64 then
65 (cd $SRC/uts && $make -k clobber_h)
66 (cd $SRC/head && $make clobber)
69 if [ "$targ" = install ]
70 then
71 targ=install_h
73 # Just the parts of "make sgs" we need, and
74 # skip them if they appear to be done.
75 # ... stuff under $SRC
76 test -f $SRC/uts/common/sys/priv_names.h ||
77 (cd $SRC/uts && $make -k all_h)
79 test -f $SRC/head/rpcsvc/nispasswd.h ||
80 (cd $SRC/head && $make -k install_h)
82 # ... stuff under $ROOT (proto area)
83 test -d $ROOT/usr/include/sys ||
84 (cd $SRC && $make rootdirs)
85 test -f $ROOT/usr/include/sys/types.h ||
86 (cd $SRC/uts && $make -k install_h)
87 test -f $ROOT/usr/include/rpcsvc/daemon_utils.h ||
88 (cd $SRC/head && $make install_h)
90 # always update the sys headers to be safe
91 (cd $SRC/uts/common/sys && $make -k install_h)
95 # Need some library headers too...
96 for lib in \
97 libbsm \
98 libcmdutils \
99 libcryptoutil \
100 libdevid \
101 libdiskmgt \
102 libidmap \
103 libpam \
104 libsec \
105 libscf \
106 libshare \
107 libuutil \
108 libzpool \
109 libzfs_core \
110 libzfs \
112 (cd $SRC/lib/$lib && $make $targ)
113 done
114 # Should fix the Makefile here so all_h or install_h works.
115 (cd $SRC/lib/libzpool/$cpu && $make ../common/zfs.h)
118 ################################################################
120 do_kern() {
121 case $1 in
122 lint) targ=modlintlib ;;
123 *) targ=$1 ;;
124 esac
125 (cd $SRC/uts/$x/zfs && $make $targ)
128 ################################################################
130 # Build all libraries used by the other targets in here.
132 # Run this once (at least) in each new workspace where you
133 # will run "make-zfs install", if you want to avoid linking
134 # against the libraries from your build host.
136 do_deplibs() {
138 # install all the lib headers
139 if [ "$1" = install ] ; then
140 (cd $SRC/lib && $make install_h)
143 # Wow, building libc takes a while. Really want that?
144 for lib in \
145 libc \
146 libavl \
147 libnvpair \
148 libsec \
149 libcmdutils \
150 libdevinfo \
151 libuutil \
152 libbrand \
153 libzonecfg \
154 libinetutil \
155 libdladm \
156 libdlpi \
157 libdiskmgt \
158 libumem \
159 libdisasm \
160 libidmap \
161 libdevid \
162 libsaveargs
164 (cd $SRC/lib/$lib && $make $1)
165 done
168 ################################################################
170 do_libs() {
172 for lib in \
173 libavl \
174 libcmdutils \
175 libuutil \
176 libzpool \
177 libzfs_core \
178 libzfs \
179 pyzfs
181 (cd $SRC/lib/$lib && $make $1)
182 done
183 (cd $SRC/lib/libshare && $make $1 PLUGINS=)
186 ################################################################
188 do_cmds() {
190 for cmd in \
191 isaexec \
192 fstyp \
193 zdb \
194 zfs \
195 zhack \
196 zinject \
197 zpool \
198 ztest \
199 zstreamdump \
200 pyzfs
202 (cd $SRC/cmd/$cmd && $make $1)
203 done
205 case $1 in
206 install)
207 # mount programs need fslib.o
208 (cd $SRC/cmd/fs.d/zfs && $make $1)
209 # Build just the ZFS devfsadm module
210 (cd $SRC/cmd/devfsadm/$cpu && $make SUNW_zfs_link.so \
211 ${ROOT}/usr/lib/devfsadm/linkmod \
212 ${ROOT}/usr/lib/devfsadm/linkmod/SUNW_zfs_link.so )
214 clean|clobber)
215 (cd $SRC/cmd/fs.d/zfs && $make clobber)
216 (cd $SRC/cmd/fs.d && $make ${1}_local)
217 (cd $SRC/cmd/devfsadm && $make $1)
219 esac
221 (cd $SRC/cmd/syseventd/modules/zfs_mod && $make $1)
223 # Build the MDB modules, WITH the linktest
224 (cd $SRC/cmd/mdb/tools && $make $1)
225 for a in $mdb_arch
227 case $1 in
228 install|lint)
229 (cd $SRC/cmd/mdb/$x/$a/kmdb &&
230 $make kmdb_modlinktest.o )
232 clean|clobber)
233 (cd $SRC/cmd/mdb/$x/$a/kmdb &&
234 $make -k $1 )
236 esac
238 (cd $SRC/cmd/mdb/$x/$a/zfs &&
239 $make $1 KMDB_LINKTEST_ENABLE= )
241 (cd $SRC/cmd/mdb/$x/$a/libzpool &&
242 $make $1 )
244 done
247 ################################################################
249 do_mans() {
251 case "$1" in
252 install)
253 (cd $SRC/man/man1m && make \
254 $ROOT/usr/share/man/man1m/zdb.1m \
255 $ROOT/usr/share/man/man1m/zfs.1m \
256 $ROOT/usr/share/man/man1m/zfs-program.1m \
257 $ROOT/usr/share/man/man1m/zpool.1m )
258 (cd $SRC/man/man5 && make \
259 $ROOT/usr/share/man/man5/zpool-features.5 )
261 lint)
262 (cd $SRC/man/man1m && make zdb.1m.check zfs.1m.check zfs-program.1m.check \
263 zpool.1m.check)
264 (cd $SRC/man/man5 && make zpool-features.5.check)
267 (cd $SRC/man/man1m && make $1)
268 (cd $SRC/man/man5 && make $)
270 esac
273 ################################################################
274 # This builds $SRC/TAGS (and cscope.files) in a helpful order.
276 do_tags() {
277 (cd $SRC ;
278 find uts/common/sys -name '*.[ch]' -print |sort
279 find uts/common/fs/zfs -name '*.[ch]' -print |sort
280 find lib/libzpool -name '*.[ch]' -print |sort
281 find lib/libzfs -name '*.[ch]' -print |sort
282 find cmd/zpool -name '*.[ch]' -print |sort
283 find cmd/zfs -name '*.[ch]' -print |sort
284 find cmd/zdb -name '*.[ch]' -print |sort
285 find cmd/zhack -name '*.[ch]' -print |sort
286 find cmd/zinject -name '*.[ch]' -print |sort
287 find cmd/ztest -name '*.[ch]' -print |sort
288 find common/zfs -name '*.[ch]' -print |sort
289 echo cmd/mdb/common/modules/zfs/zfs.c
290 ) > $SRC/cscope.files
292 (cd $SRC ;
293 exctags -e --langmap=c:+.ndl -h ndl -L - < cscope.files
294 cscope -b )
297 ################################################################
298 # This creates a tarfile one can use to update a test machine.
300 do_tar() {
301 git_rev=`git rev-parse --short=8 HEAD`
302 files="
303 kernel/drv/$arch64/zfs
304 kernel/drv/zfs
305 kernel/fs/$arch64/zfs
306 kernel/fs/zfs
307 kernel/kmdb/$arch64/zfs
308 kernel/kmdb/zfs
309 lib/$arch64/libzfs.so.1
310 lib/$arch64/libzfs_core.so.1
311 lib/libzfs.so.1
312 lib/libzfs_core.so.1
313 usr/bin/$arch32/ztest
314 usr/bin/$arch64/ztest
315 usr/lib/$arch64/libzpool.so.1
316 usr/lib/devfsadm/linkmod/SUNW_zfs_link.so
317 usr/lib/fs/zfs/bootinstall
318 usr/lib/fs/zfs/fstyp.so.1
319 usr/lib/libzpool.so.1
320 usr/lib/mdb/kvm/$arch64/zfs.so
321 usr/lib/mdb/kvm/zfs.so
322 usr/lib/mdb/proc/$arch64/libzpool.so
323 usr/lib/mdb/proc/libzpool.so
324 sbin/zfs
325 sbin/zpool
326 usr/lib/sysevent/modules/zfs_mod.so
327 usr/lib/zfs/pyzfs.py
328 usr/lib/zfs/pyzfs.pyc
329 usr/sbin/$arch32/zdb
330 usr/sbin/$arch64/zdb
331 usr/sbin/$arch32/zhack
332 usr/sbin/$arch64/zhack
333 usr/sbin/$arch32/zinject
334 usr/sbin/$arch64/zinject
335 usr/sbin/zstreamdump
336 usr/share/man/man1m/zdb.1m
337 usr/share/man/man1m/zfs.1m
338 usr/share/man/man1m/zfs-program.1m
339 usr/share/man/man1m/zpool.1m
340 usr/share/man/man5/zpool-features.5
342 (cd $ROOT && tar cfj ../../zfs-${git_rev}.tar.bz2 $files)
345 ################################################################
347 if [ "$1" = "" ]; then
348 set '?' # force usage
351 set -x
353 for arg
355 case "$arg" in
356 install)
357 build_tools
358 set -e
359 do_hdrs $arg
360 do_kern $arg
361 do_libs $arg
362 do_cmds $arg
363 do_mans $arg
365 lint)
366 do_kern $arg
367 do_libs $arg
368 do_cmds $arg
369 do_mans $arg
371 clean)
372 do_mans $arg
373 do_cmds $arg
374 do_libs $arg
375 do_kern $arg
377 clobber)
378 do_mans $arg
379 do_cmds $arg
380 do_libs $arg
381 do_kern $arg
382 do_hdrs $arg
383 clobber_tools
385 deplibs)
386 build_tools
387 set -e
388 do_hdrs install
389 do_deplibs install
391 tags)
392 do_tags
394 tar)
395 do_tar
398 echo "Usage: $0 {install|lint|clean|clobber|deplibs|tags|tar}";
399 exit 1;
401 esac
402 done