# SPDX-License-Identifier: GPL-2.0-or-later
FPC ?= fpc
LAZARUS ?= /usr/lib/lazarus/4.4
LCL = -Fu$(LAZARUS)/lcl/units/x86_64-linux -Fu$(LAZARUS)/lcl/units/x86_64-linux/gtk2 -Fu$(LAZARUS)/components/lazutils/lib/x86_64-linux -Fu$(LAZARUS)/packager/units/x86_64-linux
FLAGS = -Flbuild/link -Mobjfpc -Sh -O2 -g -gl -Fusrc
.PHONY: all test gui-test deb clean
all:
	python3 tools/prepare-link.py
	mkdir -p build/units bin
	$(FPC) $(FLAGS) $(LCL) -FUbuild/units -FEbin -obrokenseal src/brokenseal.lpr
test:
	mkdir -p build/tests
	$(FPC) $(FLAGS) -Cr -Co -FUbuild/tests -FEbuild/tests tests/testdesktop.pas
	build/tests/testdesktop
	$(FPC) $(FLAGS) -Cr -Co -FUbuild/tests -FEbuild/tests tests/testrules.pas
	build/tests/testrules
	$(FPC) $(FLAGS) -Cr -Co -FUbuild/tests -FEbuild/tests tests/inspectsave.pas
gui-test: all test
	python3 tests/gui.py
deb: all test
	python3 tools/package.py
clean:
	rm -rf build/units build/tests bin
