All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] build: generic top-level rule to build individual files
@ 2022-03-28  7:41 Jan Beulich
  2022-03-29 10:28 ` Anthony PERARD
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Beulich @ 2022-03-28  7:41 UTC (permalink / raw)
  To: xen-devel
  Cc: Andrew Cooper, George Dunlap, Julien Grall, Stefano Stabellini,
	Wei Liu, Anthony Perard

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".

Signed-off-by: Jan Beulich <jbeulich@suse.com>

[1] https://savannah.gnu.org/bugs/?10593

--- a/Makefile
+++ b/Makefile
@@ -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:



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] build: generic top-level rule to build individual files
  2022-03-28  7:41 [PATCH] build: generic top-level rule to build individual files Jan Beulich
@ 2022-03-29 10:28 ` Anthony PERARD
  2022-03-29 10:57   ` Jan Beulich
  0 siblings, 1 reply; 3+ messages in thread
From: Anthony PERARD @ 2022-03-29 10:28 UTC (permalink / raw)
  To: Jan Beulich
  Cc: xen-devel, Andrew Cooper, George Dunlap, Julien Grall,
	Stefano Stabellini, Wei Liu

On Mon, Mar 28, 2022 at 09:41:26AM +0200, Jan Beulich wrote:
> --- a/Makefile
> +++ b/Makefile
> @@ -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`.

> +
>  .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 <anthony.perard@citrix.com>

Thanks,

-- 
Anthony PERARD


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] build: generic top-level rule to build individual files
  2022-03-29 10:28 ` Anthony PERARD
@ 2022-03-29 10:57   ` Jan Beulich
  0 siblings, 0 replies; 3+ messages in thread
From: Jan Beulich @ 2022-03-29 10:57 UTC (permalink / raw)
  To: Anthony PERARD
  Cc: xen-devel, Andrew Cooper, George Dunlap, Julien Grall,
	Stefano Stabellini, Wei Liu

On 29.03.2022 12:28, Anthony PERARD wrote:
> On Mon, Mar 28, 2022 at 09:41:26AM +0200, Jan Beulich wrote:
>> --- a/Makefile
>> +++ b/Makefile
>> @@ -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`.

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).

>> @@ -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.

Oh, right - thanks for pointing out. I should have really noticed by
looking at context in the file ...

> With at least the .PHONY business taking care of: Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>

Thanks.

Jan



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-03-29 10:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-28  7:41 [PATCH] build: generic top-level rule to build individual files Jan Beulich
2022-03-29 10:28 ` Anthony PERARD
2022-03-29 10:57   ` Jan Beulich

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.