From 872bd68983dc5ea69f386f8c5e30da3e3b88b38d Mon Sep 17 00:00:00 2001 From: Hilko Bengen Date: Tue, 12 Oct 2021 22:56:59 +0200 Subject: [PATCH] Stop using which in buildsystem command -v does not portably support multiple arguments, so we have to work around that. --- 3rdparty.mk | 10 +++++----- Makefile | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/3rdparty.mk b/3rdparty.mk index 31f0d50..4bc1106 100644 --- a/3rdparty.mk +++ b/3rdparty.mk @@ -16,7 +16,7 @@ $(or \ $(findstring -redhat-linux,$(3rdparty_NATIVE_ARCH))),\ $(eval 3rdparty_ARCHS=i386-linux-musl x86_64-linux-musl i686-w64-mingw32 x86_64-w64-mingw32)\ $(foreach arch,i686-w64-mingw32 x86_64-w64-mingw32,\ - $(if $(not $(shell which $(arch)-gcc)),$(error $(arch)-gcc not found)))),\ + $(if $(not $(shell command -v $(arch)-gcc)),$(error $(arch)-gcc not found)))),\ $(if $(or $(findstring -apple-darwin,$(3rdparty_NATIVE_ARCH)),\ $(findstring -freebsd,$(3rdparty_NATIVE_ARCH))),\ $(eval 3rdparty_ARCHS=$(3rdparty_NATIVE_ARCH))),\ @@ -110,7 +110,7 @@ _3rdparty/build/$1/musl-$(musl_VERSION)/.build-stamp: _3rdparty/src/musl-$(musl_ # Make gcc wrapper available as -gcc @mkdir -p _3rdparty/tgt/bin ln -sf $(abspath _3rdparty/tgt/$1)/bin/musl-gcc _3rdparty/tgt/bin/$1-gcc - $(foreach tool,ar ranlib ld, ln -sf $(shell which $(tool)) _3rdparty/tgt/bin/$1-$(tool); ) + $(foreach tool,ar ranlib ld, ln -sf $(shell command -v $(tool)) _3rdparty/tgt/bin/$1-$(tool); ) touch $$@ endef @@ -125,7 +125,7 @@ _3rdparty/build/$1/yara-$(yara_VERSION)/.build-stamp: _3rdparty/src/yara-$(yara_ --prefix=$(abspath _3rdparty/tgt/$1) \ --disable-shared \ --disable-magic --disable-cuckoo --enable-dotnet --enable-macho --enable-dex \ - CC=$$(firstword $$(shell PATH=$$(PATH) which $1-gcc gcc cc)) \ + CC=$$(firstword $$(shell PATH=$$(PATH) $$(firstword $$(foreach cand,$1-gcc gcc cc,$$(shell -v $$(cand)))))) \ CPPFLAGS="-I$(abspath _3rdparty/tgt/$1/include) $(if $(findstring -mingw32,$1),-UHAVE__MKGMTIME)" \ CFLAGS="$(if $(findstring -linux-musl,$1),-static)" \ LDFLAGS="$$(shell PKG_CONFIG_PATH=$$(abspath _3rdparty/tgt/$1/lib/pkgconfig) \ @@ -143,8 +143,8 @@ endef define build_openssl_TEMPLATE _3rdparty/build/$1/openssl-$(openssl_VERSION)/.build-stamp: \ private export CC=$(or \ - $(if $(shell which gcc),gcc),\ - $(if $(shell which cc),cc),\ + $(if $(shell command -v gcc),gcc),\ + $(if $(shell command -v cc),cc),\ $(error 3rdparty/openssl: gcc or cc not found)) _3rdparty/build/$1/openssl-$(openssl_VERSION)/.build-stamp: \ private export CFLAGS=$(if $(findstring -linux-musl,$1),-static) $(if $(findstring x86_64,$1),-m64,-m32) diff --git a/Makefile b/Makefile index eb351f5..b1e04cd 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,8 @@ $(if $(filter 4.%,$(MAKE_VERSION)),,\ $(error GNU make 4.0 or above is required.)) -SED := $(firstword $(shell which gsed sed)) -TAR := $(firstword $(shell which gtar tar)) +SED := $(firstword $(foreach cand,gsed sed,$(shell command -v $(cand)))) +TAR := $(firstword $(foreach cand,gtar tar,$(shell command -v $(cand)))) export GOPATH=$(CURDIR)/_gopath @@ -63,7 +63,7 @@ $(if $(findstring linux,$(3rdparty_NATIVE_ARCH)),\ $(eval unit-test: private export GOARCH=amd64)\ $(eval unit-test: private export PKG_CONFIG_PATH=$(CURDIR)/_3rdparty/tgt/x86_64-linux-musl/lib/pkgconfig)\ ,\ - $(eval unit-test: private export CC=$(firstword $(shell which gcc cc)))\ + $(eval unit-test: private export CC=$(firstword $(foreach cand,gcc cc,$(shell command -v $(cand)))))\ $(eval unit-test: private export PKG_CONFIG_PATH=$(CURDIR)/_3rdparty/tgt/$(3rdparty_NATIVE_ARCH)/lib/pkgconfig)) $(EXE) unit-test: private export CGO_ENABLED=1