From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48563) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VKUDu-00066Y-Nn for qemu-devel@nongnu.org; Fri, 13 Sep 2013 10:19:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VKUDt-0004vD-JP for qemu-devel@nongnu.org; Fri, 13 Sep 2013 10:19:50 -0400 Received: from 1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.d.1.0.0.b.8.0.1.0.0.2.ip6.arpa ([2001:8b0:1d0::1]:43970 helo=mnementh.archaic.org.uk) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VKUDt-0004ts-Aa for qemu-devel@nongnu.org; Fri, 13 Sep 2013 10:19:49 -0400 From: Peter Maydell Date: Fri, 13 Sep 2013 15:19:37 +0100 Message-Id: <1379081979-11186-2-git-send-email-peter.maydell@linaro.org> In-Reply-To: <1379081979-11186-1-git-send-email-peter.maydell@linaro.org> References: <1379081979-11186-1-git-send-email-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [Qemu-devel] [PATCH 1/3] rules.mak: New logical functions for handling y/n values List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Paolo Bonzini , =?UTF-8?q?=C3=81kos=20Kov=C3=A1cs?= , Anthony Liguori , patches@linaro.org Add new logical functions for handling y/n values like those we use in CONFIG_FOO variables: lnot : logical NOT land : logical AND lor : logical OR eq : equality ne : non-equality lif : like Make's $(if) but with an eq-like test and a couple of utility functions: isempty : true if argument is empty notempty : true if argument is not empty Based on an idea by Ákos Kovács . Signed-off-by: Peter Maydell --- rules.mak | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/rules.mak b/rules.mak index abc2e84..ccbf0e3 100644 --- a/rules.mak +++ b/rules.mak @@ -89,6 +89,24 @@ find-in-path = $(if $(find-string /, $1), \ $(wildcard $1), \ $(wildcard $(patsubst %, %/$1, $(subst :, ,$(PATH))))) +# Logical functions (for operating on y/n values like CONFIG_FOO vars) +# Inputs to these must be either "y" (true) or "n" or "" (both false) +# Output is always either "y" or "n". +# Usage: $(call land,$(CONFIG_FOO),$(CONFIG_BAR)) +# Logical NOT +lnot = $(if $(subst n,,$1),n,y) +# Logical AND +land = $(if $(findstring yy,$1$2),y,n) +# Logical OR +lor = $(if $(findstring y,$1$2),y,n) +# Comparison: note that "n" is eq to "". +eq = $(if $(filter $(call lnot,$1),$(call lnot,$2)),y,n) +ne = $(if $(filter $(call lnot,$1),$(call lnot,$2)),n,y) + +# Returns "y" or "n" depending on whether input argument is the empty string +isempty = $(if $1,n,y) +notempty = $(if $1,y,n) + # Generate files with tracetool TRACETOOL=$(PYTHON) $(SRC_PATH)/scripts/tracetool.py -- 1.7.9.5