@@ -228,6 +228,9 @@ SUBARCH := $(shell uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ \
-e s/ppc.*/powerpc/ -e s/mips.*/mips/ \
-e s/sh[234].*/sh/ -e s/aarch64.*/arm64/ )
+KCONFIG_CONFIG ?= .config
+export KCONFIG_CONFIG
+
# Cross compiling and selecting different set of gcc/bin-utils
# ---------------------------------------------------------------------------
#
@@ -248,6 +251,10 @@ SUBARCH := $(shell uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ \
# "make" in the configured kernel build directory always uses that.
# Default value for CROSS_COMPILE is not to prefix executables
# Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile
+ARCH ?= $(shell grep -s ^CONFIG_ARCH= $(KCONFIG_CONFIG) | sed -e s/^CONFIG_ARCH=// -e s/\"//g)
+ifeq ($(ARCH),)
+ undefine ARCH
+endif
ARCH ?= $(SUBARCH)
CROSS_COMPILE ?= $(CONFIG_CROSS_COMPILE:"%"=%)
@@ -287,9 +294,6 @@ endif
# Where to locate arch specific headers
hdr-arch := $(SRCARCH)
-KCONFIG_CONFIG ?= .config
-export KCONFIG_CONFIG
-
# SHELL used by kbuild
CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
else if [ -x /bin/bash ]; then echo /bin/bash; \
@@ -1364,8 +1364,12 @@ static void prop_add_env(const char *env)
sym_env_list->right.sym = sym;
p = getenv(env);
- if (p)
+ if (p) {
sym_add_default(sym, p);
- else
+ if ((strcmp(sym->name, "ARCH") == 0) ||
+ (strcmp(sym->name, "CROSS_COMPILE") == 0))
+ sym->flags &= ~SYMBOL_AUTO;
+ } else {
menu_warn(current_entry, "environment variable %s undefined", env);
+ }
}