|
@@ -1,14 +1,29 @@
|
|
GOMINVERSION = 1.16
|
|
GOMINVERSION = 1.16
|
|
NEBULA_CMD_PATH = "./cmd/nebula"
|
|
NEBULA_CMD_PATH = "./cmd/nebula"
|
|
-BUILD_NUMBER ?= dev+$(shell date -u '+%Y%m%d%H%M%S')
|
|
|
|
GO111MODULE = on
|
|
GO111MODULE = on
|
|
export GO111MODULE
|
|
export GO111MODULE
|
|
|
|
|
|
-# 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")
|
|
|
|
|
|
+# Set up OS specific bits
|
|
|
|
+ifeq ($(OS),Windows_NT)
|
|
|
|
+ #TODO: we should be able to ditch awk as well
|
|
|
|
+ GOVERSION := $(shell go version | awk "{print substr($$3, 3)}")
|
|
|
|
+ GOISMIN := $(shell IF "$(GOVERSION)" GEQ "$(GOMINVERSION)" ECHO 1)
|
|
|
|
+ NEBULA_CMD_SUFFIX = .exe
|
|
|
|
+ NULL_FILE = nul
|
|
|
|
+else
|
|
|
|
+ GOVERSION := $(shell go version | awk '{print substr($$3, 3)}')
|
|
|
|
+ GOISMIN := $(shell expr "$(GOVERSION)" ">=" "$(GOMINVERSION)")
|
|
|
|
+ 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
|
|
endif
|
|
endif
|
|
|
|
|
|
LDFLAGS = -X main.Build=$(BUILD_NUMBER)
|
|
LDFLAGS = -X main.Build=$(BUILD_NUMBER)
|
|
@@ -67,8 +82,8 @@ bin-freebsd: build/freebsd-amd64/nebula build/freebsd-amd64/nebula-cert
|
|
mv $? .
|
|
mv $? .
|
|
|
|
|
|
bin:
|
|
bin:
|
|
- go build $(BUILD_ARGS) -ldflags "$(LDFLAGS)" -o ./nebula ${NEBULA_CMD_PATH}
|
|
|
|
- go build $(BUILD_ARGS) -ldflags "$(LDFLAGS)" -o ./nebula-cert ./cmd/nebula-cert
|
|
|
|
|
|
+ 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
|
|
|
|
|
|
install:
|
|
install:
|
|
go install $(BUILD_ARGS) -ldflags "$(LDFLAGS)" ${NEBULA_CMD_PATH}
|
|
go install $(BUILD_ARGS) -ldflags "$(LDFLAGS)" ${NEBULA_CMD_PATH}
|
|
@@ -134,10 +149,10 @@ cert/cert.pb.go: cert/cert.proto .FORCE
|
|
$(MAKE) -C cert cert.pb.go
|
|
$(MAKE) -C cert cert.pb.go
|
|
|
|
|
|
service:
|
|
service:
|
|
- @echo > /dev/null
|
|
|
|
|
|
+ @echo > $(NULL_FILE)
|
|
$(eval NEBULA_CMD_PATH := "./cmd/nebula-service")
|
|
$(eval NEBULA_CMD_PATH := "./cmd/nebula-service")
|
|
ifeq ($(words $(MAKECMDGOALS)),1)
|
|
ifeq ($(words $(MAKECMDGOALS)),1)
|
|
- $(MAKE) service ${.DEFAULT_GOAL} --no-print-directory
|
|
|
|
|
|
+ @$(MAKE) service ${.DEFAULT_GOAL} --no-print-directory
|
|
endif
|
|
endif
|
|
|
|
|
|
bin-docker: bin build/linux-amd64/nebula build/linux-amd64/nebula-cert
|
|
bin-docker: bin build/linux-amd64/nebula build/linux-amd64/nebula-cert
|