-
Notifications
You must be signed in to change notification settings - Fork 32
/
Makefile
79 lines (65 loc) · 2.19 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
BIN := mkr
VERSION := 0.58.0
CURRENT_REVISION := $(shell git rev-parse --short HEAD)
BUILD_LDFLAGS := "-w -s -X main.gitcommit=$(CURRENT_REVISION)"
export CGO_ENABLED := 0
.PHONY: all
all: clean cross test rpm deb
.PHONY: devel-deps
devel-deps:
go install github.com/Songmu/goxz/cmd/goxz
.PHONY: test
test:
go test -v ./...
.PHONY: build
build:
go build -ldflags=$(BUILD_LDFLAGS) -o $(BIN) .
.PHONY: cross
cross: devel-deps
goxz -d snapshot -os darwin -arch amd64,arm64 \
-build-ldflags=$(BUILD_LDFLAGS)
goxz -d snapshot -os linux -arch 386,amd64,arm64,arm \
-build-ldflags=$(BUILD_LDFLAGS)
.PHONY: rpm
rpm: rpm-v2
.PHONY: rpm-v2
rpm-v2: rpm-v2-x86 rpm-v2-arm64
.PHONY: rpm-v2-x86
rpm-v2-x86:
GOOS=linux GOARCH=amd64 make build
rpmbuild --define "_builddir `pwd`" --define "_version ${VERSION}" \
--define "buildarch x86_64" --target x86_64 --define "dist .el7.centos" \
-bb packaging/rpm/mkr-v2.spec
rpmbuild --define "_builddir `pwd`" --define "_version ${VERSION}" \
--define "buildarch x86_64" --target x86_64 --define "dist .amzn2" \
-bb packaging/rpm/mkr-v2.spec
.PHONY: rpm-v2-arm64
rpm-v2-arm64:
GOOS=linux GOARCH=arm64 make build
rpmbuild --define "_builddir `pwd`" --define "_version ${VERSION}" \
--define "buildarch aarch64" --target aarch64 --define "dist .el7.centos" \
-bb packaging/rpm/mkr-v2.spec
rpmbuild --define "_builddir `pwd`" --define "_version ${VERSION}" \
--define "buildarch aarch64" --target aarch64 --define "dist .amzn2" \
-bb packaging/rpm/mkr-v2.spec
.PHONY: deb
deb: deb-v2-x86 deb-v2-arm64 deb-v2-arm
.PHONY: deb-v2-x86
deb-v2-x86:
GOOS=linux GOARCH=amd64 make build
cp $(BIN) packaging/deb-v2/debian/$(BIN).bin
cd packaging/deb-v2 && debuild --no-tgz-check -rfakeroot -uc -us
.PHONY: deb-v2-arm64
deb-v2-arm64:
GOOS=linux GOARCH=arm64 make build
cp $(BIN) packaging/deb-v2/debian/$(BIN).bin
cd packaging/deb-v2 && debuild --no-tgz-check -rfakeroot -uc -us -aarm64
.PHONY: deb-v2-arm
deb-v2-arm:
GOOS=linux GOARCH=arm ARM=6 make build # Build ARMv6 binary for Raspbian
cp $(BIN) packaging/deb-v2/debian/$(BIN).bin
cd packaging/deb-v2 && debuild --no-tgz-check -rfakeroot -uc -us -aarmhf
.PHONY: clean
clean:
rm -fr build snapshot
go clean