#!/bin/csh -f

set DEV_TOP = `pwd`

set TOUCH = ORIG
if ( ! -e configure.arwp ) then
	touch configure.arwp
	set TOUCH = TOUCH
endif

set nonomatch

set DIRS = ( src )
set EXES = ( ARWpost )

set i = 1
foreach dir ( $DIRS )
	if ( -d $dir ) then 
		( cd $dir ; make -i DEV_TOP="${DEV_TOP}" TARGET="$EXES[$i].exe" clean )
	endif
	/bin/rm -f $EXES[$i].exe
	@ i ++
end

#	The nuclear option

find . -name \*.exe -exec \rm {} \; 
find . -name \*.o -exec \rm {} \; 
find . -name \*.a -exec \rm {} \; 


if ( "$1" == '-a' ) then
	/bin/rm -rf ./netcdf_links
	foreach dir ( $DIRS )
		if ( -d $dir ) then 
			( cd $dir ; make -i DEV_TOP="${DEV_TOP}" TARGET="${dir}.exe" clobber >& /dev/null )
		endif
	end
	if ( -e configure.arwp ) then
		/bin/cp configure.arwp configure.arwp.backup
		/bin/rm -f configure.arwp
	endif
endif

if ( ( $TOUCH == TOUCH ) && ( -e configure.arwp ) ) then
	/bin/rm -f configure.arwp
endif
