#!/usr/bin/make -f

PKG_BLANKON = praya-gnome-shell-extension
PKG_GENERIC = praya-gnome-shell-extension-generic

%:
	dh $@

override_dh_auto_build:
	make build-mo

# The unit suite needs node (JS) and python3 (prefs/generator). Neither is part
# of the standard IRGSH build chroot, and the package does not run them at
# build time otherwise. Run them when both are present, skip otherwise, so the
# package builds on a bare build-deps-only environment. Run `make test` from a
# dev checkout for the full suite.
override_dh_auto_test:
	@if command -v node >/dev/null 2>&1 && command -v python3 >/dev/null 2>&1; then \
		make test; \
	else \
		echo "dh_auto_test: skipping tests (node and/or python3 not installed)"; \
	fi

override_dh_auto_install:
	# ---- BlankOn variant (extension + distro integration) ----
	debian/install-extension.sh $(CURDIR)/debian/$(PKG_BLANKON) 0
	install -d $(CURDIR)/debian/$(PKG_BLANKON)/usr/share/glib-2.0/schemas
	install -m 644 debian/10_praya.gschema.override $(CURDIR)/debian/$(PKG_BLANKON)/usr/share/glib-2.0/schemas/
	install -d $(CURDIR)/debian/$(PKG_BLANKON)/usr/lib/praya-extension
	install -m 755 debian/praya-update-user.sh $(CURDIR)/debian/$(PKG_BLANKON)/usr/lib/praya-extension/
	install -d $(CURDIR)/debian/$(PKG_BLANKON)/etc/skel/.config/autostart
	install -m 644 debian/praya-extension-update.desktop $(CURDIR)/debian/$(PKG_BLANKON)/etc/skel/.config/autostart/

	# ---- Generic variant (extension only, no BlankOn integration) ----
	debian/install-extension.sh $(CURDIR)/debian/$(PKG_GENERIC) 1
