2019-07-30 22:53:10 -07:00
|
|
|
EXTENSION ?=
|
|
|
|
DIST_DIR ?= dist/
|
|
|
|
GOOS ?= linux
|
|
|
|
ARCH ?= $(shell uname -m)
|
|
|
|
BUILDINFOSDET ?=
|
|
|
|
|
2019-07-31 15:14:36 -07:00
|
|
|
DOCKER_REPO := cloudflare/
|
2019-07-30 22:53:10 -07:00
|
|
|
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)'
|
|
|
|
|
2020-10-28 16:51:28 -07:00
|
|
|
RTRDUMP_NAME := rtrdump
|
|
|
|
RTRMON_NAME := rtrmon
|
2020-02-26 21:12:05 -08:00
|
|
|
|
2019-07-30 22:53:10 -07:00
|
|
|
OUTPUT_GORTR := $(DIST_DIR)gortr-$(GORTR_VERSION)-$(GOOS)-$(ARCH)$(EXTENSION)
|
2020-02-26 21:12:05 -08:00
|
|
|
OUTPUT_RTRDUMP := $(DIST_DIR)rtrdump-$(GORTR_VERSION)-$(GOOS)-$(ARCH)$(EXTENSION)
|
2020-10-28 16:51:28 -07:00
|
|
|
OUTPUT_RTRMON := $(DIST_DIR)rtrmon-$(GORTR_VERSION)-$(GOOS)-$(ARCH)$(EXTENSION)
|
2019-07-30 22:53:10 -07:00
|
|
|
|
|
|
|
.PHONY: vet
|
|
|
|
vet:
|
|
|
|
go vet cmd/gortr/gortr.go
|
|
|
|
|
2019-10-20 23:28:54 -07:00
|
|
|
.PHONY: test
|
|
|
|
test:
|
|
|
|
go test -v github.com/cloudflare/gortr/lib
|
2019-10-27 21:27:59 -07:00
|
|
|
go test -v github.com/cloudflare/gortr/prefixfile
|
2019-10-20 23:28:54 -07:00
|
|
|
|
2019-07-30 22:53:10 -07:00
|
|
|
.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
|
|
|
|
|
2020-02-26 21:12:05 -08:00
|
|
|
.PHONY: build-rtrdump
|
|
|
|
build-rtrdump:
|
|
|
|
go build -ldflags $(LDFLAGS) -o $(OUTPUT_RTRDUMP) cmd/rtrdump/rtrdump.go
|
|
|
|
|
2020-10-28 16:51:28 -07:00
|
|
|
.PHONY: build-rtrmon
|
|
|
|
build-rtrmon:
|
2020-10-28 16:53:32 -07:00
|
|
|
go build -ldflags $(LDFLAGS) -o $(OUTPUT_RTRMON) cmd/rtrmon/rtrmon.go
|
2020-10-28 16:51:28 -07:00
|
|
|
|
2019-07-30 22:53:10 -07:00
|
|
|
.PHONY: docker-gortr
|
|
|
|
docker-gortr:
|
2019-07-31 15:14:36 -07:00
|
|
|
docker build -t $(DOCKER_REPO)$(GORTR_NAME):$(GORTR_VERSION) --build-arg LDFLAGS=$(LDFLAGS) -f Dockerfile.gortr .
|
2019-07-30 22:53:10 -07:00
|
|
|
|
2020-02-26 21:12:05 -08:00
|
|
|
.PHONY: docker-rtrdump
|
|
|
|
docker-rtrdump:
|
|
|
|
docker build -t $(DOCKER_REPO)$(RTRDUMP_NAME):$(GORTR_VERSION) --build-arg LDFLAGS=$(LDFLAGS) -f Dockerfile.rtrdump .
|
|
|
|
|
2020-10-28 16:51:28 -07:00
|
|
|
.PHONY: docker-rtrmon
|
|
|
|
docker-rtrmon:
|
2020-10-28 16:53:32 -07:00
|
|
|
docker build -t $(DOCKER_REPO)$(RTRMON_NAME):$(GORTR_VERSION) --build-arg LDFLAGS=$(LDFLAGS) -f Dockerfile.rtrmon .
|
2020-10-28 16:51:28 -07:00
|
|
|
|
2019-07-30 22:53:10 -07:00
|
|
|
.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 \
|
2020-02-27 14:13:43 -08:00
|
|
|
cmd/gortr/cf.pub=/usr/share/gortr/cf.pub \
|
2020-10-28 16:51:28 -07:00
|
|
|
$(OUTPUT_RTRDUMP)=/usr/bin/rtrdump \
|
|
|
|
$(OUTPUT_RTRMON)=/usr/bin/rtrmon
|
2019-07-30 22:53:10 -07:00
|
|
|
|
|
|
|
.PHONY: package-rpm-gortr
|
|
|
|
package-rpm-gortr: prepare
|
|
|
|
fpm -s dir -t rpm -n $(GORTR_NAME) -v $(VERSION_PKG) \
|
2020-10-28 16:53:32 -07:00
|
|
|
--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
|