-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
94 lines (75 loc) · 2.32 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
85
86
87
88
89
90
91
92
93
94
.POSIX:
.SUFFIXES:
PKGNAME=qol-assist
MODULE=github.com/getsolus/qol-assist
MANPAGE=$(PKGNAME).1
SERVICE=$(PKGNAME)-migration.service
VERSION="1.1.0"
PREFIX?=/usr/local
BINDIR?=$(DESTDIR)$(PREFIX)/bin
MANDIR?=$(DESTDIR)$(PREFIX)/man
SYSDIR?=$(DESTDIR)/etc/$(PKGNAME).d
USRDIR?=$(DESTDIR)$(PREFIX)/share/defaults/$(PKGNAME).d
TRACKDIR?=$(DESTDIR)/var/lib/$(PKGNAME)
SYSTEMDUNITDIR?=$(DESTDIR)/etc/systemd/system
GO?=go
GOFLAGS?=
GOSRC!=find . -name "*.go"
GOSRC+=go.mod go.sum
# Exists in GNUMake but not in NetBSD make and others.
RM?=rm -f
qol-assist: $(GOSRC)
$(GO) build $(GOFLAGS) \
-ldflags " \
-X $(MODULE)/cli.VersionNumber=$(VERSION) \
-X $(MODULE)/core.TrackDir=$(TRACKDIR) \
-X $(MODULE)/core.SysDir=$(SYSDIR) \
-X $(MODULE)/core.UsrDir=$(USRDIR)" \
-o $@
qol-assist-migration.service: resources/$(SERVICE).in
cp resources/$(SERVICE).in $(SERVICE)
sed -i "s:@TRACKDIR@:$(TRACKDIR):g" $(SERVICE)
sed -i "s:@BINDIR@:$(BINDIR):g" $(SERVICE)
qol-assist.1: resources/$(MANPAGE).scd.in
scdoc < resources/$(MANPAGE).scd.in > $(MANPAGE)
sed -i "s:%TRACKDIR%:$(TRACKDIR):g" $(MANPAGE)
all: qol-assist qol-assist-migration.service qol-assist.1
clean:
$(GO) mod tidy
$(RM) $(DOCS) $(PKGNAME) $(SERVICE) $(MANPAGE) *.tar.gz
$(RM) -r vendor
install: all
install -Dm 0755 $(PKGNAME) $(BINDIR)/$(PKGNAME)
install -Dm 0644 $(PKGNAME)-migration.service $(SYSTEMDUNITDIR)/$(PKGNAME)-migration.service
install -Dm 0644 $(MANPAGE) $(MANDIR)/$(MANPAGE)
RMDIR_IF_EMPTY:=sh -c "\
if test -d $$0 && ! ls -1qA $$0 | grep -q . ; then \
rmdir $$0; \
fi"
uninstall:
$(RM) $(BINDIR)/$(PKGNAME)
$(RM) $(SYSTEMDUNITDIR)/$(PKGNAME)-migration.service
$(RM) $()
check:
$(GO) get -u github.com/securego/gosec/cmd/gosec
$(GO) get -u honnef.co/go/tools/cmd/staticcheck
$(GO) get -u gitlab.com/opennota/check/cmd/aligncheck
$(GO) fmt -x ./...
$(GO) vet ./...
gosec -exclude=G204 ./...
staticcheck ./...
aligncheck ./...
$(GO) test -cover ./...
vendor: check clean
$(GO) mod vendor
package: vendor
tar --exclude=".git" \
--exclude="*.tar.gz" \
--exclude="examples" \
--exclude="tags" \
--exclude=".vscode" \
--exclude=".idea" \
--exclude="*~" \
-zcvf $(PKGNAME)-v$(VERSION).tar.gz ../$(PKGNAME)
.DEFAULT_GOAL := all
.PHONY: all clean install uninstall check vendor package