2022-05-17 10:14:59 +00:00
|
|
|
ifeq ($(OS),Windows_NT)
|
|
|
|
SHELL := pwsh.exe
|
|
|
|
.SHELLFLAGS := -NoProfile -Command
|
|
|
|
EXT=.exe
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
2020-05-15 09:39:16 +00:00
|
|
|
# Go parameters
|
|
|
|
GOCMD=go
|
|
|
|
GOBUILD=$(GOCMD) build
|
|
|
|
GOCLEAN=$(GOCMD) clean
|
|
|
|
GOTEST=$(GOCMD) test
|
|
|
|
GOGET=$(GOCMD) get
|
2022-05-17 10:14:59 +00:00
|
|
|
BINARY_NAME=cscli$(EXT)
|
2022-04-01 09:17:45 +00:00
|
|
|
# names longer than 15 chars break 'pgrep'
|
|
|
|
BINARY_NAME_COVER=$(BINARY_NAME).cover
|
2020-05-15 09:39:16 +00:00
|
|
|
PREFIX?="/"
|
|
|
|
BIN_PREFIX = $(PREFIX)"/usr/local/bin/"
|
|
|
|
|
2022-02-01 08:22:47 +00:00
|
|
|
.PHONY: all
|
2020-05-15 09:39:16 +00:00
|
|
|
all: clean build
|
|
|
|
|
|
|
|
build: clean
|
2022-06-17 14:12:49 +00:00
|
|
|
@$(GOBUILD) $(LD_OPTS) -o $(BINARY_NAME)
|
2020-05-15 09:39:16 +00:00
|
|
|
|
2022-04-01 09:17:45 +00:00
|
|
|
build-bincover: clean
|
2022-04-05 09:00:11 +00:00
|
|
|
$(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)
|
2022-04-01 09:17:45 +00:00
|
|
|
|
2020-05-15 09:39:16 +00:00
|
|
|
static: clean
|
2022-06-17 14:12:49 +00:00
|
|
|
@$(GOBUILD) $(LD_OPTS_STATIC) -o $(BINARY_NAME) -a -tags netgo
|
2020-05-15 09:39:16 +00:00
|
|
|
|
2022-02-01 08:22:47 +00:00
|
|
|
.PHONY: install
|
2020-05-15 09:39:16 +00:00
|
|
|
install: install-conf install-bin
|
|
|
|
|
|
|
|
install-conf:
|
|
|
|
|
|
|
|
install-bin:
|
|
|
|
@install -v -m 755 -D "$(BINARY_NAME)" "$(BIN_PREFIX)/$(BINARY_NAME)" || exit
|
|
|
|
|
|
|
|
uninstall:
|
2022-05-17 10:14:59 +00:00
|
|
|
@$(RM) $(CSCLI_CONFIG) $(WIN_IGNORE_ERR)
|
|
|
|
@$(RM) $(BIN_PREFIX)$(BINARY_NAME) $(WIN_IGNORE_ERR)
|
2020-05-15 09:39:16 +00:00
|
|
|
|
|
|
|
clean:
|
2022-05-17 10:14:59 +00:00
|
|
|
@$(RM) $(BINARY_NAME) $(BINARY_NAME_COVER) $(WIN_IGNORE_ERR)
|