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>,
	Jan Beulich <jbeulich@suse.com>,
	Anthony PERARD <anthony.perard@citrix.com>
Subject: [Xen-devel] [XEN PATCH v2 09/12] xen/build: include include/config/auto.conf in main Makefile
Date: Fri, 17 Jan 2020 10:53:55 +0000	[thread overview]
Message-ID: <20200117105358.607910-10-anthony.perard@citrix.com> (raw)
In-Reply-To: <20200117105358.607910-1-anthony.perard@citrix.com>

We are going to generate the CFLAGS early from "xen/Makefile" instead
of in "Rules.mk", but we need to include "config/auto.conf", so
include it in "Makefile".

Before including "config/auto.conf" we check which make target a user
is calling, as some targets don't need "auto.conf". For targets that
needs auto.conf, make will generate it (and a default .config if
missing).

root-make-done is to avoid doing the calculation again once Rules.mk
takes over and is been executed with the root Makefile. When Rules.mk
is including xen/Makefile, `config-build' and `need-config' are
undefined so auto.conf will not be included again (it is already
included by Rules.mk) and kconfig target are out of reach of Rules.mk.

The way targets are filtered is inspireds by Kbuild, with some code
imported from Linux. That's why there is PHONY variable that isn't
used yet, for example.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
---
 xen/Makefile | 96 +++++++++++++++++++++++++++++++++++++++-------------
 1 file changed, 73 insertions(+), 23 deletions(-)

diff --git a/xen/Makefile b/xen/Makefile
index 5d72d82be260..80679b4a6b17 100644
--- a/xen/Makefile
+++ b/xen/Makefile
@@ -49,7 +49,71 @@ default: build
 .PHONY: dist
 dist: install
 
-build install:: include/config/auto.conf
+
+ifndef root-make-done
+# section to run before calling Rules.mk, but only once.
+#
+# To make sure we do not include .config for any of the *config targets
+# catch them early, and hand them over to tools/kconfig/Makefile
+
+clean-targets := %clean
+no-dot-config-targets := $(clean-targets) \
+			 uninstall debug cloc \
+			 cscope TAGS tags MAP gtags \
+			 xenversion
+
+config-build	:=
+need-config	:= 1
+
+ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),)
+	ifeq ($(filter-out $(no-dot-config-targets), $(MAKECMDGOALS)),)
+		need-config :=
+	endif
+endif
+
+ifneq ($(filter config %config,$(MAKECMDGOALS)),)
+	config-build := 1
+endif
+
+export root-make-done := 1
+endif # root-make-done
+
+ifdef config-build
+# ===========================================================================
+# *config targets only - make sure prerequisites are updated, and descend
+# in tools/kconfig to make the *config target
+
+config: FORCE
+	$(MAKE) -f $(BASEDIR)/tools/kconfig/Makefile.kconfig ARCH=$(ARCH) SRCARCH=$(SRCARCH) HOSTCC="$(HOSTCC)" HOSTCXX="$(HOSTCXX)" $@
+
+# Config.mk tries to include .config file, don't try to remake it
+%/.config: ;
+
+%config: FORCE
+	$(MAKE) -f $(BASEDIR)/tools/kconfig/Makefile.kconfig ARCH=$(ARCH) SRCARCH=$(SRCARCH) HOSTCC="$(HOSTCC)" HOSTCXX="$(HOSTCXX)" $@
+
+else # !config-build
+
+ifdef need-config
+include include/config/auto.conf
+# Read in dependencies to all Kconfig* files, make sure to run syncconfig if
+# changes are detected.
+include include/config/auto.conf.cmd
+
+# Allow people to just run `make` as before and not force them to configure
+$(KCONFIG_CONFIG):
+	$(MAKE) -f $(BASEDIR)/tools/kconfig/Makefile.kconfig ARCH=$(ARCH) SRCARCH=$(SRCARCH) HOSTCC="$(HOSTCC)" HOSTCXX="$(HOSTCXX)" defconfig
+
+# The actual configuration files used during the build are stored in
+# include/generated/ and include/config/. Update them if .config is newer than
+# include/config/auto.conf (which mirrors .config).
+#
+# This exploits the 'multi-target pattern rule' trick.
+# The syncconfig should be executed only once to make all the targets.
+%/auto.conf %/auto.conf.cmd: $(KCONFIG_CONFIG)
+	$(MAKE) -f $(BASEDIR)/tools/kconfig/Makefile.kconfig ARCH=$(ARCH) SRCARCH=$(SRCARCH) HOSTCC="$(HOSTCC)" HOSTCXX="$(HOSTCXX)" syncconfig
+
+endif # need-config
 
 .PHONY: build install uninstall clean distclean MAP
 build install uninstall debug clean distclean MAP::
@@ -251,9 +315,6 @@ cscope:
 _MAP:
 	$(NM) -n $(TARGET)-syms | grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' > System.map
 
-.PHONY: FORCE
-FORCE:
-
 %.o %.i %.s: %.c FORCE
 	$(MAKE) -f $(BASEDIR)/Rules.mk -C $(*D) $(@F)
 
@@ -274,25 +335,6 @@ $(foreach base,arch/x86/mm/guest_walk_% \
                arch/x86/mm/shadow/guest_%, \
     $(foreach ext,o i s,$(call build-intermediate,$(base).$(ext))))
 
-kconfig := oldconfig config menuconfig defconfig \
-	nconfig xconfig gconfig savedefconfig listnewconfig olddefconfig \
-	randconfig $(notdir $(wildcard arch/$(SRCARCH)/configs/*_defconfig))
-.PHONY: $(kconfig)
-$(kconfig):
-	$(MAKE) -f $(BASEDIR)/tools/kconfig/Makefile.kconfig ARCH=$(ARCH) SRCARCH=$(SRCARCH) HOSTCC="$(HOSTCC)" HOSTCXX="$(HOSTCXX)" $@
-
-include/config/%.conf: include/config/auto.conf.cmd $(KCONFIG_CONFIG)
-	$(MAKE) -f $(BASEDIR)/tools/kconfig/Makefile.kconfig ARCH=$(ARCH) SRCARCH=$(SRCARCH) HOSTCC="$(HOSTCC)" HOSTCXX="$(HOSTCXX)" syncconfig
-
-# Allow people to just run `make` as before and not force them to configure
-$(KCONFIG_CONFIG):
-	$(MAKE) -f $(BASEDIR)/tools/kconfig/Makefile.kconfig ARCH=$(ARCH) SRCARCH=$(SRCARCH) HOSTCC="$(HOSTCC)" HOSTCXX="$(HOSTCXX)" defconfig
-
-# Break the dependency chain for the first run
-include/config/auto.conf.cmd: ;
-
--include $(BASEDIR)/include/config/auto.conf.cmd
-
 .PHONY: cloc
 cloc:
 	$(eval tmpfile := $(shell mktemp))
@@ -304,3 +346,11 @@ cloc:
 	cloc --list-file=$(tmpfile)
 	rm $(tmpfile)
 
+endif #config-build
+
+PHONY += FORCE
+FORCE:
+
+# Declare the contents of the PHONY variable as phony.  We keep that
+# information in a variable so we can use it in if_changed and friends.
+.PHONY: $(PHONY)
-- 
Anthony PERARD


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

  parent reply	other threads:[~2020-01-17 10:54 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-17 10:53 [Xen-devel] [XEN PATCH v2 00/12] xen: Build system improvements Anthony PERARD
2020-01-17 10:53 ` [Xen-devel] [XEN PATCH v2 01/12] xen/build: Remove left over -DMAX_PHYS_IRQS Anthony PERARD
2020-01-17 11:03   ` Jan Beulich
2020-01-17 10:53 ` [Xen-devel] [XEN PATCH v2 02/12] xen/build: Use obj-y += subdir/ instead of subdir-y Anthony PERARD
2020-01-29 14:19   ` Jan Beulich
2020-01-30 16:54     ` Anthony PERARD
2020-01-31  8:35       ` Jan Beulich
2020-02-03 11:31         ` Anthony PERARD
2020-01-17 10:53 ` [Xen-devel] [XEN PATCH v2 03/12] xen/build: use $(clean) shorthand for clean targets Anthony PERARD
2020-01-29 14:21   ` Jan Beulich
2020-01-17 10:53 ` [Xen-devel] [XEN PATCH v2 04/12] xen/build: extract clean target from Rules.mk Anthony PERARD
2020-01-29 14:30   ` Jan Beulich
2020-01-30 18:10     ` Anthony PERARD
2020-01-31  8:50       ` Jan Beulich
2020-01-17 10:53 ` [Xen-devel] [XEN PATCH v2 05/12] xen/include: remove include of Config.mk Anthony PERARD
2020-01-29 15:28   ` Jan Beulich
2020-01-29 15:33     ` Jan Beulich
2020-01-30 18:34       ` Anthony PERARD
2020-01-31  8:56         ` Jan Beulich
2020-01-17 10:53 ` [Xen-devel] [XEN PATCH v2 06/12] xen/test/livepatch: " Anthony PERARD
2020-01-17 17:17   ` Ross Lagerwall
2020-01-17 10:53 ` [Xen-devel] [XEN PATCH v2 07/12] xen/build: run targets csopes, tags, .. without Rules.mk Anthony PERARD
2020-01-30 11:29   ` Jan Beulich
2020-01-17 10:53 ` [Xen-devel] [XEN PATCH v2 08/12] xen/build: make tests in test/ directly Anthony PERARD
2020-01-30 11:31   ` Jan Beulich
2020-01-17 10:53 ` Anthony PERARD [this message]
2020-01-30 13:06   ` [Xen-devel] [XEN PATCH v2 09/12] xen/build: include include/config/auto.conf in main Makefile Jan Beulich
2020-02-03 11:45     ` Anthony PERARD
2020-02-03 12:20       ` Jan Beulich
2020-01-17 10:53 ` [Xen-devel] [XEN PATCH v2 10/12] xen/build: use new $(c_flags) and $(a_flags) instead of $(CFLAGS) Anthony PERARD
2020-01-30 13:29   ` Jan Beulich
2020-02-03 12:17     ` Anthony PERARD
2020-02-03 12:34       ` Jan Beulich
2020-01-17 10:53 ` [Xen-devel] [XEN PATCH v2 11/12] xen/build: introduce ccflags-y and CFLAGS_$@ Anthony PERARD
2020-01-30 13:39   ` Jan Beulich
2020-02-03 14:23     ` Anthony PERARD
2020-02-03 15:20       ` Jan Beulich
2020-01-17 10:53 ` [Xen-devel] [XEN PATCH v2 12/12] xen/build: have the root Makefile generates the CFLAGS Anthony PERARD
2020-01-30 14:33   ` Jan Beulich
2020-02-03 13:57     ` Anthony PERARD
2020-02-03 15:26       ` Jan Beulich
2020-01-21 13:59 ` [Xen-devel] [XEN PATCH v2.1 13/12] Makefile: Fix install-tests Anthony PERARD
2020-01-30 11:37   ` Jan Beulich
2020-02-03 14:29     ` Anthony PERARD
2020-02-03 15:21       ` Jan Beulich
2020-01-21 13:59 ` [Xen-devel] [XEN PATCH v2.1 14/12] squash! xen/build: introduce ccflags-y and CFLAGS_$@ Anthony PERARD
2020-01-21 13:59 ` [Xen-devel] [XEN PATCH v2.1 15/12] squash! xen/build: have the root Makefile generates the CFLAGS Anthony PERARD
2020-01-30 13:32   ` Jan Beulich
2020-02-03 14:32     ` Anthony PERARD
2020-01-21 14:08 ` [Xen-devel] [XEN PATCH v2 00/12] xen: Build system improvements 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=20200117105358.607910-10-anthony.perard@citrix.com \
    --to=anthony.perard@citrix.com \
    --cc=George.Dunlap@eu.citrix.com \
    --cc=andrew.cooper3@citrix.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).