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