With in-tree builds Config.mk includes a .config file (if present) from
the top-level directory. Similar functionality is wanted with out-of-
tree builds. Yet the concept of "top-level directory" becomes fuzzy in
that case, because there is not really a requirement to have identical
top-level directory structure in the output tree; in fact there's no
need for anything top-level-ish there. Look for such a .config, but only
if the tree layout matches (read: if the directory we're building in is
named "xen").
Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
RFC: The directory name based heuristic of course isn't nice. But I
couldn't think of anything better. Suggestions?
RFC: There also being a .config in the top-level source dir would be a
little problematic: It would be included _after_ the one in the
object tree. Yet if such a scenario is to be expected/supported at
all, it makes more sense the other way around.
--- a/xen/Makefile
+++ b/xen/Makefile
@@ -236,8 +236,17 @@ endif
include scripts/Kbuild.include
-# Don't break if the build process wasn't called from the top level
-# we need XEN_TARGET_ARCH to generate the proper config
+# Don't break if the build process wasn't called from the top level. We need
+# XEN_TARGET_ARCH to generate the proper config. If building outside of the
+# source tree also check whether we need to include a "top-level" .config:
+# Config.mk, using $(XEN_ROOT)/.config, would look only in the source tree.
+ifeq ($(building_out_of_srctree),1)
+# Try to avoid including a random unrelated .config: Assume our parent dir
+# is a "top-level" one only when the objtree is .../xen.
+ifeq ($(patsubst %/xen,,$(abs_objtree)),)
+-include ../.config
+endif
+endif
include $(XEN_ROOT)/Config.mk
# Set ARCH/SUBARCH appropriately.
--- a/xen/Rules.mk
+++ b/xen/Rules.mk
@@ -17,6 +17,13 @@ __build:
-include $(objtree)/include/config/auto.conf
+# See commentary around the similar contruct in Makefile.
+ifneq ($(abs_objtree),$(abs_srctree))
+ifeq ($(patsubst %/xen,,$(abs_objtree)),)
+../.config: ;
+-include ../.config
+endif
+endif
include $(XEN_ROOT)/Config.mk
include $(srctree)/scripts/Kbuild.include
© 2016 - 2023 Red Hat, Inc.