
PC := fpc
PFLAGS := -Mobjfpc -Sh

ifdef DEBUG
TEMP := temp/debug
PFLAGS += -dDEBUG
PFLAGS += -Sa -ghl -Cr
else
TEMP := temp/release
PFLAGS += -CX -Xs -XX -O2
endif

PFLAGS += -FU$(TEMP)

durandal:
	mkdir -p $(TEMP)
	$(PC) durandal.pas $(PFLAGS)

durandal-random:
	mkdir -p $(TEMP)
	$(PC) durandal.pas $(PFLAGS) -dRANDOM_MOVER -odurandal-random

all: durandal durandal-random

test: durandal
	rm -f *.log
	@status=0; for t in tests/*.exp; do expect $$t || status=1; done; exit $$status

clean:
	rm -rf temp/debug temp/release temp/win64
	rm -f temp/*.o temp/*.ppu

distclean: clean
	rm -f durandal durandal-random durandal.exe durandal-random.exe

.PHONY: durandal durandal-random all test clean distclean

# make PC=/home/roland/Applications/fpc-322-x86_64-win64/fpc.exe
