#! /bin/sh
(echo; echo $0 "$@"; pwd; set | grep CODEMGR) >>/tmp/nseflg.out
#
#ident	"@(#)nse.dir.flp	1.5	92/06/17 SMI"
#
# Copyright (c) 1992 by Sun Microsystems, Inc.
#


#
# find_files(pat,dirs...)
#
# pat   = pattern to pass to find
# dirs  = space separated list of directories for find to visit
#
find_files() {
 
        pat=$1
        shift
 
        for dir in $*
        do
           if [ -d $CODEMGR_WS_ROOT/$dir ]; then
              find $CODEMGR_WS_ROOT/$dir -name "$pat" -print
           fi
        done
 
} # find_files()


echo_file() {
        #
        # Check to make sure a file exists, if it does then
        # echo it out.
        #
        if [ -f $CODEMGR_WS_ROOT/$1 ]; then
                echo $1
        fi
} # echo_file()


PWD=`pwd`

case $PWD in
*/usr/src/cmd/*)
	echo_file usr/src/cmd/Makefile.cmd
	echo_file usr/src/cmd/Makefile.targ
	echo_file usr/src/Makefile.master
	;;
*/usr/src/uts/*)
	echo_file usr/src/uts/Makefile
	echo_file usr/src/uts/Makefile.targ
	echo_file usr/src/uts/Makefile.uts
	echo_file usr/src/Makefile.master
	;;
*/usr/src/ucbcmd/*)
        echo_file usr/src/ucbcmd/Makefile.ucbcmd
        echo_file usr/src/ucbcmd/Makefile.ucbtarg
        echo_file usr/src/cmd/Makefile.targ
        echo_file usr/src/Makefile.master
        ;;
*/usr/src/lib/*)
        echo_file usr/src/lib/Makefile.lib
        echo_file usr/src/lib/Makefile.targ
        echo_file usr/src/lib/Makefile.mach
        echo_file usr/src/Makefile.master
        ;;
*/usr/src/ucblib/*)
        echo_file usr/src/ucblib/Makefile.ucbtarg
        echo_file usr/src/Makefile.master
        ;;
*/usr/src/stand/kadb*)

	#
	# Find all of the header files
	#
	find_files "s.*.h" \
		   usr/src/uts/sunmmu\
		   usr/src/uts/srmmu\
		   usr/src/uts/common/sys\
		   usr/src/uts/common/vm\
		   usr/src/uts/common/os\
		   usr/src/uts/common/rpc\
		   usr/src/uts/common/nfs\
		   usr/src/uts/sun\
		   usr/src/uts/sun4/sys\
		   usr/src/uts/sun4c/sys\
		   usr/src/uts/sun4m/sys\
		   usr/src/uts/sparc/sys\
		   usr/src/cmd/adb/sparc\
		   usr/src/stand/sys\
		   usr/src/head

	#
	# These are all of the supporting directories
	#
	find_files "s.*" \
		   usr/src/cmd/adb/sparc\
		   usr/src/stand/lib\
		   usr/src/uts/adb\
		   usr/src/uts/sun/promif\
		   usr/src/cmd/adb/common

	echo_file usr/src/Makefile.master
	echo_file usr/src/cmd/Makefile.cmd
	echo_file usr/src/cmd/Makefile.targ
	echo_file usr/src/lib/Makefile.lib
	echo_file usr/src/uts/Makefile.uts
	;;
*/usr/src/stand/boot*)
	#
	# Get required header files
	#
	find_files "s.*.h"\
		usr/src/uts/sun4\
		usr/src/uts/sun4c\
		usr/src/uts/sun4m\
		usr/src/uts/sunmmu\
		usr/src/uts/sparc\
		usr/src/uts/sun\
		usr/src/uts/common/sys\
		usr/src/uts/common/vm\
		usr/src/uts/common/os\
		usr/src/uts/common/rpc\
		usr/src/uts/common/nfs\
		usr/src/stand/sys
	#
	# Get required directories
	#
	find_files "s.*"\
		usr/src/uts/sun/promif\
		usr/src/stand/lib

	echo_file usr/src/lib/Makefile.lib
	echo_file usr/src/Makefile.master
	;;
*/usr/src/stand)
	#
	# Find all of the header files
	#
	find_files "s.*.h" \
		   usr/src/uts/sunmmu\
		   usr/src/uts/srmmu\
		   usr/src/uts/common/sys\
		   usr/src/uts/common/vm\
		   usr/src/uts/common/os\
		   usr/src/uts/common/rpc\
		   usr/src/uts/common/nfs\
		   usr/src/uts/sun\
		   usr/src/uts/sun4/sys\
		   usr/src/uts/sun4c/sys\
		   usr/src/uts/sun4m/sys\
		   usr/src/uts/sparc/sys\
		   usr/src/cmd/adb/sparc\
		   usr/src/head

	#
	# These are all of the supporting directories
	#
	find_files "s.*" \
		   usr/src/cmd/adb/sparc\
		   usr/src/uts/adb\
		   usr/src/uts/sun/promif\
		   usr/src/cmd/adb/common

	echo_file usr/src/Makefile.master
	echo_file usr/src/cmd/Makefile.cmd
	echo_file usr/src/cmd/Makefile.targ
	echo_file usr/src/lib/Makefile.lib
	echo_file usr/src/uts/Makefile.uts
	;;

*/usr/src/*)
	echo_file usr/src/Makefile.master
	;;
esac
if [ -n "$CODEMGR_NSE_DIR_FLG" ]; then
	$CODEMGR_NSE_DIR_FLG
else
	find $PWD -name 's.*' -print
fi
exit 0
