forked from cloudflare/gortr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
98 lines (82 loc) · 2.97 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
EXTENSION ?=
DIST_DIR ?= dist/
GOOS ?= linux
ARCH ?= $(shell uname -m)
BUILDINFOSDET ?=
DOCKER_REPO := cloudflare/
GORTR_NAME := gortr
GORTR_VERSION := $(shell git describe --tags $(git rev-list --tags --max-count=1))
VERSION_PKG := $(shell echo $(GORTR_VERSION) | sed 's/^v//g')
ARCH := x86_64
LICENSE := BSD-3
URL := https://github.com/cloudflare/gortr
DESCRIPTION := GoRTR: a RPKI-to-Router server
BUILDINFOS := ($(shell date +%FT%T%z)$(BUILDINFOSDET))
LDFLAGS := '-X main.version=$(GORTR_VERSION) -X main.buildinfos=$(BUILDINFOS)'
RTRDUMP_NAME := rtrdump
RTRMON_NAME := rtrmon
OUTPUT_GORTR := $(DIST_DIR)gortr-$(GORTR_VERSION)-$(GOOS)-$(ARCH)$(EXTENSION)
OUTPUT_RTRDUMP := $(DIST_DIR)rtrdump-$(GORTR_VERSION)-$(GOOS)-$(ARCH)$(EXTENSION)
OUTPUT_RTRMON := $(DIST_DIR)rtrmon-$(GORTR_VERSION)-$(GOOS)-$(ARCH)$(EXTENSION)
.PHONY: vet
vet:
go vet cmd/gortr/gortr.go
.PHONY: test
test:
go test -v github.com/cloudflare/gortr/lib
go test -v github.com/cloudflare/gortr/prefixfile
.PHONY: prepare
prepare:
mkdir -p $(DIST_DIR)
.PHONY: clean
clean:
rm -rf $(DIST_DIR)
.PHONY: dist-key
dist-key: prepare
cp cmd/gortr/cf.pub $(DIST_DIR)
.PHONY: build-gortr
build-gortr: prepare
go build -ldflags $(LDFLAGS) -o $(OUTPUT_GORTR) cmd/gortr/gortr.go
.PHONY: build-rtrdump
build-rtrdump:
go build -ldflags $(LDFLAGS) -o $(OUTPUT_RTRDUMP) cmd/rtrdump/rtrdump.go
.PHONY: build-rtrmon
build-rtrmon:
go build -ldflags $(LDFLAGS) -o $(OUTPUT_RTRMON) cmd/rtrmon/rtrmon.go
.PHONY: docker-gortr
docker-gortr:
docker build -t $(DOCKER_REPO)$(GORTR_NAME):$(GORTR_VERSION) --build-arg LDFLAGS=$(LDFLAGS) -f Dockerfile.gortr .
.PHONY: docker-rtrdump
docker-rtrdump:
docker build -t $(DOCKER_REPO)$(RTRDUMP_NAME):$(GORTR_VERSION) --build-arg LDFLAGS=$(LDFLAGS) -f Dockerfile.rtrdump .
.PHONY: docker-rtrmon
docker-rtrmon:
docker build -t $(DOCKER_REPO)$(RTRMON_NAME):$(GORTR_VERSION) --build-arg LDFLAGS=$(LDFLAGS) -f Dockerfile.rtrmon .
.PHONY: package-deb-gortr
package-deb-gortr: prepare
fpm -s dir -t deb -n $(GORTR_NAME) -v $(VERSION_PKG) \
--description "$(DESCRIPTION)" \
--url "$(URL)" \
--architecture $(ARCH) \
--license "$(LICENSE)" \
--package $(DIST_DIR) \
$(OUTPUT_GORTR)=/usr/bin/gortr \
package/gortr.service=/lib/systemd/system/gortr.service \
package/gortr.env=/etc/default/gortr \
cmd/gortr/cf.pub=/usr/share/gortr/cf.pub \
$(OUTPUT_RTRDUMP)=/usr/bin/rtrdump \
$(OUTPUT_RTRMON)=/usr/bin/rtrmon
.PHONY: package-rpm-gortr
package-rpm-gortr: prepare
fpm -s dir -t rpm -n $(GORTR_NAME) -v $(VERSION_PKG) \
--description "$(DESCRIPTION)" \
--url "$(URL)" \
--architecture $(ARCH) \
--license "$(LICENSE) "\
--package $(DIST_DIR) \
$(OUTPUT_GORTR)=/usr/bin/gortr \
package/gortr.service=/lib/systemd/system/gortr.service \
package/gortr.env=/etc/default/gortr \
cmd/gortr/cf.pub=/usr/share/gortr/cf.pub \
$(OUTPUT_RTRDUMP)=/usr/bin/rtrdump \
$(OUTPUT_RTRMON)=/usr/bin/rtrmon