aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile62
1 files changed, 52 insertions, 10 deletions
diff --git a/Makefile b/Makefile
index 433493a2b77b..f908accd332b 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)
@@ -315,6 +352,7 @@ OBJCOPY = $(CROSS_COMPILE)objcopy
315OBJDUMP = $(CROSS_COMPILE)objdump 352OBJDUMP = $(CROSS_COMPILE)objdump
316AWK = awk 353AWK = awk
317GENKSYMS = scripts/genksyms/genksyms 354GENKSYMS = scripts/genksyms/genksyms
355INSTALLKERNEL := installkernel
318DEPMOD = /sbin/depmod 356DEPMOD = /sbin/depmod
319KALLSYMS = scripts/kallsyms 357KALLSYMS = scripts/kallsyms
320PERL = perl 358PERL = perl
@@ -353,7 +391,8 @@ KERNELVERSION = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
353 391
354export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION 392export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION
355export ARCH SRCARCH CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC 393export ARCH SRCARCH CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC
356export CPP AR NM STRIP OBJCOPY OBJDUMP MAKE AWK GENKSYMS PERL UTS_MACHINE 394export CPP AR NM STRIP OBJCOPY OBJDUMP
395export MAKE AWK GENKSYMS INSTALLKERNEL PERL UTS_MACHINE
357export HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS 396export HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS
358 397
359export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS 398export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS
@@ -444,6 +483,11 @@ ifeq ($(config-targets),1)
444include $(srctree)/arch/$(SRCARCH)/Makefile 483include $(srctree)/arch/$(SRCARCH)/Makefile
445export KBUILD_DEFCONFIG KBUILD_KCONFIG 484export KBUILD_DEFCONFIG KBUILD_KCONFIG
446 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
447config: scripts_basic outputmakefile FORCE 491config: scripts_basic outputmakefile FORCE
448 $(Q)mkdir -p include/linux include/config 492 $(Q)mkdir -p include/linux include/config
449 $(Q)$(MAKE) $(build)=scripts/kconfig $@ 493 $(Q)$(MAKE) $(build)=scripts/kconfig $@
@@ -571,6 +615,9 @@ KBUILD_CFLAGS += $(call cc-option,-fno-strict-overflow)
571# revert to pre-gcc-4.4 behaviour of .eh_frame 615# revert to pre-gcc-4.4 behaviour of .eh_frame
572KBUILD_CFLAGS += $(call cc-option,-fno-dwarf2-cfi-asm) 616KBUILD_CFLAGS += $(call cc-option,-fno-dwarf2-cfi-asm)
573 617
618# conserve stack if available
619KBUILD_CFLAGS += $(call cc-option,-fconserve-stack)
620
574# Add user supplied CPPFLAGS, AFLAGS and CFLAGS as the last assignments 621# Add user supplied CPPFLAGS, AFLAGS and CFLAGS as the last assignments
575# But warn user when we do so 622# But warn user when we do so
576warn-assign = \ 623warn-assign = \
@@ -591,12 +638,12 @@ endif
591 638
592# Use --build-id when available. 639# Use --build-id when available.
593LDFLAGS_BUILD_ID = $(patsubst -Wl$(comma)%,%,\ 640LDFLAGS_BUILD_ID = $(patsubst -Wl$(comma)%,%,\
594 $(call ld-option, -Wl$(comma)--build-id,)) 641 $(call cc-ldoption, -Wl$(comma)--build-id,))
595LDFLAGS_MODULE += $(LDFLAGS_BUILD_ID) 642LDFLAGS_MODULE += $(LDFLAGS_BUILD_ID)
596LDFLAGS_vmlinux += $(LDFLAGS_BUILD_ID) 643LDFLAGS_vmlinux += $(LDFLAGS_BUILD_ID)
597 644
598ifeq ($(CONFIG_STRIP_ASM_SYMS),y) 645ifeq ($(CONFIG_STRIP_ASM_SYMS),y)
599LDFLAGS_vmlinux += -X 646LDFLAGS_vmlinux += $(call ld-option, -X,)
600endif 647endif
601 648
602# Default kernel image to build when no specific target is given. 649# Default kernel image to build when no specific target is given.
@@ -980,11 +1027,6 @@ prepare0: archprepare FORCE
980# All the preparing.. 1027# All the preparing..
981prepare: prepare0 1028prepare: prepare0
982 1029
983# Leave this as default for preprocessing vmlinux.lds.S, which is now
984# done in arch/$(ARCH)/kernel/Makefile
985
986export CPPFLAGS_vmlinux.lds += -P -C -U$(ARCH)
987
988# The asm symlink changes when $(ARCH) changes. 1030# The asm symlink changes when $(ARCH) changes.
989# Detect this and ask user to run make mrproper 1031# Detect this and ask user to run make mrproper
990# If asm is a stale symlink (point to dir that does not exist) remove it 1032# If asm is a stale symlink (point to dir that does not exist) remove it