GO ?= go

.PHONY: build lint install uninstall install-openrc uninstall-openrc

all: build

build:
	$(GO) build -o hjem

lint:
	$(GO) vet ./...
	$(GO) fmt ./...

install:
	cp hjem /usr/local/bin

uninstall:
	$(RM) /usr/local/bin/hjem

install-openrc:
	cp hjem.initd /etc/init.d/hjem
	user="$${SUDO_USER:-$${DOAS_USER}}"; \
	echo "command_user=$$user" >> /etc/init.d/hjem

uninstall-openrc:
	$(RM) /etc/init.d/hjem
