2021-03-02 20:29:05 +01:00
|
|
|
GOMINVERSION = 1.16
|
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
|
|
|
|
|
2021-03-02 20:29:05 +01:00
|
|
|
# Ensure the version of go we are using is at least what is defined in GOMINVERSION at the top of this file
|
|
|
|
GOVERSION := $(shell go version | awk '{print substr($$3, 3)}')
|
|
|
|
GOISMIN := $(shell expr "$(GOVERSION)" ">=" "$(GOMINVERSION)")
|
|
|
|
ifneq "$(GOISMIN)" "1"
|
|
|
|
$(error "go version $(GOVERSION) is not supported, upgrade to $(GOMINVERSION) or above")
|
|
|
|
endif
|
|
|
|
|
2020-06-26 19:46:23 +02:00
|
|
|
LDFLAGS = -X main.Build=$(BUILD_NUMBER)
|
|
|
|
|
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 \
|
2020-06-26 19:46:23 +02:00
|
|
|
linux-mips64le \
|
|
|
|
linux-mips-softfloat
|
2019-12-21 07:15:41 +01:00
|
|
|
|
|
|
|
ALL = $(ALL_LINUX) \
|
2019-12-20 19:55:15 +01:00
|
|
|
darwin-amd64 \
|
2021-02-17 19:11:57 +01:00
|
|
|
darwin-arm64 \
|
2020-05-27 04:23:23 +02:00
|
|
|
freebsd-amd64 \
|
2019-12-20 19:55:15 +01:00
|
|
|
windows-amd64
|
2019-12-20 19:44:11 +01:00
|
|
|
|
2021-03-29 21:29:20 +02:00
|
|
|
e2e:
|
2021-03-31 17:26:35 +02:00
|
|
|
$(TEST_ENV) go test -tags=e2e_testing -count=1 $(TEST_FLAGS) ./e2e
|
|
|
|
|
|
|
|
e2ev: TEST_FLAGS = -v
|
|
|
|
e2ev: e2e
|
|
|
|
|
|
|
|
e2evv: TEST_ENV += TEST_LOGS=1
|
|
|
|
e2evv: e2ev
|
|
|
|
|
|
|
|
e2evvv: TEST_ENV += TEST_LOGS=2
|
|
|
|
e2evvv: e2ev
|
|
|
|
|
|
|
|
e2evvvv: TEST_ENV += TEST_LOGS=3
|
|
|
|
e2evvvv: e2ev
|
2021-03-02 20:29:05 +01:00
|
|
|
|
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)
|
|
|
|
|
2020-05-27 04:23:23 +02:00
|
|
|
release-freebsd: build/nebula-freebsd-amd64.tar.gz
|
|
|
|
|
2021-03-01 17:15:15 +01:00
|
|
|
BUILD_ARGS = -trimpath
|
|
|
|
|
2019-12-21 15:31:48 +01:00
|
|
|
bin-windows: build/windows-amd64/nebula.exe build/windows-amd64/nebula-cert.exe
|
|
|
|
mv $? .
|
|
|
|
|
|
|
|
bin-darwin: build/darwin-amd64/nebula build/darwin-amd64/nebula-cert
|
|
|
|
mv $? .
|
|
|
|
|
2020-05-27 04:23:23 +02:00
|
|
|
bin-freebsd: build/freebsd-amd64/nebula build/freebsd-amd64/nebula-cert
|
|
|
|
mv $? .
|
|
|
|
|
2019-11-19 18:00:20 +01:00
|
|
|
bin:
|
2021-03-01 17:15:15 +01:00
|
|
|
go build $(BUILD_ARGS) -ldflags "$(LDFLAGS)" -o ./nebula ${NEBULA_CMD_PATH}
|
|
|
|
go build $(BUILD_ARGS) -ldflags "$(LDFLAGS)" -o ./nebula-cert ./cmd/nebula-cert
|
2019-11-19 18:00:20 +01:00
|
|
|
|
|
|
|
install:
|
2021-03-01 17:15:15 +01:00
|
|
|
go install $(BUILD_ARGS) -ldflags "$(LDFLAGS)" ${NEBULA_CMD_PATH}
|
|
|
|
go install $(BUILD_ARGS) -ldflags "$(LDFLAGS)" ./cmd/nebula-cert
|
2020-06-26 19:46:23 +02:00
|
|
|
|
|
|
|
build/linux-arm-%: GOENV += GOARM=$(word 3, $(subst -, ,$*))
|
|
|
|
build/linux-mips-%: GOENV += GOMIPS=$(word 3, $(subst -, ,$*))
|
|
|
|
|
|
|
|
# Build an extra small binary for mips-softfloat
|
|
|
|
build/linux-mips-softfloat/%: LDFLAGS += -s -w
|
2019-12-20 19:44:11 +01:00
|
|
|
|
|
|
|
build/%/nebula: .FORCE
|
|
|
|
GOOS=$(firstword $(subst -, , $*)) \
|
2020-06-26 19:46:23 +02:00
|
|
|
GOARCH=$(word 2, $(subst -, ,$*)) $(GOENV) \
|
2021-03-01 17:15:15 +01:00
|
|
|
go build $(BUILD_ARGS) -o $@ -ldflags "$(LDFLAGS)" ${NEBULA_CMD_PATH}
|
2019-12-20 19:44:11 +01:00
|
|
|
|
|
|
|
build/%/nebula-cert: .FORCE
|
|
|
|
GOOS=$(firstword $(subst -, , $*)) \
|
2020-06-26 19:46:23 +02:00
|
|
|
GOARCH=$(word 2, $(subst -, ,$*)) $(GOENV) \
|
2021-03-01 17:15:15 +01:00
|
|
|
go build $(BUILD_ARGS) -o $@ -ldflags "$(LDFLAGS)" ./cmd/nebula-cert
|
2019-12-20 19:44:11 +01:00
|
|
|
|
2019-12-21 15:31:48 +01:00
|
|
|
build/%/nebula.exe: build/%/nebula
|
|
|
|
mv $< $@
|
|
|
|
|
|
|
|
build/%/nebula-cert.exe: build/%/nebula-cert
|
|
|
|
mv $< $@
|
|
|
|
|
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
|
|
|
|
2019-12-21 15:31:48 +01:00
|
|
|
build/nebula-%.zip: build/%/nebula.exe build/%/nebula-cert.exe
|
|
|
|
cd build/$* && zip ../nebula-$*.zip nebula.exe nebula-cert.exe
|
|
|
|
|
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
|
2021-04-01 00:32:02 +02:00
|
|
|
go build github.com/gogo/protobuf/protoc-gen-gogofaster
|
2021-04-01 17:23:31 +02:00
|
|
|
PATH="$(CURDIR):$(PATH)" protoc --gogofaster_out=paths=source_relative:. $<
|
2021-04-01 00:32:02 +02:00
|
|
|
rm protoc-gen-gogofaster
|
2019-11-19 18:00:20 +01:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2021-03-01 17:15:15 +01:00
|
|
|
bin-docker: bin build/linux-amd64/nebula build/linux-amd64/nebula-cert
|
|
|
|
|
|
|
|
smoke-docker: bin-docker
|
|
|
|
cd .github/workflows/smoke/ && ./build.sh
|
|
|
|
cd .github/workflows/smoke/ && ./smoke.sh
|
|
|
|
|
|
|
|
smoke-docker-race: BUILD_ARGS = -race
|
|
|
|
smoke-docker-race: smoke-docker
|
|
|
|
|
2019-11-19 18:00:20 +01:00
|
|
|
.FORCE:
|
2021-03-31 17:26:35 +02:00
|
|
|
.PHONY: e2e e2ev e2evv e2evvv e2evvvv test test-cov-html bench bench-cpu bench-cpu-long bin proto release service smoke-docker smoke-docker-race
|
2019-11-19 18:00:20 +01:00
|
|
|
.DEFAULT_GOAL := bin
|