#!/bin/csh -f

set config=
set clean=
set dflt=(MONET ARPA MATISSE VANGOGH CALDER UCBVAX GENERIC \
	CALDER.PROF UCBVAX.PROF ARPA.PROF)
set mach=

foreach i ($*)
	switch ($i)

	case -v:
		set verbose
	case -x:
		set echo
		breaksw
	case config:
	case -config:
		set config = 1
		set clean = 1
		breaksw
	case clean:
	case -clean:
		set clean = 1
		breaksw
	default:
		set mach=($mach $i)
		breaksw
	endsw
end

if ($mach[1] == "") set mach=($dflt)

foreach i ($mach)
	echo $i
	if ($config == 1) then
		cd conf
		if ($i =~ *.PROF) then
			config -p $i
		else
			config $i
		endif
		cd ../$i
		make -s depend
		cd ..
	endif
	cd $i
	if ($clean == 1) make -s clean
	make -k >&errs
	tail -4 errs
	cd ..
end
