make-smbsrv revision 12b65585e720714b31036daaa2b30eb76014048e
830N/A#!/bin/ksh
830N/A#
830N/A# This file and its contents are supplied under the terms of the
830N/A# Common Development and Distribution License ("CDDL"), version 1.0.
830N/A# You may only use this file in accordance with the terms of version
830N/A# 1.0 of the CDDL.
830N/A#
830N/A# A full copy of the text of the CDDL should have accompanied this
830N/A# source. A copy of the CDDL is also available via the Internet at
830N/A# http://www.illumos.org/license/CDDL.
830N/A#
830N/A
830N/A#
830N/A# Copyright 2014 Nexenta Systems, Inc. All rights reserved.
830N/A#
830N/A
830N/A# Use distributed make (dmake) by default.
830N/Amake=${MAKE:-dmake}
830N/A
830N/ACLOSED_IS_PRESENT=no
830N/Aexport CLOSED_IS_PRESENT
830N/A
839N/Aexport SOURCEDEBUG=yes
839N/A
830N/A[ -n "$SRC" ] || {
830N/A echo "SRC not set. Run 'ws' or 'bldenv' first."
1258N/A exit 1
1258N/A}
830N/A
830N/Acpu=`uname -p`
830N/Acase $cpu in
830N/Ai386)
830N/A x=intel
830N/A mdb_arch="ia32 amd64"
830N/A arch64=amd64
830N/A ;;
830N/Asparc)
1244N/A x=sparc
1244N/A mdb_arch=v9
830N/A arch64=sparcv9
1244N/A ;;
1244N/A*) echo "Huh?" ; exit 1;;
844N/Aesac
844N/A
830N/A################################################################
830N/A
830N/Abuild_tools() {
830N/A test -f $SRC/tools/proto/root_i386-nd/opt/onbld/bin/genoffsets ||
830N/A (cd $SRC/tools && $make install)
830N/A (cd $SRC/common/mapfiles; $make install)
830N/A}
830N/A
830N/Aclobber_tools() {
830N/A (cd $SRC/tools && $make clobber)
830N/A (cd $SRC/common/mapfiles; $make clobber)
830N/A}
830N/A
830N/A################################################################
844N/A
844N/Ado_hdrs() {
830N/A
902N/Atarg=$1
902N/Aif [ "$targ" = clobber ]
854N/Athen
854N/A (cd $SRC/uts && $make -k clobber_h)
830N/A (cd $SRC/head && $make clobber)
830N/Afi
830N/A
902N/Aif [ "$targ" = install ]
854N/Athen
854N/A targ=install_h
854N/A
854N/A # Just the parts of "make sgs" we need, and
854N/A # skip them if they appear to be done.
854N/A # ... stuff under $SRC
865N/A test -f $SRC/uts/common/sys/priv_names.h ||
1058N/A (cd $SRC/uts && $make -k all_h)
1240N/A
1240N/A test -f $SRC/head/rpcsvc/nispasswd.h ||
854N/A (cd $SRC/head && $make -k install_h)
902N/A
902N/A # ... stuff under $ROOT (proto area)
902N/A test -d $ROOT/usr/include/sys ||
830N/A (cd $SRC && $make rootdirs)
830N/A test -f $ROOT/usr/include/sys/types.h ||
830N/A (cd $SRC/uts && $make -k install_h)
830N/A test -f $ROOT/usr/include/rpcsvc/daemon_utils.h ||
830N/A (cd $SRC/head && $make install_h)
830N/A
830N/A # always update the smbsrv headers to be safe
830N/A (cd $SRC/uts/common/gssapi && $make -k install_h)
830N/A (cd $SRC/uts/common/sys && $make -k install_h)
830N/A (cd $SRC/uts/common/smb && $make -k install_h)
830N/A (cd $SRC/uts/common/smbsrv && $make -k install_h)
830N/A
830N/Afi
830N/A
830N/A# Need some library headers too...
902N/Afor lib in \
902N/A libbsm \
902N/A libcmdutils \
830N/A libcryptoutil \
902N/A libdevid \
830N/A libfakekernel \
830N/A libgss \
830N/A libkrb5 \
830N/A libidmap \
902N/A libpam \
830N/A libsec \
830N/A libscf \
830N/A libshare \
830N/A libsmbfs \
830N/A libsqlite \
830N/A libuutil \
830N/A passwdutil \
830N/A smbsrv
830N/Ado
830N/A (cd $SRC/lib/$lib && $make $targ)
830N/Adone
830N/A}
830N/A
830N/A################################################################
830N/A
830N/Ado_kern() {
990N/A case $1 in
990N/A lint) targ=modlintlib ;;
990N/A *) targ=$1 ;;
990N/A esac
990N/A ( unset SOURCEDEBUG ;
990N/A (cd $SRC/uts/$x/nsmb && $make $targ) ;
990N/A (cd $SRC/uts/$x/smbfs && $make $targ) ;
990N/A (cd $SRC/uts/$x/smbsrv && $make $targ) )
990N/A}
990N/A
990N/A################################################################
990N/A
990N/A# Note lib1 builds prerequisite libraries not delivered by the
990N/A# tar file we create below. To accelerate clean/install, we
990N/A# skip these on clean (but still nuke them for clobber)
990N/A
990N/Ado_lib1() {
830N/A
990N/Afor lib in \
990N/A libavl \
830N/A libgss \
830N/A libkrb5 \
830N/A libcmdutils \
830N/A libsqlite \
830N/A libuutil
830N/Ado
830N/A (cd $SRC/lib/$lib && $make $1)
830N/Adone
830N/A}
830N/A
830N/A# lib2 builds stuff we include in the tar file,
830N/A# or that we don't mind rebuilding after clean.
830N/A
830N/Ado_lib2() {
830N/A
830N/Afor lib in \
libfakekernel \
libsmbfs
do
(cd $SRC/lib/$lib && $make $1)
done
(cd $SRC/lib/libshare && $make $1 PLUGINS=smb)
(cd $SRC/lib/smbsrv && $make $1)
(cd $SRC/lib/passwdutil && $make $1)
(cd $SRC/lib/pam_modules/smb && $make $1)
}
################################################################
do_cmds() {
case $1 in
install)
# mount programs need fslib.o
(cd $SRC/cmd/fs.d && $make fslib.o)
(cd $SRC/cmd/fs.d/smbclnt && $make $1 catalog)
;;
clean|clobber)
(cd $SRC/cmd/fs.d/smbclnt && $make $1)
(cd $SRC/cmd/fs.d && $make ${1}_local)
;;
esac
(cd $SRC/cmd/devfsadm && $make $1)
(cd $SRC/cmd/smbsrv && $make $1)
# Build the MDB modules, WITH the linktest
(cd $SRC/cmd/mdb/tools && $make $1)
for a in $mdb_arch
do
case $1 in
install|lint)
(cd $SRC/cmd/mdb/$x/$a/kmdb &&
$make kmdb_modlinktest.o )
;;
clean|clobber)
(cd $SRC/cmd/mdb/$x/$a/kmdb &&
$make -k $1 )
;;
esac
(cd $SRC/cmd/mdb/$x/$a/nsmb &&
$make $1 KMDB_LINKTEST_ENABLE= )
(cd $SRC/cmd/mdb/$x/$a/smbfs &&
$make $1 KMDB_LINKTEST_ENABLE= )
(cd $SRC/cmd/mdb/$x/$a/smbsrv &&
$make $1 KMDB_LINKTEST_ENABLE= )
(cd $SRC/cmd/mdb/$x/$a/libfksmbsrv &&
$make $1 KMDB_LINKTEST_ENABLE= )
# We build these libraries (to the proto area), so we need to
# build the mdb modules too so mdb will load them.
(cd $SRC/cmd/mdb/$x/$a/libcmdutils &&
$make $1 )
(cd $SRC/cmd/mdb/$x/$a/libavl &&
$make $1 )
done
(cd $SRC/cmd/Adm/sun && $make $1)
# Deal with mode 0400 file annoyance...
# See usr/src/cmd/Adm/sun/Makefile
if [ $1 = install ]; then
chmod a+r $ROOT/var/smb/smbpasswd
fi
}
################################################################
# This builds $SRC/TAGS (and cscope.files) in a helpful order.
do_tags() {
(cd $SRC ;
find uts/common/sys -name '*.[ch]' -print |sort
find uts/common/net -name '*.[ch]' -print |sort
find uts/common/netinet -name '*.[ch]' -print |sort
find uts/common/smb -name '*.[ch]' -print |sort
find uts/common/smbsrv -name '*.ndl' -print |sort
find uts/common/smbsrv -name '*.[ch]' -print |sort
find uts/common/fs/smbsrv -name '*.[ch]' -print |sort
find uts/common/gssapi -name '*.[ch]' -print |sort
find head -name '*.h' -print |sort
find lib/smbsrv -name '*.[ch]' -print |sort
find lib/libsmbfs -name '*.[ch]' -print |sort
find lib/libads -name '*.[ch]' -print |sort
find lib/libgss -name '*.[ch]' -print |sort
find cmd/smbsrv -name '*.[ch]' -print |sort
find common/smbsrv -name '*.[ch]' -print |sort
) > $SRC/cscope.files
(cd $SRC ;
exctags -e --langmap=c:+.ndl -h ndl -L - < cscope.files
cscope -b )
}
################################################################
# This creates a tarfile one can use to update a test machine.
do_tar() {
files="
usr/kernel/drv/$arch64/smbsrv
usr/kernel/drv/smbsrv
usr/kernel/kmdb/$arch64/smbsrv
usr/kernel/kmdb/smbsrv
usr/lib/fs/smb/$arch64/libshare_smb.so.1
usr/lib/fs/smb/libshare_smb.so.1
usr/lib/libsmbfs.so.1
usr/lib/mdb/kvm/$arch64/smbsrv.so
usr/lib/mdb/kvm/smbsrv.so
usr/lib/reparse/libreparse_smb.so.1
usr/lib/security/pam_smb_passwd.so.1
usr/lib/smbsrv/libmlrpc.so.1
usr/lib/smbsrv/libmlsvc.so.1
usr/lib/smbsrv/libsmb.so.1
usr/lib/smbsrv/libsmbns.so.1
usr/lib/smbsrv/smbd
usr/sbin/devfsadm
usr/sbin/smbadm
usr/sbin/smbstat
"
(cd $ROOT && tar cfj ../../smbsrv.tar.bz2 $files)
}
################################################################
if [ "$1" = "" ]; then
set '?' # force usage
fi
set -x
for arg
do
case "$arg" in
install)
build_tools
set -e
do_hdrs $arg
do_kern $arg
do_lib1 $arg
do_lib2 $arg
do_cmds $arg
;;
lint)
do_kern $arg
do_lib1 $arg
do_lib2 $arg
do_cmds $arg
;;
clean)
# intentionally skip: lib1, hdrs, tools
do_cmds $arg
do_lib2 $arg
do_kern $arg
;;
clobber)
do_cmds $arg
do_lib2 $arg
do_lib1 $arg
do_kern $arg
do_hdrs $arg
clobber_tools
;;
tags)
do_tags
;;
tar)
do_tar
;;
*)
echo "Usage: $0 {install|lint|clean|clobber|tags|tar}";
exit 1;
;;
esac
done