#!/bin/sh

MACH=`uname -p`

#PATH=/usr/ccs/bin:/opt/onbld/bin:/opt/onbld/bin/${MACH}:/opt/teamware/bin:/opt/SUNWspro/bin:$PATH
#export PATH

#automount map for generic tools: teamware/onbld/ongk
TOOLPATH=/shared/ON/tools
 
#Locally mounted compiler always has precedence 
#Impt for Sustaining work to freeze construction set by mounting locally
#
if [ -d /opt/SUNWspro/bin ]; then
        SP=/opt/SUNWspro/bin
else
        if [ "$SPRO_BIN" ]; then
                SP=${SPRO_BIN}
        else
                echo "Error: SPRO_BIN undefined in env" && exit 1
        fi
fi
[ ! -d $SP ] && echo "${SP} not found!" && exit 1
 
if [ -d /opt/onbld/bin ]; then
        BLD="/opt/onbld/bin:/opt/onbld/bin/${MACH}"
else
        BLD="${TOOLPATH}/onbld/bin:${TOOLPATH}/onbld/bin/${MACH}"
fi
if [ -d /opt/teamware/bin ]; then
        TW="/opt/teamware/bin"
else
        TW="${TOOLPATH}/teamware/bin"
fi
PATH="/usr/ccs/bin:${BLD}:${TW}:${SP}:$PATH"
export PATH


CODEMGR_WS=/builds/on495-gate
ROOT=${CODEMGR_WS}/proto/root_${MACH}
CODEMGR_WS=/builds4/on495-sun4-eol
ROOT=${CODEMGR_WS}/proto/root_${MACH}
SRC=${CODEMGR_WS}/usr/src
TMPDIR=/tmp

export MACH CODEMGR_WS ROOT SRC TMPDIR

cd $SRC
for dir in uts uts/sun4c uts/sun4d uts/sun4m uts/sun4u uts/i86pc
do
        cd $dir
        rm -f cscope.* tags tags.list
        make cscope.files >/dev/null
        make tags >/dev/null
        cscope-fast -bq >/dev/null 2>&1
        cd $SRC
done


#(cd $SRC/uts; make tags; cscope-fast -q -b ) >/dev/null 2>&1

# sparc targets
#(cd $SRC/uts/sun4; make tags cscope.out ) >/dev/null 2>&1
#(cd $SRC/uts/sun4c; make tags cscope.out ) >/dev/null 2>&1
#(cd $SRC/uts/sun4d; make tags cscope.out ) >/dev/null 2>&1
#(cd $SRC/uts/sun4e; make tags cscope.out ) >/dev/null 2>&1
#(cd $SRC/uts/sun4m; make tags cscope.out ) >/dev/null 2>&1

# x86 targets
#(cd $SRC/uts/i86pc; make tags cscope.out ) >/dev/null 2>&1

# full

INCLUDEDIRS=${CODEMGR_WS}/proto/root_$MACH/usr/include
export INCLUDEDIRS  

rm -f cscope.*
find . -name SCCS -prune -o -type d -name '.del-*' -prune -o -type f \( \
        -name '*.[Ccshlxy]' -o \
        -name 'Makefile*' -o \
        -name '*.adb' -o \
        -name '*.il' -o \
        -name '*.cc' \
        \) -print > cscope.files
cscope-fast -bq >/dev/null 2>&1

