VERSION := $(shell cat VERSION)
BINARY := klp
LDFLAGS := -ldflags "-X github.com/yeho/klp/cmd.Version=$(VERSION)"

.PHONY: build install clean service-install service-uninstall

build:
	go build $(LDFLAGS) -o $(BINARY) .

install: build
	mkdir -p ~/.local/bin
	-~/.local/bin/klp service stop 2>/dev/null || true
	cp $(BINARY) ~/.local/bin/
	~/.local/bin/klp service start

clean:
	rm -f $(BINARY)

service-install:
	mkdir -p ~/.config/systemd/user
	cp klp.service ~/.config/systemd/user/
	systemctl --user daemon-reload
	@echo "Service installed. Enable with: systemctl --user enable --now klp"

service-uninstall:
	systemctl --user stop klp || true
	systemctl --user disable klp || true
	rm -f ~/.config/systemd/user/klp.service
	systemctl --user daemon-reload

autostart-install:
	mkdir -p ~/.config/autostart
	cp klp.desktop ~/.config/autostart/

autostart-uninstall:
	rm -f ~/.config/autostart/klp.desktop
