Received: from eggs.gnu.org ([2001:4830:134:3::10]:36695) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VWpc3-0008Tk-D0 for qemu-devel@nongnu.org; Thu, 17 Oct 2013 11:35:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VWpbx-0004XO-Vw for qemu-devel@nongnu.org; Thu, 17 Oct 2013 11:35:47 -0400 Received: from mail-ea0-x236.google.com ([2a00:1450:4013:c01::236]:40643) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VWpbx-0004Ve-Ob for qemu-devel@nongnu.org; Thu, 17 Oct 2013 11:35:41 -0400 Received: by mail-ea0-f182.google.com with SMTP id o10so1147601eaj.41 for ; Thu, 17 Oct 2013 08:35:41 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Thu, 17 Oct 2013 17:35:29 +0200 Message-Id: <1382024133-15764-2-git-send-email-pbonzini@redhat.com> In-Reply-To: <1382024133-15764-1-git-send-email-pbonzini@redhat.com> References: <1382024133-15764-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [Qemu-devel] [PULL 1/5] 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: Peter Maydell From: Peter Maydell 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 lxor : logical XOR leqv : logical equality, inverse of lxor lif : like Make's $(if) but with an eq-like test Based on an idea by Ákos Kovács . Signed-off-by: Peter Maydell Signed-off-by: Paolo Bonzini --- rules.mak | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/rules.mak b/rules.mak index abc2e84..65a1b96 100644 --- a/rules.mak +++ b/rules.mak @@ -89,6 +89,23 @@ 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) +# Logical XOR (note that this is the inverse of leqv) +lxor = $(if $(filter $(call lnot,$1),$(call lnot,$2)),n,y) +# Logical equivalence (note that leqv "","n" is true) +leqv = $(if $(filter $(call lnot,$1),$(call lnot,$2)),y,n) +# Logical if: like make's $(if) but with an leqv-like test +lif = $(if $(subst n,,$1),$2,$3) + # Generate files with tracetool TRACETOOL=$(PYTHON) $(SRC_PATH)/scripts/tracetool.py -- 1.8.3.1