1
0
mirror of https://github.com/cloudflare/gortr.git synced 2024-05-19 06:50:10 +00:00
cloudflare-gortr/Makefile

99 lines
3.0 KiB
Makefile
Raw Normal View History

EXTENSION ?=
DIST_DIR ?= dist/
GOOS ?= linux
ARCH ?= $(shell uname -m)
BUILDINFOSDET ?=
2019-07-31 15:14:36 -07:00
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)'
2020-10-28 16:51:28 -07:00
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)
2020-10-28 16:51:28 -07:00
OUTPUT_RTRMON := $(DIST_DIR)rtrmon-$(GORTR_VERSION)-$(GOOS)-$(ARCH)$(EXTENSION)
.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
go test -v github.com/cloudflare/gortr/prefixfile
2019-10-20 23:28:54 -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
.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
.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 .
.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
.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 \
2020-10-28 16:51:28 -07:00
$(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) \
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