
PC := fpc
PFLAGS := -Mobjfpc -Sh

TEMP := units
PFLAGS += -FU$(TEMP)

ifdef DEBUG
PFLAGS += -ghl
PFLAGS += -dDEBUG
else
PFLAGS += -CX -Xs -XX
endif

UNITS := $(filter-out moustique.pas perft.pas,$(wildcard *.pas))

default: moustique

all: moustique perft

%: %.pas $(UNITS) $(TEMP)
	@$(PC) $< $(PFLAGS)

$(TEMP):
	$(info Creating directory for temporary files)
	mkdir $@

play: moustique
	rm -fv *.debug *.log
	xboard -debug -debugfile xboard.debug -cp -fcp ./$< -fd ./ -fUCI

clean:
	rm -fv $(TEMP)/*.o $(TEMP)/*.ppu

distclean: clean
	rm -fv moustique perft *.exe

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