diff --git a/Makefile b/Makefile index 9af5622..99869dd 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,6 @@ -BUILD_REQUIRE_GO_MAJOR ?= 1 -BUILD_REQUIRE_GO_MINOR ?= 20 - -GOCMD=go -GOBUILD=$(GOCMD) build -GOTEST=$(GOCMD) test +GO = go +GOBUILD = $(GO) build +GOTEST = $(GO) test BINARY_NAME=crowdsec-cloudflare-bouncer TARBALL_NAME=$(BINARY_NAME).tgz @@ -19,7 +16,7 @@ LD_OPTS_VARS=\ -X 'github.com/crowdsecurity/go-cs-lib/version.Tag=$(BUILD_TAG)' export CGO_ENABLED=0 -export LD_OPTS=-ldflags "-a -s -w -extldflags '-static' $(LD_OPTS_VARS)" \ +export LD_OPTS=-ldflags "-s -extldflags '-static' $(LD_OPTS_VARS)" \ -trimpath -tags netgo .PHONY: all @@ -55,7 +52,7 @@ clean: clean-release-dir clean-debian clean-rpm # .PHONY: binary -binary: goversion +binary: $(GOBUILD) $(LD_OPTS) -o $(BINARY_NAME) .PHONY: build @@ -80,7 +77,7 @@ export CF_TOKEN export CF_ZONE_ID .PHONY: test -test: goversion +test: @$(GOTEST) $(LD_OPTS) ./... .PHONY: func-tests @@ -96,7 +93,7 @@ RELDIR = $(BINARY_NAME)-$(BUILD_VERSION) .PHONY: vendor vendor: vendor-remove - $(GOCMD) mod vendor + $(GO) mod vendor tar czf vendor.tgz vendor tar --create --auto-compress --file=$(RELDIR)-vendor.tar.xz vendor @@ -134,7 +131,5 @@ release: clean tarball # .PHONY: platform-all -platform-all: goversion clean +platform-all: clean python3 .github/release.py run-build $(BINARY_NAME) - -include mk/goversion.mk diff --git a/mk/goversion.mk b/mk/goversion.mk deleted file mode 100644 index 7c9f9d5..0000000 --- a/mk/goversion.mk +++ /dev/null @@ -1,31 +0,0 @@ - -BUILD_GOVERSION = $(subst go,,$(shell go env GOVERSION)) - -go_major_minor = $(subst ., ,$(BUILD_GOVERSION)) -GO_MAJOR_VERSION = $(word 1, $(go_major_minor)) -GO_MINOR_VERSION = $(word 2, $(go_major_minor)) - -GO_VERSION_VALIDATION_ERR_MSG = Golang version ($(BUILD_GOVERSION)) is not supported, please use at least $(BUILD_REQUIRE_GO_MAJOR).$(BUILD_REQUIRE_GO_MINOR) - - -.PHONY: goversion -goversion: $(if $(findstring devel,$(shell go env GOVERSION)),goversion_devel,goversion_check) - - -.PHONY: goversion_devel -goversion_devel: - $(warning WARNING: You are using a development version of Golang ($(BUILD_GOVERSION)) which is not supported. For production environments, use a stable version (at least $(BUILD_REQUIRE_GO_MAJOR).$(BUILD_REQUIRE_GO_MINOR))) - $(info ) - - -.PHONY: goversion_check -goversion_check: - @if [ $(GO_MAJOR_VERSION) -gt $(BUILD_REQUIRE_GO_MAJOR) ]; then \ - exit 0; \ - elif [ $(GO_MAJOR_VERSION) -lt $(BUILD_REQUIRE_GO_MAJOR) ]; then \ - echo '$(GO_VERSION_VALIDATION_ERR_MSG)';\ - exit 1; \ - elif [ $(GO_MINOR_VERSION) -lt $(BUILD_REQUIRE_GO_MINOR) ] ; then \ - echo '$(GO_VERSION_VALIDATION_ERR_MSG)';\ - exit 1; \ - fi