-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
106 lines (86 loc) · 2.82 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
95
96
97
98
99
100
101
102
103
104
105
106
BIN := waybar-eyes
VERSION := $(shell git describe --long --tags | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g')
PREFIX ?= /usr
LIB_DIR = $(DESTDIR)$(PREFIX)/lib
BIN_DIR = $(DESTDIR)$(PREFIX)/bin
SHARE_DIR = $(DESTDIR)$(PREFIX)/share
export CGO_CPPFLAGS := ${CPPFLAGS}
export CGO_CFLAGS := ${CFLAGS}
export CGO_CXXFLAGS := ${CXXFLAGS}
export CGO_LDFLAGS := ${LDFLAGS}
export GOFLAGS := -buildmode=pie -trimpath -mod=readonly -modcacherw
.PHONY: local
local: vendor build
.PHONY: run
run: local
go run main.go
.PHONY: generate
generate:
go generate -mod=vendor ./...
.PHONY: build
build: main.go
go build -trimpath -ldflags "-X github.com/cyrinux/waybar-eyes/main.Version=$(VERSION) -linkmode=external" -o $(BIN) main.go
.PHONY: debug
debug: main.go
go build -gcflags='all=-N -l' -ldflags "-X github.com/cyrinux/waybar-eyes/main.Version=$(VERSION) -linkmode=external" -o $(BIN) main.go
dlv exec ./waybar-eyes
.PHONY: release
release: build
strip $(BIN) 2>/dev/null || true
upx -9 $(BIN) 2>/dev/null || true
.PHONY: vendor
vendor:
go mod tidy
go mod vendor
.PHONY: clean
clean:
rm -f "$(BIN)"
rm -rf dist
rm -rf vendor
.PHONY: fmt
fmt: ## Verifies all files have been `gofmt`ed.
@echo "+ $@"
@gofmt -s -l .
.PHONY: lint
lint: ## Verifies `golint` passes.
@echo "+ $@"
@if [ ! -z "$(shell revive ./... | grep -v vendor | tee /dev/stderr)" ]; then \
exit 1; \
fi
.PHONY: vet
vet: ## Verifies `go vet` passes.
@echo "+ $@"
@if [ ! -z "$(shell go vet $(shell go list ./... | grep -v vendor) | tee /dev/stderr)" ]; then \
exit 1; \
fi
.PHONY: staticcheck
staticcheck: ## Verifies `staticcheck` passes
@echo "+ $@"
@if [ ! -z "$(shell staticcheck $(shell go list ./... | grep -v vendor) | tee /dev/stderr)" ]; then \
exit 1; \
fi
.PHONY: dist
dist: clean vendor build
$(eval TMP := $(shell mktemp -d))
mkdir "$(TMP)/$(BIN)-$(VERSION)"
cp -r * "$(TMP)/$(BIN)-$(VERSION)"
(cd "$(TMP)" && tar -cvzf "$(BIN)-$(VERSION)-src.tar.gz" "$(BIN)-$(VERSION)")
mkdir "$(TMP)/$(BIN)-$(VERSION)-linux64"
cp -r LICENSE.md README.md example models $(BIN).service "$(TMP)/$(BIN)-$(VERSION)-linux64"
(cd "$(TMP)" && tar -cvzf "$(BIN)-$(VERSION)-linux64.tar.gz" "$(BIN)-$(VERSION)-linux64")
mkdir -p dist
mv "$(TMP)/$(BIN)-$(VERSION)"-*.tar.gz dist
git archive -o "dist/$(BIN)-$(VERSION).tar.gz" --format tar.gz --prefix "$(BIN)-$(VERSION)/" "$(VERSION)"
for file in dist/*; do \
gpg --detach-sign --armor "$$file"; \
done
rm -rf "$(TMP)"
rm -f "dist/$(BIN)-$(VERSION).tar.gz"
.PHONY: install
install:
install -Dm755 -t "$(BIN_DIR)/" $(BIN)
install -Dm644 -t "$(SHARE_DIR)/$(BIN)/models" models/*.xml
install -Dm644 -t "$(LIB_DIR)/systemd/user/" $(BIN).service
install -Dm644 -t "$(SHARE_DIR)/licenses/$(BIN)/" LICENSE.md
install -Dm644 -t "$(SHARE_DIR)/doc/$(BIN)/" README.md
install -Dm644 -t "$(SHARE_DIR)/doc/$(BIN)/example" example/style.css