#! /bin/csh -f

set SRC=hack
set LISTNAME=hack.l
set LIBNAME="HACK  v9.2b'Fin 23.11.96"
set CFGNAME=HACKcfg
# set MSGNAME=HACKmsg
set TARGET=hack.lib

######################################################################

# Create help file for GNU Tools assembly

echo "ASSEMBLE"						>  __$SRC.s
echo "	NIBASC /HPHP48-X/	* Download header"	>> __$SRC.s
echo "	INCLUDE	SupRomEntr.a	* Supported Entries"	>> __$SRC.s
echo "	INCLUDE	__head.a	* Library header"	>> __$SRC.s
echo "	LISTM			* List includes"	>> __$SRC.s
echo "RPL"						>> __$SRC.s
echo "	INCLUDE $SRC.s"					>> __$SRC.s
echo "ASSEMBLE"						>> __$SRC.s
echo "	CLRLIST	INCLUDE"				>> __$SRC.s
echo "	INCLUDE	__hash.a	* Library tables"	>> __$SRC.s
echo "	INCLUDE	__end.a		* Library end"		>> __$SRC.s
echo "RPL"						>> __$SRC.s

######################################################################
echo Assembling rpl..
rplcomp __$SRC.s __$SRC.a __$SRC.ext
######################################################################

echo Building tables..
echo "OUTPUT __xx.o"				> __build.mn
echo "LLIST __xx.lr"				>> __build.mn
if ($?CFGNAME) then
 echo "CONFIGURE $CFGNAME"			>> __build.mn
endif
if ($?MSGNAME) then
 echo "MESSAGE $MSGNAME"			>> __build.mn
endif
if ($?LIBNAME) then
 echo "NAME $LIBNAME"				>> __build.mn
endif
echo "ROMPHEAD __head.a"			>> __build.mn
echo "REL __$SRC.o"				>> __build.mn
echo "TABLE __hash.a"				>> __build.mn
echo "FINISH __end.a"				>> __build.mn
echo "END"					>> __build.mn

makerom __build.mn __build.m

######################################################################

echo Assembling code..
if ($1 == -l) then
	sasm -EH __$SRC
	mv __$SRC.l $LISTNAME
else
	sasm -EHN __$SRC
endif
lbcrc __$SRC.o

mv __$SRC.o $TARGET

######################################################################
