# Brain-dead makefile to compile and run all the benchmarks.

# Configuration:
#   USETALC - if defined use the TALC assembler otherwise use MASM

ifdef USETALC
POPFLAGS = --TALC
else
POPFALGS = --MS
endif

out=test.out
POPCORN = popcorn
single = check_array.exe check_loops.exe check_big_fact.exe check_spill.exe \
	check_exn.exe check_exn2.exe fact.exe fib.exe hanoi.exe int_queue.exe \
	ast.exe


compile: $(single) 
	$(POPCORN) $(POPFLAGS) -o check_globals.exe \
		check_globals.pop check_globals2.pop
	$(POPCORN) $(POPFLAGS) -o int_msort.exe int_list.pop int_msort.pop
	$(POPCORN) --TALC -o msort.exe list.pop msort.pop
	$(POPCORN) -o combine.exe list.pop combine.pop


run:
	rm -f $(out)
	./check_array.exe >> $(out)
	./check_loops.exe >> $(out)
	./check_big_fact.exe >> $(out)
	./check_globals.exe >> $(out)
#	./check_spill.exe 
	./check_exn2.exe >> $(out)
	./check_exn.exe >> $(out)
	./fact.exe 10 >> $(out)
	./fib.exe 10 >> $(out)
	./hanoi.exe >> $(out)
	./ast.exe >> $(out)
	./int_msort.exe 5 >> $(out)
	./int_queue.exe  >> $(out)
	./msort.exe 5 >> $(out)
	./combine.exe >> $(out)

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

clean: exe_only
	rm -f *.exe

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