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

#
# IMP compiler makefile
#
# Rev 003 26-Aug-26 FC   In it4prede.inc, jafserver was being explicitly
#                        taken from \tc2v2. Showed up on Debian with only
#                        Imp installed.  Remove the \tc2v2.
# Rev 002 14-Feb-26 FC   Reformatted Rev 001 changes to fit trad. 80 cols.
#                        Added 3L copyright notice.
# Rev 001 12-Sep-25 FC   Changed from PolyMake PVCS to GnuWin32 make with
#                        all sources in current directory.
#

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

#001 .PATH.bin = bin

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

#001
CC = t4c
IMP = t4i

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

#001
.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 pass3.bin

MISC =		ti.bin fpinput.bin udivrem.bin

#001 ti.b4 : $(FRONTEND) $(BACKEND) $(MISC)
#001	linkt <@<
#001 $[s,"\n",$**]
#001 $(IRTLT4T8)
#001 $(IT4HARN)
#001 <,$@

#001
#001 Windows now has a longer command-line limit (8192 chars),
#001 so no need to split everything up into separate lines.
#001 Just as well, as GNU make $file cmd wasn't working for me.
#001
ti.b4 : $(FRONTEND) $(BACKEND) $(MISC)
	@echo $^ >$*.in
	@echo $(IRTLT4T8) >>$*.in
	@echo $(IT4HARN) >>$*.in
	linkt @$*.in,$@

#001 removed PolyMake square brackets from around all the
#001 following dependencies

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

pass1.bin :	lloption.inc tablesns.inc

pass2.bin :	common.inc options.inc lflags.inc lloption.inc \
		opcodes.inc ops.inc perm.inc reloc.inc stream3l.inc \
		p2p3.inc dbgarea.inc dbgflags.inc

pass3.bin :	common.inc p2p3.inc ops.inc opcodes.inc tags.inc \
		perm.inc dbgarea.inc

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

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

#
# HEADGEN.  It's a little utility used to build Pascal.
# Unfortunately because the "utility" is really a variant IMP
# front end (it sucks in a file of %external %specs and generates
# I-code) it needs to be linked with the IMP Pass1, and therefore
# must live here.  It should be abolished ASAP by adding an
# option switch to the standard IMP compiler which will do this
# job.  ICHEAD.INC is the name of the file that HEADGEN creates
# when it is run.  PASPRE.IMP is the name of its input file.  Again,
# it really belongs with Pascal; it's here because HEADGEN is.
#

headgen.b4 :	headgen.bin pass1.bin actinc.bin
#001	linkt $[s,"+",$**]+$(IRTLT4)+$(IT4HARN),$@

headgen.bin :   option3l.inc

ichead.inc :	headgen.b4 paspre.imp
	afserver -:b headgen.b4 -:o 1
