diff mbox series

[XEN,v8,32/47] build: shuffle main Makefile

Message ID 20211125134006.1076646-33-anthony.perard@citrix.com (mailing list archive)
State Superseded
Headers show
Series xen: Build system improvements, now with out-of-tree build! | expand

Commit Message

Anthony PERARD Nov. 25, 2021, 1:39 p.m. UTC
Reorganize a bit the Makefile ahead of patch
"build: adding out-of-tree support to the xen build"

This should only be code movement without functional changes.

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

Notes:
    v8:
    - new patch

 xen/Makefile | 58 ++++++++++++++++++++++++++--------------------------
 1 file changed, 29 insertions(+), 29 deletions(-)

Comments

Jan Beulich Dec. 21, 2021, 2:18 p.m. UTC | #1
On 25.11.2021 14:39, Anthony PERARD wrote:
> Reorganize a bit the Makefile ahead of patch
> "build: adding out-of-tree support to the xen build"

Without you saying so it's not clear why that's good of even
necessary. Moving things around always has the potential of
breaking subtle ordering requirements, so I'd prefer to see
what good the movement does.

Jan
Anthony PERARD Jan. 20, 2022, 5:27 p.m. UTC | #2
On Tue, Dec 21, 2021 at 03:18:34PM +0100, Jan Beulich wrote:
> On 25.11.2021 14:39, Anthony PERARD wrote:
> > Reorganize a bit the Makefile ahead of patch
> > "build: adding out-of-tree support to the xen build"
> 
> Without you saying so it's not clear why that's good of even
> necessary. Moving things around always has the potential of
> breaking subtle ordering requirements, so I'd prefer to see
> what good the movement does.

Some explanation about why most of the code movement is needed:


In Kbuild, *srctree and *objtree are been set after setting $(quiet),
$(Q), $(KBUILD_VERBOSE). We will do the same. Also, we need to set the
$(*tree) variables only on first execution of Makefile, not in sub-make,
the we need to move them. Been before or after $(KBUILD_VERBOSE) doesn't
seems to matter, but they needs to be in the area, in "root-make-done"
guard.

$(XEN_ROOT) as the same issue as $(*srctree), it will be set only after we
know the value of $(abs_srctree).

"Kbuild.include" needs to be included after $(srctree) is set.

We can't include "Config.mk" without knowing $(XEN_ROOT), it needs to move.

We can't calculate without $(TARGET_*ARCH) without $(XEN_TARGET_ARCH)
which is set if needed in "Config.mk".

$(ARCH) and $(SRCARCH) seems misplaced before the patch, Not moving them
might mean wrong value might be exported if "Config.mk" isn't included.
I think I have to investigate this one, and potentially produce a new patch.

So the code movement is just because we need to be careful when setting
the different $(*tree) variables, and $(XEN_ROOT).


I'll add something like that to the commit message.

Cheers,
diff mbox series

Patch

diff --git a/xen/Makefile b/xen/Makefile
index 318320e79c7d..bfc96562c5ec 100644
--- a/xen/Makefile
+++ b/xen/Makefile
@@ -19,38 +19,11 @@  export PYTHON		?= $(PYTHON_INTERPRETER)
 
 export CHECKPOLICY	?= checkpolicy
 
-export XEN_ROOT := $(CURDIR)/..
-
-abs_objtree := $(CURDIR)
-abs_srctree := $(CURDIR)
-
-export abs_srctree abs_objtree
-
-srctree := .
-objtree := .
-export srctree objtree
-
 # Do not use make's built-in rules and variables
 MAKEFLAGS += -rR
 
 EFI_MOUNTPOINT ?= $(BOOT_DIR)/efi
 
-ARCH=$(XEN_TARGET_ARCH)
-SRCARCH=$(shell echo $(ARCH) | \
-          sed -e 's/x86.*/x86/' -e s'/arm\(32\|64\)/arm/g' \
-              -e s'/riscv.*/riscv/g')
-export ARCH SRCARCH
-
-# Don't break if the build process wasn't called from the top level
-# we need XEN_TARGET_ARCH to generate the proper config
-include $(XEN_ROOT)/Config.mk
-
-# Set ARCH/SUBARCH appropriately.
-export TARGET_SUBARCH  := $(XEN_TARGET_ARCH)
-export TARGET_ARCH     := $(shell echo $(XEN_TARGET_ARCH) | \
-                            sed -e 's/x86.*/x86/' -e s'/arm\(32\|64\)/arm/g' \
-                                -e s'/riscv.*/riscv/g')
-
 # Allow someone to change their config file
 export KCONFIG_CONFIG ?= .config
 
@@ -64,8 +37,6 @@  default: build
 .PHONY: dist
 dist: install
 
-include scripts/Kbuild.include
-
 ifneq ($(root-make-done),y)
 # section to run before calling Rules.mk, but only once.
 
@@ -141,6 +112,17 @@  endif
 
 export quiet Q KBUILD_VERBOSE
 
+abs_objtree := $(CURDIR)
+abs_srctree := $(CURDIR)
+
+export abs_srctree abs_objtree
+
+srctree := .
+objtree := .
+export srctree objtree
+
+export XEN_ROOT := $(CURDIR)/..
+
 # 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
 
@@ -163,6 +145,24 @@  ifneq ($(filter %config,$(MAKECMDGOALS)),)
     config-build := y
 endif
 
+include scripts/Kbuild.include
+
+ARCH=$(XEN_TARGET_ARCH)
+SRCARCH=$(shell echo $(ARCH) | \
+          sed -e 's/x86.*/x86/' -e s'/arm\(32\|64\)/arm/g' \
+              -e s'/riscv.*/riscv/g')
+export ARCH SRCARCH
+
+# Don't break if the build process wasn't called from the top level
+# we need XEN_TARGET_ARCH to generate the proper config
+include $(XEN_ROOT)/Config.mk
+
+# Set ARCH/SUBARCH appropriately.
+export TARGET_SUBARCH  := $(XEN_TARGET_ARCH)
+export TARGET_ARCH     := $(shell echo $(XEN_TARGET_ARCH) | \
+                            sed -e 's/x86.*/x86/' -e s'/arm\(32\|64\)/arm/g' \
+                                -e s'/riscv.*/riscv/g')
+
 export CONFIG_SHELL := $(SHELL)
 export YACC = $(if $(BISON),$(BISON),bison)
 export LEX = $(if $(FLEX),$(FLEX),flex)