[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 03/24] add rules for nesting
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PATCH 03/24] add rules for nesting |
Date: |
Sun, 3 Jun 2012 14:25:37 +0200 |
This adds the 'magic' rules that take care of subdirectories.
The subdirectory makefiles in the source tree are not complete; they
only define some variables (listed in nested-vars) according to the
configuration.
The magic rules descend into subdirectory makefiles and gather the
evaluated values of those variables. The values from all subdirectories
are joined together, each prefixed with the subdirectory name, and used
by the "real" makefiles.
Signed-off-by: Paolo Bonzini <address@hidden>
---
rules.mak | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/rules.mak b/rules.mak
index efef6f2..3126c8c 100644
--- a/rules.mak
+++ b/rules.mak
@@ -73,3 +73,24 @@ TRACETOOL=$(PYTHON) $(SRC_PATH)/scripts/tracetool.py
# will delete the target of a rule if commands exit with a nonzero exit status
.DELETE_ON_ERROR:
+
+# magic to descend into other directories
+
+save-var = $(eval $2 = $(value $1))$(eval $1 :=)
+restore-var = $(eval $1 = $(value $2))$(eval $2 :=)
+
+define unnest-var-1
+$(eval nested-dirs := $(patsubst %, $3%, $(filter %/, $2)))
+$(eval all-files += $(patsubst %, $3%, $(filter-out %/, $2)))
+$(foreach nested-dir,$(nested-dirs),
+ $(foreach var,$(nested-vars),$(call
save-var,$(var),save-$(nested-dir)-$(var)))
+ $(eval include $(SRC_PATH)/$(nested-dir)Makefile)
+ $(call unnest-var-1,$1,$($1),$(nested-dir))
+ $(foreach var,$(nested-vars),$(call
restore-var,$(var),save-$(nested-dir)-$(var))))
+endef
+
+define unnest-var
+$(eval all-files :=)
+$(call unnest-var-1,$1,$($1),)
+$(eval $1 := $$(all-files))
+endef
--
1.7.10.1
- [Qemu-devel] [PATCH 00/24] per-directory Makefile snippets, limit vpath abuse, Paolo Bonzini, 2012/06/03
- [Qemu-devel] [PATCH 01/24] remove trace-nested-y, Paolo Bonzini, 2012/06/03
- [Qemu-devel] [PATCH 03/24] add rules for nesting,
Paolo Bonzini <=
- [Qemu-devel] [PATCH 02/24] do not sprinkle around GENERATED_HEADERS dependencies, Paolo Bonzini, 2012/06/03
- [Qemu-devel] [PATCH 04/24] move *-user/ objects to nested Makefile, Paolo Bonzini, 2012/06/03
- [Qemu-devel] [PATCH 06/24] move libobj-y variable to nested Makefile, Paolo Bonzini, 2012/06/03
- [Qemu-devel] [PATCH 05/24] move obj-TARGET-y variables to nested Makefile, Paolo Bonzini, 2012/06/03
- [Qemu-devel] [PATCH 07/24] move other target-*/ objects to nested Makefiles, Paolo Bonzini, 2012/06/03
- [Qemu-devel] [PATCH 08/24] move rules for nesting to Makefile.objs, Paolo Bonzini, 2012/06/03
- [Qemu-devel] [PATCH 09/24] use nested Makefile rules for qom/ objects, Paolo Bonzini, 2012/06/03
- [Qemu-devel] [PATCH 10/24] move block/ objects to nested Makefile, Paolo Bonzini, 2012/06/03