aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorSam Ravnborg <sam@ravnborg.org>2009-09-20 06:24:55 -0400
committerSam Ravnborg <sam@ravnborg.org>2009-09-20 06:24:55 -0400
commit575543347b5baed0ca927cb90ba8807396fe9cc9 (patch)
tree2ca85e5c092edef5a779562ebf227b6449e21f6f /Makefile
parentcaa27b66bd7188fd063769eaf4b33533ef0709e6 (diff)
kbuild: save ARCH & CROSS_COMPILE when building a kernel
When building a kernel for a different architecture kbuild requires the user always to specify ARCH and CROSS_COMPILE on the command-line. We use the asm symlink to detect if user forgets to specify the correct ARCH value - but that symlink is about to die. And we do now want to loose this check. This patch save the settings of ARCH and CROSS_COMPILE in two files named: include/generated/kernel.arch include/generated/kernel.cross The settings are saved during "make *config" time and always read. If user try to change the settings we error out. This works both for plain builds and for O=... builds. So now you can do: $ mkdir sparc64 $ make O=sparc64 ARCH=sparc64 CROSS_COMPILE=sparc64-linux- defconfig $ cd sparc64 $ make Notice that you no longer need to tell kbuild the settings of ARCH and CROSS_COMPILE when you type make in the output directory. Likewise for plain builds where you do not use O=... Signed-off-by: Sam Ravnborg <sam@ravnborg.org> Cc: Roland McGrath <roland@redhat.com>
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile46
1 files changed, 44 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index 305d00594adc..a45b0a23182b 100644
--- a/Makefile
+++ b/Makefile
@@ -179,9 +179,46 @@ SUBARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
179# Alternatively CROSS_COMPILE can be set in the environment. 179# Alternatively CROSS_COMPILE can be set in the environment.
180# Default value for CROSS_COMPILE is not to prefix executables 180# Default value for CROSS_COMPILE is not to prefix executables
181# Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile 181# Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile
182#
183# To force ARCH and CROSS_COMPILE settings include kernel.* files
184# in the kernel tree - do not patch this file.
182export KBUILD_BUILDHOST := $(SUBARCH) 185export KBUILD_BUILDHOST := $(SUBARCH)
183ARCH ?= $(SUBARCH) 186
184CROSS_COMPILE ?= 187# Kbuild save the ARCH and CROSS_COMPILE setting in kernel.* files.
188# Restore these settings and check that user did not specify
189# conflicting values.
190
191saved_arch := $(shell cat include/generated/kernel.arch 2> /dev/null)
192saved_cross := $(shell cat include/generated/kernel.cross 2> /dev/null)
193
194ifneq ($(CROSS_COMPILE),)
195 ifneq ($(saved_cross),)
196 ifneq ($(CROSS_COMPILE),$(saved_cross))
197 $(error CROSS_COMPILE changed from \
198 "$(saved_cross)" to \
199 to "$(CROSS_COMPILE)". \
200 Use "make mrproper" to fix it up)
201 endif
202 endif
203else
204 CROSS_COMPILE := $(saved_cross)
205endif
206
207ifneq ($(ARCH),)
208 ifneq ($(saved_arch),)
209 ifneq ($(saved_arch),$(ARCH))
210 $(error ARCH changed from \
211 "$(saved_arch)" to "$(ARCH)". \
212 Use "make mrproper" to fix it up)
213 endif
214 endif
215else
216 ifneq ($(saved_arch),)
217 ARCH := $(saved_arch)
218 else
219 ARCH := $(SUBARCH)
220 endif
221endif
185 222
186# Architecture as present in compile.h 223# Architecture as present in compile.h
187UTS_MACHINE := $(ARCH) 224UTS_MACHINE := $(ARCH)
@@ -446,6 +483,11 @@ ifeq ($(config-targets),1)
446include $(srctree)/arch/$(SRCARCH)/Makefile 483include $(srctree)/arch/$(SRCARCH)/Makefile
447export KBUILD_DEFCONFIG KBUILD_KCONFIG 484export KBUILD_DEFCONFIG KBUILD_KCONFIG
448 485
486# save ARCH & CROSS_COMPILE settings
487$(shell mkdir -p include/generated && \
488 echo $(ARCH) > include/generated/kernel.arch && \
489 echo $(CROSS_COMPILE) > include/generated/kernel.cross)
490
449config: scripts_basic outputmakefile FORCE 491config: scripts_basic outputmakefile FORCE
450 $(Q)mkdir -p include/linux include/config 492 $(Q)mkdir -p include/linux include/config
451 $(Q)$(MAKE) $(build)=scripts/kconfig $@ 493 $(Q)$(MAKE) $(build)=scripts/kconfig $@