From 8467879cdfaede36ab545bf873deb8497d41f3e5 Mon Sep 17 00:00:00 2001 From: Shahid Date: Tue, 7 Feb 2023 14:05:24 +0530 Subject: [PATCH] Update Makefile Adding check before using `GOOS` and `GOARCH` variables in `go build` command. Ref. https://github.com/cloudflare/cfssl/pull/1267#discussion_r1083938333 --- Makefile | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Makefile b/Makefile index 366b7b1cd..6c72dc03b 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,11 @@ all: bin/cfssl bin/cfssl-bundle bin/cfssl-certinfo bin/cfssl-newkey bin/cfssl-sc bin/%: $(shell find . -type f -name '*.go') @mkdir -p $(dir $@) +ifneq ($(and $(TARGETOS),$(TARGETARCH)),) GOOS=$(TARGETOS) GOARCH=$(TARGETARCH) go build -ldflags $(LDFLAGS) -o $@ ./cmd/$(@F) +else + go build -ldflags $(LDFLAGS) -o $@ ./cmd/$(@F) +endif .PHONY: install install: install-cfssl install-cfssl-bundle install-cfssl-certinfo install-cfssl-newkey install-cfssl-scan install-cfssljson install-mkbundle install-multirootca @@ -25,7 +29,11 @@ serve: bin/goose: $(shell find vendor -type f -name '*.go') @mkdir -p $(dir $@) +ifneq ($(and $(TARGETOS),$(TARGETARCH)),) GOOS=$(TARGETOS) GOARCH=$(TARGETARCH) go build -o $@ ./vendor/bitbucket.org/liamstask/goose/cmd/goose +else + go build -o $@ ./vendor/bitbucket.org/liamstask/goose/cmd/goose +endif .PHONY: clean clean: