-
Notifications
You must be signed in to change notification settings - Fork 86
/
Makefile
84 lines (68 loc) · 2.83 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
PROGNM := sbctl
PREFIX := /usr/local
BINDIR := $(PREFIX)/bin
LIBDIR := $(PREFIX)/lib
SHRDIR := $(PREFIX)/share
DOCDIR := $(PREFIX)/share/doc
MANDIR := $(PREFIX)/share/man
MANS = $(basename $(wildcard docs/*.txt))
GOFLAGS ?= -buildmode=pie -trimpath
TAG = $(shell git describe --abbrev=0 --tags)
GIT_DESCRIBE = $(shell git describe | sed 's/-/./g;s/^v//;')
VERSION = $(shell if test -f VERSION; then cat VERSION; else echo -n $(GIT_DESCRIBE) ; fi)
all: man build
build: sbctl
man: $(MANS)
$(MANS):
docs/sbctl.%: docs/sbctl.%.txt docs/asciidoc.conf
a2x --no-xmllint --asciidoc-opts="-f docs/asciidoc.conf" -d manpage -f manpage -D docs $<
.PHONY: sbctl
sbctl:
go build -ldflags="-X github.com/foxboron/sbctl.Version=$(VERSION)" -o $@ ./cmd/$@
.PHONY: completions
completions: sbctl
./sbctl completion bash | install -D /dev/stdin contrib/completions/bash-completion/completions/sbctl
./sbctl completion zsh | install -D /dev/stdin contrib/completions/zsh/site-functions/_sbctl
./sbctl completion fish | install -D /dev/stdin contrib/completions/fish/vendor_completions.d/sbctl.fish
install: sbctl completions man
install -Dm755 sbctl -t '$(DESTDIR)$(BINDIR)'
for manfile in $(MANS); do \
install -Dm644 "$$manfile" -t '$(DESTDIR)$(MANDIR)/man'"$${manfile##*.}"; \
done;
install -Dm644 contrib/completions/bash-completion/completions/sbctl '$(DESTDIR)$(SHRDIR)/bash-completion/completions/sbctl'
install -Dm644 contrib/completions/zsh/site-functions/_sbctl '$(DESTDIR)$(SHRDIR)/zsh/site-functions/_sbctl'
install -Dm644 contrib/completions/fish/vendor_completions.d/sbctl.fish '$(DESTDIR)$(SHRDIR)/fish/vendor_completions.d/sbctl.fish'
install -Dm755 contrib/kernel-install/91-sbctl.install '$(DESTDIR)$(LIBDIR)/kernel/install.d/91-sbctl.install'
install -Dm644 LICENSE -t '$(DESTDIR)$(SHRDIR)/licenses/$(PROGNM)'
.PHONY: release
release:
echo -n "$(GIT_DESCRIBE)" > VERSION
mkdir -p releases
git archive --prefix=${PROGNM}-${TAG}/ --add-file=VERSION -o releases/${PROGNM}-${TAG}.tar.gz ${TAG};
gpg --detach-sign -o releases/${PROGNM}-${TAG}.tar.gz.sig releases/${PROGNM}-${TAG}.tar.gz
gh release upload ${TAG} releases/${PROGNM}-${TAG}.tar.gz.sig releases/${PROGNM}-${TAG}.tar.gz
.PHONY: push-aur
push-aur:
git subtree push -P "contrib/aur/sbctl-git" aur:sbctl-git.git master
clean:
rm -f $(MANS)
rm -f sbctl
.PHONY: lint
lint:
go vet ./...
go run honnef.co/go/tools/cmd/[email protected] ./...
.PHONY: test
test:
go test -v ./...
.PHONY: integration
integration:
# vmtest doesn't allow provide a way to pass --tags to the command that compiles
# the test (see: vmtest.RunGoTestsInVM) so we pass it as an env variable.
GOFLAGS=--tags=integration go test -v tests/integration_test.go
.PHONY: local-aur
.ONESHELL:
local-aur:
cd ./contrib/aur/sbctl-git
mkdir -p ./src
ln -srfT $(CURDIR) ./src/sbctl
makepkg --holdver --syncdeps --noextract --force