kbuild: Make the toolchain variables easily overwritable
authorBastian Blank <waldi@debian.org>
Sun, 22 Feb 2009 14:39:35 +0000 (15:39 +0100)
committerSalvatore Bonaccorso <carnil@debian.org>
Fri, 14 Jul 2023 20:24:08 +0000 (21:24 +0100)
Forwarded: not-needed

Allow make variables to be overridden for each flavour by a file in
the build tree, .kernelvariables.

We currently use this for ARCH, KERNELRELEASE, CC, and in some cases
also CROSS_COMPILE, KCFLAGS.

This file can only be read after we establish the build tree, and all
use of $(ARCH) needs to be moved after this.

[bwh: Updated for 5.3: include .kernelvariables from current directory
 rather than using undefined $(obj).]

Gbp-Pq: Topic debian
Gbp-Pq: Name kernelvariables.patch

Makefile

index 77f5b8f40cd309f159e3ac007c54cf0fa2ed0653..e2a521e0e0d40bd1ab8a6c6c561cbc69988366c7 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -376,31 +376,6 @@ include scripts/subarch.include
 # Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile
 ARCH           ?= $(SUBARCH)
 
-# Architecture as present in compile.h
-UTS_MACHINE    := $(ARCH)
-SRCARCH        := $(ARCH)
-
-# Additional ARCH settings for x86
-ifeq ($(ARCH),i386)
-        SRCARCH := x86
-endif
-ifeq ($(ARCH),x86_64)
-        SRCARCH := x86
-endif
-
-# Additional ARCH settings for sparc
-ifeq ($(ARCH),sparc32)
-       SRCARCH := sparc
-endif
-ifeq ($(ARCH),sparc64)
-       SRCARCH := sparc
-endif
-
-# Additional ARCH settings for sh
-ifeq ($(ARCH),sh64)
-       SRCARCH := sh
-endif
-
 KCONFIG_CONFIG ?= .config
 export KCONFIG_CONFIG
 
@@ -484,6 +459,30 @@ CFLAGS_KERNEL      =
 AFLAGS_KERNEL  =
 LDFLAGS_vmlinux =
 
+-include .kernelvariables
+
+# Architecture as present in compile.h
+UTS_MACHINE    := $(ARCH)
+SRCARCH        := $(ARCH)
+
+# Additional ARCH settings for x86
+ifeq ($(ARCH),i386)
+        SRCARCH := x86
+endif
+ifeq ($(ARCH),x86_64)
+        SRCARCH := x86
+endif
+
+# Additional ARCH settings for sparc
+ifeq ($(ARCH),sparc64)
+       SRCARCH := sparc
+endif
+
+# Additional ARCH settings for sh
+ifeq ($(ARCH),sh64)
+       SRCARCH := sh
+endif
+
 # Use USERINCLUDE when you must reference the UAPI directories only.
 USERINCLUDE    := \
                -I$(srctree)/arch/$(SRCARCH)/include/uapi \