Skip to contentSkip to conversation

avoid CONFIG_NO_* using rules.mak logical functions

PATCH Superseded Peter Maydell 1 participant 4 messages Sep 13, 2013 Kbuild

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover avoid CONFIG_NO_* using rules.mak logical functions

This is based on a set of patches by Ákos Kovács which were lurking at the beginning of his KConfig patchset but which I think make a nice standalone cleanup. Since I basically rewrote all of patch 1 in review comments I figured it was easier to just write it as a new patch. Patch 2 and 3 are Ákos', though I fixed a few missed conversions in patch 2.

Peter Maydell (1):
rules.mak: New logical functions for handling y/n values

Ákos Kovács (2):
Makefile.target: CONFIG_NO_* variables removed default-configs/: CONFIG_GDBSTUB_XML removed

 Makefile.target                           |   10 +++-------
 default-configs/arm-linux-user.mak        |    2 --
 default-configs/arm-softmmu.mak           |    1 -
 default-configs/armeb-linux-user.mak      |    2 --
 default-configs/m68k-linux-user.mak       |    2 --
 default-configs/m68k-softmmu.mak          |    1 -
 default-configs/ppc-linux-user.mak        |    2 --
 default-configs/ppc-softmmu.mak           |    1 -
 default-configs/ppc64-linux-user.mak      |    2 --
 default-configs/ppc64-softmmu.mak         |    1 -
 default-configs/ppc64abi32-linux-user.mak |    2 --
 default-configs/ppcemb-softmmu.mak        |    1 -
 hw/pci/Makefile.objs                      |    2 +-
 rules.mak                                 |   18 ++++++++++++++++++
 target-arm/Makefile.objs                  |    2 +-
 target-i386/Makefile.objs                 |    2 +-
 target-ppc/Makefile.objs                  |    2 +-
 17 files changed, 25 insertions(+), 28 deletions(-)
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 1/3 rules.mak: New logical functions for handling y/n values

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 <[email protected]>.

---
 rules.mak |   18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
rules.mak +18 -0
index abc2e84..ccbf0e3 100644
@@ -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
 
Signature · 1 line
1.7.9.5
#2 lore raw

PATCH 2/3 Makefile.target: CONFIG_NO_* variables removed

In reply to Peter Maydell

From: Ákos Kovács <[email protected]>

CONFIG_NO_* variables replaced with the lnot logical function

[PMM: fixed a few CONFIG_NO_* uses that were missed]
---
 Makefile.target           |    8 ++------
 hw/pci/Makefile.objs      |    2 +-
 target-arm/Makefile.objs  |    2 +-
 target-i386/Makefile.objs |    2 +-
 target-ppc/Makefile.objs  |    2 +-
 5 files changed, 6 insertions(+), 10 deletions(-)
Makefile.target +2 -6
index 9a49852..bbc668b 100644
@@ -70,10 +70,6 @@ all: $(PROGS) stap
 # Dummy command so that make thinks it has done something
 	@true
 
-CONFIG_NO_PCI = $(if $(subst n,,$(CONFIG_PCI)),n,y)
-CONFIG_NO_KVM = $(if $(subst n,,$(CONFIG_KVM)),n,y)
-CONFIG_NO_XEN = $(if $(subst n,,$(CONFIG_XEN)),n,y)
-
 #########################################################
 # cpu emulator library
 obj-y = exec.o translate-all.o cpu-exec.o
@@ -84,7 +80,7 @@ obj-y += fpu/softfloat.o
 obj-y += target-$(TARGET_BASE_ARCH)/
 obj-y += disas.o
 obj-$(CONFIG_GDBSTUB_XML) += gdbstub-xml.o
-obj-$(CONFIG_NO_KVM) += kvm-stub.o
+obj-$(call lnot,$(CONFIG_KVM)) += kvm-stub.o
 
 #########################################################
 # Linux user emulator target
@@ -125,7 +121,7 @@ LIBS+=$(libs_softmmu)
 
 # xen support
 obj-$(CONFIG_XEN) += xen-all.o xen-mapcache.o
-obj-$(CONFIG_NO_XEN) += xen-stub.o
+obj-$(call lnot,$(CONFIG_XEN)) += xen-stub.o
 
 # Hardware support
 ifeq ($(TARGET_NAME), sparc64)
hw/pci/Makefile.objs +1 -1
index 720f438..80f8aa6 100644
@@ -5,7 +5,7 @@ common-obj-$(CONFIG_PCI) += slotid_cap.o
 common-obj-$(CONFIG_PCI) += pci_host.o pcie_host.o
 common-obj-$(CONFIG_PCI) += pcie.o pcie_aer.o pcie_port.o
 
-common-obj-$(CONFIG_NO_PCI) += pci-stub.o
+common-obj-$(call lnot,$(CONFIG_PCI)) += pci-stub.o
 common-obj-$(CONFIG_ALL) += pci-stub.o
 
 common-obj-$(CONFIG_PCI_HOTPLUG_OLD) += pci-hotplug-old.o
target-arm/Makefile.objs +1 -1
index 6453f5c..356fbfc 100644
@@ -1,7 +1,7 @@
 obj-y += arm-semi.o
 obj-$(CONFIG_SOFTMMU) += machine.o
 obj-$(CONFIG_KVM) += kvm.o
-obj-$(CONFIG_NO_KVM) += kvm-stub.o
+obj-$(call lnot,$(CONFIG_KVM)) += kvm-stub.o
 obj-y += translate.o op_helper.o helper.o cpu.o
 obj-y += neon_helper.o iwmmxt_helper.o
 obj-y += gdbstub.o
target-i386/Makefile.objs +1 -1
index da1fc40..027b94e 100644
@@ -4,6 +4,6 @@ obj-y += smm_helper.o misc_helper.o mem_helper.o seg_helper.o
 obj-y += gdbstub.o
 obj-$(CONFIG_SOFTMMU) += machine.o arch_memory_mapping.o arch_dump.o
 obj-$(CONFIG_KVM) += kvm.o
-obj-$(CONFIG_NO_KVM) += kvm-stub.o
+obj-$(call lnot,$(CONFIG_KVM)) += kvm-stub.o
 obj-$(CONFIG_LINUX_USER) += ioport-user.o
 obj-$(CONFIG_BSD_USER) += ioport-user.o
target-ppc/Makefile.objs +1 -1
index f72e399..94d6d0c 100644
@@ -5,7 +5,7 @@ obj-y += machine.o mmu_helper.o mmu-hash32.o
 obj-$(TARGET_PPC64) += mmu-hash64.o
 endif
 obj-$(CONFIG_KVM) += kvm.o kvm_ppc.o
-obj-$(CONFIG_NO_KVM) += kvm-stub.o
+obj-$(call lnot,$(CONFIG_KVM)) += kvm-stub.o
 obj-y += excp_helper.o
 obj-y += fpu_helper.o
 obj-y += int_helper.o
Signature · 1 line
1.7.9.5
#3 lore raw

PATCH 3/3 default-configs/: CONFIG_GDBSTUB_XML removed

In reply to Peter Maydell

From: Ákos Kovács <[email protected]>

Makefile.target: Build gdbstub-xml.o only when
TARGET_XML_FILES is not empty.

---
 Makefile.target                           |    2 +-
 default-configs/arm-linux-user.mak        |    2 --
 default-configs/arm-softmmu.mak           |    1 -
 default-configs/armeb-linux-user.mak      |    2 --
 default-configs/m68k-linux-user.mak       |    2 --
 default-configs/m68k-softmmu.mak          |    1 -
 default-configs/ppc-linux-user.mak        |    2 --
 default-configs/ppc-softmmu.mak           |    1 -
 default-configs/ppc64-linux-user.mak      |    2 --
 default-configs/ppc64-softmmu.mak         |    1 -
 default-configs/ppc64abi32-linux-user.mak |    2 --
 default-configs/ppcemb-softmmu.mak        |    1 -
 12 files changed, 1 insertion(+), 18 deletions(-)
Makefile.target +1 -1
index bbc668b..af6ac7e 100644
@@ -79,7 +79,7 @@ obj-$(CONFIG_TCG_INTERPRETER) += disas/tci.o
 obj-y += fpu/softfloat.o
 obj-y += target-$(TARGET_BASE_ARCH)/
 obj-y += disas.o
-obj-$(CONFIG_GDBSTUB_XML) += gdbstub-xml.o
+obj-$(call notempty,$(TARGET_XML_FILES)) += gdbstub-xml.o
 obj-$(call lnot,$(CONFIG_KVM)) += kvm-stub.o
 
 #########################################################
default-configs/arm-linux-user.mak +0 -2
index 46d4aa2..413361a 100644
@@ -1,3 +1 @@
 # Default configuration for arm-linux-user
-
-CONFIG_GDBSTUB_XML=y
default-configs/arm-softmmu.mak +0 -1
index ac0815d..d13bc2b 100644
@@ -2,7 +2,6 @@
 
 include pci.mak
 include usb.mak
-CONFIG_GDBSTUB_XML=y
 CONFIG_VGA=y
 CONFIG_ISA_MMIO=y
 CONFIG_NAND=y
default-configs/armeb-linux-user.mak +0 -2
index 41d0cc4..bf2ffe7 100644
@@ -1,3 +1 @@
 # Default configuration for armeb-linux-user
-
-CONFIG_GDBSTUB_XML=y
default-configs/m68k-linux-user.mak +0 -2
index f3487aa..06cd5ed 100644
@@ -1,3 +1 @@
 # Default configuration for m68k-linux-user
-
-CONFIG_GDBSTUB_XML=y
default-configs/m68k-softmmu.mak +0 -1
index 51fe5bb..d9552df 100644
@@ -3,5 +3,4 @@
 include pci.mak
 include usb.mak
 CONFIG_COLDFIRE=y
-CONFIG_GDBSTUB_XML=y
 CONFIG_PTIMER=y
default-configs/ppc-linux-user.mak +0 -2
index 681a945..6273df2 100644
@@ -1,3 +1 @@
 # Default configuration for ppc-linux-user
-
-CONFIG_GDBSTUB_XML=y
default-configs/ppc-softmmu.mak +0 -1
index eac0b28..f5cd0bd 100644
@@ -3,7 +3,6 @@
 include pci.mak
 include sound.mak
 include usb.mak
-CONFIG_GDBSTUB_XML=y
 CONFIG_ISA_MMIO=y
 CONFIG_ESCC=y
 CONFIG_M48T59=y
default-configs/ppc64-linux-user.mak +0 -2
index 089c08f..422d3fb 100644
@@ -1,3 +1 @@
 # Default configuration for ppc64-linux-user
-
-CONFIG_GDBSTUB_XML=y
default-configs/ppc64-softmmu.mak +0 -1
index 7831c2b..975112a 100644
@@ -3,7 +3,6 @@
 include pci.mak
 include sound.mak
 include usb.mak
-CONFIG_GDBSTUB_XML=y
 CONFIG_ISA_MMIO=y
 CONFIG_ESCC=y
 CONFIG_M48T59=y
default-configs/ppc64abi32-linux-user.mak +0 -2
index f038ffd..1c657ec 100644
@@ -1,3 +1 @@
 # Default configuration for ppc64abi32-linux-user
-
-CONFIG_GDBSTUB_XML=y
default-configs/ppcemb-softmmu.mak +0 -1
index 86080a7..4411203 100644
@@ -3,7 +3,6 @@
 include pci.mak
 include sound.mak
 include usb.mak
-CONFIG_GDBSTUB_XML=y
 CONFIG_ISA_MMIO=y
 CONFIG_ESCC=y
 CONFIG_M48T59=y
Signature · 1 line
1.7.9.5