PREFIX    ?= /usr
DESTDIR   ?=

# Daemon goes under libexec — not on $PATH; D-Bus / systemd activation
# is how the rest of the session reaches it. Matches the convention
# `xdg-desktop-portal-crustace` and upstream's `-gnome` / `-kde` follow.
LIBEXECDIR = $(DESTDIR)$(PREFIX)/libexec
DATADIR    = $(DESTDIR)$(PREFIX)/share
SYSTEMDDIR = $(DESTDIR)$(PREFIX)/lib/systemd/user

DBUS_DIR    = $(DATADIR)/dbus-1/services

.PHONY: all start install uninstall clean distclean

all:
	cargo build --release

start: all
	./target/release/crustace-notifier

install:
	install -Dm755 target/release/crustace-notifier                       $(LIBEXECDIR)/crustace-notifier
	install -Dm644 data/org.freedesktop.Notifications.service          $(DBUS_DIR)/org.freedesktop.Notifications.service
	install -Dm644 data/crustace-notifier.service                         $(SYSTEMDDIR)/crustace-notifier.service

uninstall:
	rm -f $(LIBEXECDIR)/crustace-notifier
	rm -f $(DBUS_DIR)/org.freedesktop.Notifications.service
	rm -f $(SYSTEMDDIR)/crustace-notifier.service

clean:
	cargo clean

distclean: clean
	dh_clean
	rm -f Cargo.lock
