# Configuration:
#   USETALC - if defined use the TALC assembler otherwise use MASM
# NG: USETALC doesn't work yet

ASSEMBLER = --TALC

LIBFILES = core

LIBFILES = core

ifdef NOTALC
ASSEMBLER=--MS
else
ASSEMBLER=--TALC
endif

ifdef WINDIR
O=obj
A=lib
else
O=o
A=a
endif


POPFLAGS = $(ASSEMBLER) $(addprefix $(POPLIB), $(addsuffix .$(O), $(LIBFILES)))

OUTFILE=test.out
REFFILE=ref.out
POPCORN=popcorn.exe

# Bsearch and rec don't work because of typing problems involving
# templates and exceptions.  I haven't looked at bs2 yet.
BUGGY = bsearch.exe rec.exe bs2.exe 

EXES = cg.exe cg2.exe cg3.exe cg4.exe cg5.exe cg6.exe \
	cgh1.exe cghole.exe dot.exe intswitch-inter.exe itj.exe jmp.exe \
	nested.exe qe2.exe test_stdlib.exe while-inter.exe

compile: $(EXES)
#	cd interpret; make all

run:
	rm -f $(OUTFILE)
	./cg.exe >> $(OUTFILE)
	./cg2.exe >> $(OUTFILE)
	./cg3.exe >> $(OUTFILE)
	./cg4.exe >> $(OUTFILE)
	./cg5.exe >> $(OUTFILE)
	./cg6.exe >> $(OUTFILE)
	./cgh1.exe >> $(OUTFILE)
	./cghole.exe >> $(OUTFILE)
	./dot.exe >> $(OUTFILE)
	./intswitch-inter.exe >> $(OUTFILE)
	./itj.exe >> $(OUTFILE)
	./jmp.exe >> $(OUTFILE)
	./nested.exe >> $(OUTFILE)
	./qe2.exe >> $(OUTFILE)
	./while-inter.exe >> $(OUTFILE)
#	./interpret/test.exe >> $(OUTFILE)	    # interpret subdirectory

check:
	diff $(OUTFILE) $(REFFILE)

ref:
	cp $(OUTFILE) $(REFFILE)

bench:
	./interpret/bench.exe

exe_only:
	rm -f *~ *.obj *.tal* *.lst

clean: exe_only
	rm -f *.exe
	rm -f *.ver
	rm -f *.pdb # produced by debugging
	rm -f *.ilk # produced by debugging
	rm -f $(OUTFILE)
	cd interpret; make clean

%.exe: %.pop
	$(POPCORN) $(POPFLAGS) -o $@ $<

# EOF: Makefile


