Merge remote-tracking branch 'origin/master'
[unleashed/lotheac.git] / usr / src / tools / quick / make-zfs
bloba3c3da78ad37b141449bb9cfc17b1849e23cbebb
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=i386
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 \
114 (cd $SRC/lib/$lib && $make $targ)
115 done
116 # Should fix the Makefile here so all_h or install_h works.
117 (cd $SRC/lib/libzpool/$cpu && $make ../common/zfs.h)
120 ################################################################
122 do_kern() {
123 case $1 in
124 lint) targ=modlintlib ;;
125 *) targ=$1 ;;
126 esac
127 (cd $SRC/uts/$x/zfs && $make $targ)
130 ################################################################
132 # Build all libraries used by the other targets in here.
134 # Run this once (at least) in each new workspace where you
135 # will run "make-zfs install", if you want to avoid linking
136 # against the libraries from your build host.
138 do_deplibs() {
140 # install all the lib headers
141 if [ "$1" = install ] ; then
142 (cd $SRC/lib && $make install_h)
145 # Wow, building libc takes a while. Really want that?
146 for lib in \
147 libc \
148 libavl \
149 libnvpair \
150 libsec \
151 libcmdutils \
152 libdevinfo \
153 libuutil \
154 libbrand \
155 libzonecfg \
156 libinetutil \
157 libdladm \
158 libdlpi \
159 libdiskmgt \
160 libumem \
161 libdisasm \
162 libidmap \
163 libdevid \
164 libsaveargs
166 (cd $SRC/lib/$lib && $make $1)
167 done
170 ################################################################
172 do_libs() {
174 for lib in \
175 libavl \
176 libcmdutils \
177 libuutil \
178 libzpool \
179 libzfs_core \
180 libzfs
182 (cd $SRC/lib/$lib && $make $1)
183 done
184 (cd $SRC/lib/libshare && $make $1 PLUGINS=)
187 ################################################################
189 do_cmds() {
191 for cmd in \
192 isaexec \
193 fstyp \
194 zdb \
195 zfs \
196 zhack \
197 zinject \
198 zpool \
199 ztest \
200 zstreamdump
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)
226 # kmdb_arch is 64-bit only
227 for a in $kmdb_arch
229 case $1 in
230 install|lint)
231 (cd $SRC/cmd/mdb/$x/$a/kmdb &&
232 $make kmdb_modlinktest.o )
234 clean|clobber)
235 (cd $SRC/cmd/mdb/$x/$a/kmdb &&
236 $make -k $1 )
238 esac
240 (cd $SRC/cmd/mdb/$x/$a/zfs &&
241 $make $1 KMDB_LINKTEST_ENABLE= )
243 done
245 # mdb_arch is both 32-bit & 64-bit
246 for a in $mdb_arch
248 (cd $SRC/cmd/mdb/$x/$a/libzpool &&
249 $make $1 )
251 done
254 ################################################################
256 do_mans() {
258 case "$1" in
259 install)
260 (cd $SRC/man/man5 && make \
261 $ROOT/usr/share/man/man5/zpool-features.5 )
262 (cd $SRC/man/man8 && make \
263 $ROOT/usr/share/man/man8/zdb.8 \
264 $ROOT/usr/share/man/man8/zfs.8 \
265 $ROOT/usr/share/man/man8/zfs-program.8 \
266 $ROOT/usr/share/man/man8/zpool.8 )
268 lint)
269 (cd $SRC/man/man5 && make zpool-features.5.check)
270 (cd $SRC/man/man8 && make zdb.8.check zfs.8.check zfs-program.8.check \
271 zpool.8.check)
274 (cd $SRC/man/man8 && make $1)
275 (cd $SRC/man/man5 && make $)
277 esac
280 ################################################################
281 # This builds $SRC/TAGS (and cscope.files) in a helpful order.
283 do_tags() {
284 (cd $SRC ;
285 find uts/common/sys -name '*.[ch]' -print |sort
286 find uts/common/fs/zfs -name '*.[ch]' -print |sort
287 find lib/libzpool -name '*.[ch]' -print |sort
288 find lib/libzfs -name '*.[ch]' -print |sort
289 find cmd/zpool -name '*.[ch]' -print |sort
290 find cmd/zfs -name '*.[ch]' -print |sort
291 find cmd/zdb -name '*.[ch]' -print |sort
292 find cmd/zhack -name '*.[ch]' -print |sort
293 find cmd/zinject -name '*.[ch]' -print |sort
294 find cmd/ztest -name '*.[ch]' -print |sort
295 find common/zfs -name '*.[ch]' -print |sort
296 echo cmd/mdb/common/modules/zfs/zfs.c
297 ) > $SRC/cscope.files
299 (cd $SRC ;
300 exctags -e --langmap=c:+.ndl -h ndl -L - < cscope.files
301 cscope -b )
304 ################################################################
305 # This creates a tarfile one can use to update a test machine.
307 do_tar() {
308 git_rev=`git rev-parse --short=8 HEAD`
309 files="
310 kernel/drv/$arch64/zfs
311 kernel/fs/$arch64/zfs
312 kernel/kmdb/$arch64/zfs
313 lib/$arch64/libzfs.so.1
314 lib/$arch64/libzfs_core.so.1
315 lib/libzfs.so.1
316 lib/libzfs_core.so.1
317 usr/bin/$arch32/ztest
318 usr/bin/$arch64/ztest
319 usr/lib/$arch64/libzpool.so.1
320 usr/lib/devfsadm/linkmod/SUNW_zfs_link.so
321 usr/lib/fs/zfs/bootinstall
322 usr/lib/fs/zfs/fstyp.so.1
323 usr/lib/libzpool.so.1
324 usr/lib/mdb/kvm/$arch64/zfs.so
325 usr/lib/mdb/proc/$arch64/libzpool.so
326 usr/lib/mdb/proc/libzpool.so
327 sbin/zfs
328 sbin/zpool
329 usr/lib/sysevent/modules/zfs_mod.so
330 usr/sbin/$arch32/zdb
331 usr/sbin/$arch64/zdb
332 usr/sbin/$arch32/zhack
333 usr/sbin/$arch64/zhack
334 usr/sbin/$arch32/zinject
335 usr/sbin/$arch64/zinject
336 usr/sbin/zstreamdump
337 usr/share/man/man5/zpool-features.5
338 usr/share/man/man8/zdb.8
339 usr/share/man/man8/zfs.8
340 usr/share/man/man8/zfs-program.8
341 usr/share/man/man8/zpool.8
343 (cd $ROOT && tar cfj ../../zfs-${git_rev}.tar.bz2 $files)
346 ################################################################
348 if [ "$1" = "" ]; then
349 set '?' # force usage
352 set -x
354 for arg
356 case "$arg" in
357 install)
358 build_tools
359 set -e
360 do_hdrs $arg
361 do_kern $arg
362 do_libs $arg
363 do_cmds $arg
364 do_mans $arg
366 lint)
367 do_kern $arg
368 do_libs $arg
369 do_cmds $arg
370 do_mans $arg
372 clean)
373 do_mans $arg
374 do_cmds $arg
375 do_libs $arg
376 do_kern $arg
378 clobber)
379 do_mans $arg
380 do_cmds $arg
381 do_libs $arg
382 do_kern $arg
383 do_hdrs $arg
384 clobber_tools
386 deplibs)
387 build_tools
388 set -e
389 do_hdrs install
390 do_deplibs install
392 tags)
393 do_tags
395 tar)
396 do_tar
399 echo "Usage: $0 {install|lint|clean|clobber|deplibs|tags|tar}";
400 exit 1;
402 esac
403 done