From 04169cac6e590f9d59bb158ee68d01fca54a9256 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20Trma=C4=8D?= Date: Tue, 16 Aug 2022 23:09:09 +0200 Subject: [PATCH] Fix looking for commands with GNU make 4.2.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before https://git.savannah.gnu.org/cgit/make.git/commit/job.c?h=4.3&id=1af314465e5dfe3e8baa839a32a72e83c04f26ef , make was incorrectly trying to avoid running a shell for (command -v). Use the workaround recommended in https://savannah.gnu.org/bugs/index.php?57625 . Signed-off-by: Miloslav Trmač --- Makefile | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 0881c7fd..6a8f3448 100644 --- a/Makefile +++ b/Makefile @@ -29,9 +29,14 @@ GOBIN := $(GOPATH)/bin endif # Scripts may also use CONTAINER_RUNTIME, so we need to export it. -# N/B: Need to use 'command -v' here for compatibility with MacOS. -export CONTAINER_RUNTIME ?= $(if $(shell command -v podman),podman,docker) -GOMD2MAN ?= $(if $(shell command -v go-md2man),go-md2man,$(GOBIN)/go-md2man) +# Note possibly non-obvious aspects of this: +# - We need to use 'command -v' here, not 'which', for compatibility with MacOS. +# - GNU Make 4.2.1 (included in Ubuntu 20.04) incorrectly tries to avoid invoking +# a shell, and fails because there is no /usr/bin/command. The trailing ';' in +# $(shell … ;) defeats that heuristic (recommended in +# https://savannah.gnu.org/bugs/index.php?57625 ). +export CONTAINER_RUNTIME ?= $(if $(shell command -v podman ;),podman,docker) +GOMD2MAN ?= $(if $(shell command -v go-md2man ;),go-md2man,$(GOBIN)/go-md2man) # Go module support: set `-mod=vendor` to use the vendored sources. # See also hack/make.sh.