[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH for-4.9] xen/test/Makefile: Fix clean target, broken by pattern rule



On Mon, Jun 19, 2017 at 03:23:26PM +0100, Ian Jackson wrote:
> In "xen/test/livepatch: Regularise Makefiles" we reworked
> xen/test/Makefile to use a pattern rule.  However, there are two
> problems with this.  Both are related to the way that xen/Rules.mk is
> implicitly part of this Makefile because of the way that Makefiles
> under xen/ are invoked by their parent directory Makefiles.
> 
> Firstly, the Rules.mk `clean' target overrides the pattern rule in
> xen/test/Makefile.  The result is that `make -C xen clean' does not
> actually run the livepatch clean target.
> 
> The Rules.mk clean target does have provision for recursing into
> subdirectories, but that feature is tangled up with complex object
> file iteration machinery which is not desirable here.  However, we can
> extend the Rules.mk clean target since it is a double-colon rules.
> 
> Sadly this involves duplicating the SUBDIR iteration boilerplate.  (A
> make function could be used but the cure would be worse than the
> disease.)
> 
> Secondly, Rules.mk has a number of -include directives.  make likes to
> try to (re)build files mentioned in includes.  With the % pattern
> rule, this applies to those files too.
> 
> As a result, make -C xen clean would try to build `.*.d' (for example)
> in xen/test.  This would fail with an error message.  The error would
> be ignored because of the `-', but it's annoying and ugly.

Aaah.
> 
> Solve this by limiting the % pattern rule to the targets we expect it
> to handle.  These are those listed in the top-level Makefile, apart
> from: those which are subdir- or component-qualified; clean targets
> (which are handled specially, even distclean); and dist,
> src-tarball-*, etc. (which are converted to install by an earlier
> Makefile).
> 
> Reported-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
> Signed-off-by: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>

Acked-by: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>


> ---
>  xen/test/Makefile | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/xen/test/Makefile b/xen/test/Makefile
> index aa1a23b..aaa4996 100644
> --- a/xen/test/Makefile
> +++ b/xen/test/Makefile
> @@ -7,7 +7,12 @@ ifneq ($(XEN_TARGET_ARCH),x86_32)
>  SUBDIRS += livepatch
>  endif
>  
> -%:
> +install build subtree-force-update uninstall: %:
>       set -e; for s in $(SUBDIRS); do \
>               $(MAKE) -f $(BASEDIR)/Rules.mk -C $$s $*; \
>       done
> +
> +clean::
> +     set -e; for s in $(SUBDIRS); do \
> +             $(MAKE) -f $(BASEDIR)/Rules.mk -C $$s $@; \
> +     done
> -- 
> 2.1.4
> 
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@xxxxxxxxxxxxx
> https://lists.xen.org/xen-devel

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.