14f4cb30bSGordon Ross#!/bin/ksh 24f4cb30bSGordon Ross# 34f4cb30bSGordon Ross# This file and its contents are supplied under the terms of the 44f4cb30bSGordon Ross# Common Development and Distribution License ("CDDL"), version 1.0. 54f4cb30bSGordon Ross# You may only use this file in accordance with the terms of version 64f4cb30bSGordon Ross# 1.0 of the CDDL. 74f4cb30bSGordon Ross# 84f4cb30bSGordon Ross# A full copy of the text of the CDDL should have accompanied this 94f4cb30bSGordon Ross# source. A copy of the CDDL is also available via the Internet at 104f4cb30bSGordon Ross# http://www.illumos.org/license/CDDL. 114f4cb30bSGordon Ross# 124f4cb30bSGordon Ross 134f4cb30bSGordon Ross# 14*7206bf49SGordon Ross# Copyright 2014 Nexenta Systems, Inc. All rights reserved. 154f4cb30bSGordon Ross# 164f4cb30bSGordon Ross 174f4cb30bSGordon Ross# Use distributed make (dmake) by default. 184f4cb30bSGordon Rossmake=${MAKE:-dmake} 194f4cb30bSGordon Ross 204f4cb30bSGordon RossCLOSED_IS_PRESENT=no 214f4cb30bSGordon Rossexport CLOSED_IS_PRESENT 224f4cb30bSGordon Ross 234f4cb30bSGordon Rossexport SOURCEDEBUG=yes 244f4cb30bSGordon Ross 254f4cb30bSGordon Ross[ -n "$SRC" ] || { 264f4cb30bSGordon Ross echo "SRC not set. Run 'ws' or 'bldenv' first." 274f4cb30bSGordon Ross exit 1 284f4cb30bSGordon Ross} 294f4cb30bSGordon Ross 304f4cb30bSGordon Rosscpu=`uname -p` 314f4cb30bSGordon Rosscase $cpu in 324f4cb30bSGordon Rossi386) 334f4cb30bSGordon Ross x=intel 344f4cb30bSGordon Ross mdb_arch="ia32 amd64" 354f4cb30bSGordon Ross arch64=amd64 364f4cb30bSGordon Ross ;; 374f4cb30bSGordon Rosssparc) 384f4cb30bSGordon Ross x=sparc 394f4cb30bSGordon Ross mdb_arch=v9 404f4cb30bSGordon Ross arch64=sparcv9 414f4cb30bSGordon Ross ;; 424f4cb30bSGordon Ross*) echo "Huh?" ; exit 1;; 434f4cb30bSGordon Rossesac 444f4cb30bSGordon Ross 454f4cb30bSGordon Ross################################################################ 464f4cb30bSGordon Ross 474f4cb30bSGordon Rossbuild_tools() { 484f4cb30bSGordon Ross test -f $SRC/tools/proto/root_i386-nd/opt/onbld/bin/genoffsets || 494f4cb30bSGordon Ross (cd $SRC/tools && $make install) 504f4cb30bSGordon Ross (cd $SRC/common/mapfiles; $make install) 514f4cb30bSGordon Ross} 524f4cb30bSGordon Ross 534f4cb30bSGordon Rossclobber_tools() { 544f4cb30bSGordon Ross (cd $SRC/tools && $make clobber) 554f4cb30bSGordon Ross (cd $SRC/common/mapfiles; $make clobber) 564f4cb30bSGordon Ross} 574f4cb30bSGordon Ross 584f4cb30bSGordon Ross################################################################ 594f4cb30bSGordon Ross 604f4cb30bSGordon Rossdo_hdrs() { 614f4cb30bSGordon Ross 624f4cb30bSGordon Rosstarg=$1 634f4cb30bSGordon Rossif [ "$targ" = clobber ] 644f4cb30bSGordon Rossthen 654f4cb30bSGordon Ross (cd $SRC/uts && $make -k clobber_h) 664f4cb30bSGordon Ross (cd $SRC/head && $make clobber) 674f4cb30bSGordon Rossfi 684f4cb30bSGordon Ross 694f4cb30bSGordon Rossif [ "$targ" = install ] 704f4cb30bSGordon Rossthen 714f4cb30bSGordon Ross targ=install_h 724f4cb30bSGordon Ross 734f4cb30bSGordon Ross # Just the parts of "make sgs" we need, and 744f4cb30bSGordon Ross # skip them if they appear to be done. 754f4cb30bSGordon Ross # ... stuff under $SRC 764f4cb30bSGordon Ross test -f $SRC/uts/common/sys/priv_names.h || 774f4cb30bSGordon Ross (cd $SRC/uts && $make -k all_h) 784f4cb30bSGordon Ross 794f4cb30bSGordon Ross test -f $SRC/head/rpcsvc/nispasswd.h || 804f4cb30bSGordon Ross (cd $SRC/head && $make -k install_h) 814f4cb30bSGordon Ross 824f4cb30bSGordon Ross # ... stuff under $ROOT (proto area) 834f4cb30bSGordon Ross test -d $ROOT/usr/include/sys || 844f4cb30bSGordon Ross (cd $SRC && $make rootdirs) 854f4cb30bSGordon Ross test -f $ROOT/usr/include/sys/types.h || 864f4cb30bSGordon Ross (cd $SRC/uts && $make -k install_h) 874f4cb30bSGordon Ross test -f $ROOT/usr/include/rpcsvc/daemon_utils.h || 884f4cb30bSGordon Ross (cd $SRC/head && $make install_h) 894f4cb30bSGordon Ross 904f4cb30bSGordon Ross # always update the smbsrv headers to be safe 914f4cb30bSGordon Ross # test -f $ROOT/usr/include/smbsrv/wintypes.h || 924f4cb30bSGordon Ross (cd $SRC/uts/common/sys && $make -k install_h) 934f4cb30bSGordon Ross (cd $SRC/uts/common/smb && $make -k install_h) 944f4cb30bSGordon Ross (cd $SRC/uts/common/smbsrv && $make -k install_h) 954f4cb30bSGordon Ross 964f4cb30bSGordon Rossfi 974f4cb30bSGordon Ross 984f4cb30bSGordon Ross# Need some library headers too... 994f4cb30bSGordon Rossfor lib in \ 1004f4cb30bSGordon Ross libbsm \ 1014f4cb30bSGordon Ross libcmdutils \ 1024f4cb30bSGordon Ross libcryptoutil \ 1034f4cb30bSGordon Ross libdevid \ 104*7206bf49SGordon Ross libfakekernel \ 1054f4cb30bSGordon Ross libidmap \ 1064f4cb30bSGordon Ross libpam \ 1074f4cb30bSGordon Ross libsec \ 1084f4cb30bSGordon Ross libscf \ 1094f4cb30bSGordon Ross libshare \ 1104f4cb30bSGordon Ross libsmbfs \ 1114f4cb30bSGordon Ross libsqlite \ 1124f4cb30bSGordon Ross libuutil \ 1134f4cb30bSGordon Ross passwdutil \ 1144f4cb30bSGordon Ross smbsrv 1154f4cb30bSGordon Rossdo 1164f4cb30bSGordon Ross (cd $SRC/lib/$lib && $make $targ) 1174f4cb30bSGordon Rossdone 1184f4cb30bSGordon Ross} 1194f4cb30bSGordon Ross 1204f4cb30bSGordon Ross################################################################ 1214f4cb30bSGordon Ross 1224f4cb30bSGordon Rossdo_kern() { 1234f4cb30bSGordon Ross case $1 in 1244f4cb30bSGordon Ross lint) targ=modlintlib ;; 1254f4cb30bSGordon Ross *) targ=$1 ;; 1264f4cb30bSGordon Ross esac 1274f4cb30bSGordon Ross ( unset SOURCEDEBUG ; 1284f4cb30bSGordon Ross (cd $SRC/uts/$x/nsmb && $make $targ) ; 1294f4cb30bSGordon Ross (cd $SRC/uts/$x/smbfs && $make $targ) ; 1304f4cb30bSGordon Ross (cd $SRC/uts/$x/smbsrv && $make $targ) ) 1314f4cb30bSGordon Ross} 1324f4cb30bSGordon Ross 1334f4cb30bSGordon Ross################################################################ 1344f4cb30bSGordon Ross 135*7206bf49SGordon Ross# Note lib1 builds prerequisite libraries not delivered by the 136*7206bf49SGordon Ross# tar file we create below. To accelerate clean/install, we 137*7206bf49SGordon Ross# skip these on clean (but still nuke them for clobber) 138*7206bf49SGordon Ross 139*7206bf49SGordon Rossdo_lib1() { 1404f4cb30bSGordon Ross 1414f4cb30bSGordon Rossfor lib in \ 1424f4cb30bSGordon Ross libavl \ 1434f4cb30bSGordon Ross libcmdutils \ 1444f4cb30bSGordon Ross libsqlite \ 1454f4cb30bSGordon Ross libuutil 1464f4cb30bSGordon Rossdo 1474f4cb30bSGordon Ross (cd $SRC/lib/$lib && $make $1) 1484f4cb30bSGordon Rossdone 149*7206bf49SGordon Ross} 150*7206bf49SGordon Ross 151*7206bf49SGordon Ross# lib2 builds stuff we include in the tar file, 152*7206bf49SGordon Ross# or that we don't mind rebuilding after clean. 153*7206bf49SGordon Ross 154*7206bf49SGordon Rossdo_lib2() { 155*7206bf49SGordon Ross 156*7206bf49SGordon Rossfor lib in \ 157*7206bf49SGordon Ross libfakekernel \ 158*7206bf49SGordon Ross libsmbfs 159*7206bf49SGordon Rossdo 160*7206bf49SGordon Ross (cd $SRC/lib/$lib && $make $1) 161*7206bf49SGordon Rossdone 1624f4cb30bSGordon Ross 1634f4cb30bSGordon Ross(cd $SRC/lib/libshare && $make $1 PLUGINS=smb) 1644f4cb30bSGordon Ross(cd $SRC/lib/smbsrv && $make $1) 1654f4cb30bSGordon Ross(cd $SRC/lib/passwdutil && $make $1) 1664f4cb30bSGordon Ross(cd $SRC/lib/pam_modules/smb && $make $1) 1674f4cb30bSGordon Ross 1684f4cb30bSGordon Ross} 1694f4cb30bSGordon Ross 1704f4cb30bSGordon Ross################################################################ 1714f4cb30bSGordon Ross 1724f4cb30bSGordon Rossdo_cmds() { 1734f4cb30bSGordon Ross 1744f4cb30bSGordon Rosscase $1 in 1754f4cb30bSGordon Rossinstall) 1764f4cb30bSGordon Ross # mount programs need fslib.o 1774f4cb30bSGordon Ross (cd $SRC/cmd/fs.d && $make fslib.o) 1784f4cb30bSGordon Ross (cd $SRC/cmd/fs.d/smbclnt && $make $1 catalog) 1794f4cb30bSGordon Ross ;; 1804f4cb30bSGordon Rossclean|clobber) 1814f4cb30bSGordon Ross (cd $SRC/cmd/fs.d/smbclnt && $make $1) 1824f4cb30bSGordon Ross (cd $SRC/cmd/fs.d && $make ${1}_local) 1834f4cb30bSGordon Ross ;; 1844f4cb30bSGordon Rossesac 1854f4cb30bSGordon Ross 1864f4cb30bSGordon Ross(cd $SRC/cmd/devfsadm && $make $1) 1874f4cb30bSGordon Ross(cd $SRC/cmd/smbsrv && $make $1) 1884f4cb30bSGordon Ross 1894f4cb30bSGordon Ross# Build the MDB modules, WITH the linktest 1904f4cb30bSGordon Ross(cd $SRC/cmd/mdb/tools && $make $1) 1914f4cb30bSGordon Rossfor a in $mdb_arch 1924f4cb30bSGordon Rossdo 1934f4cb30bSGordon Ross case $1 in 1944f4cb30bSGordon Ross install|lint) 1954f4cb30bSGordon Ross (cd $SRC/cmd/mdb/$x/$a/kmdb && 1964f4cb30bSGordon Ross $make kmdb_modlinktest.o ) 1974f4cb30bSGordon Ross ;; 1984f4cb30bSGordon Ross clean|clobber) 1994f4cb30bSGordon Ross (cd $SRC/cmd/mdb/$x/$a/kmdb && 2004f4cb30bSGordon Ross $make -k $1 ) 2014f4cb30bSGordon Ross ;; 2024f4cb30bSGordon Ross esac 2034f4cb30bSGordon Ross 2044f4cb30bSGordon Ross (cd $SRC/cmd/mdb/$x/$a/nsmb && 2054f4cb30bSGordon Ross $make $1 KMDB_LINKTEST_ENABLE= ) 2064f4cb30bSGordon Ross (cd $SRC/cmd/mdb/$x/$a/smbfs && 2074f4cb30bSGordon Ross $make $1 KMDB_LINKTEST_ENABLE= ) 2084f4cb30bSGordon Ross (cd $SRC/cmd/mdb/$x/$a/smbsrv && 2094f4cb30bSGordon Ross $make $1 KMDB_LINKTEST_ENABLE= ) 210*7206bf49SGordon Ross (cd $SRC/cmd/mdb/$x/$a/libfksmbsrv && 211*7206bf49SGordon Ross $make $1 KMDB_LINKTEST_ENABLE= ) 212*7206bf49SGordon Ross 213*7206bf49SGordon Ross# We build these libraries (to the proto area), so we need to 214*7206bf49SGordon Ross# build the mdb modules too so mdb will load them. 215*7206bf49SGordon Ross (cd $SRC/cmd/mdb/$x/$a/libcmdutils && 216*7206bf49SGordon Ross $make $1 ) 217*7206bf49SGordon Ross (cd $SRC/cmd/mdb/$x/$a/libavl && 218*7206bf49SGordon Ross $make $1 ) 219*7206bf49SGordon Ross 2204f4cb30bSGordon Rossdone 2214f4cb30bSGordon Ross 2224f4cb30bSGordon Ross(cd $SRC/cmd/Adm/sun && $make $1) 2234f4cb30bSGordon Ross 2244f4cb30bSGordon Ross# Deal with mode 0400 file annoyance... 2254f4cb30bSGordon Ross# See usr/src/cmd/Adm/sun/Makefile 2264f4cb30bSGordon Rossif [ $1 = install ]; then 2274f4cb30bSGordon Ross chmod a+r $ROOT/var/smb/smbpasswd 2284f4cb30bSGordon Rossfi 2294f4cb30bSGordon Ross} 2304f4cb30bSGordon Ross 2314f4cb30bSGordon Ross 2324f4cb30bSGordon Ross################################################################ 2334f4cb30bSGordon Ross# This builds $SRC/TAGS (and cscope.files) in a helpful order. 2344f4cb30bSGordon Ross 2354f4cb30bSGordon Rossdo_tags() { 2364f4cb30bSGordon Ross (cd $SRC ; 2374f4cb30bSGordon Ross find uts/common/sys -name '*.[ch]' -print |sort 2384f4cb30bSGordon Ross find uts/common/net -name '*.[ch]' -print |sort 2394f4cb30bSGordon Ross find uts/common/netinet -name '*.[ch]' -print |sort 2404f4cb30bSGordon Ross find uts/common/smb -name '*.[ch]' -print |sort 2414f4cb30bSGordon Ross find uts/common/smbsrv -name '*.ndl' -print |sort 2424f4cb30bSGordon Ross find uts/common/smbsrv -name '*.[ch]' -print |sort 2434f4cb30bSGordon Ross find uts/common/fs/smbsrv -name '*.[ch]' -print |sort 2444f4cb30bSGordon Ross find lib/libsmbfs -name '*.[ch]' -print |sort 2454f4cb30bSGordon Ross find lib/smbsrv -name '*.[ch]' -print |sort 2464f4cb30bSGordon Ross find cmd/smbsrv -name '*.[ch]' -print |sort 2474f4cb30bSGordon Ross find common/smbsrv -name '*.[ch]' -print |sort 2484f4cb30bSGordon Ross ) > $SRC/cscope.files 2494f4cb30bSGordon Ross 2504f4cb30bSGordon Ross (cd $SRC ; 2514f4cb30bSGordon Ross exctags -e --langmap=c:+.ndl -h ndl -L - < cscope.files 2524f4cb30bSGordon Ross cscope -b ) 2534f4cb30bSGordon Ross} 2544f4cb30bSGordon Ross 2554f4cb30bSGordon Ross################################################################ 2564f4cb30bSGordon Ross# This creates a tarfile one can use to update a test machine. 2574f4cb30bSGordon Ross 2584f4cb30bSGordon Rossdo_tar() { 2594f4cb30bSGordon Ross files=" 2604f4cb30bSGordon Rossusr/kernel/drv/$arch64/smbsrv 2614f4cb30bSGordon Rossusr/kernel/drv/smbsrv 2624f4cb30bSGordon Rossusr/kernel/kmdb/$arch64/smbsrv 2634f4cb30bSGordon Rossusr/kernel/kmdb/smbsrv 2644f4cb30bSGordon Rossusr/lib/fs/smb/$arch64/libshare_smb.so.1 2654f4cb30bSGordon Rossusr/lib/fs/smb/libshare_smb.so.1 2664f4cb30bSGordon Rossusr/lib/libsmbfs.so.1 2674f4cb30bSGordon Rossusr/lib/mdb/kvm/$arch64/smbsrv.so 2684f4cb30bSGordon Rossusr/lib/mdb/kvm/smbsrv.so 2694f4cb30bSGordon Rossusr/lib/reparse/libreparse_smb.so.1 2704f4cb30bSGordon Rossusr/lib/security/pam_smb_passwd.so.1 2714f4cb30bSGordon Rossusr/lib/smbsrv/libmlrpc.so.1 2724f4cb30bSGordon Rossusr/lib/smbsrv/libmlsvc.so.1 2734f4cb30bSGordon Rossusr/lib/smbsrv/libsmb.so.1 2744f4cb30bSGordon Rossusr/lib/smbsrv/libsmbns.so.1 2754f4cb30bSGordon Rossusr/lib/smbsrv/smbd 2764f4cb30bSGordon Rossusr/sbin/devfsadm 2774f4cb30bSGordon Rossusr/sbin/smbadm 2784f4cb30bSGordon Rossusr/sbin/smbstat 2794f4cb30bSGordon Ross" 2804f4cb30bSGordon Ross 2814f4cb30bSGordon Ross (cd $ROOT && tar cfj ../../smbsrv.tar.bz2 $files) 2824f4cb30bSGordon Ross} 2834f4cb30bSGordon Ross 2844f4cb30bSGordon Ross################################################################ 2854f4cb30bSGordon Ross 2864f4cb30bSGordon Rossif [ "$1" = "" ]; then 2874f4cb30bSGordon Ross set '?' # force usage 2884f4cb30bSGordon Rossfi 2894f4cb30bSGordon Ross 2904f4cb30bSGordon Rossset -x 2914f4cb30bSGordon Ross 2924f4cb30bSGordon Rossfor arg 2934f4cb30bSGordon Rossdo 2944f4cb30bSGordon Ross case "$arg" in 295*7206bf49SGordon Ross install) 2964f4cb30bSGordon Ross build_tools 2974f4cb30bSGordon Ross set -e 2984f4cb30bSGordon Ross do_hdrs $arg 2994f4cb30bSGordon Ross do_kern $arg 300*7206bf49SGordon Ross do_lib1 $arg 301*7206bf49SGordon Ross do_lib2 $arg 3024f4cb30bSGordon Ross do_cmds $arg 3034f4cb30bSGordon Ross ;; 3044f4cb30bSGordon Ross lint) 3054f4cb30bSGordon Ross do_kern $arg 306*7206bf49SGordon Ross do_lib1 $arg 307*7206bf49SGordon Ross do_lib2 $arg 3084f4cb30bSGordon Ross do_cmds $arg 3094f4cb30bSGordon Ross ;; 3104f4cb30bSGordon Ross clean) 311*7206bf49SGordon Ross # intentionally skip: lib1, hdrs, tools 3124f4cb30bSGordon Ross do_cmds $arg 313*7206bf49SGordon Ross do_lib2 $arg 3144f4cb30bSGordon Ross do_kern $arg 3154f4cb30bSGordon Ross ;; 3164f4cb30bSGordon Ross clobber) 3174f4cb30bSGordon Ross do_cmds $arg 318*7206bf49SGordon Ross do_lib2 $arg 319*7206bf49SGordon Ross do_lib1 $arg 3204f4cb30bSGordon Ross do_kern $arg 3214f4cb30bSGordon Ross do_hdrs $arg 3224f4cb30bSGordon Ross clobber_tools 3234f4cb30bSGordon Ross ;; 3244f4cb30bSGordon Ross tags) 3254f4cb30bSGordon Ross do_tags 3264f4cb30bSGordon Ross ;; 3274f4cb30bSGordon Ross tar) 3284f4cb30bSGordon Ross do_tar 3294f4cb30bSGordon Ross ;; 3304f4cb30bSGordon Ross *) 331*7206bf49SGordon Ross echo "Usage: $0 {install|lint|clean|clobber|tags|tar}"; 3324f4cb30bSGordon Ross exit 1; 3334f4cb30bSGordon Ross ;; 3344f4cb30bSGordon Ross esac 3354f4cb30bSGordon Rossdone 336