Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop using which in buildsystem #72

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions 3rdparty.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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))),\
Expand Down Expand Up @@ -110,7 +110,7 @@ _3rdparty/build/$1/musl-$(musl_VERSION)/.build-stamp: _3rdparty/src/musl-$(musl_
# Make gcc wrapper available as <triplet>-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

Expand All @@ -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) \
Expand All @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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
Expand Down