From: Dan Fuhry Date: Thu, 25 Apr 2024 04:05:36 +0000 (-0400) Subject: Makefile: fix on GNU make 3.81 (macos) X-Git-Url: https://go.fuhry.dev/?a=commitdiff_plain;h=573359c0201700f4d1b8a1ed29bdf4680eac7ca6;p=runtime.git Makefile: fix on GNU make 3.81 (macos) --- diff --git a/Makefile b/Makefile index 6192578..2c1b756 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,10 @@ +GO = $(shell which go) GOMAINSRCS = $(shell find . -type f -name main.go | cut -c 3- | paste -s -d ' ' -) GOMAINDIRS = $(GOMAINSRCS:/main.go=) -GOOS ?= $(shell go env GOOS) -GOARCH ?= $(shell go env GOARCH) +GOOS ?= $(shell $(GO) env GOOS) +GOARCH ?= $(shell $(GO) env GOARCH) -ifeq ($(GOOS)/$(GOARCH),$(shell env - go env GOOS)/$(shell env - go env GOARCH)) +ifeq ($(GOOS)/$(GOARCH),$(shell env - $(GO) env GOOS)/$(shell env - $(GO) env GOARCH)) NATIVE_BUILD := 1 else NATIVE_BUILD := 0 @@ -54,17 +55,17 @@ LDFLAGS += -X "go.fuhry.dev/runtime/constants.RootCAName=$(ROOT_CA_NAME)" LDFLAGS += -X "go.fuhry.dev/runtime/constants.IntCAName=$(INT_CA_NAME)" LDFLAGS += -X "go.fuhry.dev/runtime/constants.DeviceTrustTokenName=$(DEVICE_TRUST_TOKEN_NAME)" -define GOPROG_template = +define GOPROG_template GOMAINS += $(1)/$(2) all: $(1)/$(2) $(1)/$(2): $(1)/main.go - go build -ldflags '$$(LDFLAGS)' $$(GOBUILDFLAGS) -o $$@ $$< + $(GO) build -ldflags '$$(LDFLAGS)' $$(GOBUILDFLAGS) -o $$@ $$< endef $(foreach maindir,$(GOMAINDIRS),$(eval $(call GOPROG_template,$(maindir),$(shell basename $(maindir))))) -.PHONY: $(GOMAINDIRS) clean all +.PHONY: clean all list clean: if test -z "$(GOMAINS)"; then \ @@ -75,3 +76,6 @@ clean: exit 1; \ fi rm -fv $(GOMAINS) + +list: + @LC_ALL=C $(MAKE) -pRrq -f $(firstword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: '/(^|\n)# Files(\n|$$)/,/(^|\n)# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | grep -E -v -e '^[^[:alnum:]]' -e '^$@$$' diff --git a/sase/ws_proxy_client/Makefile b/sase/ws_proxy_client/Makefile index bfab546..de40e1d 100644 --- a/sase/ws_proxy_client/Makefile +++ b/sase/ws_proxy_client/Makefile @@ -1,6 +1,6 @@ GOSRC = $(wildcard *.go) GOEXE = $(shell basename `pwd`) -GOBUILDFLAGS := -buildmode=pie -trimpath +GOBUILDFLAGS := -buildmode=pie -trimpath -tags=pkcs11 all: $(GOEXE)