From ad5dbd85eaba9e3dc64ad4536dae512497376a8e Mon Sep 17 00:00:00 2001 From: Thomas Roehl Date: Wed, 25 May 2022 15:45:21 +0200 Subject: [PATCH] Minor updates for Makefiles --- Makefile | 27 +++++++++++++++------------ collectors/Makefile | 2 +- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index 13c7d1b..6cfd3b3 100644 --- a/Makefile +++ b/Makefile @@ -16,20 +16,23 @@ COMPONENT_DIRS := collectors \ internal/multiChanTicker BINDIR = bin +GOBIN = $(shell which go) .PHONY: all all: $(APP) $(APP): $(GOSRC) - make -C collectors - if [ "$(shell go version | cut -d' ' -f 3 | cut -d '.' -f1-2)" == "go1.16" ]; then \ + if [ "$(shell $(GOBIN) version | cut -d' ' -f 3 | cut -d '.' -f1-2)" == "go1.16" ]; then \ + echo "1.16"; \ cp go.mod.1.16 go.mod; \ else \ + echo "1.17+"; \ cp go.mod.1.17+ go.mod; \ fi - go get - go build -o $(APP) $(GOSRC_APP) + make -C collectors + $(GOBIN) get + $(GOBIN) build -o $(APP) $(GOSRC_APP) install: $(APP) @WORKSPACE=$(PREFIX) @@ -56,25 +59,25 @@ clean: .PHONY: fmt fmt: - go fmt $(GOSRC_COLLECTORS) - go fmt $(GOSRC_SINKS) - go fmt $(GOSRC_RECEIVERS) - go fmt $(GOSRC_APP) - @for F in $(GOSRC_INTERNAL); do go fmt $$F; done + $(GOBIN) fmt $(GOSRC_COLLECTORS) + $(GOBIN) fmt $(GOSRC_SINKS) + $(GOBIN) fmt $(GOSRC_RECEIVERS) + $(GOBIN) fmt $(GOSRC_APP) + @for F in $(GOSRC_INTERNAL); do $(GOBIN) fmt $$F; done # Examine Go source code and reports suspicious constructs .PHONY: vet vet: - go vet ./... + $(GOBIN) vet ./... # Run linter for the Go programming language. # Using static analysis, it finds bugs and performance issues, offers simplifications, and enforces style rules .PHONY: staticcheck staticcheck: - go install honnef.co/go/tools/cmd/staticcheck@latest - $$(go env GOPATH)/bin/staticcheck ./... + $(GOBIN) install honnef.co/go/tools/cmd/staticcheck@latest + $$($(GOBIN) env GOPATH)/bin/staticcheck ./... .ONESHELL: .PHONY: RPM diff --git a/collectors/Makefile b/collectors/Makefile index 20418ed..74dadce 100644 --- a/collectors/Makefile +++ b/collectors/Makefile @@ -1,6 +1,6 @@ # LIKWID version LIKWID_VERSION = 5.2.1 -LIKWID_INSTALLED_FOLDER=$(shell dirname $(shell which likwid-topology 2>/dev/null)) +LIKWID_INSTALLED_FOLDER=$(shell dirname $(shell which likwid-topology 2>/dev/null) 2>/dev/null) LIKWID_FOLDER="$(shell pwd)/likwid"