[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 1/4] rules.mak: New logical functions for handlin
From: |
Peter Maydell |
Subject: |
[Qemu-devel] [PATCH v2 1/4] rules.mak: New logical functions for handling y/n values |
Date: |
Fri, 13 Sep 2013 18:25:51 +0100 |
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 <address@hidden>.
Signed-off-by: Peter Maydell <address@hidden>
---
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.7.9.5
- [Qemu-devel] [PATCH v2 0/4] avoid CONFIG_NO_* using rules.mak logic/string fns, Peter Maydell, 2013/09/13
- [Qemu-devel] [PATCH v2 3/4] Makefile.target: CONFIG_NO_* variables removed, Peter Maydell, 2013/09/13
- [Qemu-devel] [PATCH v2 2/4] rules.mak: New string testing functions, Peter Maydell, 2013/09/13
- [Qemu-devel] [PATCH v2 4/4] default-configs/: CONFIG_GDBSTUB_XML removed, Peter Maydell, 2013/09/13
- [Qemu-devel] [PATCH v2 1/4] rules.mak: New logical functions for handling y/n values,
Peter Maydell <=
- Re: [Qemu-devel] [PATCH v2 0/4] avoid CONFIG_NO_* using rules.mak logic/string fns, Paolo Bonzini, 2013/09/13
- Re: [Qemu-devel] [PATCH v2 0/4] avoid CONFIG_NO_* using rules.mak logic/string fns, Peter Maydell, 2013/09/26