#!/usr/bin/make -f

VENDOR ?= 1
CLEAN ?= 1
DEBUG ?= 0
DESTDIR=debian/tmp

%:
	dh $@ --with=systemd

override_dh_auto_clean:
	if test "${CLEAN}" = "1"; then \
		cargo clean; \
	fi

	if ! ischroot && test "${VENDOR}" = "1"; then \
		mkdir -p .cargo; \
		cargo vendor --sync plugins/Cargo.toml \
			--sync bin/Cargo.toml \
			--sync service/Cargo.toml \
			| head -n -1 > .cargo/config; \
		echo 'directory = "vendor"' >> .cargo/config; \
		tar pcf vendor.tar vendor; \
		rm -rf vendor; \
	fi

override_dh_auto_build:
	just rootdir=$(DESTDIR) build-vendored

override_dh_auto_install:
	just rootdir=$(DESTDIR) install

override_dh_fixperms:
	dh_fixperms
	chmod +x debian/pop-launcher/usr/lib/pop-launcher/scripts/**/*.sh