#! /bin/csh
#		This is a shell script that will re-build a new UIL
#		compiler. They are being rebuilt to add in new widgets
#		to UIL. The first Portion of the test will add a 
#		widget created with the MOTIF toolkit (MA - Browse). The
#		second portion will add an Athena widget (AA - Label) to 
#		UIL.

# NOTE:		These Tests assume that the user has the MIT Athena widget
#		set installed. If this is not the case then all test's dealing
#		with the Motif Plus Athena will fail. The compilation of the
#		Mrm interface created with the extra Athena Widget will also
#		fail. You still can do testing of 1.1 against the 1.1 Plus
#		extra Motif widget (Browse).

# Start Build

# Copy over all C and Header files from the regular MOTIF Tree for
# UIL and for the WML Technology. This is needed to recompile
# these files to add in new widget Technology.

echo "Copying in All Uil files"
echo "..."
cp ../../../clients/uil/*.[ch] uil
chmod +r+w uil/*

echo "Copying in all WML files"
echo "..."
mkdir wml
cp ../../../tools/wml/* wml
cd wml
make clean
chmod +r+w *
cd ..

mkdir Xm


# MA is a directory that contains all files needed to rebuild UIL 
# with a new widget created with the MOTIF toolkit (Browse).
#
# AA is a directory that contains all files needed to rebuild UIL
# with a new widget created from the Athena toolkit (Label).
#
# To add new Widget of your own, simply follow the steps below. All
# files that are copied to the directories uil and wml MUST be
# modified for any new widget(s) added to UIL.

foreach dir (MA AA)

	echo "Building Technology for Directory" $dir
	echo "..."

	cp output/$dir/Xm.h Xm
        chmod +r+w Xm/*
	
# Building WML Technology

	echo "Modifing Makefile for New Install path"
	echo "..."
	cd wml
	sed "s,(UILSRC),(MYINSTALL)," Makefile > makefile
	cp ../output/$dir/motif.wml .
	echo "Making and Installing WML Technology"
	echo "..."
	make -f makefile MYINSTALL=../uil
	rm -f makefile
	cd ..

# Building and Installing New Uil Compiler

	echo "Building uil/uil"
	echo "..."
	cd uil
	make WIDGETSET=$dir
	echo "Installing the Uil compiler in the appropriate output directory"
	echo "..."
	cp uil ../output/$dir
	cd ..

# Building Mrm Interface (DisplayUid)

	echo "Building Mrm Interface (displayUid) in ./output/"$dir
	echo "..."
	cd output/$dir
	make -i
	cd ../..

# Cleanup all .o's for next Test.
	
	echo "Cleaning in ./uil"
	echo "..."
	cd uil
	make clean
	cd ..

end

# Build 1.1 Mrm Interface file (displayUid)

	echo "Build 1.1 Mrm Interface (displayUid)"
	echo "..."
	cd output/1.1
	make
	cd ../..

# Clean All files Copied In for Testing

	echo "Clean all"
	echo "..."
	cd uil
	rm -f *.[ohcy]
	cd ..

	cd Xm
        rm -f *
        cd ..

	cd wml
	rm -f *
	cd ..

	echo "All Files Built"
	echo "..."
	echo "Now run ./Test"
	echo ""
