# Copyright (C) 3L Ltd. 1987-1992

#
# Flattener makefile
#
# Rev 002 26-Aug-26 FC   Remove explicit \tc2v2 from invocation of jafserver at
#                        it4prede.inc.  Discovered with only Imp installed when
#                        porting to Wine.
# Rev 001 30-Jun-26 FC   Forked from transputer Imp compiler (gmake) makefile
#

IRTLT4 = \ti1v4\irtlt4.bin
IRTLT4T8 = \ti1v4\irtlt4t8.bin
IT4HARN = \ti1v4\t4harn.bin

.SUFFIXES: .imp .bin .b4 .dat .inc

CC = t4c
IMP = t4i

.c.bin :
	$(CC) $(CFLAGS) $<

.imp.bin :
	$(IMP) $(IMPFLAGS) $<

#
# special: messages.inc, opcodes.inc: build from .dat using tgen
#
.dat.inc :
	tgen -file $* -output $*


FRONTEND =	pass1.bin

BACKEND =	pass2.bin

MISC =		flatten.bin

flatten.b4 : $(FRONTEND) $(BACKEND) $(MISC)
	@echo $^ >$*.in
	@echo $(IRTLT4T8) >>$*.in
	@echo $(IT4HARN) >>$*.in
	linkt @$*.in,$@

flatten.bin :	common.inc option3l.inc p2p3.inc stream3l.inc it4prede.inc

pass1.bin :	lloption.inc tablesns.inc

pass2.bin :	common.inc options.inc stream3l.inc p2p3.inc

#
# source/target filenames, it4prede.imp/.inc
# are built in to the code of SQUISH
#
it4prede.inc :	it4prede.imp squish.b4
	jafserver -:b squish.b4

squish.b4 :	squish.bin
	linkt $<+$(IRTLT4)+$(IT4HARN),squish.b4

