SHELL = /bin/bash -o pipefail export PATH := $(shell go env GOPATH)/bin:$(PATH) ROOT_DIR=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) BUILD_DIR=$(ROOT_DIR)/build BIN=$(BUILD_DIR)/sshpoke GO_VERSION=$(shell go version | sed -e 's/go version //') .PHONY: run clean_backend build: generate deps fmt @echo " ► Building with ${GO_VERSION}" @CGO_ENABLED=0 go build -tags=release -o $(BIN) . @echo $(BIN) test: deps fmt @echo " ► Running tests" @go test -timeout 1m ./... -v -cpu 4 fmt: @echo " ► Running gofmt" @gofmt -l -s -w `go list -f '{{.Dir}}' ${ROOT_DIR}/... | grep -v /vendor/` deps: @echo " ► Installing dependencies" @go mod tidy @go mod vendor run: @$(BIN) clean: @rm -rf $(BUILD_DIR) generate: @echo " ► Performing code generation" @cd $(ROOT_DIR)/pkg/plugin && go generate install_protobuf: @go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28 @go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2 update_sshlib: @rm -rf cryptolib && \ git clone https://go.googlesource.com/crypto cryptolib && \ rm -rf pkg/proto/ssh && \ mv cryptolib/ssh pkg/proto/ && \ mv cryptolib/internal/poly1305 pkg/proto/ssh/internal/ && \ find pkg/proto/ssh -type f -name '*.go' -exec sed -i 's?golang.org/x/crypto/ssh?github.com/Neur0toxine/sshpoke/pkg/proto/ssh?g' {} \; && \ find pkg/proto/ssh -type f -name '*.go' -exec sed -i 's?golang.org/x/crypto/internal/poly1305?github.com/Neur0toxine/sshpoke/pkg/proto/ssh/internal/poly1305?g' {} \; && \ find pkg/proto/ssh -type f -name '*_test.go' -delete && \ patch -p0 < patch/ssh_fakehost.patch && \ rm -rf pkg/proto/ssh/test && \ rm -rf pkg/proto/ssh/testdata && \ rm -rf cryptolib