NAME = netoik-api VERSION = $(shell [ -d ".git" ] && git describe | sed "s/-/./g") BRANCH = $(shell [ -d ".git" ] && git branch --show-current) SYSCONFDIR = $(shell rpm --eval "%{_sysconfdir}") UNITDIR = $(shell rpm --eval "%{_unitdir}") BINDIR = $(shell rpm --eval "%{_bindir}") VARDIR = $(shell rpm --eval "%{_var}") .PHONY: build build: bin/server bin/server: cmd/server/main.go pkg/*/*.go go.mod go.sum mkdir --parents bin CGO_ENABLED=0 go build -o "$@" ./cmd/server/main.go .PHONY: version version: @echo $(VERSION) .PHONY: tarball tarball: $(HOME)/rpmbuild/SOURCES/$(NAME)-$(VERSION).tar.gz $(HOME)/rpmbuild/SOURCES/$(NAME)-%.tar.gz: . git archive --format=tar.gz --output=$@ --prefix=$(NAME)-$(VERSION)/ --worktree-attributes --verbose $(BRANCH) .PHONY: install install: mkdir --parents $(DESTDIR)$(VARDIR)/$(NAME)/captcha mkdir --parents $(DESTDIR)$(SYSCONFDIR)/$(NAME) install server.conf.sample $(DESTDIR)$(SYSCONFDIR)/$(NAME)/server.conf.sample install server.conf.sample $(DESTDIR)$(SYSCONFDIR)/$(NAME)/server.conf mkdir --parents $(DESTDIR)$(UNITDIR) install systemd/netoik-api-server.service $(DESTDIR)$(UNITDIR)/netoik-api-server.service mkdir --parents $(DESTDIR)$(BINDIR) install bin/server $(DESTDIR)$(BINDIR)/$(NAME)-server