diff --git a/.github/workflows/go-tests.yml b/.github/workflows/go-tests.yml index 322bf8f42..e4ff3435e 100644 --- a/.github/workflows/go-tests.yml +++ b/.github/workflows/go-tests.yml @@ -120,19 +120,20 @@ jobs: fetch-depth: 0 submodules: false - - name: Build + - name: Build and run tests run: | - make build - - - name: Run tests - run: | - set -o pipefail go install github.com/ory/go-acc@v0.2.8 go install github.com/kyoh86/richgo@v0.3.10 + set -o pipefail + make build go-acc ./... -o coverage.out --ignore database,notifications,protobufs,cwversion,cstest,models \ | sed 's/ *coverage:.*of statements in.*//' \ | richgo testfilter + - name: Build and run tests (static) + run: | + make clean build test BUILD_STATIC=yes + - name: Upload unit coverage to Codecov uses: codecov/codecov-action@v2 with: diff --git a/.github/workflows/release_publish-package.yml b/.github/workflows/release_publish-package.yml index 2a3bb42cd..fcd572165 100644 --- a/.github/workflows/release_publish-package.yml +++ b/.github/workflows/release_publish-package.yml @@ -37,67 +37,12 @@ jobs: - name: Check out code into the Go module directory uses: actions/checkout@v3 - name: Build the binaries - run: make release_static + run: | + make release BUILD_STATIC=yes + mv crowdsec-release.tgz crowdsec-release.static.tgz - name: Upload to release uses: JasonEtco/upload-to-release@master with: args: crowdsec-release-static.tgz application/x-gzip env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - test_tarball: - strategy: - matrix: - tarball: - - name: crowdsec-release - - name: crowdsec-release-static - name: Download tarball and run functional tests - runs-on: ubuntu-20.04 - needs: [build, build_static] - steps: - - id: fetch_prerelease_version - uses: pozetroninc/github-action-get-latest-release@master - with: - repository: crowdsecurity/crowdsec - excludes: draft - - name: download tarball - run: wget -qO - https://github.com/crowdsecurity/crowdsec/releases/download/${{ steps.fetch_prerelease_version.outputs.release }}/${{ matrix.tarball.name }}.tgz | tar xvzf - - - name: "Force machineid" - run: | - sudo chmod +w /etc/machine-id - echo githubciXXXXXXXXXXXXXXXXXXXXXXXX | sudo tee /etc/machine-id - - name: Install release - run: | - cd crowdsec-${{ steps.fetch_prerelease_version.outputs.release }} - sudo ./wizard.sh --unattended - - name: Check out code to get functional tests scripts - uses: actions/checkout@v3 - - name: "Test post-install base" - run: | - cd scripts/func_tests/ - ./tests_post-install_0base.sh - - name: "Test post-install bouncer" - run: | - cd scripts/func_tests/ - ./tests_post-install_1bouncers.sh - - name: "Test post-install collections" - run: | - cd scripts/func_tests/ - ./tests_post-install_2collections.sh - - name: "Test post-install macines" - run: | - cd scripts/func_tests/ - ./tests_post-install_3machines.sh - - name: "Test post-install ip management" - run: | - cd scripts/func_tests/ - ./tests_post-install_99ip_mgmt.sh - - name: "Test cold logs" - run: | - cd scripts/func_tests/ - ./tests_post-install_4cold-logs.sh - - name: "Uninstall" - run: sudo ./wizard.sh --uninstall - - name: "Test post remove" - run: | - cd scripts/func_tests/ - bash -x ./tests_post-remove_0base.sh diff --git a/Makefile b/Makefile index d295ee068..a687316e8 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,13 @@ -ifeq ($(OS),Windows_NT) -SHELL := pwsh.exe -.SHELLFLAGS := -NoProfile -Command -ROOT= $(shell (Get-Location).Path) -SYSTEM=windows -EXT=.exe + +ifeq ($(OS), Windows_NT) + SHELL := pwsh.exe + .SHELLFLAGS := -NoProfile -Command + ROOT = $(shell (Get-Location).Path) + SYSTEM = windows + EXT = .exe else -ROOT?= $(shell pwd) -SYSTEM?= $(shell uname -s | tr '[A-Z]' '[a-z]') + ROOT ?= $(shell pwd) + SYSTEM ?= $(shell uname -s | tr '[A-Z]' '[a-z]') endif ifneq ("$(wildcard $(CURDIR)/platform/$(SYSTEM).mk)", "") @@ -15,7 +16,7 @@ else include $(CURDIR)/platform/linux.mk endif -ifneq ($(OS),Windows_NT) +ifneq ($(OS), Windows_NT) include $(ROOT)/platform/unix_common.mk endif @@ -48,21 +49,24 @@ MINIMUM_SUPPORTED_GO_MINOR_VERSION = 17 GO_VERSION_VALIDATION_ERR_MSG = Golang version ($(BUILD_GOVERSION)) is not supported, please use at least $(MINIMUM_SUPPORTED_GO_MAJOR_VERSION).$(MINIMUM_SUPPORTED_GO_MINOR_VERSION) LD_OPTS_VARS= \ --X github.com/crowdsecurity/crowdsec/cmd/crowdsec.bincoverTesting=$(BINCOVER_TESTING) \ --X github.com/crowdsecurity/crowdsec/cmd/crowdsec-cli.bincoverTesting=$(BINCOVER_TESTING) \ --X github.com/crowdsecurity/crowdsec/pkg/cwversion.Version=$(BUILD_VERSION) \ --X github.com/crowdsecurity/crowdsec/pkg/cwversion.BuildDate=$(BUILD_TIMESTAMP) \ --X github.com/crowdsecurity/crowdsec/pkg/cwversion.Codename=$(BUILD_CODENAME) \ --X github.com/crowdsecurity/crowdsec/pkg/cwversion.Tag=$(BUILD_TAG) \ --X github.com/crowdsecurity/crowdsec/pkg/cwversion.GoVersion=$(BUILD_GOVERSION) \ +-X 'github.com/crowdsecurity/crowdsec/cmd/crowdsec.bincoverTesting=$(BINCOVER_TESTING)' \ +-X 'github.com/crowdsecurity/crowdsec/cmd/crowdsec-cli.bincoverTesting=$(BINCOVER_TESTING)' \ +-X 'github.com/crowdsecurity/crowdsec/pkg/cwversion.Version=$(BUILD_VERSION)' \ +-X 'github.com/crowdsecurity/crowdsec/pkg/cwversion.BuildDate=$(BUILD_TIMESTAMP)' \ +-X 'github.com/crowdsecurity/crowdsec/pkg/cwversion.Codename=$(BUILD_CODENAME)' \ +-X 'github.com/crowdsecurity/crowdsec/pkg/cwversion.Tag=$(BUILD_TAG)' \ +-X 'github.com/crowdsecurity/crowdsec/pkg/cwversion.GoVersion=$(BUILD_GOVERSION)' \ -X 'github.com/crowdsecurity/crowdsec/pkg/csconfig.defaultConfigDir=$(DEFAULT_CONFIGDIR)' \ -X 'github.com/crowdsecurity/crowdsec/pkg/csconfig.defaultDataDir=$(DEFAULT_DATADIR)' -export LD_OPTS=-ldflags "-s -w $(LD_OPTS_VARS)" -export LD_OPTS_STATIC=-ldflags "-s -w $(LD_OPTS_VARS) -extldflags '-static'" +ifdef BUILD_STATIC + export LD_OPTS=-ldflags "-s -w $(LD_OPTS_VARS) -extldflags '-static'" -tags netgo,osusergo,sqlite_omit_load_extension +else + export LD_OPTS=-ldflags "-s -w $(LD_OPTS_VARS)" +endif -GOCMD=go -GOTEST=$(GOCMD) test +GOCMD = go +GOTEST = $(GOCMD) test RELDIR = crowdsec-$(BUILD_VERSION) @@ -72,27 +76,23 @@ build: goversion crowdsec cscli plugins .PHONY: all all: clean test build -.PHONY: static -static: crowdsec_static cscli_static plugins_static - .PHONY: plugins plugins: http-plugin slack-plugin splunk-plugin email-plugin dummy-plugin -plugins_static: http-plugin_static slack-plugin_static splunk-plugin_static email-plugin_static dummy-plugin_static - +.PHONY: goversion goversion: -ifneq ($(OS),Windows_NT) +ifneq ($(OS), Windows_NT) @if [ $(GO_MAJOR_VERSION) -gt $(MINIMUM_SUPPORTED_GO_MAJOR_VERSION) ]; then \ - exit 0 ;\ - elif [ $(GO_MAJOR_VERSION) -lt $(MINIMUM_SUPPORTED_GO_MAJOR_VERSION) ]; then \ - echo '$(GO_VERSION_VALIDATION_ERR_MSG)';\ - exit 1; \ - elif [ $(GO_MINOR_VERSION) -lt $(MINIMUM_SUPPORTED_GO_MINOR_VERSION) ] ; then \ - echo '$(GO_VERSION_VALIDATION_ERR_MSG)';\ - exit 1; \ - fi + exit 0 ;\ + elif [ $(GO_MAJOR_VERSION) -lt $(MINIMUM_SUPPORTED_GO_MAJOR_VERSION) ]; then \ + echo '$(GO_VERSION_VALIDATION_ERR_MSG)';\ + exit 1; \ + elif [ $(GO_MINOR_VERSION) -lt $(MINIMUM_SUPPORTED_GO_MINOR_VERSION) ] ; then \ + echo '$(GO_VERSION_VALIDATION_ERR_MSG)';\ + exit 1; \ + fi else -#This needs Set-ExecutionPolicy -Scope CurrentUser Unrestricted + # This needs Set-ExecutionPolicy -Scope CurrentUser Unrestricted @$(ROOT)/scripts/check_go_version.ps1 $(MINIMUM_SUPPORTED_GO_MAJOR_VERSION) $(MINIMUM_SUPPORTED_GO_MINOR_VERSION) endif @@ -139,27 +139,6 @@ email-plugin: goversion dummy-plugin: goversion $(MAKE) -C $(DUMMY_PLUGIN_FOLDER) build --no-print-directory GOARCH=$(GOARCH) GOOS=$(GOOS) RM="$(RM)" WIN_IGNORE_ERR="$(WIN_IGNORE_ERR)" CP="$(CP)" CPR="$(CPR)" MKDIR="$(MKDIR)" -cscli_static: goversion - @$(MAKE) -C $(CSCLI_FOLDER) static --no-print-directory GOARCH=$(GOARCH) GOOS=$(GOOS) RM="$(RM)" WIN_IGNORE_ERR="$(WIN_IGNORE_ERR)" CP="$(CP)" CPR="$(CPR)" MKDIR="$(MKDIR)" - -crowdsec_static: goversion - @$(MAKE) -C $(CROWDSEC_FOLDER) static --no-print-directory GOARCH=$(GOARCH) GOOS=$(GOOS) RM="$(RM)" WIN_IGNORE_ERR="$(WIN_IGNORE_ERR)" CP="$(CP)" CPR="$(CPR)" MKDIR="$(MKDIR)" - -http-plugin_static: goversion - @$(MAKE) -C $(HTTP_PLUGIN_FOLDER) static --no-print-directory GOARCH=$(GOARCH) GOOS=$(GOOS) RM="$(RM)" WIN_IGNORE_ERR="$(WIN_IGNORE_ERR)" CP="$(CP)" CPR="$(CPR)" MKDIR="$(MKDIR)" - -slack-plugin_static: goversion - @$(MAKE) -C $(SLACK_PLUGIN_FOLDER) static --no-print-directory GOARCH=$(GOARCH) GOOS=$(GOOS) RM="$(RM)" WIN_IGNORE_ERR="$(WIN_IGNORE_ERR)" CP="$(CP)" CPR="$(CPR)" MKDIR="$(MKDIR)" - -splunk-plugin_static:goversion - @$(MAKE) -C $(SPLUNK_PLUGIN_FOLDER) static --no-print-directory GOARCH=$(GOARCH) GOOS=$(GOOS) RM="$(RM)" WIN_IGNORE_ERR="$(WIN_IGNORE_ERR)" CP="$(CP)" CPR="$(CPR)" MKDIR="$(MKDIR)" - -email-plugin_static:goversion - @$(MAKE) -C $(EMAIL_PLUGIN_FOLDER) static --no-print-directory GOARCH=$(GOARCH) GOOS=$(GOOS) RM="$(RM)" WIN_IGNORE_ERR="$(WIN_IGNORE_ERR)" CP="$(CP)" CPR="$(CPR)" MKDIR="$(MKDIR)" - -dummy-plugin_static:goversion - $(MAKE) -C $(DUMMY_PLUGIN_FOLDER) static --no-print-directory GOARCH=$(GOARCH) GOOS=$(GOOS) RM="$(RM)" WIN_IGNORE_ERR="$(WIN_IGNORE_ERR)" CP="$(CP)" CPR="$(CPR)" MKDIR="$(MKDIR)" - .PHONY: testclean testclean: bats-clean @$(RM) pkg/apiserver/ent $(WIN_IGNORE_ERR) @@ -212,12 +191,9 @@ package-common: package: package-common @tar cvzf crowdsec-release.tgz $(RELDIR) -package_static: package-common - @tar cvzf crowdsec-release-static.tgz $(RELDIR) - .PHONY: check_release check_release: -ifneq ($(OS),Windows_NT) +ifneq ($(OS), Windows_NT) @if [ -d $(RELDIR) ]; then echo "$(RELDIR) already exists, abort" ; exit 1 ; fi else @if (Test-Path -Path $(RELDIR)) { echo "$(RELDIR) already exists, abort" ; exit 1 ; } @@ -226,9 +202,6 @@ endif .PHONY: release release: check_release build package -.PHONY: release_static -release_static: check_release static package_static - .PHONY: windows_installer windows_installer: build @.\make_installer.ps1 -version $(BUILD_VERSION) diff --git a/cmd/crowdsec-cli/Makefile b/cmd/crowdsec-cli/Makefile index b8f2753d3..d4e7ca723 100644 --- a/cmd/crowdsec-cli/Makefile +++ b/cmd/crowdsec-cli/Makefile @@ -1,34 +1,31 @@ -ifeq ($(OS),Windows_NT) -SHELL := pwsh.exe -.SHELLFLAGS := -NoProfile -Command -EXT=.exe +ifeq ($(OS), Windows_NT) + SHELL := pwsh.exe + .SHELLFLAGS := -NoProfile -Command + EXT = .exe endif - # Go parameters -GOCMD=go -GOBUILD=$(GOCMD) build -GOCLEAN=$(GOCMD) clean -GOTEST=$(GOCMD) test -GOGET=$(GOCMD) get -BINARY_NAME=cscli$(EXT) +GOCMD = go +GOBUILD = $(GOCMD) build +GOCLEAN = $(GOCMD) clean +GOTEST = $(GOCMD) test +GOGET = $(GOCMD) get + +BINARY_NAME = cscli$(EXT) # names longer than 15 chars break 'pgrep' -BINARY_NAME_COVER=$(BINARY_NAME).cover -PREFIX?="/" +BINARY_NAME_COVER = $(BINARY_NAME).cover +PREFIX ?= "/" BIN_PREFIX = $(PREFIX)"/usr/local/bin/" .PHONY: all all: clean build build: clean - @$(GOBUILD) $(LD_OPTS) -o $(BINARY_NAME) + $(GOBUILD) $(LD_OPTS) -o $(BINARY_NAME) build-bincover: clean $(GOTEST) . -tags testrunmain -coverpkg=$(go list github.com/crowdsecurity/crowdsec/... | grep -v -e 'pkg/database' -e 'plugins/notifications' -e 'pkg/protobufs' -e 'pkg/cwversions' -e 'pkg/cstest' -e 'pkg/models') -covermode=atomic $(LD_OPTS) -c -o $(BINARY_NAME_COVER) -static: clean - @$(GOBUILD) $(LD_OPTS_STATIC) -o $(BINARY_NAME) -a -tags netgo - .PHONY: install install: install-conf install-bin diff --git a/cmd/crowdsec/Makefile b/cmd/crowdsec/Makefile index 4284db57c..94efa22a8 100644 --- a/cmd/crowdsec/Makefile +++ b/cmd/crowdsec/Makefile @@ -1,26 +1,26 @@ -ifeq ($(OS),Windows_NT) -SHELL := pwsh.exe -.SHELLFLAGS := -NoProfile -Command -EXT=.exe +ifeq ($(OS), Windows_NT) + SHELL := pwsh.exe + .SHELLFLAGS := -NoProfile -Command + EXT = .exe endif # Go parameters -GOCMD=go -GOBUILD=$(GOCMD) build -GOCLEAN=$(GOCMD) clean -GOTEST=$(GOCMD) test -GOGET=$(GOCMD) get +GOCMD = go +GOBUILD = $(GOCMD) build +GOCLEAN = $(GOCMD) clean +GOTEST = $(GOCMD) test +GOGET = $(GOCMD) get -CROWDSEC_BIN=crowdsec$(EXT) +CROWDSEC_BIN = crowdsec$(EXT) # names longer than 15 chars break 'pgrep' -CROWDSEC_BIN_COVER=$(CROWDSEC_BIN).cover -PREFIX?="/" +CROWDSEC_BIN_COVER = $(CROWDSEC_BIN).cover +PREFIX ?= "/" CFG_PREFIX = $(PREFIX)"/etc/crowdsec/config/" BIN_PREFIX = $(PREFIX)"/usr/local/bin/" DATA_PREFIX = $(PREFIX)"/var/run/crowdsec/" PID_DIR = $(PREFIX)"/var/run/" -SYSTEMD_PATH_FILE="/etc/systemd/system/crowdsec.service" +SYSTEMD_PATH_FILE = "/etc/systemd/system/crowdsec.service" .PHONY: all all: clean test build @@ -31,14 +31,11 @@ build: clean build-bincover: clean $(GOTEST) . -tags testrunmain -coverpkg=$(go list github.com/crowdsecurity/crowdsec/... | grep -v -e 'pkg/database' -e 'plugins/notifications' -e 'pkg/protobufs' -e 'pkg/cwversions' -e 'pkg/cstest' -e 'pkg/models') -covermode=atomic $(LD_OPTS) -c -o $(CROWDSEC_BIN_COVER) -static: clean - $(GOBUILD) $(LD_OPTS_STATIC) -o $(CROWDSEC_BIN) -a -tags netgo - test: $(GOTEST) $(LD_OPTS) -v ./... clean: - @$(RM) $(CROWDSEC_BIN) $(CROWDSEC_BIN).test $(CROWDSEC_BIN_COVER) $(WIN_IGNORE_ERR) + @$(RM) $(CROWDSEC_BIN) $(CROWDSEC_BIN).test $(CROWDSEC_BIN_COVER) $(WIN_IGNORE_ERR) .PHONY: install install: install-conf install-bin diff --git a/plugins/notifications/dummy/Makefile b/plugins/notifications/dummy/Makefile index 71035f3a9..edbf047a4 100644 --- a/plugins/notifications/dummy/Makefile +++ b/plugins/notifications/dummy/Makefile @@ -1,23 +1,20 @@ -ifeq ($(OS),Windows_NT) -SHELL := pwsh.exe -.SHELLFLAGS := -NoProfile -Command -EXT=.exe +ifeq ($(OS), Windows_NT) + SHELL := pwsh.exe + .SHELLFLAGS := -NoProfile -Command + EXT = .exe endif - # Go parameters -GOCMD=go -GOBUILD=$(GOCMD) build -GOCLEAN=$(GOCMD) clean -GOTEST=$(GOCMD) test -GOGET=$(GOCMD) get -BINARY_NAME=notification-dummy$(EXT) +GOCMD = go +GOBUILD = $(GOCMD) build +GOCLEAN = $(GOCMD) clean +GOTEST = $(GOCMD) test +GOGET = $(GOCMD) get + +BINARY_NAME = notification-dummy$(EXT) + +build: clean + $(GOBUILD) $(LD_OPTS) -o $(BINARY_NAME) clean: @$(RM) $(BINARY_NAME) $(WIN_IGNORE_ERR) - -build: clean - @$(GOBUILD) $(LD_OPTS) -o $(BINARY_NAME) - -static: clean - $(GOBUILD) $(LD_OPTS_STATIC) -o $(BINARY_NAME) -a -tags netgo diff --git a/plugins/notifications/email/Makefile b/plugins/notifications/email/Makefile index 17cef999b..24d76a091 100644 --- a/plugins/notifications/email/Makefile +++ b/plugins/notifications/email/Makefile @@ -1,23 +1,20 @@ -ifeq ($(OS),Windows_NT) -SHELL := pwsh.exe -.SHELLFLAGS := -NoProfile -Command -EXT=.exe +ifeq ($(OS), Windows_NT) + SHELL := pwsh.exe + .SHELLFLAGS := -NoProfile -Command + EXT = .exe endif - # Go parameters -GOCMD=go -GOBUILD=$(GOCMD) build -GOCLEAN=$(GOCMD) clean -GOTEST=$(GOCMD) test -GOGET=$(GOCMD) get -BINARY_NAME=notification-email$(EXT) +GOCMD = go +GOBUILD = $(GOCMD) build +GOCLEAN = $(GOCMD) clean +GOTEST = $(GOCMD) test +GOGET = $(GOCMD) get + +BINARY_NAME = notification-email$(EXT) + +build: clean + $(GOBUILD) $(LD_OPTS) -o $(BINARY_NAME) clean: @$(RM) $(BINARY_NAME) $(WIN_IGNORE_ERR) - -build: clean - @$(GOBUILD) $(LD_OPTS) -o $(BINARY_NAME) - -static: clean - $(GOBUILD) $(LD_OPTS_STATIC) -o $(BINARY_NAME) -a -tags netgo diff --git a/plugins/notifications/http/Makefile b/plugins/notifications/http/Makefile index ad3bea252..8a15bec6d 100644 --- a/plugins/notifications/http/Makefile +++ b/plugins/notifications/http/Makefile @@ -1,23 +1,20 @@ -ifeq ($(OS),Windows_NT) -SHELL := pwsh.exe -.SHELLFLAGS := -NoProfile -Command -EXT=.exe +ifeq ($(OS), Windows_NT) + SHELL := pwsh.exe + .SHELLFLAGS := -NoProfile -Command + EXT = .exe endif - # Go parameters -GOCMD=go -GOBUILD=$(GOCMD) build -GOCLEAN=$(GOCMD) clean -GOTEST=$(GOCMD) test -GOGET=$(GOCMD) get -BINARY_NAME=notification-http$(EXT) +GOCMD = go +GOBUILD = $(GOCMD) build +GOCLEAN = $(GOCMD) clean +GOTEST = $(GOCMD) test +GOGET = $(GOCMD) get -clean: - @$(RM) $(BINARY_NAME) $(WIN_IGNORE_ERR) +BINARY_NAME = notification-http$(EXT) build: clean $(GOBUILD) $(LD_OPTS) -o $(BINARY_NAME) -static: clean - $(GOBUILD) $(LD_OPTS_STATIC) -o $(BINARY_NAME) -a -tags netgo +clean: + @$(RM) $(BINARY_NAME) $(WIN_IGNORE_ERR) diff --git a/plugins/notifications/slack/Makefile b/plugins/notifications/slack/Makefile index a101a235a..f7ee08ecd 100644 --- a/plugins/notifications/slack/Makefile +++ b/plugins/notifications/slack/Makefile @@ -1,23 +1,20 @@ -ifeq ($(OS),Windows_NT) -SHELL := pwsh.exe -.SHELLFLAGS := -NoProfile -Command -EXT=.exe +ifeq ($(OS), Windows_NT) + SHELL := pwsh.exe + .SHELLFLAGS := -NoProfile -Command + EXT = .exe endif # Go parameters -GOCMD=go -GOBUILD=$(GOCMD) build -GOCLEAN=$(GOCMD) clean -GOTEST=$(GOCMD) test -GOGET=$(GOCMD) get -BINARY_NAME=notification-slack$(EXT) +GOCMD = go +GOBUILD = $(GOCMD) build +GOCLEAN = $(GOCMD) clean +GOTEST = $(GOCMD) test +GOGET = $(GOCMD) get + +BINARY_NAME = notification-slack$(EXT) build: clean - @$(GOBUILD) $(LD_OPTS) -o $(BINARY_NAME) + $(GOBUILD) $(LD_OPTS) -o $(BINARY_NAME) clean: @$(RM) $(BINARY_NAME) $(WIN_IGNORE_ERR) - - -static: clean - $(GOBUILD) $(LD_OPTS_STATIC) -o $(BINARY_NAME) -a -tags netgo diff --git a/plugins/notifications/splunk/Makefile b/plugins/notifications/splunk/Makefile index bd99de357..b52850b83 100644 --- a/plugins/notifications/splunk/Makefile +++ b/plugins/notifications/splunk/Makefile @@ -1,24 +1,20 @@ -ifeq ($(OS),Windows_NT) -SHELL := pwsh.exe -.SHELLFLAGS := -NoProfile -Command -EXT=.exe +ifeq ($(OS), Windows_NT) + SHELL := pwsh.exe + .SHELLFLAGS := -NoProfile -Command + EXT = .exe endif - - # Go parameters -GOCMD=go -GOBUILD=$(GOCMD) build -GOCLEAN=$(GOCMD) clean -GOTEST=$(GOCMD) test -GOGET=$(GOCMD) get -BINARY_NAME=notification-splunk$(EXT) +GOCMD = go +GOBUILD = $(GOCMD) build +GOCLEAN = $(GOCMD) clean +GOTEST = $(GOCMD) test +GOGET = $(GOCMD) get + +BINARY_NAME = notification-splunk$(EXT) build: clean $(GOBUILD) $(LD_OPTS) -o $(BINARY_NAME) clean: @$(RM) $(BINARY_NAME) $(WIN_IGNORE_ERR) - -static: clean - $(GOBUILD) $(LD_OPTS_STATIC) -o $(BINARY_NAME) -a -tags netgo