2019-11-19 19:55:02 +01:00
|
|
|
NEBULA_CMD_PATH = "./cmd/nebula"
|
2019-11-19 18:00:20 +01:00
|
|
|
BUILD_NUMBER ?= dev+$(shell date -u '+%Y%m%d%H%M%S')
|
|
|
|
GO111MODULE = on
|
|
|
|
export GO111MODULE
|
|
|
|
|
2019-12-21 07:15:41 +01:00
|
|
|
ALL_LINUX = linux-amd64 \
|
2019-12-20 19:55:15 +01:00
|
|
|
linux-386 \
|
|
|
|
linux-ppc64le \
|
2019-12-20 20:08:18 +01:00
|
|
|
linux-arm-5 \
|
2019-12-20 19:55:15 +01:00
|
|
|
linux-arm-6 \
|
2019-12-20 20:08:18 +01:00
|
|
|
linux-arm-7 \
|
2019-12-20 19:55:15 +01:00
|
|
|
linux-arm64 \
|
|
|
|
linux-mips \
|
|
|
|
linux-mipsle \
|
|
|
|
linux-mips64 \
|
2019-12-21 07:15:41 +01:00
|
|
|
linux-mips64le
|
|
|
|
|
|
|
|
ALL = $(ALL_LINUX) \
|
2019-12-20 19:55:15 +01:00
|
|
|
darwin-amd64 \
|
|
|
|
windows-amd64
|
2019-12-20 19:44:11 +01:00
|
|
|
|
|
|
|
all: $(ALL:%=build/%/nebula) $(ALL:%=build/%/nebula-cert)
|
|
|
|
|
|
|
|
release: $(ALL:%=build/nebula-%.tar.gz)
|
2019-11-19 18:00:20 +01:00
|
|
|
|
2019-12-21 07:15:41 +01:00
|
|
|
release-linux: $(ALL_LINUX:%=build/nebula-%.tar.gz)
|
|
|
|
|
2019-11-19 18:00:20 +01:00
|
|
|
bin:
|
2019-12-20 19:44:11 +01:00
|
|
|
go build -trimpath -ldflags "-X main.Build=$(BUILD_NUMBER)" -o ./nebula ${NEBULA_CMD_PATH}
|
|
|
|
go build -trimpath -ldflags "-X main.Build=$(BUILD_NUMBER)" -o ./nebula-cert ./cmd/nebula-cert
|
2019-11-19 18:00:20 +01:00
|
|
|
|
|
|
|
install:
|
2019-12-20 19:44:11 +01:00
|
|
|
go install -trimpath -ldflags "-X main.Build=$(BUILD_NUMBER)" ${NEBULA_CMD_PATH}
|
|
|
|
go install -trimpath -ldflags "-X main.Build=$(BUILD_NUMBER)" ./cmd/nebula-cert
|
|
|
|
|
|
|
|
build/%/nebula: .FORCE
|
|
|
|
GOOS=$(firstword $(subst -, , $*)) \
|
2019-12-20 19:55:15 +01:00
|
|
|
GOARCH=$(word 2, $(subst -, ,$*)) \
|
|
|
|
GOARM=$(word 3, $(subst -, ,$*)) \
|
|
|
|
go build -trimpath -o $@ -ldflags "-X main.Build=$(BUILD_NUMBER)" ${NEBULA_CMD_PATH}
|
2019-12-20 19:44:11 +01:00
|
|
|
|
|
|
|
build/%/nebula-cert: .FORCE
|
|
|
|
GOOS=$(firstword $(subst -, , $*)) \
|
2019-12-20 19:55:15 +01:00
|
|
|
GOARCH=$(word 2, $(subst -, ,$*)) \
|
|
|
|
GOARM=$(word 3, $(subst -, ,$*)) \
|
|
|
|
go build -trimpath -o $@ -ldflags "-X main.Build=$(BUILD_NUMBER)" ./cmd/nebula-cert
|
2019-12-20 19:44:11 +01:00
|
|
|
|
|
|
|
build/nebula-%.tar.gz: build/%/nebula build/%/nebula-cert
|
|
|
|
tar -zcv -C build/$* -f $@ nebula nebula-cert
|
2019-11-19 18:00:20 +01:00
|
|
|
|
|
|
|
vet:
|
|
|
|
go vet -v ./...
|
|
|
|
|
|
|
|
test:
|
|
|
|
go test -v ./...
|
|
|
|
|
|
|
|
test-cov-html:
|
|
|
|
go test -coverprofile=coverage.out
|
|
|
|
go tool cover -html=coverage.out
|
|
|
|
|
|
|
|
bench:
|
|
|
|
go test -bench=.
|
|
|
|
|
|
|
|
bench-cpu:
|
|
|
|
go test -bench=. -benchtime=5s -cpuprofile=cpu.pprof
|
|
|
|
go tool pprof go-audit.test cpu.pprof
|
|
|
|
|
|
|
|
bench-cpu-long:
|
|
|
|
go test -bench=. -benchtime=60s -cpuprofile=cpu.pprof
|
|
|
|
go tool pprof go-audit.test cpu.pprof
|
|
|
|
|
|
|
|
proto: nebula.pb.go cert/cert.pb.go
|
|
|
|
|
|
|
|
nebula.pb.go: nebula.proto .FORCE
|
|
|
|
go build github.com/golang/protobuf/protoc-gen-go
|
|
|
|
PATH="$(PWD):$(PATH)" protoc --go_out=. $<
|
|
|
|
rm protoc-gen-go
|
|
|
|
|
|
|
|
cert/cert.pb.go: cert/cert.proto .FORCE
|
|
|
|
$(MAKE) -C cert cert.pb.go
|
|
|
|
|
2019-11-19 19:55:02 +01:00
|
|
|
service:
|
|
|
|
@echo > /dev/null
|
|
|
|
$(eval NEBULA_CMD_PATH := "./cmd/nebula-service")
|
|
|
|
ifeq ($(words $(MAKECMDGOALS)),1)
|
|
|
|
$(MAKE) service ${.DEFAULT_GOAL} --no-print-directory
|
|
|
|
endif
|
|
|
|
|
2019-11-19 18:00:20 +01:00
|
|
|
.FORCE:
|
2019-11-19 19:55:02 +01:00
|
|
|
.PHONY: test test-cov-html bench bench-cpu bench-cpu-long bin proto release service
|
2019-11-19 18:00:20 +01:00
|
|
|
.DEFAULT_GOAL := bin
|