qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
	"Ákos Kovács" <akoskovacs@gmx.com>,
	"Anthony Liguori" <anthony@codemonkey.ws>,
	patches@linaro.org
Subject: [Qemu-devel] [PATCH 1/3] rules.mak: New logical functions for handling y/n values
Date: Fri, 13 Sep 2013 15:19:37 +0100	[thread overview]
Message-ID: <1379081979-11186-2-git-send-email-peter.maydell@linaro.org> (raw)
In-Reply-To: <1379081979-11186-1-git-send-email-peter.maydell@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 <akoskovacs@gmx.com>.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 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

  reply	other threads:[~2013-09-13 14:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-13 14:19 [Qemu-devel] [PATCH 0/3] avoid CONFIG_NO_* using rules.mak logical functions Peter Maydell
2013-09-13 14:19 ` Peter Maydell [this message]
2013-09-13 14:19 ` [Qemu-devel] [PATCH 2/3] Makefile.target: CONFIG_NO_* variables removed Peter Maydell
2013-09-13 14:19 ` [Qemu-devel] [PATCH 3/3] default-configs/: CONFIG_GDBSTUB_XML removed Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1379081979-11186-2-git-send-email-peter.maydell@linaro.org \
    --to=peter.maydell@linaro.org \
    --cc=akoskovacs@gmx.com \
    --cc=anthony@codemonkey.ws \
    --cc=patches@linaro.org \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).