xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Anthony PERARD <anthony.perard@citrix.com>
To: <xen-devel@lists.xenproject.org>
Cc: Stefano Stabellini <sstabellini@kernel.org>,
	Julien Grall <julien@xen.org>, Wei Liu <wl@xen.org>,
	Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
	George Dunlap <George.Dunlap@eu.citrix.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Ian Jackson <ian.jackson@eu.citrix.com>,
	Anthony PERARD <anthony.perard@gmail.com>,
	Jan Beulich <jbeulich@suse.com>,
	Anthony PERARD <anthony.perard@citrix.com>
Subject: [Xen-devel] [XEN PATCH v3 09/23] xen/build: extract clean target from Rules.mk
Date: Wed, 26 Feb 2020 11:33:41 +0000	[thread overview]
Message-ID: <20200226113355.2532224-10-anthony.perard@citrix.com> (raw)
In-Reply-To: <20200226113355.2532224-1-anthony.perard@citrix.com>

From: Anthony PERARD <anthony.perard@gmail.com>

Most of the code executed by Rules.mk isn't necessary for the clean
target, especially not the CFLAGS. This patch makes running make clean
much faster.

The patch extract the clean target into a different Makefile,
Makefile.clean.

Since Makefile.clean, doesn't want to include Config.mk, we need to
define the variables DEPS_INCLUDE and DEPS in a place common to
Rules.mk and Makefile.clean, this is Kbuild.include. DEPS_RM is only
needed in Makefile.clean so can be defined there.

Even so Rules.mk includes Config.mk, it includes Kbuild.include after,
so the effective definition of DEPS_INCLUDE is "xen/" one and the
same one as used by Makefile.clean.

This is inspired by Kbuild, with Makefile.clean partially copied from
Linux v5.4.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
---

Notes:
    v3:
    - rewrite of commit message
    - have only subdir-all, without intermediare variable subdir-y and
      subdir-n in Makefile.clean

 xen/Rules.mk               | 12 ------------
 xen/scripts/Kbuild.include |  7 ++++++-
 xen/scripts/Makefile.clean | 30 ++++++++++++++++++++++++++++++
 3 files changed, 36 insertions(+), 13 deletions(-)
 create mode 100644 xen/scripts/Makefile.clean

diff --git a/xen/Rules.mk b/xen/Rules.mk
index e3b19319b1f5..0c1a3ee5905d 100644
--- a/xen/Rules.mk
+++ b/xen/Rules.mk
@@ -100,8 +100,6 @@ SPECIAL_DATA_SECTIONS := rodata $(foreach a,1 2 4 8 16, \
 
 include $(BASEDIR)/arch/$(TARGET_ARCH)/Rules.mk
 
-DEPS = .*.d
-
 include Makefile
 
 define gendep
@@ -118,10 +116,6 @@ $(foreach o,$(filter-out %/,$(obj-y) $(obj-bin-y) $(extra-y)),$(eval $(call gend
 subdir-y := $(subdir-y) $(filter %/, $(obj-y))
 obj-y    := $(patsubst %/, %/built_in.o, $(obj-y))
 
-subdir-n   := $(subdir-n) $(subdir-) $(filter %/, $(obj-n) $(obj-))
-
-subdir-all := $(subdir-y) $(subdir-n)
-
 $(filter %.init.o,$(obj-y) $(obj-bin-y) $(extra-y)): CFLAGS += -DINIT_SECTIONS_ONLY
 
 ifeq ($(CONFIG_COVERAGE),y)
@@ -185,12 +179,6 @@ FORCE:
 %/built_in_bin.o: FORCE
 	$(MAKE) -f $(BASEDIR)/Rules.mk -C $* built_in_bin.o
 
-.PHONY: clean
-clean:: $(addprefix _clean_, $(subdir-all))
-	rm -f *.o .*.o.tmp *~ core $(DEPS_RM)
-_clean_%/: FORCE
-	$(MAKE) $(clean) $*
-
 SRCPATH := $(patsubst $(BASEDIR)/%,%,$(CURDIR))
 
 %.o: %.c Makefile
diff --git a/xen/scripts/Kbuild.include b/xen/scripts/Kbuild.include
index 2465cc4060c3..6a9b0c39da53 100644
--- a/xen/scripts/Kbuild.include
+++ b/xen/scripts/Kbuild.include
@@ -2,6 +2,11 @@
 ####
 # kbuild: Generic definitions
 
+###
+# dependencies
+DEPS = .*.d
+DEPS_INCLUDE = $(addsuffix .d2, $(basename $(wildcard $(DEPS))))
+
 # cc-ifversion
 # Usage:  EXTRA_CFLAGS += $(call cc-ifversion, -lt, 0402, -O1)
 cc-ifversion = $(shell [ $(CONFIG_GCC_VERSION)0 $(1) $(2)000 ] && echo $(3) || echo $(4))
@@ -9,4 +14,4 @@ cc-ifversion = $(shell [ $(CONFIG_GCC_VERSION)0 $(1) $(2)000 ] && echo $(3) || e
 # Shorthand for $(MAKE) clean
 # Usage:
 # $(MAKE) $(clean) dir
-clean := -f $(BASEDIR)/Rules.mk clean -C
+clean := -f $(BASEDIR)/scripts/Makefile.clean clean -C
diff --git a/xen/scripts/Makefile.clean b/xen/scripts/Makefile.clean
new file mode 100644
index 000000000000..53379e6102cc
--- /dev/null
+++ b/xen/scripts/Makefile.clean
@@ -0,0 +1,30 @@
+# SPDX-License-Identifier: GPL-2.0
+# ==========================================================================
+# Cleaning up
+# ==========================================================================
+
+clean::
+
+include $(BASEDIR)/scripts/Kbuild.include
+
+include Makefile
+
+# Figure out what we need to clean from the various variables
+# ==========================================================================
+subdir-all := $(subdir-y) $(subdir-n) $(subdir-) \
+              $(filter %/, $(obj-y) $(obj-n) $(obj-))
+
+DEPS_RM = $(DEPS) $(DEPS_INCLUDE)
+.PHONY: clean
+clean:: $(addprefix _clean_, $(subdir-all))
+	rm -f *.o .*.o.tmp *~ core $(DEPS_RM)
+
+# Descending
+# ---------------------------------------------------------------------------
+
+_clean_%/: FORCE
+	$(MAKE) $(clean) $*
+
+# Force execution of pattern rules (for which PHONY cannot be directly used).
+.PHONY: FORCE
+FORCE:
-- 
Anthony PERARD


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  parent reply	other threads:[~2020-02-26 11:34 UTC|newest]

Thread overview: 76+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-26 11:33 [Xen-devel] [XEN PATCH v3 00/23] xen: Build system improvements Anthony PERARD
2020-02-26 11:33 ` [Xen-devel] [XEN PATCH v3 01/23] xen/include: remove include of Config.mk Anthony PERARD
2020-02-26 11:33 ` [Xen-devel] [XEN PATCH v3 02/23] Makefile: Fix install-tests Anthony PERARD
2020-02-26 11:33 ` [Xen-devel] [XEN PATCH v3 03/23] xen/build: Remove confusing comment on the %.s:%.S rule Anthony PERARD
2020-02-26 11:53   ` Wei Liu
2020-02-26 11:33 ` [Xen-devel] [XEN PATCH v3 04/23] xen/build: remove use of AFLAGS-y Anthony PERARD
2020-02-26 12:58   ` Jan Beulich
2020-02-26 11:33 ` [Xen-devel] [XEN PATCH v3 05/23] xen/build: Allow to test clang .include without asm symlink Anthony PERARD
2020-02-27  9:05   ` Roger Pau Monné
2020-02-27  9:22     ` Jan Beulich
2020-02-26 11:33 ` [Xen-devel] [XEN PATCH v3 06/23] xen/build: Fix section-renaming of libfdt and libelf Anthony PERARD
2020-02-27  9:38   ` Jan Beulich
2020-02-26 11:33 ` [Xen-devel] [XEN PATCH v3 07/23] xen/build: Use obj-y += subdir/ instead of subdir-y Anthony PERARD
2020-02-27  9:22   ` Roger Pau Monné
2020-02-27  9:43   ` Jan Beulich
2020-03-04 14:14     ` Jan Beulich
2020-03-05  9:24   ` Jan Beulich
2020-03-05 13:42     ` Andrew Cooper
2020-03-05 15:02     ` Julien Grall
2020-03-05 15:59       ` Anthony PERARD
2020-03-05 16:31         ` Julien Grall
2020-03-09  6:46     ` Tian, Kevin
2020-02-26 11:33 ` [Xen-devel] [XEN PATCH v3 08/23] xen/build: use $(clean) shorthand for clean targets Anthony PERARD
2020-02-26 11:33 ` Anthony PERARD [this message]
2020-03-04 14:13   ` [Xen-devel] [XEN PATCH v3 09/23] xen/build: extract clean target from Rules.mk Jan Beulich
2020-02-26 11:33 ` [Xen-devel] [XEN PATCH v3 10/23] xen/build: run targets csopes, tags, .. without Rules.mk Anthony PERARD
2020-03-04 14:17   ` Jan Beulich
2020-02-26 11:33 ` [Xen-devel] [XEN PATCH v3 11/23] xen/build: make tests in test/ directly Anthony PERARD
2020-02-26 11:33 ` [Xen-devel] [XEN PATCH v3 12/23] xen/build: Move as-option-add to xen/ Anthony PERARD
2020-03-04 14:17   ` Jan Beulich
2020-02-26 11:33 ` [Xen-devel] [XEN PATCH v3 13/23] xen/build: include include/config/auto.conf in main Makefile Anthony PERARD
2020-03-04 14:29   ` Jan Beulich
2020-03-10 17:10     ` Anthony PERARD
2020-03-11  9:26       ` Jan Beulich
2020-02-26 11:33 ` [Xen-devel] [XEN PATCH v3 14/23] xen/build: use new $(c_flags) and $(a_flags) instead of $(CFLAGS) Anthony PERARD
2020-02-27 10:22   ` Roger Pau Monné
2020-03-10 17:55     ` Anthony PERARD
2020-03-04 14:42   ` Jan Beulich
2020-03-10 17:43     ` Anthony PERARD
2020-02-26 11:33 ` [Xen-devel] [XEN PATCH v3 15/23] xen/build: have the root Makefile generates the CFLAGS Anthony PERARD
2020-02-27 11:05   ` Roger Pau Monné
2020-03-17 18:05     ` Anthony PERARD
2020-03-19 16:24       ` Anthony PERARD
2020-03-23 15:11         ` Roger Pau Monné
2020-03-24 17:11           ` [Xen-devel] " Anthony PERARD
2020-03-04 15:00   ` Jan Beulich
2020-03-17 18:35     ` Anthony PERARD
2020-03-18 10:20       ` Jan Beulich
2020-02-26 11:33 ` [Xen-devel] [XEN PATCH v3 16/23] xen/build: introduce if_changed and if_changed_rule Anthony PERARD
2020-03-04 15:45   ` Jan Beulich
2020-03-18 10:44     ` Anthony PERARD
2020-03-18 11:14       ` Jan Beulich
2020-02-26 11:33 ` [Xen-devel] [XEN PATCH v3 17/23] xen/build: Start using if_changed Anthony PERARD
2020-02-27 13:09   ` Roger Pau Monné
2020-03-04 16:00     ` Jan Beulich
2020-03-18 10:52       ` Anthony PERARD
2020-02-26 11:33 ` [Xen-devel] [XEN PATCH v3 18/23] xen/build: use if_changed on built_in.o Anthony PERARD
2020-03-04 16:03   ` Jan Beulich
2020-03-18 10:55     ` Anthony PERARD
2020-02-26 11:33 ` [Xen-devel] [XEN PATCH v3 19/23] xen/build: Use if_changed_rules with %.o:%.c targets Anthony PERARD
2020-03-04 16:09   ` Jan Beulich
2020-03-18 11:14     ` Anthony PERARD
2020-02-26 11:33 ` [Xen-devel] [XEN PATCH v3 20/23] xen/build: factorise generation of the linker scripts Anthony PERARD
2020-02-27 13:14   ` Roger Pau Monné
2020-03-05 11:07     ` Jan Beulich
2020-03-05 11:05   ` Jan Beulich
2020-03-18 11:59     ` Anthony PERARD
2020-02-26 11:33 ` [Xen-devel] [XEN PATCH v3 21/23] xen/build: Use if_changed for prelink*.o Anthony PERARD
2020-02-27 13:16   ` Roger Pau Monné
2020-03-04 16:12     ` Jan Beulich
2020-02-26 11:33 ` [Xen-devel] [XEN PATCH v3 22/23] xen, symbols: rework file symbols selection Anthony PERARD
2020-03-05 14:44   ` Jan Beulich
2020-02-26 11:33 ` [Xen-devel] [XEN PATCH v3 23/23] xen/build: use if_changed to build guest_%.o Anthony PERARD
2020-03-05 15:12   ` Jan Beulich
2020-02-27 21:17 ` [Xen-devel] [XEN PATCH v3 00/23] xen: Build system improvements Stewart Hildebrand
2020-03-06 10:12   ` Anthony PERARD

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200226113355.2532224-10-anthony.perard@citrix.com \
    --to=anthony.perard@citrix.com \
    --cc=George.Dunlap@eu.citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=anthony.perard@gmail.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=jbeulich@suse.com \
    --cc=julien@xen.org \
    --cc=konrad.wilk@oracle.com \
    --cc=sstabellini@kernel.org \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).