#! /bin/csh -f
# script to make directories and links for an architecture
# modified from the Ptolemy MAKEARCH script
#
# Author: Brian L. Evans
# Version: @(#)MAKEARCH	1.2	05/18/97

if (! $?PTARCH ) then
	echo The environment variable PTARCH must be set.
	exit 1
endif

# optmkdir -- make a directory if it does not exist
alias optmkdir \
'if ( ! -d \!:1 ) echo making directory $cwd/\!:1 ; if ( ! -d \!:1 ) mkdir \!:1'

# optlink -- make a symbolic link if it does not exist, from a file in a
# different directory to the same name in this directory.  args: dir filename

alias optlink \
'if ( ! -e \!:2 ) echo making link \!:1/\!:2 ; if ( ! -e \!:2 ) ln -s \!:1/\!:2 .'

# optdifflink -- make a symbolic link if it does not exist, with a different
# name

alias optdifflink \
'if ( ! -e \!:2 ) echo `pwd`: making link \!:1 \!:2 ; if ( ! -e \!:2 ) ln -s \!:1 \!:2 '

# Quiet versions of pushd and popd.
alias pushd 'pushd \!* > /dev/null'
alias popd 'popd \!* > /dev/null'

# Make the top-level directories
optmkdir bin.$PTARCH
optmkdir lib.$PTARCH
optmkdir obj.$PTARCH

# Now, make stuff under obj.$PTARCH

cd obj.$PTARCH
optlink ../src makefile

foreach x (c30sim libc30asm libc30sim)
	optmkdir $x
	cd $x
	optlink ../../src/$x makefile
	if (-r ../../src/$x/make.template) then
		optlink ../../src/$x make.template
	endif
	cd ..
end

# This is for the top-level makefile
touch obj.$PTARCH
