build: generic top-level rule to build individual files
PATCH 1/1 build: generic top-level rule to build individual files
In particular when cross-compiling or having in place other tool chain overrides, invoking make to build individual files (e.g. object, preprocessed, or assembly ones) so far involves putting the various overrides on the command line instead of simply getting them from ./.config.
Furthermore this helps working around a yet unaddressed make quirk [1]:
Variables put on the command line are invisible to $(shell ...), unless invoked from a recursive make: During the recursive invocation such variables are put in the recursive make's environment and hence become "visible".
[1] https://savannah.gnu.org/bugs/?10593
Makefile +10 -0
@@ -75,6 +75,13 @@ ifeq (x86_64,$(XEN_TARGET_ARCH)) XEN_TARGET_ARCH=x86_32 $(MAKE) -C stubdom pv-grub-if-enabled endif +define do-subtree +$(1)/%: FORCE + $$(MAKE) -C $(1) $$* +endef + +$(foreach m,$(wildcard */Makefile),$(eval $(call do-subtree,$(patsubst %/Makefile,%,$(m))))) + .PHONY: build-docs build-docs: $(MAKE) -C docs build
@@ -334,3 +341,6 @@ uninstall: uninstall-tools-public-header .PHONY: xenversion xenversion: @$(MAKE) --no-print-directory -C xen xenversion + +PHONY += FORCE +FORCE:
Makefile ifeq (x86_64,$(XEN_TARGET_ARCH)) · line 83
Quoted 12 lines · Jan Beulich
Makefile +6
-0@@ -75,6 +75,13 @@ ifeq (x86_64,$(XEN_TARGET_ARCH)) XEN_TARGET_ARCH=x86_32 $(MAKE) -C stubdom pv-grub-if-enabled endif +define do-subtree +$(1)/%: FORCE + $$(MAKE) -C $(1) $$* +endef + +$(foreach m,$(wildcard */Makefile),$(eval $(call do-subtree,$(patsubst %/Makefile,%,$(m)))))
Any reason to not use $(SUBSYSTEMS) instead of $(wildcard ) ? Or maybe you would rather been able to run make xen/foo/bar.o even after running ./configure --disable-xen.
Makefile uninstall: uninstall-tools-public-header · line 345
Quoted 10 lines
Makefile +3
-0+ .PHONY: build-docs build-docs: $(MAKE) -C docs build@@ -334,3 +341,6 @@ uninstall: uninstall-tools-public-header .PHONY: xenversion xenversion: @$(MAKE) --no-print-directory -C xen xenversion + +PHONY += FORCE
That's a Kbuild construct which will not work here. You need to write ".PHONY: FORCE" instead.
In Kbuild, there's a ".PHONY: $(PHONY)", and various macros needs to know what's .PHONY.
With at least the .PHONY business taking care of: Reviewed-by: Anthony PERARD <[email protected]>
Thanks,
Signature · 1 line
Anthony PERARD
Quoted 7 lines · Anthony PERARD
Quoted 6 lines · Jan Beulich
Makefile +0
-0@@ -75,6 +75,13 @@ ifeq (x86_64,$(XEN_TARGET_ARCH)) XEN_TARGET_ARCH=x86_32 $(MAKE) -C stubdom pv-grub-if-enabled endif
Quoted 10 lines
Makefile ifeq (x86_64,$(XEN_TARGET_ARCH)) · line 83
Quoted 6 lines
Makefile +6
-0+define do-subtree +$(1)/%: FORCE + $$(MAKE) -C $(1) $$* +endef + +$(foreach m,$(wildcard */Makefile),$(eval $(call do-subtree,$(patsubst %/Makefile,%,$(m)))))Any reason to not use $(SUBSYSTEMS) instead of $(wildcard ) ? Or maybe you would rather been able to run
make xen/foo/bar.oeven after running./configure --disable-xen.
This particular case I don't care about as much, but I think it is helpful if any subtree which has a Makefile can be recursed into this way. That way if someone hooks other trees (xtf, mini-os) into the tree, they're as accessible. As would be subtrees which aren't subsystems by which still have a Makefile (such may or may not appear).
Quoted 10 lines
Makefile uninstall: uninstall-tools-public-header · line 345
Quoted 6 lines
Makefile +2
-0@@ -334,3 +341,6 @@ uninstall: uninstall-tools-public-header .PHONY: xenversion xenversion: @$(MAKE) --no-print-directory -C xen xenversion + +PHONY += FORCEThat's a
Kbuildconstruct which will not work here. You need to write ".PHONY: FORCE" instead.
Quoted 2 lines
In
Kbuild, there's a ".PHONY: $(PHONY)", and various macros needs to know what's .PHONY.
Oh, right - thanks for pointing out. I should have really noticed by looking at context in the file ...
Quoted 1 line
With at least the .PHONY business taking care of: Reviewed-by: Anthony PERARD <[email protected]>
Thanks.
Jan