#/bin/csh -f
#
# @(#)mkdom	1.5 12/14/92
#
# Copyright (c) 1990, 1991, 1992 The Regents of the University of California.
# All rights reserved.
# 
# Permission is hereby granted, without written agreement and without
# license or royalty fees, to use, copy, modify, and distribute this
# software and its documentation for any purpose, provided that the above
# copyright notice and the following two paragraphs appear in all copies
# of this software.
# 
# IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY 
# FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES 
# ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF 
# THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF 
# SUCH DAMAGE.
# 
# THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
# PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
# CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES,
# ENHANCEMENTS, OR MODIFICATIONS.
#
# Programmer:		T.M. Parks
# Date of creation:	5 February 1992
#

# Check for proper usage.
if ($#argv < 1) then
	echo Usage: mkdom domain
	echo "	Use this program to quickly generate the necessary"
	echo "	source files for a new domain.  The resulting domain"
	echo "	will not do much, but at least it will compile."
	exit
endif

if ( ! $?PTOLEMY ) setenv PTOLEMY ~ptolemy

set domain = $1
set DOM = `echo $domain | tr a-z A-Z`	# upper case domain abbreviation
set dom = `echo $domain | tr A-Z a-z`	# lower case domain abbreviation

# Check that a valid domain abbreviation has been supplied.
# This prevents accidental overwriting of the orginal files.
if ($DOM == "XXX") then
	echo Choose a domain abbreviation other than XXX.
	exit
endif

# Check that the program is being run from a resonable directory.
if ($cwd !~ */src/domains/$dom/kernel) then
	echo Run this program in the .../src/domains/$dom/kernel directory.
	exit
endif

# Process the source files.
set dir = $PTOLEMY/src/domains/xxx/kernel
foreach file ( PortHole.h PortHole.cc Geodesic.h \
		Scheduler.h Scheduler.cc Star.h Star.cc \
		Wormhole.h Wormhole.cc )

	echo $DOM$file
	sed -e "s/XXX/$DOM/g" -e "s/xxx/$dom/g" < $dir/XXX$file > $DOM$file	
end

# Process the make.template file.
sed -e "s/XXX/$DOM/g" -e "s/xxx/$dom/g" < $dir/make.template > make.template

