name := "freling_netatmo_algo"
exe_cli := "./packing_cli"
exe_gui := "./packing_gui"
build_sh := "build.sh"

params := "lenna.png 0 0 64 64 100 100 100 64 80 200 70 220"


build-raylib:
	cd src/3rd-party/raylib-4.0.0/src && \
	make CC=clang \
	PLATFORM=PLATFORM_DESKTOP \
	RAYLIB_MODULE_AUDIO=FALSE \
	RAYLIB_MODULE_MODELS=FALSE

build-cli:
	tup {{exe_cli}}

build-gui: build-raylib
	tup {{exe_gui}}

run-cli: build-cli
	{{exe_cli}} {{params}}

run-gui: build-gui
	nixGL {{exe_gui}} {{params}}

generate-build:
	git clean -xf src/
	rm --force {{exe_cli}} {{exe_gui}}
	tup generate {{build_sh}}

debug: build-cli
	lldb {{exe_cli}} {{params}}

memcheck: build-cli
    valgrind --leak-check=yes {{exe_cli}} {{params}}

massif: build-cli
    valgrind --tool=massif --massif-out-file=pipeline.massif {{exe_cli}} {{params}}
    ms_print pipeline.massif

callgrind: build-cli
    valgrind --tool=callgrind {{exe_cli}} {{params}}

archive: #generate-build
	git archive --add-file={{build_sh}} --output={{name}}.zip --prefix={{name}}/ HEAD
