2019-11-20 02:55:02 +08:00
|
|
|
NEBULA_CMD_PATH = "./cmd/nebula"
|
2021-11-05 02:20:44 +08:00
|
|
|
CGO_ENABLED = 0
|
|
|
|
export CGO_ENABLED
|
2019-11-20 01:00:20 +08:00
|
|
|
|
2021-05-01 04:04:47 +08:00
|
|
|
# Set up OS specific bits
|
|
|
|
ifeq ($(OS),Windows_NT)
|
|
|
|
NEBULA_CMD_SUFFIX = .exe
|
|
|
|
NULL_FILE = nul
|
2023-07-11 01:43:48 +08:00
|
|
|
# RIO on windows does pointer stuff that makes go vet angry
|
|
|
|
VET_FLAGS = -unsafeptr=false
|
2021-05-01 04:04:47 +08:00
|
|
|
else
|
|
|
|
NEBULA_CMD_SUFFIX =
|
|
|
|
NULL_FILE = /dev/null
|
|
|
|
endif
|
|
|
|
|
|
|
|
# Only defined the build number if we haven't already
|
|
|
|
ifndef BUILD_NUMBER
|
|
|
|
ifeq ($(shell git describe --exact-match 2>$(NULL_FILE)),)
|
|
|
|
BUILD_NUMBER = $(shell git describe --abbrev=0 --match "v*" | cut -dv -f2)-$(shell git branch --show-current)-$(shell git describe --long --dirty | cut -d- -f2-)
|
|
|
|
else
|
|
|
|
BUILD_NUMBER = $(shell git describe --exact-match --dirty | cut -dv -f2)
|
|
|
|
endif
|
2021-03-03 03:29:05 +08:00
|
|
|
endif
|
|
|
|
|
2024-05-02 21:37:11 +08:00
|
|
|
DOCKER_IMAGE_REPO ?= nebulaoss/nebula
|
|
|
|
DOCKER_IMAGE_TAG ?= latest
|
|
|
|
|
2020-06-27 01:46:23 +08:00
|
|
|
LDFLAGS = -X main.Build=$(BUILD_NUMBER)
|
|
|
|
|
2019-12-21 14:15:41 +08:00
|
|
|
ALL_LINUX = linux-amd64 \
|
2019-12-21 02:55:15 +08:00
|
|
|
linux-386 \
|
|
|
|
linux-ppc64le \
|
2019-12-21 03:08:18 +08:00
|
|
|
linux-arm-5 \
|
2019-12-21 02:55:15 +08:00
|
|
|
linux-arm-6 \
|
2019-12-21 03:08:18 +08:00
|
|
|
linux-arm-7 \
|
2019-12-21 02:55:15 +08:00
|
|
|
linux-arm64 \
|
|
|
|
linux-mips \
|
|
|
|
linux-mipsle \
|
|
|
|
linux-mips64 \
|
2020-06-27 01:46:23 +08:00
|
|
|
linux-mips64le \
|
2021-10-13 22:55:32 +08:00
|
|
|
linux-mips-softfloat \
|
2024-04-30 22:55:44 +08:00
|
|
|
linux-riscv64 \
|
|
|
|
linux-loong64
|
2019-12-21 14:15:41 +08:00
|
|
|
|
2023-06-23 00:13:31 +08:00
|
|
|
ALL_FREEBSD = freebsd-amd64 \
|
|
|
|
freebsd-arm64
|
|
|
|
|
2023-07-28 03:27:35 +08:00
|
|
|
ALL_OPENBSD = openbsd-amd64 \
|
|
|
|
openbsd-arm64
|
|
|
|
|
|
|
|
ALL_NETBSD = netbsd-amd64 \
|
|
|
|
netbsd-arm64
|
|
|
|
|
2019-12-21 14:15:41 +08:00
|
|
|
ALL = $(ALL_LINUX) \
|
2023-06-23 00:13:31 +08:00
|
|
|
$(ALL_FREEBSD) \
|
2023-07-28 03:27:35 +08:00
|
|
|
$(ALL_OPENBSD) \
|
|
|
|
$(ALL_NETBSD) \
|
2019-12-21 02:55:15 +08:00
|
|
|
darwin-amd64 \
|
2021-02-18 02:11:57 +08:00
|
|
|
darwin-arm64 \
|
2022-03-19 01:23:10 +08:00
|
|
|
windows-amd64 \
|
2023-07-28 03:27:35 +08:00
|
|
|
windows-arm64
|
2019-12-21 02:44:11 +08:00
|
|
|
|
2021-03-30 03:29:20 +08:00
|
|
|
e2e:
|
2021-03-31 23:26:35 +08: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-03 03:29:05 +08:00
|
|
|
|
2022-09-01 22:44:58 +08:00
|
|
|
e2e-bench: TEST_FLAGS = -bench=. -benchmem -run=^$
|
|
|
|
e2e-bench: e2e
|
|
|
|
|
2024-04-30 23:02:16 +08:00
|
|
|
DOCKER_BIN = build/linux-amd64/nebula build/linux-amd64/nebula-cert
|
|
|
|
|
2019-12-21 02:44:11 +08:00
|
|
|
all: $(ALL:%=build/%/nebula) $(ALL:%=build/%/nebula-cert)
|
|
|
|
|
2024-05-02 21:37:11 +08:00
|
|
|
docker: docker/linux-$(shell go env GOARCH)
|
|
|
|
|
2019-12-21 02:44:11 +08:00
|
|
|
release: $(ALL:%=build/nebula-%.tar.gz)
|
2019-11-20 01:00:20 +08:00
|
|
|
|
2019-12-21 14:15:41 +08:00
|
|
|
release-linux: $(ALL_LINUX:%=build/nebula-%.tar.gz)
|
|
|
|
|
2023-06-23 00:13:31 +08:00
|
|
|
release-freebsd: $(ALL_FREEBSD:%=build/nebula-%.tar.gz)
|
2020-05-27 10:23:23 +08:00
|
|
|
|
2023-07-28 03:27:35 +08:00
|
|
|
release-openbsd: $(ALL_OPENBSD:%=build/nebula-%.tar.gz)
|
|
|
|
|
|
|
|
release-netbsd: $(ALL_NETBSD:%=build/nebula-%.tar.gz)
|
|
|
|
|
2023-05-05 03:42:45 +08:00
|
|
|
release-boringcrypto: build/nebula-linux-$(shell go env GOARCH)-boringcrypto.tar.gz
|
|
|
|
|
2021-03-02 00:15:15 +08:00
|
|
|
BUILD_ARGS = -trimpath
|
|
|
|
|
2019-12-21 22:31:48 +08:00
|
|
|
bin-windows: build/windows-amd64/nebula.exe build/windows-amd64/nebula-cert.exe
|
|
|
|
mv $? .
|
|
|
|
|
2022-03-19 01:23:10 +08:00
|
|
|
bin-windows-arm64: build/windows-arm64/nebula.exe build/windows-arm64/nebula-cert.exe
|
|
|
|
mv $? .
|
|
|
|
|
2019-12-21 22:31:48 +08:00
|
|
|
bin-darwin: build/darwin-amd64/nebula build/darwin-amd64/nebula-cert
|
|
|
|
mv $? .
|
|
|
|
|
2020-05-27 10:23:23 +08:00
|
|
|
bin-freebsd: build/freebsd-amd64/nebula build/freebsd-amd64/nebula-cert
|
|
|
|
mv $? .
|
|
|
|
|
2023-06-23 00:13:31 +08:00
|
|
|
bin-freebsd-arm64: build/freebsd-arm64/nebula build/freebsd-arm64/nebula-cert
|
|
|
|
mv $? .
|
|
|
|
|
2023-05-05 03:42:45 +08:00
|
|
|
bin-boringcrypto: build/linux-$(shell go env GOARCH)-boringcrypto/nebula build/linux-$(shell go env GOARCH)-boringcrypto/nebula-cert
|
|
|
|
mv $? .
|
|
|
|
|
2019-11-20 01:00:20 +08:00
|
|
|
bin:
|
2021-05-01 04:04:47 +08:00
|
|
|
go build $(BUILD_ARGS) -ldflags "$(LDFLAGS)" -o ./nebula${NEBULA_CMD_SUFFIX} ${NEBULA_CMD_PATH}
|
|
|
|
go build $(BUILD_ARGS) -ldflags "$(LDFLAGS)" -o ./nebula-cert${NEBULA_CMD_SUFFIX} ./cmd/nebula-cert
|
2019-11-20 01:00:20 +08:00
|
|
|
|
|
|
|
install:
|
2021-03-02 00:15:15 +08:00
|
|
|
go install $(BUILD_ARGS) -ldflags "$(LDFLAGS)" ${NEBULA_CMD_PATH}
|
|
|
|
go install $(BUILD_ARGS) -ldflags "$(LDFLAGS)" ./cmd/nebula-cert
|
2020-06-27 01:46:23 +08: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-21 02:44:11 +08:00
|
|
|
|
2023-05-05 03:42:45 +08:00
|
|
|
# boringcrypto
|
|
|
|
build/linux-amd64-boringcrypto/%: GOENV += GOEXPERIMENT=boringcrypto CGO_ENABLED=1
|
|
|
|
build/linux-arm64-boringcrypto/%: GOENV += GOEXPERIMENT=boringcrypto CGO_ENABLED=1
|
|
|
|
|
2019-12-21 02:44:11 +08:00
|
|
|
build/%/nebula: .FORCE
|
|
|
|
GOOS=$(firstword $(subst -, , $*)) \
|
2020-06-27 01:46:23 +08:00
|
|
|
GOARCH=$(word 2, $(subst -, ,$*)) $(GOENV) \
|
2021-03-02 00:15:15 +08:00
|
|
|
go build $(BUILD_ARGS) -o $@ -ldflags "$(LDFLAGS)" ${NEBULA_CMD_PATH}
|
2019-12-21 02:44:11 +08:00
|
|
|
|
|
|
|
build/%/nebula-cert: .FORCE
|
|
|
|
GOOS=$(firstword $(subst -, , $*)) \
|
2020-06-27 01:46:23 +08:00
|
|
|
GOARCH=$(word 2, $(subst -, ,$*)) $(GOENV) \
|
2021-03-02 00:15:15 +08:00
|
|
|
go build $(BUILD_ARGS) -o $@ -ldflags "$(LDFLAGS)" ./cmd/nebula-cert
|
2019-12-21 02:44:11 +08:00
|
|
|
|
2019-12-21 22:31:48 +08:00
|
|
|
build/%/nebula.exe: build/%/nebula
|
|
|
|
mv $< $@
|
|
|
|
|
|
|
|
build/%/nebula-cert.exe: build/%/nebula-cert
|
|
|
|
mv $< $@
|
|
|
|
|
2019-12-21 02:44:11 +08:00
|
|
|
build/nebula-%.tar.gz: build/%/nebula build/%/nebula-cert
|
|
|
|
tar -zcv -C build/$* -f $@ nebula nebula-cert
|
2019-11-20 01:00:20 +08:00
|
|
|
|
2019-12-21 22:31:48 +08:00
|
|
|
build/nebula-%.zip: build/%/nebula.exe build/%/nebula-cert.exe
|
|
|
|
cd build/$* && zip ../nebula-$*.zip nebula.exe nebula-cert.exe
|
|
|
|
|
2024-05-02 21:37:11 +08:00
|
|
|
docker/%: build/%/nebula build/%/nebula-cert
|
|
|
|
docker build . $(DOCKER_BUILD_ARGS) -f docker/Dockerfile --platform "$(subst -,/,$*)" --tag "${DOCKER_IMAGE_REPO}:${DOCKER_IMAGE_TAG}" --tag "${DOCKER_IMAGE_REPO}:$(BUILD_NUMBER)"
|
|
|
|
|
2019-11-20 01:00:20 +08:00
|
|
|
vet:
|
2023-07-11 01:43:48 +08:00
|
|
|
go vet $(VET_FLAGS) -v ./...
|
2019-11-20 01:00:20 +08:00
|
|
|
|
|
|
|
test:
|
|
|
|
go test -v ./...
|
|
|
|
|
2023-05-09 01:27:01 +08:00
|
|
|
test-boringcrypto:
|
|
|
|
GOEXPERIMENT=boringcrypto CGO_ENABLED=1 go test -v ./...
|
|
|
|
|
2019-11-20 01:00:20 +08:00
|
|
|
test-cov-html:
|
|
|
|
go test -coverprofile=coverage.out
|
|
|
|
go tool cover -html=coverage.out
|
|
|
|
|
2023-12-22 00:59:21 +08:00
|
|
|
build-test-mobile:
|
|
|
|
GOARCH=amd64 GOOS=ios go build $(shell go list ./... | grep -v '/cmd/\|/examples/')
|
|
|
|
GOARCH=arm64 GOOS=ios go build $(shell go list ./... | grep -v '/cmd/\|/examples/')
|
|
|
|
GOARCH=amd64 GOOS=android go build $(shell go list ./... | grep -v '/cmd/\|/examples/')
|
|
|
|
GOARCH=arm64 GOOS=android go build $(shell go list ./... | grep -v '/cmd/\|/examples/')
|
|
|
|
|
2019-11-20 01:00:20 +08:00
|
|
|
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 06:32:02 +08:00
|
|
|
go build github.com/gogo/protobuf/protoc-gen-gogofaster
|
2021-04-01 23:23:31 +08:00
|
|
|
PATH="$(CURDIR):$(PATH)" protoc --gogofaster_out=paths=source_relative:. $<
|
2021-04-01 06:32:02 +08:00
|
|
|
rm protoc-gen-gogofaster
|
2019-11-20 01:00:20 +08:00
|
|
|
|
|
|
|
cert/cert.pb.go: cert/cert.proto .FORCE
|
|
|
|
$(MAKE) -C cert cert.pb.go
|
|
|
|
|
2019-11-20 02:55:02 +08:00
|
|
|
service:
|
2021-05-01 04:04:47 +08:00
|
|
|
@echo > $(NULL_FILE)
|
2019-11-20 02:55:02 +08:00
|
|
|
$(eval NEBULA_CMD_PATH := "./cmd/nebula-service")
|
|
|
|
ifeq ($(words $(MAKECMDGOALS)),1)
|
2021-05-01 04:04:47 +08:00
|
|
|
@$(MAKE) service ${.DEFAULT_GOAL} --no-print-directory
|
2019-11-20 02:55:02 +08:00
|
|
|
endif
|
|
|
|
|
2021-03-02 00:15:15 +08: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
|
2023-05-05 05:50:23 +08:00
|
|
|
cd .github/workflows/smoke/ && NAME="smoke-p256" CURVE="P256" ./build.sh
|
|
|
|
cd .github/workflows/smoke/ && NAME="smoke-p256" ./smoke.sh
|
2021-03-02 00:15:15 +08:00
|
|
|
|
2022-06-22 02:35:23 +08:00
|
|
|
smoke-relay-docker: bin-docker
|
|
|
|
cd .github/workflows/smoke/ && ./build-relay.sh
|
|
|
|
cd .github/workflows/smoke/ && ./smoke-relay.sh
|
|
|
|
|
2021-03-02 00:15:15 +08:00
|
|
|
smoke-docker-race: BUILD_ARGS = -race
|
2023-10-31 22:32:39 +08:00
|
|
|
smoke-docker-race: CGO_ENABLED = 1
|
2021-03-02 00:15:15 +08:00
|
|
|
smoke-docker-race: smoke-docker
|
|
|
|
|
2024-04-30 23:02:16 +08:00
|
|
|
smoke-vagrant/%: bin-docker build/%/nebula
|
|
|
|
cd .github/workflows/smoke/ && ./build.sh $*
|
|
|
|
cd .github/workflows/smoke/ && ./smoke-vagrant.sh $*
|
|
|
|
|
2019-11-20 01:00:20 +08:00
|
|
|
.FORCE:
|
2024-04-30 23:02:16 +08:00
|
|
|
.PHONY: bench bench-cpu bench-cpu-long bin build-test-mobile e2e e2ev e2evv e2evvv e2evvvv proto release service smoke-docker smoke-docker-race test test-cov-html smoke-vagrant/%
|
2019-11-20 01:00:20 +08:00
|
|
|
.DEFAULT_GOAL := bin
|