[PATCH v5 4/5] tools/nolibc: add kernel and nolibc specific ARCH variables

From: Zhangjin Wu
Date: Mon Jun 19 2023 - 08:28:42 EST


Like the KARCH added for tools/testing/selftests/nolibc/Makefile, adds
KARCH for tools/include/nolibc/Makefile too, at the same time, adds
NARCH for the ARCH supported by nolibc (arch-<NARCH>.h).

It allows users to customize both kernel and nolibc specific ARCH
variables for different architectures and their variants easily.

Signed-off-by: Zhangjin Wu <falcon@xxxxxxxxxxx>
---
tools/include/nolibc/Makefile | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/tools/include/nolibc/Makefile b/tools/include/nolibc/Makefile
index 64d67b080744..14a6416fa57f 100644
--- a/tools/include/nolibc/Makefile
+++ b/tools/include/nolibc/Makefile
@@ -23,8 +23,14 @@ else
Q=@
endif

-nolibc_arch := $(patsubst arm64,aarch64,$(ARCH))
-arch_file := arch-$(nolibc_arch).h
+# kernel supported ARCH names by architecture
+KARCH = $(or $(KARCH_$(ARCH)),$(ARCH))
+
+# nolibc supported ARCH names by architecture
+NARCH_arm64 = aarch64
+NARCH = $(or $(NARCH_$(ARCH)),$(ARCH))
+
+arch_file := arch-$(NARCH).h
all_files := \
compiler.h \
ctype.h \
@@ -83,8 +89,8 @@ headers:
fi > $(OUTPUT)sysroot/include/arch.h

headers_standalone: headers
- $(Q)$(MAKE) -C $(srctree) headers
- $(Q)$(MAKE) -C $(srctree) headers_install INSTALL_HDR_PATH=$(OUTPUT)sysroot
+ $(Q)$(MAKE) -C $(srctree) ARCH=$(KARCH) headers
+ $(Q)$(MAKE) -C $(srctree) ARCH=$(KARCH) headers_install INSTALL_HDR_PATH=$(OUTPUT)sysroot

clean:
$(call QUIET_CLEAN, nolibc) rm -rf "$(OUTPUT)sysroot"
--
2.25.1