]> xenbits.xensource.com Git - people/iwj/xen.git/commitdiff
xen/test/Makefile: Fix clean target, broken by pattern rule
authorIan Jackson <ian.jackson@eu.citrix.com>
Mon, 19 Jun 2017 14:04:08 +0000 (15:04 +0100)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Wed, 21 Jun 2017 10:54:08 +0000 (11:54 +0100)
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 rule.

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.

Solve this by limiting the % pattern rule to the targets we expect it
to handle.  These are those listed in the top-level Makefile help
message, 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@citrix.com>
Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
Tested-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Acked-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Release-acked-by: Julien Grall <julien.grall@arm.com>
(cherry picked from commit 592e834522086009975bd48d59386094771bd06b)
(cherry picked from commit b38b1479a532f08fedd7f3b761673bc78b66739d)

xen/test/Makefile

index aa1a23b835b0a89eca6d5092691b3cf0a0e593b8..aaa499664396e056242fa6ef97ce1fc82153ef0d 100644 (file)
@@ -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