# clobber local
cd /usr/src/local
cd EXOS ; 	make -f makefile clean ; cd ..
cd cdb ; 	make -f cdb.mk clobber ; cd ..
cd cpt ; 	make -f cpt.mk clobber ; cd ..
cd dwb ; 	make -f text.mk clobber ; cd ..
cd exos ; 	make -f Makefile clean ; cd ..
cd ksh-i ; 	make -f makefile clobber ; cd ..
cd nfs ; 	make -f nfs.mk clobber ; cd ..
cd opmon.440 ; 	make -f opmon.mk clean ; cd ..
cd opmon ; 	make -f opmon.mk clean ; cd ..
cd pascal ; 	make -f pascal.mk clobber ; cd ..
cd postscr ; 	make -f postscr.mk clobber ; cd ..
cd ucb ; 	make -f ucb.mk clobber ; cd ..
cd x ; 		make -f Makefile clobber ; cd ..

# clobber uts
cd /usr/src
cd uts/ns32000; make -f /usr/src/uts/ns32000/unix.mk clobber; cd ../..
cd uts/clipper; make -f /usr/src/uts/clipper/makefile clobber; cd ../..

# clobber lib
cd lib; make clobber; cd ..

# clobber cmd
SRC=/usr/src
LSRC=/usr/src
cd /usr/src/cmd
MAKE="make -f"
for arg in *
do(
#	Local version takes precedence over official version
	if [ -f $LSRC/cmd/$arg -o -d $LSRC/cmd/$arg ]
	then	source=$LSRC
	else	source=$SRC
	fi
	cd ${source}/cmd
	OBJ=
	B=`basename $arg`
#	Is this an aberrant file with its makefile in the $SRC/cmd directory?
#	If so then skip this file since it will handled by the makefile
	case $B in
		*.c | *.s)
			b=`basename $B ".[cs]"`
			if [ -f $b.mk ]
			then	continue
			fi
			;;
	esac
	echo "\n======== $B"
	BASE=$B
#	if not a directory then remove suffix and determine the file type
	if [ ! -d $B ] 
	then	BASE=`echo $B | sed -e 's/\(.*\)\..*/\1/'`
		if [ -f ${BASE}.mk -o -f $LSRC/cmd/${BASE}.mk ]
		then	B=${BASE}.mk
		elif [ -f ${BASE}.rc -o -f $LSRC/cmd/${BASE}.rc ]
		then	B=${BASE}.rc
		elif [ -f ${BASE}.c  -o -f $LSRC/cmd/${BASE}.c ] 
		then	B=${BASE}.c
		elif [ -f ${BASE}.sh -o -f $LSRC/cmd/${BASE}.sh ] 
		then	B=${BASE}.sh
		elif [ -f ${BASE}.y -o -f $LSRC/cmd/${BASE}.y ]
		then	B=${BASE}.y
		elif [ -f ${BASE}.l -o -f $LSRC/cmd/${BASE}.l ] 
		then	B=${BASE}.l
		elif [ -f ${BASE}.s -o -f $LSRC/cmd/${BASE}.s ] 
		then	B=${BASE}.s
		elif [ -f ${BASE}.o -o -f $LSRC/cmd/${BASE}.o ] 
		then	B=${BASE}.o
		fi
	fi
#
	if [ "$source" = "$SRC" -a -f $LSRC/cmd/$B ]
	then	source=$LSRC
		cd ${source}/cmd
	fi
#
#	Now build the command according to its file type
	case $B in

	*.mk)
		CMD="$MAKE -b -f ${BASE}.mk clobber"
		echo "$CMD"
		;;
	*.c)
		rm -f ./${BASE}.o ./${BASE}
		lib=
		;;
	*.s)	
		rm -f ./${BASE}.o ./{BASE}
		;;
	*.o)	rm -f $B 
		;;
	*)
		if [ -d $B ]
		then	echo "cd $B"
			cd $B
			if [ -f $B.mk ]; then
				CMD="$MAKE $B.mk clobber"
				echo "$CMD"
				eval $CMD
			elif [ -f $B.rc ]
			then	sh -x $B.rc
			else	echo "**** Build of $B failed (no makefile found in directory)"
			fi
			rm -f *.o
		else	echo "**** Build of ${BASE} failed (can not determine file type)"
		fi

	esac
);done
