Message ID | 1497882206-31657-1-git-send-email-ian.jackson@eu.citrix.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
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@citrix.com> > Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com> Acked-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> > --- > 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@lists.xen.org > https://lists.xen.org/xen-devel
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. > > 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@citrix.com> > Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com> And Tested-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> > --- > 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@lists.xen.org > https://lists.xen.org/xen-devel
Hi, On 06/19/2017 09:14 PM, Konrad Rzeszutek Wilk wrote: > 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. >> >> 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@citrix.com> >> Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com> > > And > Tested-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Release-acked-by: Julien Grall <julien.grall@arm.com> Cheers,
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