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 2014 Nexenta Systems, Inc. All rights reserved. 15# 16 17# Use distributed make (dmake) by default. 18make=${MAKE:-dmake} 19 20CLOSED_IS_PRESENT=no 21export CLOSED_IS_PRESENT 22 23# Do this if you want to use dbx or gdb 24# export SOURCEDEBUG=yes 25 26[ -n "$SRC" ] || { 27 echo "SRC not set. Run 'ws' or 'bldenv' first." 28 exit 1 29} 30 31cpu=`uname -p` 32case $cpu in 33i386) 34 x=intel 35 kmdb_arch="amd64" 36 mdb_arch="ia32 amd64" 37 arch64=amd64 38 ;; 39sparc) 40 x=sparc 41 kmdb_arch=v9 42 mdb_arch="v7 v9" 43 arch64=sparcv9 44 ;; 45*) echo "Huh?" ; exit 1;; 46esac 47 48################################################################ 49 50build_tools() { 51 test -f $SRC/tools/proto/root_i386-nd/opt/onbld/bin/genoffsets || 52 (cd $SRC/tools && $make install) 53 (cd $SRC/common/mapfiles; $make install) 54} 55 56clobber_tools() { 57 (cd $SRC/tools && $make clobber) 58 (cd $SRC/common/mapfiles; $make clobber) 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 install_h) 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 install_h) 90 test -f $ROOT/usr/include/rpcsvc/daemon_utils.h || 91 (cd $SRC/head && $make install_h) 92 93 # always update the smb headers to be safe 94 (cd $SRC/uts/common/smb && $make -k install_h) 95 96fi 97 98# Need some library headers too... 99for lib in \ 100 libcryptoutil \ 101 libmlrpc \ 102 libpam \ 103 libsec \ 104 libshare \ 105 libsmbfs \ 106 passwdutil 107do 108 (cd $SRC/lib/$lib && $make $targ) 109done 110} 111 112################################################################ 113 114do_kern() { 115 case $1 in 116 lint) targ=modlintlib ;; 117 *) targ=$1 ;; 118 esac 119 ( unset SOURCEDEBUG ; 120 (cd $SRC/uts/$x/nsmb && $make $targ) ; 121 (cd $SRC/uts/$x/smbfs && $make $targ) ) 122} 123 124################################################################ 125 126# Note lib1 builds prerequisite libraries not delivered by the 127# tar file we create below. To accelerate clean/install, we 128# skip these on clean (but still nuke them for clobber) 129 130do_lib1() { 131 : 132} 133 134# lib2 builds stuff we include in the tar file, 135# or that we don't mind rebuilding after clean. 136 137do_lib2() { 138 139(cd $SRC/lib/libsmbfs && $make $1) 140[ "$1" = install ] && 141 (cd $SRC/lib/libsmbfs && $make _msg) 142(cd $SRC/lib/libmlrpc && $make $1) 143(cd $SRC/lib/libshare && $make $1 PLUGINS=smbfs) 144(cd $SRC/lib/passwdutil && $make $1) 145(cd $SRC/lib/pam_modules/smbfs && $make $1) 146 147} 148 149################################################################ 150 151do_cmds() { 152 153case $1 in 154install) 155 # mount programs need fslib.o 156 (cd $SRC/cmd/fs.d && $make fslib.o) 157 (cd $SRC/cmd/fs.d/smbclnt && $make $1 catalog) 158 ;; 159clean|clobber) 160 (cd $SRC/cmd/fs.d/smbclnt && $make $1) 161 (cd $SRC/cmd/fs.d && $make ${1}_local) 162 ;; 163esac 164 165# Build the MDB modules, WITH the linktest 166(cd $SRC/cmd/mdb/tools && $make $1) 167 168# kmdb_arch is 64-bit only 169for a in $kmdb_arch 170do 171 case $1 in 172 install|lint) 173 (cd $SRC/cmd/mdb/$x/$a/kmdb && 174 $make kmdb_modlinktest.o ) 175 ;; 176 clean|clobber) 177 (cd $SRC/cmd/mdb/$x/$a/kmdb && 178 $make -k $1 ) 179 ;; 180 esac 181 182 (cd $SRC/cmd/mdb/$x/$a/nsmb && 183 $make $1 KMDB_LINKTEST_ENABLE= ) 184 (cd $SRC/cmd/mdb/$x/$a/smbfs && 185 $make $1 KMDB_LINKTEST_ENABLE= ) 186done 187} 188 189 190################################################################ 191# This builds $SRC/TAGS (and cscope.files) in a helpful order. 192 193do_tags() { 194 (cd $SRC ; 195 find uts/common/sys -name '*.[ch]' -print |sort 196 find uts/common/net -name '*.[ch]' -print |sort 197 find uts/common/netinet -name '*.[ch]' -print |sort 198 find uts/common/smb -name '*.[ch]' -print |sort 199 find uts/common/netsmb -name '*.[ch]' -print |sort 200 find uts/common/fs/smbclnt -name '*.[ch]' -print |sort 201 find head -name '*.h' -print |sort 202 find lib/libsmbfs -name '*.[ch]' -print |sort 203 find cmd/fs.d/smbclnt -name '*.[ch]' -print |sort 204 find common/smbclnt -name '*.[ch]' -print |sort 205 ) > $SRC/cscope.files 206 207 (cd $SRC ; 208 exctags -e --langmap=c:+.ndl -h ndl -L - < cscope.files 209 cscope -b ) 210} 211 212################################################################ 213# This creates a tarfile one can use to update a test machine. 214 215do_tar() { 216 git_rev=`git rev-parse --short=8 HEAD` 217 files=" 218lib/svc/manifest/network/smb/client.xml 219lib/svc/method/smb-client 220opt/smbcl-tests/tests/srvenum 221opt/smbcl-tests/tests/srvinfo 222opt/smbcl-tests/tests/tconn 223usr/bin/smbutil 224usr/kernel/drv/$arch64/nsmb 225usr/kernel/fs/$arch64/smbfs 226usr/kernel/kmdb/$arch64/nsmb 227usr/kernel/kmdb/$arch64/smbfs 228usr/lib/$arch64/libsmbfs.so.1 229usr/lib/fs/smbfs/$arch64/libshare_smbfs.so.1 230usr/lib/fs/smbfs/chacl 231usr/lib/fs/smbfs/dfshares 232usr/lib/fs/smbfs/libshare_smbfs.so.1 233usr/lib/fs/smbfs/lsacl 234usr/lib/fs/smbfs/mount 235usr/lib/fs/smbfs/share 236usr/lib/fs/smbfs/umount 237usr/lib/fs/smbfs/unshare 238usr/lib/libmlrpc.so.2 239usr/lib/libsmbfs.so.1 240usr/lib/mdb/kvm/$arch64/nsmb.so 241usr/lib/mdb/kvm/$arch64/smbfs.so 242usr/lib/mdb/kvm/nsmb.so 243usr/lib/mdb/kvm/smbfs.so 244usr/lib/security/$arch64/pam_smbfs_login.so.1 245usr/lib/security/pam_smbfs_login.so.1 246usr/lib/smbfs/smbiod 247usr/lib/smbfs/smbiod-svc 248" 249 250 (cd $ROOT && tar cfj ../../smbclnt-${git_rev}.tar.bz2 $files) 251} 252 253################################################################ 254 255if [ "$1" = "" ]; then 256 set '?' # force usage 257fi 258 259set -x 260 261for arg 262do 263 case "$arg" in 264 install) 265 build_tools 266 set -e 267 do_hdrs $arg 268 do_kern $arg 269 do_lib1 $arg 270 do_lib2 $arg 271 do_cmds $arg 272 ;; 273 lint) 274 do_kern $arg 275 do_lib1 $arg 276 do_lib2 $arg 277 do_cmds $arg 278 ;; 279 clean) 280 # intentionally skip: lib1, hdrs, tools 281 do_cmds $arg 282 do_lib2 $arg 283 do_kern $arg 284 ;; 285 clobber) 286 do_cmds $arg 287 do_lib2 $arg 288 do_lib1 $arg 289 do_kern $arg 290 do_hdrs $arg 291 clobber_tools 292 ;; 293 tags) 294 do_tags 295 ;; 296 tar) 297 do_tar 298 ;; 299 *) 300 echo "Usage: $0 {install|lint|clean|clobber|tags|tar}"; 301 exit 1; 302 ;; 303 esac 304done 305