[PATCH 3/9] sandbox: source/invoke um Makefiles provided by host architecture
Ahmad Fatoum
a.fatoum at pengutronix.de
Mon Nov 25 07:35:17 PST 2024
It can make sense to use an existing arch's implementation for low-level
things like setjmp/longjmp. Copy the Linux scheme that enables this.
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
Makefile | 2 ++
arch/sandbox/Makefile | 9 +++++++++
scripts/subarch.include | 11 +++++++++++
3 files changed, 22 insertions(+)
create mode 100644 scripts/subarch.include
diff --git a/Makefile b/Makefile
index aa66d0cf3b38..bc75c6335177 100644
--- a/Makefile
+++ b/Makefile
@@ -321,6 +321,8 @@ KERNELVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(S
BUILDSYSTEM_VERSION =
export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION BUILDSYSTEM_VERSION
+include $(srctree)/scripts/subarch.include
+
# Cross compiling and selecting different set of gcc/bin-utils
# ---------------------------------------------------------------------------
#
diff --git a/arch/sandbox/Makefile b/arch/sandbox/Makefile
index 8f6425760619..157e856c59b1 100644
--- a/arch/sandbox/Makefile
+++ b/arch/sandbox/Makefile
@@ -19,6 +19,14 @@ board-y := arch/sandbox/board
BOARD := $(board-y)/
lds-y := $(BOARD)/barebox.lds
+HEADER_ARCH := $(SUBARCH)
+HOST_DIR := arch/$(HEADER_ARCH)
+
+-include $(srctree)/$(HOST_DIR)/Makefile.um
+
+common-y += $(HOST_DIR)/um/
+
+KBUILD_CPPFLAGS += -I$(srctree)/$(HOST_DIR)/include
TEXT_BASE = $(CONFIG_TEXT_BASE)
KBUILD_CFLAGS += -Dmalloc=barebox_malloc -Dcalloc=barebox_calloc \
@@ -49,6 +57,7 @@ machdirs := $(patsubst %,arch/sandbox/mach-%/,$(machine-y))
KBUILD_CPPFLAGS += $(patsubst %,-I$(srctree)/%include,$(machdirs))
archprepare: maketools
+ $(Q)$(MAKE) $(build)=$(HOST_DIR)/um
PHONY += maketools
diff --git a/scripts/subarch.include b/scripts/subarch.include
new file mode 100644
index 000000000000..caf3c641b52a
--- /dev/null
+++ b/scripts/subarch.include
@@ -0,0 +1,11 @@
+# SUBARCH tells the usermode build what the underlying arch is. That is set
+# first, and if a usermode build is happening, the "ARCH=sandbox" on the command
+# line overrides the setting of ARCH below. If a native build is happening,
+# then ARCH is assigned, getting whatever value it gets normally, and
+# SUBARCH is subsequently ignored.
+
+SUBARCH := $(shell uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ \
+ -e s/arm.*/arm/ -e s/sa110/arm/ \
+ -e s/aarch64.*/arm/ \
+ -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \
+ -e s/riscv.*/riscv/)
--
2.39.5
More information about the barebox
mailing list