xref: /linux/arch/powerpc/Makefile (revision c47ca98d32a22a412ddbc69916cf62bdcdfa1a4e)
114cf11afSPaul Mackerras# This file is included by the global makefile so that you can add your own
214cf11afSPaul Mackerras# architecture-specific flags and dependencies. Remember to do have actions
314cf11afSPaul Mackerras# for "archclean" and "archdep" for cleaning up and making dependencies for
414cf11afSPaul Mackerras# this architecture.
514cf11afSPaul Mackerras#
614cf11afSPaul Mackerras# This file is subject to the terms and conditions of the GNU General Public
714cf11afSPaul Mackerras# License.  See the file "COPYING" in the main directory of this archive
814cf11afSPaul Mackerras# for more details.
914cf11afSPaul Mackerras#
1014cf11afSPaul Mackerras# Copyright (C) 1994 by Linus Torvalds
1114cf11afSPaul Mackerras# Changes for PPC by Gary Thomas
1214cf11afSPaul Mackerras# Rewritten by Cort Dougan and Paul Mackerras
1314cf11afSPaul Mackerras#
1414cf11afSPaul Mackerras
1514cf11afSPaul MackerrasHAS_BIARCH	:= $(call cc-option-yn, -m32)
1614cf11afSPaul Mackerras
1714cf11afSPaul Mackerras# Set default 32 bits cross compilers for vdso and boot wrapper
1814cf11afSPaul MackerrasCROSS32_COMPILE ?=
1914cf11afSPaul Mackerras
2014cf11afSPaul Mackerrasifeq ($(HAS_BIARCH),y)
2114cf11afSPaul Mackerrasifeq ($(CROSS32_COMPILE),)
224bf4f42aSNicholas Pigginifdef CONFIG_PPC32
234bf4f42aSNicholas Piggin# These options will be overridden by any -mcpu option that the CPU
244bf4f42aSNicholas Piggin# or platform code sets later on the command line, but they are needed
254bf4f42aSNicholas Piggin# to set a sane 32-bit cpu target for the 64-bit cross compiler which
264bf4f42aSNicholas Piggin# may default to the wrong ISA.
274bf4f42aSNicholas PigginKBUILD_CFLAGS		+= -mcpu=powerpc
284bf4f42aSNicholas PigginKBUILD_AFLAGS		+= -mcpu=powerpc
294bf4f42aSNicholas Pigginendif
3014cf11afSPaul Mackerrasendif
3114cf11afSPaul Mackerrasendif
3214cf11afSPaul Mackerras
33ca786f83SAdrian Bunkifeq ($(CROSS_COMPILE),)
348a5abdf8SPaul MackerrasKBUILD_DEFCONFIG := $(shell uname -m)_defconfig
35ca786f83SAdrian Bunkelse
36ca786f83SAdrian BunkKBUILD_DEFCONFIG := ppc64_defconfig
37ca786f83SAdrian Bunkendif
388a5abdf8SPaul Mackerras
39badf436fSRodrigo R. Galvaoifdef CONFIG_PPC64
4014cf11afSPaul Mackerrasnew_nm := $(shell if $(NM) --help 2>&1 | grep -- '--synthetic' > /dev/null; then echo y; else echo n; fi)
4114cf11afSPaul Mackerras
4214cf11afSPaul Mackerrasifeq ($(new_nm),y)
4314cf11afSPaul MackerrasNM		:= $(NM) --synthetic
4414cf11afSPaul Mackerrasendif
45a0588015SAnton Blanchardendif
4614cf11afSPaul Mackerras
4768201fbbSMichael Ellerman# BITS is used as extension for files which are available in a 32 bit
4868201fbbSMichael Ellerman# and a 64 bit version to simplify shared Makefiles.
4968201fbbSMichael Ellerman# e.g.: obj-y += foo_$(BITS).o
5068201fbbSMichael Ellermanexport BITS
5168201fbbSMichael Ellerman
5268201fbbSMichael Ellermanifdef CONFIG_PPC64
5368201fbbSMichael Ellerman        BITS := 64
5468201fbbSMichael Ellermanelse
5568201fbbSMichael Ellerman        BITS := 32
5614cf11afSPaul Mackerrasendif
5714cf11afSPaul Mackerras
5857073e27SMichael Ellermanmachine-y = ppc
5957073e27SMichael Ellermanmachine-$(CONFIG_PPC64) += 64
6057073e27SMichael Ellermanmachine-$(CONFIG_CPU_LITTLE_ENDIAN) += le
6157073e27SMichael EllermanUTS_MACHINE := $(subst $(space),,$(machine-y))
62190554dbSStephen Rothwell
63b40b2386SMichael Ellerman# XXX This needs to be before we override LD below
64b40b2386SMichael Ellermanifdef CONFIG_PPC32
65b40b2386SMichael EllermanKBUILD_LDFLAGS_MODULE += arch/powerpc/lib/crtsavres.o
66b40b2386SMichael Ellermanelse
675c45b528SAlan ModraKBUILD_LDFLAGS_MODULE += -T $(srctree)/arch/powerpc/kernel/module.lds
68b40b2386SMichael Ellermanifeq ($(call ld-ifversion, -ge, 225000000, y),y)
69b40b2386SMichael Ellerman# Have the linker provide sfpr if possible.
70b40b2386SMichael Ellerman# There is a corresponding test in arch/powerpc/lib/Makefile
71b40b2386SMichael EllermanKBUILD_LDFLAGS_MODULE += --save-restore-funcs
72b40b2386SMichael Ellermanelse
73b40b2386SMichael EllermanKBUILD_LDFLAGS_MODULE += arch/powerpc/lib/crtsavres.o
74b40b2386SMichael Ellermanendif
75b40b2386SMichael Ellermanendif
76b40b2386SMichael Ellerman
77badf436fSRodrigo R. Galvaoifdef CONFIG_CPU_LITTLE_ENDIAN
781421dc6dSNicholas PigginKBUILD_CFLAGS	+= -mlittle-endian
79d503ac53SMasahiro YamadaKBUILD_LDFLAGS	+= -EL
80d72b0801SIan MunsieLDEMULATION	:= lppc
81d72b0801SIan MunsieGNUTARGET	:= powerpcle
82d72b0801SIan MunsieMULTIPLEWORD	:= -mno-multiple
83d3d35d95STony BreedsKBUILD_CFLAGS_MODULE += $(call cc-option,-mno-save-toc-indirect)
84d72b0801SIan Munsieelse
851421dc6dSNicholas PigginKBUILD_CFLAGS += $(call cc-option,-mbig-endian)
86d503ac53SMasahiro YamadaKBUILD_LDFLAGS	+= -EB
87d72b0801SIan MunsieLDEMULATION	:= ppc
88d72b0801SIan MunsieGNUTARGET	:= powerpc
89d72b0801SIan MunsieMULTIPLEWORD	:= -mmultiple
90d72b0801SIan Munsieendif
91d72b0801SIan Munsie
924dc831aaSNicholas Pigginifdef CONFIG_PPC64
934dc831aaSNicholas Piggincflags-$(CONFIG_CPU_BIG_ENDIAN)		+= $(call cc-option,-mabi=elfv1)
944dc831aaSNicholas Piggincflags-$(CONFIG_CPU_BIG_ENDIAN)		+= $(call cc-option,-mcall-aixdesc)
954dc831aaSNicholas Pigginaflags-$(CONFIG_CPU_BIG_ENDIAN)		+= $(call cc-option,-mabi=elfv1)
964dc831aaSNicholas Pigginaflags-$(CONFIG_CPU_LITTLE_ENDIAN)	+= -mabi=elfv2
974dc831aaSNicholas Pigginendif
984dc831aaSNicholas Piggin
99164af597SMichael Ellermanifneq ($(cc-name),clang)
100164af597SMichael Ellerman  cflags-$(CONFIG_CPU_LITTLE_ENDIAN)	+= -mno-strict-align
101164af597SMichael Ellermanendif
102164af597SMichael Ellerman
1031421dc6dSNicholas Piggincflags-$(CONFIG_CPU_BIG_ENDIAN)		+= $(call cc-option,-mbig-endian)
1041421dc6dSNicholas Piggincflags-$(CONFIG_CPU_LITTLE_ENDIAN)	+= -mlittle-endian
105164af597SMichael Ellermanaflags-$(CONFIG_CPU_BIG_ENDIAN)		+= $(call cc-option,-mbig-endian)
106164af597SMichael Ellermanaflags-$(CONFIG_CPU_LITTLE_ENDIAN)	+= -mlittle-endian
107164af597SMichael Ellerman
10814cf11afSPaul Mackerrasifeq ($(HAS_BIARCH),y)
1091421dc6dSNicholas PigginKBUILD_CFLAGS	+= -m$(BITS)
1101421dc6dSNicholas PigginKBUILD_AFLAGS	+= -m$(BITS) -Wl,-a$(BITS)
111d503ac53SMasahiro YamadaKBUILD_LDFLAGS	+= -m elf$(BITS)$(LDEMULATION)
11243c9127dSNicholas PigginKBUILD_ARFLAGS	+= --target=elf$(BITS)-$(GNUTARGET)
11314cf11afSPaul Mackerrasendif
11414cf11afSPaul Mackerras
115c3ff2a51SChristophe Leroycflags-$(CONFIG_STACKPROTECTOR)	+= -mstack-protector-guard=tls
11606ec27aeSChristophe Leroyifdef CONFIG_PPC64
11706ec27aeSChristophe Leroycflags-$(CONFIG_STACKPROTECTOR)	+= -mstack-protector-guard-reg=r13
11806ec27aeSChristophe Leroyelse
119c3ff2a51SChristophe Leroycflags-$(CONFIG_STACKPROTECTOR)	+= -mstack-protector-guard-reg=r2
12006ec27aeSChristophe Leroyendif
121c3ff2a51SChristophe Leroy
1229c5f7d39SSuzuki PouloseLDFLAGS_vmlinux-y := -Bstatic
1239c5f7d39SSuzuki PouloseLDFLAGS_vmlinux-$(CONFIG_RELOCATABLE) := -pie
1249c5f7d39SSuzuki PouloseLDFLAGS_vmlinux	:= $(LDFLAGS_vmlinux-y)
12583a092cfSNicholas PigginLDFLAGS_vmlinux += $(call ld-option,--orphan-handling=warn)
12614cf11afSPaul Mackerras
127badf436fSRodrigo R. Galvaoifdef CONFIG_PPC64
1281fbe9cf2SAnton Blanchardifeq ($(call cc-option-yn,-mcmodel=medium),y)
1291fbe9cf2SAnton Blanchard	# -mcmodel=medium breaks modules because it uses 32bit offsets from
1301fbe9cf2SAnton Blanchard	# the TOC pointer to create pointers where possible. Pointers into the
1311fbe9cf2SAnton Blanchard	# percpu data area are created by this method.
1321fbe9cf2SAnton Blanchard	#
1331fbe9cf2SAnton Blanchard	# The kernel module loader relocates the percpu data section from the
1341fbe9cf2SAnton Blanchard	# original location (starting with 0xd...) to somewhere in the base
1351fbe9cf2SAnton Blanchard	# kernel percpu data space (starting with 0xc...). We need a full
1361fbe9cf2SAnton Blanchard	# 64bit relocation for this to work, hence -mcmodel=large.
1371fbe9cf2SAnton Blanchard	KBUILD_CFLAGS_MODULE += -mcmodel=large
1381fbe9cf2SAnton Blanchardelse
1391fbe9cf2SAnton Blanchard	export NO_MINIMAL_TOC := -mno-minimal-toc
1401fbe9cf2SAnton Blanchardendif
1411fbe9cf2SAnton Blanchardendif
1421fbe9cf2SAnton Blanchard
143a50a862eSAnton BlanchardCFLAGS-$(CONFIG_PPC64)	:= $(call cc-option,-mtraceback=no)
144badf436fSRodrigo R. Galvaoifdef CONFIG_CPU_LITTLE_ENDIAN
145238abecdSAnton BlanchardCFLAGS-$(CONFIG_PPC64)	+= $(call cc-option,-mabi=elfv2,$(call cc-option,-mcall-aixdesc))
146721aeaa9SAnton BlanchardAFLAGS-$(CONFIG_PPC64)	+= $(call cc-option,-mabi=elfv2)
147721aeaa9SAnton Blanchardelse
1484dc831aaSNicholas PigginCFLAGS-$(CONFIG_PPC64)	+= $(call cc-option,-mabi=elfv1)
149238abecdSAnton BlanchardCFLAGS-$(CONFIG_PPC64)	+= $(call cc-option,-mcall-aixdesc)
1504dc831aaSNicholas PigginAFLAGS-$(CONFIG_PPC64)	+= $(call cc-option,-mabi=elfv1)
151721aeaa9SAnton Blanchardendif
152238abecdSAnton BlanchardCFLAGS-$(CONFIG_PPC64)	+= $(call cc-option,-mcmodel=medium,$(call cc-option,-mminimal-toc))
15398679fb0SAnton BlanchardCFLAGS-$(CONFIG_PPC64)	+= $(call cc-option,-mno-pointers-to-nested-functions)
15451d42f0fSSegher Boessenkool
155d72b0801SIan MunsieCFLAGS-$(CONFIG_PPC32)	:= -ffixed-r2 $(MULTIPLEWORD)
15651d42f0fSSegher BoessenkoolCFLAGS-$(CONFIG_PPC32)	+= $(call cc-option,-mno-readonly-in-sdata)
157d23c6fb4SAnton Blanchard
158badf436fSRodrigo R. Galvaoifdef CONFIG_PPC_BOOK3S_64
159badf436fSRodrigo R. Galvaoifdef CONFIG_CPU_LITTLE_ENDIAN
160a73657eaSNicholas PigginCFLAGS-$(CONFIG_GENERIC_CPU) += -mcpu=power8
1614b7e5532SNicholas PigginCFLAGS-$(CONFIG_GENERIC_CPU) += $(call cc-option,-mtune=power9,-mtune=power8)
162a73657eaSNicholas Pigginelse
163471d7ff8SNicholas PigginCFLAGS-$(CONFIG_GENERIC_CPU) += $(call cc-option,-mtune=power7,$(call cc-option,-mtune=power5))
164471d7ff8SNicholas PigginCFLAGS-$(CONFIG_GENERIC_CPU) += $(call cc-option,-mcpu=power5,-mcpu=power4)
165a73657eaSNicholas Pigginendif
16601718ba6SScott Woodelse
16701718ba6SScott WoodCFLAGS-$(CONFIG_GENERIC_CPU) += -mcpu=powerpc64
16801718ba6SScott Woodendif
16901718ba6SScott Wood
1702a056f58SNicholas Pigginifdef CONFIG_FUNCTION_TRACER
1712a056f58SNicholas PigginCC_FLAGS_FTRACE := -pg
1728c50b72aSTorsten Duweifdef CONFIG_MPROFILE_KERNEL
1732a056f58SNicholas PigginCC_FLAGS_FTRACE += -mprofile-kernel
1742a056f58SNicholas Pigginendif
1756977f95eSNicholas Piggin# Work around gcc code-gen bugs with -pg / -fno-omit-frame-pointer in gcc <= 4.8
1766977f95eSNicholas Piggin# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=44199
1776977f95eSNicholas Piggin# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52828
1786977f95eSNicholas Pigginifneq ($(cc-name),clang)
1796977f95eSNicholas PigginCC_FLAGS_FTRACE	+= $(call cc-ifversion, -lt, 0409, -mno-sched-epilog)
1806977f95eSNicholas Pigginendif
1818c50b72aSTorsten Duweendif
1828c50b72aSTorsten Duwe
183cc62d20cSChristophe LeroyCFLAGS-$(CONFIG_TARGET_CPU_BOOL) += $(call cc-option,-mcpu=$(CONFIG_TARGET_CPU))
184d23c6fb4SAnton Blanchard
185cbf8a358STiejun Chen# Altivec option not allowed with e500mc64 in GCC.
186badf436fSRodrigo R. Galvaoifdef CONFIG_ALTIVEC
187cbf8a358STiejun ChenE5500_CPU := -mcpu=powerpc64
188cbf8a358STiejun Chenelse
18901718ba6SScott WoodE5500_CPU := $(call cc-option,-mcpu=e500mc64,-mcpu=powerpc64)
190cbf8a358STiejun Chenendif
19101718ba6SScott WoodCFLAGS-$(CONFIG_E5500_CPU) += $(E5500_CPU)
19201718ba6SScott WoodCFLAGS-$(CONFIG_E6500_CPU) += $(call cc-option,-mcpu=e6500,$(E5500_CPU))
19301718ba6SScott Wood
194badf436fSRodrigo R. Galvaoifdef CONFIG_PPC32
195badf436fSRodrigo R. Galvaoifdef CONFIG_PPC_E500MC
196847f56b0SScott WoodCFLAGS-y += $(call cc-option,-mcpu=e500mc,-mcpu=powerpc)
197847f56b0SScott Woodelse
198847f56b0SScott WoodCFLAGS-$(CONFIG_E500) += $(call cc-option,-mcpu=8540 -msoft-float,-mcpu=powerpc)
199847f56b0SScott Woodendif
200847f56b0SScott Woodendif
201847f56b0SScott Wood
2027998eb3dSGuenter Roeckasinstr := $(call as-instr,lis 9$(comma)foo@high,-DHAVE_AS_ATHIGH=1)
2037998eb3dSGuenter Roeck
2047998eb3dSGuenter RoeckKBUILD_CPPFLAGS	+= -Iarch/$(ARCH) $(asinstr)
20558aedccbSAnton BlanchardKBUILD_AFLAGS	+= -Iarch/$(ARCH) $(AFLAGS-y)
206a50a862eSAnton BlanchardKBUILD_CFLAGS	+= $(call cc-option,-msoft-float)
207a50a862eSAnton BlanchardKBUILD_CFLAGS	+= -pipe -Iarch/$(ARCH) $(CFLAGS-y)
208a0f97e06SSam RavnborgCPP		= $(CC) -E $(KBUILD_CFLAGS)
20914cf11afSPaul Mackerras
21068201fbbSMichael EllermanCHECKFLAGS	+= -m$(BITS) -D__powerpc__ -D__powerpc$(BITS)__
21162c2c5cfSDaniel Axtensifdef CONFIG_CPU_BIG_ENDIAN
21262c2c5cfSDaniel AxtensCHECKFLAGS	+= -D__BIG_ENDIAN__
21362c2c5cfSDaniel Axtenselse
21462c2c5cfSDaniel AxtensCHECKFLAGS	+= -D__LITTLE_ENDIAN__
21562c2c5cfSDaniel Axtensendif
21614cf11afSPaul Mackerras
217badf436fSRodrigo R. Galvaoifdef CONFIG_476FPE_ERR46
218d5b35cffSAlistair Popple	KBUILD_LDFLAGS_MODULE += --ppc476-workaround \
219d5b35cffSAlistair Popple		-T $(srctree)/arch/powerpc/platforms/44x/ppc476_modules.lds
220d5b35cffSAlistair Poppleendif
221d5b35cffSAlistair Popple
222d23c6fb4SAnton Blanchard# No AltiVec or VSX instructions when building kernel
223a0f97e06SSam RavnborgKBUILD_CFLAGS += $(call cc-option,-mno-altivec)
224d23c6fb4SAnton BlanchardKBUILD_CFLAGS += $(call cc-option,-mno-vsx)
225d3f67fbbSPaul Mackerras
2260197cd2eSKumar Gala# No SPE instruction when building kernel
227ce400c01SThiemo Seufer# (We use all available options to help semi-broken compilers)
2280197cd2eSKumar GalaKBUILD_CFLAGS += $(call cc-option,-mno-spe)
229ce400c01SThiemo SeuferKBUILD_CFLAGS += $(call cc-option,-mspe=no)
2300197cd2eSKumar Gala
23114cf11afSPaul Mackerras# Enable unit-at-a-time mode when possible. It shrinks the
23214cf11afSPaul Mackerras# kernel considerably.
233a0f97e06SSam RavnborgKBUILD_CFLAGS += $(call cc-option,-funit-at-a-time)
23414cf11afSPaul Mackerras
235d0679c73SAndi Kleen# FIXME: the module load should be taught about the additional relocs
236d0679c73SAndi Kleen# generated by this.
237d0679c73SAndi Kleen# revert to pre-gcc-4.4 behaviour of .eh_frame
238d0679c73SAndi KleenKBUILD_CFLAGS	+= $(call cc-option,-fno-dwarf2-cfi-asm)
239d0679c73SAndi Kleen
24057647a4dSBenjamin Herrenschmidt# Never use string load/store instructions as they are
24157647a4dSBenjamin Herrenschmidt# often slow when they are implemented at all
242a50a862eSAnton BlanchardKBUILD_CFLAGS		+= $(call cc-option,-mno-string)
24314cf11afSPaul Mackerras
244badf436fSRodrigo R. Galvaoifdef CONFIG_6xx
245a0f97e06SSam RavnborgKBUILD_CFLAGS		+= -mcpu=powerpc
246f48b8296SOlaf Heringendif
247f48b8296SOlaf Hering
24814cf11afSPaul Mackerrascpu-as-$(CONFIG_4xx)		+= -Wa,-m405
2499ddf0075SAnton Blanchardcpu-as-$(CONFIG_ALTIVEC)	+= $(call as-option,-Wa$(comma)-maltivec)
25014cf11afSPaul Mackerrascpu-as-$(CONFIG_E200)		+= -Wa,-me200
2514e4a4b75SJames Clarkecpu-as-$(CONFIG_E500)		+= -Wa,-me500
252960e3002SJoel Stanley
253960e3002SJoel Stanley# When using '-many -mpower4' gas will first try and find a matching power4
254960e3002SJoel Stanley# mnemonic and failing that it will allow any valid mnemonic that GAS knows
255960e3002SJoel Stanley# about. GCC will pass -many to GAS when assembling, clang does not.
256960e3002SJoel Stanleycpu-as-$(CONFIG_PPC_BOOK3S_64)	+= -Wa,-mpower4 -Wa,-many
25769a84059SMichael Jeansoncpu-as-$(CONFIG_PPC_E500MC)	+= $(call as-option,-Wa$(comma)-me500mc)
25814cf11afSPaul Mackerras
259222d394dSSam RavnborgKBUILD_AFLAGS += $(cpu-as-y)
260a0f97e06SSam RavnborgKBUILD_CFLAGS += $(cpu-as-y)
26114cf11afSPaul Mackerras
262164af597SMichael EllermanKBUILD_AFLAGS += $(aflags-y)
263164af597SMichael EllermanKBUILD_CFLAGS += $(cflags-y)
264164af597SMichael Ellerman
26568201fbbSMichael Ellermanhead-y				:= arch/powerpc/kernel/head_$(BITS).o
266968159c0SChristophe Leroyhead-$(CONFIG_PPC_8xx)		:= arch/powerpc/kernel/head_8xx.o
26715f6527eSJosh Boyerhead-$(CONFIG_40x)		:= arch/powerpc/kernel/head_40x.o
26814cf11afSPaul Mackerrashead-$(CONFIG_44x)		:= arch/powerpc/kernel/head_44x.o
26914cf11afSPaul Mackerrashead-$(CONFIG_FSL_BOOKE)	:= arch/powerpc/kernel/head_fsl_booke.o
27014cf11afSPaul Mackerras
2719994a338SPaul Mackerrashead-$(CONFIG_PPC64)		+= arch/powerpc/kernel/entry_64.o
27214cf11afSPaul Mackerrashead-$(CONFIG_PPC_FPU)		+= arch/powerpc/kernel/fpu.o
273e821ea70SBenjamin Herrenschmidthead-$(CONFIG_ALTIVEC)		+= arch/powerpc/kernel/vector.o
2745ac47f7aSAnton Blanchardhead-$(CONFIG_PPC_OF_BOOT_TRAMPOLINE)  += arch/powerpc/kernel/prom_init.o
27514cf11afSPaul Mackerras
276*c47ca98dSMichael Ellerman# See arch/powerpc/Kbuild for content of core part of the kernel
277*c47ca98dSMichael Ellermancore-y += arch/powerpc/
27814cf11afSPaul Mackerras
27914cf11afSPaul Mackerrasdrivers-$(CONFIG_OPROFILE)	+= arch/powerpc/oprofile/
28014cf11afSPaul Mackerras
281135f0b17STom Rini# Default to zImage, override when needed
28225431333SGrant Likelyall: zImage
28314cf11afSPaul Mackerras
284e32e78c5SSam Ravnborg# With make 3.82 we cannot mix normal and wildcard targets
285c686ecf5SAnatolij GustschinBOOT_TARGETS1 := zImage zImage.initrd uImage
28611eab297SBenjamin HerrenschmidtBOOT_TARGETS2 := zImage% dtbImage% treeImage.% cuImage.% simpleImage.% uImage.%
287cabb5587SStephen Rothwell
288e32e78c5SSam RavnborgPHONY += $(BOOT_TARGETS1) $(BOOT_TARGETS2)
289cabb5587SStephen Rothwell
29094b212c2SPaul Mackerrasboot := arch/$(ARCH)/boot
29114cf11afSPaul Mackerras
292e32e78c5SSam Ravnborg$(BOOT_TARGETS1): vmlinux
2931196d7aaSMichael Ellerman	$(Q)$(MAKE) $(build)=$(boot) $(patsubst %,$(boot)/%,$@)
294e32e78c5SSam Ravnborg$(BOOT_TARGETS2): vmlinux
2951196d7aaSMichael Ellerman	$(Q)$(MAKE) $(build)=$(boot) $(patsubst %,$(boot)/%,$@)
29614cf11afSPaul Mackerras
297e32e78c5SSam Ravnborg
298e32e78c5SSam Ravnborgbootwrapper_install:
2991196d7aaSMichael Ellerman	$(Q)$(MAKE) $(build)=$(boot) $(patsubst %,$(boot)/%,$@)
300e32e78c5SSam Ravnborg
3018662d0bcSMatthew McClintock%.dtb: scripts
3021196d7aaSMichael Ellerman	$(Q)$(MAKE) $(build)=$(boot) $(patsubst %,$(boot)/%,$@)
303773f76b1SDavid Woodhouse
304ea4d1a87SCyril Bur# Used to create 'merged defconfigs'
305ea4d1a87SCyril Bur# To use it $(call) it with the first argument as the base defconfig
306ea4d1a87SCyril Bur# and the second argument as a space separated list of .config files to merge,
307ea4d1a87SCyril Bur# without the .config suffix.
308ea4d1a87SCyril Burdefine merge_into_defconfig
309ea4d1a87SCyril Bur	$(Q)$(CONFIG_SHELL) $(srctree)/scripts/kconfig/merge_config.sh \
310ea4d1a87SCyril Bur		-m -O $(objtree) $(srctree)/arch/$(ARCH)/configs/$(1) \
311ea4d1a87SCyril Bur		$(foreach config,$(2),$(srctree)/arch/$(ARCH)/configs/$(config).config)
312ea4d1a87SCyril Bur	+$(Q)$(MAKE) -f $(srctree)/Makefile olddefconfig
313ea4d1a87SCyril Burendef
314ea4d1a87SCyril Bur
315ea4d1a87SCyril BurPHONY += pseries_le_defconfig
316ea4d1a87SCyril Burpseries_le_defconfig:
317ea4d1a87SCyril Bur	$(call merge_into_defconfig,pseries_defconfig,le)
318ea4d1a87SCyril Bur
3192adc48a6SMichael EllermanPHONY += ppc64le_defconfig
3202adc48a6SMichael Ellermanppc64le_defconfig:
3212adc48a6SMichael Ellerman	$(call merge_into_defconfig,ppc64_defconfig,le)
3222adc48a6SMichael Ellerman
3233603c52fSMichael EllermanPHONY += powernv_be_defconfig
3243603c52fSMichael Ellermanpowernv_be_defconfig:
3253603c52fSMichael Ellerman	$(call merge_into_defconfig,powernv_defconfig,be)
3263603c52fSMichael Ellerman
32744d54014SScott WoodPHONY += mpc85xx_defconfig
32844d54014SScott Woodmpc85xx_defconfig:
32944d54014SScott Wood	$(call merge_into_defconfig,mpc85xx_basic_defconfig,\
33044d54014SScott Wood		85xx-32bit 85xx-hw fsl-emb-nonhw)
33144d54014SScott Wood
33244d54014SScott WoodPHONY += mpc85xx_smp_defconfig
33344d54014SScott Woodmpc85xx_smp_defconfig:
33444d54014SScott Wood	$(call merge_into_defconfig,mpc85xx_basic_defconfig,\
33544d54014SScott Wood		85xx-32bit 85xx-smp 85xx-hw fsl-emb-nonhw)
33644d54014SScott Wood
33744d54014SScott WoodPHONY += corenet32_smp_defconfig
33844d54014SScott Woodcorenet32_smp_defconfig:
33944d54014SScott Wood	$(call merge_into_defconfig,corenet_basic_defconfig,\
340e0b80f00SClaudiu Manoil		85xx-32bit 85xx-smp 85xx-hw fsl-emb-nonhw dpaa)
34144d54014SScott Wood
34244d54014SScott WoodPHONY += corenet64_smp_defconfig
34344d54014SScott Woodcorenet64_smp_defconfig:
34444d54014SScott Wood	$(call merge_into_defconfig,corenet_basic_defconfig,\
345e0b80f00SClaudiu Manoil		85xx-64bit 85xx-smp altivec 85xx-hw fsl-emb-nonhw dpaa)
34644d54014SScott Wood
34743de32c5SAlessio Igor BoganiPHONY += mpc86xx_defconfig
34843de32c5SAlessio Igor Boganimpc86xx_defconfig:
34943de32c5SAlessio Igor Bogani	$(call merge_into_defconfig,mpc86xx_basic_defconfig,\
35043de32c5SAlessio Igor Bogani		86xx-hw fsl-emb-nonhw)
35143de32c5SAlessio Igor Bogani
35243de32c5SAlessio Igor BoganiPHONY += mpc86xx_smp_defconfig
35343de32c5SAlessio Igor Boganimpc86xx_smp_defconfig:
35443de32c5SAlessio Igor Bogani	$(call merge_into_defconfig,mpc86xx_basic_defconfig,\
35543de32c5SAlessio Igor Bogani		86xx-smp 86xx-hw fsl-emb-nonhw)
35643de32c5SAlessio Igor Bogani
3578db0c9d4SMichael EllermanPHONY += ppc32_allmodconfig
3588db0c9d4SMichael Ellermanppc32_allmodconfig:
3598db0c9d4SMichael Ellerman	$(Q)$(MAKE) KCONFIG_ALLCONFIG=$(srctree)/arch/powerpc/configs/book3s_32.config \
3608db0c9d4SMichael Ellerman		-f $(srctree)/Makefile allmodconfig
3618db0c9d4SMichael Ellerman
36264de5d8dSMichael EllermanPHONY += ppc64le_allmodconfig
36364de5d8dSMichael Ellermanppc64le_allmodconfig:
36464de5d8dSMichael Ellerman	$(Q)$(MAKE) KCONFIG_ALLCONFIG=$(srctree)/arch/powerpc/configs/le.config \
36564de5d8dSMichael Ellerman		-f $(srctree)/Makefile allmodconfig
36664de5d8dSMichael Ellerman
36764de5d8dSMichael EllermanPHONY += ppc64_book3e_allmodconfig
36864de5d8dSMichael Ellermanppc64_book3e_allmodconfig:
36964de5d8dSMichael Ellerman	$(Q)$(MAKE) KCONFIG_ALLCONFIG=$(srctree)/arch/powerpc/configs/85xx-64bit.config \
37064de5d8dSMichael Ellerman		-f $(srctree)/Makefile allmodconfig
37164de5d8dSMichael Ellerman
37214cf11afSPaul Mackerrasdefine archhelp
37370bf0333SGrant Likely  @echo '* zImage          - Build default images selected by kernel config'
37470bf0333SGrant Likely  @echo '  zImage.*        - Compressed kernel image (arch/$(ARCH)/boot/zImage.*)'
37570bf0333SGrant Likely  @echo '  uImage          - U-Boot native image format'
37670bf0333SGrant Likely  @echo '  cuImage.<dt>    - Backwards compatible U-Boot image for older'
37770bf0333SGrant Likely  @echo '                    versions which do not support device trees'
37870bf0333SGrant Likely  @echo '  dtbImage.<dt>   - zImage with an embedded device tree blob'
37970bf0333SGrant Likely  @echo '  simpleImage.<dt> - Firmware independent image.'
38070bf0333SGrant Likely  @echo '  treeImage.<dt>  - Support for older IBM 4xx firmware (not U-Boot)'
38114cf11afSPaul Mackerras  @echo '  install         - Install kernel using'
382caa27b66SSam Ravnborg  @echo '                    (your) ~/bin/$(INSTALLKERNEL) or'
383caa27b66SSam Ravnborg  @echo '                    (distribution) /sbin/$(INSTALLKERNEL) or'
38414cf11afSPaul Mackerras  @echo '                    install to $$(INSTALL_PATH) and run lilo'
385437a58dbSPaul Mackerras  @echo '  *_defconfig     - Select default config from arch/$(ARCH)/configs'
38670bf0333SGrant Likely  @echo ''
38770bf0333SGrant Likely  @echo '  Targets with <dt> embed a device tree blob inside the image'
38870bf0333SGrant Likely  @echo '  These targets support board with firmware that does not'
38970bf0333SGrant Likely  @echo '  support passing a device tree directly.  Replace <dt> with the'
39070bf0333SGrant Likely  @echo '  name of a dts file from the arch/$(ARCH)/boot/dts/ directory'
39170bf0333SGrant Likely  @echo '  (minus the .dts extension).'
39214cf11afSPaul Mackerrasendef
39314cf11afSPaul Mackerras
3943f85d63eSSam Ravnborginstall:
39525431333SGrant Likely	$(Q)$(MAKE) $(build)=$(boot) install
396928370c6SAkinobu Mita
3978150caadSRoland McGrathvdso_install:
398badf436fSRodrigo R. Galvaoifdef CONFIG_PPC64
3998150caadSRoland McGrath	$(Q)$(MAKE) $(build)=arch/$(ARCH)/kernel/vdso64 $@
4008150caadSRoland McGrathendif
4018150caadSRoland McGrath	$(Q)$(MAKE) $(build)=arch/$(ARCH)/kernel/vdso32 $@
4028150caadSRoland McGrath
40314cf11afSPaul Mackerrasarchclean:
404a3a9e99eSPaul Mackerras	$(Q)$(MAKE) $(clean)=$(boot)
40570567293SAndreas Gruenbacher
40614cf11afSPaul Mackerrasarchprepare: checkbin
40714cf11afSPaul Mackerras
408c3ff2a51SChristophe Leroyifdef CONFIG_STACKPROTECTOR
409c3ff2a51SChristophe Leroyprepare: stack_protector_prepare
410c3ff2a51SChristophe Leroy
411c3ff2a51SChristophe Leroystack_protector_prepare: prepare0
41206ec27aeSChristophe Leroyifdef CONFIG_PPC64
41306ec27aeSChristophe Leroy	$(eval KBUILD_CFLAGS += -mstack-protector-guard-offset=$(shell awk '{if ($$2 == "PACA_CANARY") print $$3;}' include/generated/asm-offsets.h))
41406ec27aeSChristophe Leroyelse
415c3ff2a51SChristophe Leroy	$(eval KBUILD_CFLAGS += -mstack-protector-guard-offset=$(shell awk '{if ($$2 == "TASK_CANARY") print $$3;}' include/generated/asm-offsets.h))
416c3ff2a51SChristophe Leroyendif
41706ec27aeSChristophe Leroyendif
418c3ff2a51SChristophe Leroy
419f2910f0eSNicholas Piggin# Check toolchain versions:
420f2910f0eSNicholas Piggin# - gcc-4.6 is the minimum kernel-wide version so nothing required.
42114cf11afSPaul Mackerrascheckbin:
42260e065f7SMichael Ellerman	@if test "x${CONFIG_CPU_LITTLE_ENDIAN}" = "xy" \
42360e065f7SMichael Ellerman	    && $(LD) --version | head -1 | grep ' 2\.24$$' >/dev/null ; then \
42460e065f7SMichael Ellerman		echo -n '*** binutils 2.24 miscompiles weak symbols ' ; \
42560e065f7SMichael Ellerman		echo 'in some circumstances.' ; \
42660e065f7SMichael Ellerman		echo -n '*** Please use a different binutils version.' ; \
42760e065f7SMichael Ellerman		false ; \
42860e065f7SMichael Ellerman	fi
429