# Equi reference implementation build project

PROJNAME=equi
CFILES=equi.c
PBTDIR=platform-build-tools
PERSFILE=PERS.DAT
# Apple IIe target configuration
A2FLAGS=-DSTACK_SIZE=256 -DLIT_STACK_SIZE=32 -DGPD_AREA_SIZE=1024 -DCMD_BUF_SIZE=13400 -DCLT_ENTRIES_MAX=256 -DEQUI_TASKS_MAX=4
# POSIX desktop target configuration
PDFLAGS=-DSTACK_SIZE=256 -DLIT_STACK_SIZE=32 -DGPD_AREA_SIZE=3072 -DCMD_BUF_SIZE=20000 -DCLT_ENTRIES_MAX=512 -DEQUI_TASKS_MAX=8
# Common flags
DFLAGS=-DPERSIST_FILE="\"$(PERSFILE)\""

desktopcc: perscopy
	cc -std=c89 -Os -o $(PROJNAME) $(CFILES) $(PDFLAGS) $(DFLAGS)
#	strip $(PROJNAME)

tcc: perscopy
	tcc -std=c89 -o $(PROJNAME) $(CFILES) $(PDFLAGS) $(DFLAGS)

a2-build:
	cl65 --standard c89 -O -Os -t apple2enh -C apple2enh-system.cfg -o $(PROJNAME).a2enh $(A2FLAGS) $(DFLAGS) $(CFILES)

a2: a2-build
	cp $(PBTDIR)/apple2/tpl.dsk $(PROJNAME)-enh.dsk
	java -jar $(PBTDIR)/apple2/ac.jar -p $(PROJNAME)-enh.dsk $(PROJNAME).system sys < $$(cl65 --print-target-path)/apple2enh/util/loader.system
	java -jar $(PBTDIR)/apple2/ac.jar -as $(PROJNAME)-enh.dsk $(PROJNAME) bin < $(PROJNAME).a2enh
	java -jar $(PBTDIR)/apple2/ac.jar -dos $(PROJNAME)-enh.dsk $(PERSFILE) bin < $(PBTDIR)/$(PERSFILE)

perscopy:
	cp $(PBTDIR)/$(PERSFILE) $(PERSFILE)

clean:
	rm -f ./$(PROJNAME) $(PERSFILE) *.dsk *.o *.apple2 *.a2enh
