ifneq (,$(wildcard ./.env))
    include .env
    export
endif

DATABASE_URL ?= sqlite://emgauwa-dev.sqlite
export DATABASE_URL

sqlx:
	cargo sqlx database drop -y
	cargo sqlx database create
	cargo sqlx migrate run
	cargo sqlx prepare --workspace

build-rpi:
	cross build --target arm-unknown-linux-gnueabihf

emgauwa-%.json: config/emgauwa-%.pkl config/lib/%.pkl config/lib/common.pkl $(wildcard .env)
	pkl eval -f json -o $@ $<

configs:
	$(MAKE) emgauwa-core.json
	$(MAKE) emgauwa-controller.json

clean:
	rm -f emgauwa-controller.json
	rm -f emgauwa-controller.sqlite
	rm -f emgauwa-core.json
	rm -f emgauwa-core.sqlite
	rm -f emgauwa-dev.sqlite