From 87ff205c8bf634e541e90e52fa09dcb51dae3da2 Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Wed, 11 Dec 2024 11:57:08 +0100 Subject: [PATCH] Handle potential pkg-config failures There are cases where we want to use an MPI provider, but the package is not installed in the system, so `pkg-config` can't find it. To solve this simply ignore the errors created and only print something if the user asks us to by passing `V=1`. Signed-off-by: Steffen Jaeckel --- makefile | 2 ++ makefile_include.mk | 18 +++++++++--------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/makefile b/makefile index 70d40d654..ddddb6cc9 100644 --- a/makefile +++ b/makefile @@ -13,9 +13,11 @@ endif ifeq ($V,1) silent= silent_stdout= +silent_stderr= else silent=@ silent_stdout= > /dev/null +silent_stderr= 2> /dev/null endif PLATFORM := $(shell uname | sed -e 's/_.*//') diff --git a/makefile_include.mk b/makefile_include.mk index 72c4d3630..c87550baf 100644 --- a/makefile_include.mk +++ b/makefile_include.mk @@ -55,13 +55,13 @@ endif ifndef EXTRALIBS ifneq ($(shell echo $(CFLAGS) | grep USE_LTM),) -EXTRALIBS=$(shell PKG_CONFIG_PATH=$(LIBPATH)/pkgconfig pkg-config --libs libtommath) -else -ifneq ($(shell echo $(CFLAGS) | grep USE_TFM),) -EXTRALIBS=$(shell PKG_CONFIG_PATH=$(LIBPATH)/pkgconfig pkg-config --libs tomsfastmath) -endif -endif +EXTRALIBS=$(shell PKG_CONFIG_PATH=$(LIBPATH)/pkgconfig pkg-config --libs libtommath ${silent_stderr} || true) +else ifneq ($(shell echo $(CFLAGS) | grep USE_TFM),) +EXTRALIBS=$(shell PKG_CONFIG_PATH=$(LIBPATH)/pkgconfig pkg-config --libs tomsfastmath ${silent_stderr} || true) +else ifneq ($(shell echo $(CFLAGS) | grep USE_GMP),) +EXTRALIBS=$(shell PKG_CONFIG_PATH=$(LIBPATH)/pkgconfig pkg-config --libs gmp ${silent_stderr} || true) endif +endif # EXTRALIBS need-help := $(filter help,$(MAKECMDGOALS)) define print-help @@ -77,13 +77,13 @@ endef # make CFLAGS="-I./src/headers/ -DLTC_SOURCE ..." ... # ifneq ($(shell echo $(CFLAGS) | grep LTM_DESC),) -LTC_CFLAGS+=$(shell PKG_CONFIG_PATH=$(LIBPATH)/pkgconfig pkg-config --cflags-only-I libtommath) +LTC_CFLAGS+=$(shell PKG_CONFIG_PATH=$(LIBPATH)/pkgconfig pkg-config --cflags-only-I libtommath ${silent_stderr} || true) endif ifneq ($(shell echo $(CFLAGS) | grep TFM_DESC),) -LTC_CFLAGS+=$(shell PKG_CONFIG_PATH=$(LIBPATH)/pkgconfig pkg-config --cflags-only-I tomsfastmath) +LTC_CFLAGS+=$(shell PKG_CONFIG_PATH=$(LIBPATH)/pkgconfig pkg-config --cflags-only-I tomsfastmath ${silent_stderr} || true) endif ifneq ($(shell echo $(CFLAGS) | grep GMP_DESC),) -LTC_CFLAGS+=$(shell PKG_CONFIG_PATH=$(LIBPATH)/pkgconfig pkg-config --cflags-only-I gmp) +LTC_CFLAGS+=$(shell PKG_CONFIG_PATH=$(LIBPATH)/pkgconfig pkg-config --cflags-only-I gmp ${silent_stderr} || true) endif LTC_CFLAGS += -I./src/headers/ -DLTC_SOURCE -Wall -Wsign-compare -Wshadow