34 lines
1.2 KiB
Makefile
34 lines
1.2 KiB
Makefile
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:
|
|
install -D --no-target-directory server.conf.sample $(DESTDIR)$(SYSCONFDIR)/$(NAME)/server.conf
|
|
install -D --target-directory=$(DESTDIR)$(SYSCONFDIR)/$(NAME) server.conf.sample
|
|
install -D --target-directory=$(DESTDIR)$(UNITDIR) systemd/netoik-api-server.service
|
|
install -D --no-target-directory bin/server $(DESTDIR)$(BINDIR)/$(NAME)-server
|
|
install --directory $(DESTDIR)$(VARDIR)/$(NAME)/captcha
|