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 23export SOURCEDEBUG=yes 24 25[ -n "$SRC" ] || { 26 echo "SRC not set. Run 'ws' or 'bldenv' first." 27 exit 1 28} 29 30cpu=`uname -p` 31case $cpu in 32i386) 33 x=intel 34 mdb_arch="ia32 amd64" 35 arch64=amd64 36 ;; 37sparc) 38 x=sparc 39 mdb_arch=v9 40 arch64=sparcv9 41 ;; 42*) echo "Huh?" ; exit 1;; 43esac 44 45################################################################ 46 47build_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) 51} 52 53clobber_tools() { 54 (cd $SRC/tools && $make clobber) 55 (cd $SRC/common/mapfiles; $make clobber) 56} 57 58################################################################ 59 60do_hdrs() { 61 62targ=$1 63if [ "$targ" = clobber ] 64then 65 (cd $SRC/uts && $make -k clobber_h) 66 (cd $SRC/head && $make clobber) 67fi 68 69if [ "$targ" = install ] 70then 71 targ=install_h 72 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) 78 79 test -f $SRC/head/rpcsvc/nispasswd.h || 80 (cd $SRC/head && $make -k install_h) 81 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) 89 90 # always update the smbsrv headers to be safe 91 (cd $SRC/uts/common/gssapi && $make -k install_h) 92 (cd $SRC/uts/common/sys && $make -k install_h) 93 (cd $SRC/uts/common/smb && $make -k install_h) 94 (cd $SRC/uts/common/smbsrv && $make -k install_h) 95 96fi 97 98# Need some library headers too... 99for lib in \ 100 libbsm \ 101 libcmdutils \ 102 libcryptoutil \ 103 libdevid \ 104 libfakekernel \ 105 libgss \ 106 libkrb5 \ 107 libidmap \ 108 libpam \ 109 libsec \ 110 libscf \ 111 libshare \ 112 libsmbfs \ 113 libsqlite \ 114 libuutil \ 115 passwdutil \ 116 smbsrv 117do 118 (cd $SRC/lib/$lib && $make $targ) 119done 120} 121 122################################################################ 123 124do_kern() { 125 case $1 in 126 lint) targ=modlintlib ;; 127 *) targ=$1 ;; 128 esac 129 ( unset SOURCEDEBUG ; 130 (cd $SRC/uts/$x/nsmb && $make $targ) ; 131 (cd $SRC/uts/$x/smbfs && $make $targ) ; 132 (cd $SRC/uts/$x/smbsrv && $make $targ) ) 133} 134 135################################################################ 136 137# Note lib1 builds prerequisite libraries not delivered by the 138# tar file we create below. To accelerate clean/install, we 139# skip these on clean (but still nuke them for clobber) 140 141do_lib1() { 142 143for lib in \ 144 libavl \ 145 libgss \ 146 libkrb5 \ 147 libcmdutils \ 148 libsqlite \ 149 libuutil 150do 151 (cd $SRC/lib/$lib && $make $1) 152done 153} 154 155# lib2 builds stuff we include in the tar file, 156# or that we don't mind rebuilding after clean. 157 158do_lib2() { 159 160for lib in \ 161 libfakekernel \ 162 libsmbfs 163do 164 (cd $SRC/lib/$lib && $make $1) 165done 166 167(cd $SRC/lib/libshare && $make $1 PLUGINS=smb) 168(cd $SRC/lib/smbsrv && $make $1) 169(cd $SRC/lib/passwdutil && $make $1) 170(cd $SRC/lib/pam_modules/smb && $make $1) 171 172} 173 174################################################################ 175 176do_cmds() { 177 178case $1 in 179install) 180 # mount programs need fslib.o 181 (cd $SRC/cmd/fs.d && $make fslib.o) 182 (cd $SRC/cmd/fs.d/smbclnt && $make $1 catalog) 183 ;; 184clean|clobber) 185 (cd $SRC/cmd/fs.d/smbclnt && $make $1) 186 (cd $SRC/cmd/fs.d && $make ${1}_local) 187 ;; 188esac 189 190(cd $SRC/cmd/devfsadm && $make $1) 191(cd $SRC/cmd/smbsrv && $make $1) 192 193# Build the MDB modules, WITH the linktest 194(cd $SRC/cmd/mdb/tools && $make $1) 195for a in $mdb_arch 196do 197 case $1 in 198 install|lint) 199 (cd $SRC/cmd/mdb/$x/$a/kmdb && 200 $make kmdb_modlinktest.o ) 201 ;; 202 clean|clobber) 203 (cd $SRC/cmd/mdb/$x/$a/kmdb && 204 $make -k $1 ) 205 ;; 206 esac 207 208 (cd $SRC/cmd/mdb/$x/$a/nsmb && 209 $make $1 KMDB_LINKTEST_ENABLE= ) 210 (cd $SRC/cmd/mdb/$x/$a/smbfs && 211 $make $1 KMDB_LINKTEST_ENABLE= ) 212 (cd $SRC/cmd/mdb/$x/$a/smbsrv && 213 $make $1 KMDB_LINKTEST_ENABLE= ) 214 (cd $SRC/cmd/mdb/$x/$a/libfksmbsrv && 215 $make $1 KMDB_LINKTEST_ENABLE= ) 216 217# We build these libraries (to the proto area), so we need to 218# build the mdb modules too so mdb will load them. 219 (cd $SRC/cmd/mdb/$x/$a/libcmdutils && 220 $make $1 ) 221 (cd $SRC/cmd/mdb/$x/$a/libavl && 222 $make $1 ) 223 224done 225 226(cd $SRC/cmd/Adm/sun && $make $1) 227 228# Deal with mode 0400 file annoyance... 229# See usr/src/cmd/Adm/sun/Makefile 230if [ $1 = install ]; then 231 chmod a+r $ROOT/var/smb/smbpasswd 232fi 233} 234 235 236################################################################ 237# This builds $SRC/TAGS (and cscope.files) in a helpful order. 238 239do_tags() { 240 (cd $SRC ; 241 find uts/common/sys -name '*.[ch]' -print |sort 242 find uts/common/net -name '*.[ch]' -print |sort 243 find uts/common/netinet -name '*.[ch]' -print |sort 244 find uts/common/smb -name '*.[ch]' -print |sort 245 find uts/common/smbsrv -name '*.ndl' -print |sort 246 find uts/common/smbsrv -name '*.[ch]' -print |sort 247 find uts/common/fs/smbsrv -name '*.[ch]' -print |sort 248 find uts/common/gssapi -name '*.[ch]' -print |sort 249 find head -name '*.h' -print |sort 250 find lib/smbsrv -name '*.[ch]' -print |sort 251 find lib/libsmbfs -name '*.[ch]' -print |sort 252 find lib/libads -name '*.[ch]' -print |sort 253 find lib/libgss -name '*.[ch]' -print |sort 254 find cmd/smbsrv -name '*.[ch]' -print |sort 255 find common/smbsrv -name '*.[ch]' -print |sort 256 ) > $SRC/cscope.files 257 258 (cd $SRC ; 259 exctags -e --langmap=c:+.ndl -h ndl -L - < cscope.files 260 cscope -b ) 261} 262 263################################################################ 264# This creates a tarfile one can use to update a test machine. 265 266do_tar() { 267 files=" 268usr/kernel/drv/$arch64/smbsrv 269usr/kernel/drv/smbsrv 270usr/kernel/kmdb/$arch64/smbsrv 271usr/kernel/kmdb/smbsrv 272usr/lib/fs/smb/$arch64/libshare_smb.so.1 273usr/lib/fs/smb/libshare_smb.so.1 274usr/lib/libsmbfs.so.1 275usr/lib/mdb/kvm/$arch64/smbsrv.so 276usr/lib/mdb/kvm/smbsrv.so 277usr/lib/reparse/libreparse_smb.so.1 278usr/lib/security/pam_smb_passwd.so.1 279usr/lib/smbsrv/libmlrpc.so.1 280usr/lib/smbsrv/libmlsvc.so.1 281usr/lib/smbsrv/libsmb.so.1 282usr/lib/smbsrv/libsmbns.so.1 283usr/lib/smbsrv/smbd 284usr/sbin/devfsadm 285usr/sbin/smbadm 286usr/sbin/smbstat 287" 288 289 (cd $ROOT && tar cfj ../../smbsrv.tar.bz2 $files) 290} 291 292################################################################ 293 294if [ "$1" = "" ]; then 295 set '?' # force usage 296fi 297 298set -x 299 300for arg 301do 302 case "$arg" in 303 install) 304 build_tools 305 set -e 306 do_hdrs $arg 307 do_kern $arg 308 do_lib1 $arg 309 do_lib2 $arg 310 do_cmds $arg 311 ;; 312 lint) 313 do_kern $arg 314 do_lib1 $arg 315 do_lib2 $arg 316 do_cmds $arg 317 ;; 318 clean) 319 # intentionally skip: lib1, hdrs, tools 320 do_cmds $arg 321 do_lib2 $arg 322 do_kern $arg 323 ;; 324 clobber) 325 do_cmds $arg 326 do_lib2 $arg 327 do_lib1 $arg 328 do_kern $arg 329 do_hdrs $arg 330 clobber_tools 331 ;; 332 tags) 333 do_tags 334 ;; 335 tar) 336 do_tar 337 ;; 338 *) 339 echo "Usage: $0 {install|lint|clean|clobber|tags|tar}"; 340 exit 1; 341 ;; 342 esac 343done 344