#!/bin/bash

# 	------------------------------------------------------------------
#	Bring a copy of the languageONE backend into languageONE directory
#	Run it thru the reWriter
#	Assemble it
#	move the .ASM into the @fltk/_Application directory (fo debugging)
#	move the .o into the @fltk directory
#	remove the .ONE file	
# 	------------------------------------------------------------------
a=$1
b=${a:1:99}

cd ..
cp @fltk/examples/$b.ONE .
if ! bin/languageONE $b; then
	exit 1
fi
if ! ./assemble $b; then
	exit 1
fi

mv $b.ASM @fltk/_Application
mv $b.o @fltk
rm $b.ONE

# 	------------------------------------------------------------------
#	Change to the @fltk directory
#	Bring a copy of the @fltk from end into @fltk directory
#	Compile/Link
#	move the result to the _Application directory
#	remove any intermediate files
# 	------------------------------------------------------------------
cd @fltk
cp $b/$1.cxx .
if ! g++ -o $1 $1.cxx $b.o @C++staticOptions; then
	exit 1
fi
mv $1 _Application
mv $1.cxx _Application
rm *.o
cd ..
