xref: /linux/arch/powerpc/Makefile (revision 5b89492c03e5c0a2c259b97d7d4c1bb9b02860aa)
114cf11afSPaul Mackerras# This file is included by the global makefile so that you can add your own
28212f898SMasahiro Yamada# architecture-specific flags and dependencies.
314cf11afSPaul Mackerras#
414cf11afSPaul Mackerras# This file is subject to the terms and conditions of the GNU General Public
514cf11afSPaul Mackerras# License.  See the file "COPYING" in the main directory of this archive
614cf11afSPaul Mackerras# for more details.
714cf11afSPaul Mackerras#
814cf11afSPaul Mackerras# Copyright (C) 1994 by Linus Torvalds
914cf11afSPaul Mackerras# Changes for PPC by Gary Thomas
1014cf11afSPaul Mackerras# Rewritten by Cort Dougan and Paul Mackerras
1114cf11afSPaul Mackerras#
1214cf11afSPaul Mackerras
1314cf11afSPaul MackerrasHAS_BIARCH	:= $(call cc-option-yn, -m32)
1414cf11afSPaul Mackerras
1514cf11afSPaul Mackerras# Set default 32 bits cross compilers for vdso and boot wrapper
1614cf11afSPaul MackerrasCROSS32_COMPILE ?=
1714cf11afSPaul Mackerras
1814cf11afSPaul Mackerrasifeq ($(HAS_BIARCH),y)
1914cf11afSPaul Mackerrasifeq ($(CROSS32_COMPILE),)
204bf4f42aSNicholas Pigginifdef CONFIG_PPC32
214bf4f42aSNicholas Piggin# These options will be overridden by any -mcpu option that the CPU
224bf4f42aSNicholas Piggin# or platform code sets later on the command line, but they are needed
234bf4f42aSNicholas Piggin# to set a sane 32-bit cpu target for the 64-bit cross compiler which
244bf4f42aSNicholas Piggin# may default to the wrong ISA.
254bf4f42aSNicholas PigginKBUILD_CFLAGS		+= -mcpu=powerpc
264bf4f42aSNicholas PigginKBUILD_AFLAGS		+= -mcpu=powerpc
274bf4f42aSNicholas Pigginendif
2814cf11afSPaul Mackerrasendif
2914cf11afSPaul Mackerrasendif
3014cf11afSPaul Mackerras
31ebd1d3b7SMathieu Malaterreifdef CONFIG_PPC_BOOK3S_32
32ebd1d3b7SMathieu MalaterreKBUILD_CFLAGS		+= -mcpu=powerpc
33ebd1d3b7SMathieu Malaterreendif
34ebd1d3b7SMathieu Malaterre
35af5cd05dSMichael Ellerman# If we're on a ppc/ppc64/ppc64le machine use that defconfig, otherwise just use
36af5cd05dSMichael Ellerman# ppc64_defconfig because we have nothing better to go on.
37af5cd05dSMichael Ellermanuname := $(shell uname -m)
38af5cd05dSMichael EllermanKBUILD_DEFCONFIG := $(if $(filter ppc%,$(uname)),$(uname),ppc64)_defconfig
398a5abdf8SPaul Mackerras
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
4514cf11afSPaul Mackerras
4668201fbbSMichael Ellerman# BITS is used as extension for files which are available in a 32 bit
4768201fbbSMichael Ellerman# and a 64 bit version to simplify shared Makefiles.
4868201fbbSMichael Ellerman# e.g.: obj-y += foo_$(BITS).o
4968201fbbSMichael Ellermanexport BITS
5068201fbbSMichael Ellerman
5168201fbbSMichael Ellermanifdef CONFIG_PPC64
5268201fbbSMichael Ellerman        BITS := 64
5368201fbbSMichael Ellermanelse
5468201fbbSMichael Ellerman        BITS := 32
5514cf11afSPaul Mackerrasendif
5614cf11afSPaul Mackerras
5757073e27SMichael Ellermanmachine-y = ppc
5857073e27SMichael Ellermanmachine-$(CONFIG_PPC64) += 64
5957073e27SMichael Ellermanmachine-$(CONFIG_CPU_LITTLE_ENDIAN) += le
6057073e27SMichael EllermanUTS_MACHINE := $(subst $(space),,$(machine-y))
61190554dbSStephen Rothwell
62b40b2386SMichael Ellerman# XXX This needs to be before we override LD below
63b40b2386SMichael Ellermanifdef CONFIG_PPC32
64b40b2386SMichael EllermanKBUILD_LDFLAGS_MODULE += arch/powerpc/lib/crtsavres.o
65b40b2386SMichael Ellermanelse
66052c805aSMasahiro Yamadaifeq ($(call ld-ifversion, -ge, 22500, y),y)
67b40b2386SMichael Ellerman# Have the linker provide sfpr if possible.
68b40b2386SMichael Ellerman# There is a corresponding test in arch/powerpc/lib/Makefile
69b40b2386SMichael EllermanKBUILD_LDFLAGS_MODULE += --save-restore-funcs
70b40b2386SMichael Ellermanelse
71b40b2386SMichael EllermanKBUILD_LDFLAGS_MODULE += arch/powerpc/lib/crtsavres.o
72b40b2386SMichael Ellermanendif
73b40b2386SMichael Ellermanendif
74b40b2386SMichael Ellerman
75badf436fSRodrigo R. Galvaoifdef CONFIG_CPU_LITTLE_ENDIAN
761421dc6dSNicholas PigginKBUILD_CFLAGS	+= -mlittle-endian
77d503ac53SMasahiro YamadaKBUILD_LDFLAGS	+= -EL
78d72b0801SIan MunsieLDEMULATION	:= lppc
79d72b0801SIan MunsieGNUTARGET	:= powerpcle
80d72b0801SIan MunsieMULTIPLEWORD	:= -mno-multiple
81d3d35d95STony BreedsKBUILD_CFLAGS_MODULE += $(call cc-option,-mno-save-toc-indirect)
82d72b0801SIan Munsieelse
831421dc6dSNicholas PigginKBUILD_CFLAGS += $(call cc-option,-mbig-endian)
84d503ac53SMasahiro YamadaKBUILD_LDFLAGS	+= -EB
85d72b0801SIan MunsieLDEMULATION	:= ppc
86d72b0801SIan MunsieGNUTARGET	:= powerpc
87d72b0801SIan MunsieMULTIPLEWORD	:= -mmultiple
88d72b0801SIan Munsieendif
89d72b0801SIan Munsie
904dc831aaSNicholas Pigginifdef CONFIG_PPC64
91465bfd9cSNathan Chancellorifndef CONFIG_CC_IS_CLANG
92661aa880SChristophe Leroycflags-$(CONFIG_PPC64_ELF_ABI_V1)	+= $(call cc-option,-mabi=elfv1)
93661aa880SChristophe Leroycflags-$(CONFIG_PPC64_ELF_ABI_V1)	+= $(call cc-option,-mcall-aixdesc)
94661aa880SChristophe Leroyaflags-$(CONFIG_PPC64_ELF_ABI_V1)	+= $(call cc-option,-mabi=elfv1)
95661aa880SChristophe Leroyaflags-$(CONFIG_PPC64_ELF_ABI_V2)	+= -mabi=elfv2
964dc831aaSNicholas Pigginendif
97465bfd9cSNathan Chancellorendif
984dc831aaSNicholas Piggin
99076f421dSMasahiro Yamadaifndef CONFIG_CC_IS_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)
11214cf11afSPaul Mackerrasendif
11314cf11afSPaul Mackerras
114c3ff2a51SChristophe Leroycflags-$(CONFIG_STACKPROTECTOR)	+= -mstack-protector-guard=tls
11506ec27aeSChristophe Leroyifdef CONFIG_PPC64
11606ec27aeSChristophe Leroycflags-$(CONFIG_STACKPROTECTOR)	+= -mstack-protector-guard-reg=r13
11706ec27aeSChristophe Leroyelse
118c3ff2a51SChristophe Leroycflags-$(CONFIG_STACKPROTECTOR)	+= -mstack-protector-guard-reg=r2
11906ec27aeSChristophe Leroyendif
120c3ff2a51SChristophe Leroy
1219c5f7d39SSuzuki PouloseLDFLAGS_vmlinux-y := -Bstatic
1229c5f7d39SSuzuki PouloseLDFLAGS_vmlinux-$(CONFIG_RELOCATABLE) := -pie
12303557853SFangrui SongLDFLAGS_vmlinux-$(CONFIG_RELOCATABLE) += -z notext
1249c5f7d39SSuzuki PouloseLDFLAGS_vmlinux	:= $(LDFLAGS_vmlinux-y)
12514cf11afSPaul Mackerras
126badf436fSRodrigo R. Galvaoifdef CONFIG_PPC64
1271fbe9cf2SAnton Blanchardifeq ($(call cc-option-yn,-mcmodel=medium),y)
1281fbe9cf2SAnton Blanchard	# -mcmodel=medium breaks modules because it uses 32bit offsets from
1291fbe9cf2SAnton Blanchard	# the TOC pointer to create pointers where possible. Pointers into the
1301fbe9cf2SAnton Blanchard	# percpu data area are created by this method.
1311fbe9cf2SAnton Blanchard	#
1321fbe9cf2SAnton Blanchard	# The kernel module loader relocates the percpu data section from the
1331fbe9cf2SAnton Blanchard	# original location (starting with 0xd...) to somewhere in the base
1341fbe9cf2SAnton Blanchard	# kernel percpu data space (starting with 0xc...). We need a full
1351fbe9cf2SAnton Blanchard	# 64bit relocation for this to work, hence -mcmodel=large.
1361fbe9cf2SAnton Blanchard	KBUILD_CFLAGS_MODULE += -mcmodel=large
1371fbe9cf2SAnton Blanchardelse
1381fbe9cf2SAnton Blanchard	export NO_MINIMAL_TOC := -mno-minimal-toc
1391fbe9cf2SAnton Blanchardendif
1401fbe9cf2SAnton Blanchardendif
1411fbe9cf2SAnton Blanchard
142a50a862eSAnton BlanchardCFLAGS-$(CONFIG_PPC64)	:= $(call cc-option,-mtraceback=no)
143465bfd9cSNathan Chancellorifndef CONFIG_CC_IS_CLANG
144661aa880SChristophe Leroyifdef CONFIG_PPC64_ELF_ABI_V2
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
152465bfd9cSNathan Chancellorendif
153238abecdSAnton BlanchardCFLAGS-$(CONFIG_PPC64)	+= $(call cc-option,-mcmodel=medium,$(call cc-option,-mminimal-toc))
15498679fb0SAnton BlanchardCFLAGS-$(CONFIG_PPC64)	+= $(call cc-option,-mno-pointers-to-nested-functions)
15551d42f0fSSegher Boessenkool
15672e7bcc2SJoel Stanley# Clang unconditionally reserves r2 on ppc32 and does not support the flag
15772e7bcc2SJoel Stanley# https://bugs.llvm.org/show_bug.cgi?id=39555
15872e7bcc2SJoel StanleyCFLAGS-$(CONFIG_PPC32)	:= $(call cc-option, -ffixed-r2)
15972e7bcc2SJoel Stanley
16072e7bcc2SJoel Stanley# Clang doesn't support -mmultiple / -mno-multiple
16172e7bcc2SJoel Stanley# https://bugs.llvm.org/show_bug.cgi?id=39556
16272e7bcc2SJoel StanleyCFLAGS-$(CONFIG_PPC32)	+= $(call cc-option, $(MULTIPLEWORD))
16372e7bcc2SJoel Stanley
16451d42f0fSSegher BoessenkoolCFLAGS-$(CONFIG_PPC32)	+= $(call cc-option,-mno-readonly-in-sdata)
165d23c6fb4SAnton Blanchard
166badf436fSRodrigo R. Galvaoifdef CONFIG_PPC_BOOK3S_64
167badf436fSRodrigo R. Galvaoifdef CONFIG_CPU_LITTLE_ENDIAN
168a73657eaSNicholas PigginCFLAGS-$(CONFIG_GENERIC_CPU) += -mcpu=power8
1694b7e5532SNicholas PigginCFLAGS-$(CONFIG_GENERIC_CPU) += $(call cc-option,-mtune=power9,-mtune=power8)
170a73657eaSNicholas Pigginelse
171471d7ff8SNicholas PigginCFLAGS-$(CONFIG_GENERIC_CPU) += $(call cc-option,-mtune=power7,$(call cc-option,-mtune=power5))
172471d7ff8SNicholas PigginCFLAGS-$(CONFIG_GENERIC_CPU) += $(call cc-option,-mcpu=power5,-mcpu=power4)
173a73657eaSNicholas Pigginendif
1742863dd2dSMichael Ellermanelse ifdef CONFIG_PPC_BOOK3E_64
17501718ba6SScott WoodCFLAGS-$(CONFIG_GENERIC_CPU) += -mcpu=powerpc64
17601718ba6SScott Woodendif
17701718ba6SScott Wood
1782a056f58SNicholas Pigginifdef CONFIG_FUNCTION_TRACER
1792a056f58SNicholas PigginCC_FLAGS_FTRACE := -pg
1808c50b72aSTorsten Duweifdef CONFIG_MPROFILE_KERNEL
1812a056f58SNicholas PigginCC_FLAGS_FTRACE += -mprofile-kernel
1822a056f58SNicholas Pigginendif
1838c50b72aSTorsten Duweendif
1848c50b72aSTorsten Duwe
185cc62d20cSChristophe LeroyCFLAGS-$(CONFIG_TARGET_CPU_BOOL) += $(call cc-option,-mcpu=$(CONFIG_TARGET_CPU))
186d23c6fb4SAnton Blanchard
187cbf8a358STiejun Chen# Altivec option not allowed with e500mc64 in GCC.
188badf436fSRodrigo R. Galvaoifdef CONFIG_ALTIVEC
189cbf8a358STiejun ChenE5500_CPU := -mcpu=powerpc64
190cbf8a358STiejun Chenelse
19101718ba6SScott WoodE5500_CPU := $(call cc-option,-mcpu=e500mc64,-mcpu=powerpc64)
192cbf8a358STiejun Chenendif
19301718ba6SScott WoodCFLAGS-$(CONFIG_E5500_CPU) += $(E5500_CPU)
19401718ba6SScott WoodCFLAGS-$(CONFIG_E6500_CPU) += $(call cc-option,-mcpu=e6500,$(E5500_CPU))
19501718ba6SScott Wood
196badf436fSRodrigo R. Galvaoifdef CONFIG_PPC32
197badf436fSRodrigo R. Galvaoifdef CONFIG_PPC_E500MC
198847f56b0SScott WoodCFLAGS-y += $(call cc-option,-mcpu=e500mc,-mcpu=powerpc)
199847f56b0SScott Woodelse
200847f56b0SScott WoodCFLAGS-$(CONFIG_E500) += $(call cc-option,-mcpu=8540 -msoft-float,-mcpu=powerpc)
201847f56b0SScott Woodendif
202847f56b0SScott Woodendif
203847f56b0SScott Wood
2047998eb3dSGuenter Roeckasinstr := $(call as-instr,lis 9$(comma)foo@high,-DHAVE_AS_ATHIGH=1)
2057998eb3dSGuenter Roeck
2069cc342f6SMasahiro YamadaKBUILD_CPPFLAGS	+= -I $(srctree)/arch/$(ARCH) $(asinstr)
207b00899b8SMasahiro YamadaKBUILD_AFLAGS	+= $(AFLAGS-y)
208a50a862eSAnton BlanchardKBUILD_CFLAGS	+= $(call cc-option,-msoft-float)
209b00899b8SMasahiro YamadaKBUILD_CFLAGS	+= -pipe $(CFLAGS-y)
210a0f97e06SSam RavnborgCPP		= $(CC) -E $(KBUILD_CFLAGS)
21114cf11afSPaul Mackerras
21268201fbbSMichael EllermanCHECKFLAGS	+= -m$(BITS) -D__powerpc__ -D__powerpc$(BITS)__
21362c2c5cfSDaniel Axtensifdef CONFIG_CPU_BIG_ENDIAN
21462c2c5cfSDaniel AxtensCHECKFLAGS	+= -D__BIG_ENDIAN__
21562c2c5cfSDaniel Axtenselse
216*5b89492cSChristophe LeroyCHECKFLAGS	+= -D__LITTLE_ENDIAN__
21762c2c5cfSDaniel Axtensendif
21814cf11afSPaul Mackerras
219badf436fSRodrigo R. Galvaoifdef CONFIG_476FPE_ERR46
220d5b35cffSAlistair Popple	KBUILD_LDFLAGS_MODULE += --ppc476-workaround \
221d5b35cffSAlistair Popple		-T $(srctree)/arch/powerpc/platforms/44x/ppc476_modules.lds
222d5b35cffSAlistair Poppleendif
223d5b35cffSAlistair Popple
224d23c6fb4SAnton Blanchard# No AltiVec or VSX instructions when building kernel
225a0f97e06SSam RavnborgKBUILD_CFLAGS += $(call cc-option,-mno-altivec)
226d23c6fb4SAnton BlanchardKBUILD_CFLAGS += $(call cc-option,-mno-vsx)
227d3f67fbbSPaul Mackerras
2280197cd2eSKumar Gala# No SPE instruction when building kernel
229ce400c01SThiemo Seufer# (We use all available options to help semi-broken compilers)
2300197cd2eSKumar GalaKBUILD_CFLAGS += $(call cc-option,-mno-spe)
231ce400c01SThiemo SeuferKBUILD_CFLAGS += $(call cc-option,-mspe=no)
2320197cd2eSKumar Gala
233ba96301cSNaveen N. Rao# Don't emit .eh_frame since we have no use for it
234ba96301cSNaveen N. RaoKBUILD_CFLAGS += -fno-asynchronous-unwind-tables
235ba96301cSNaveen N. Rao
23657647a4dSBenjamin Herrenschmidt# Never use string load/store instructions as they are
23757647a4dSBenjamin Herrenschmidt# often slow when they are implemented at all
238a50a862eSAnton BlanchardKBUILD_CFLAGS		+= $(call cc-option,-mno-string)
23914cf11afSPaul Mackerras
240548ad77dSImre Kalozcpu-as-$(CONFIG_40x)		+= -Wa,-m405
241548ad77dSImre Kalozcpu-as-$(CONFIG_44x)		+= -Wa,-m440
2429ddf0075SAnton Blanchardcpu-as-$(CONFIG_ALTIVEC)	+= $(call as-option,-Wa$(comma)-maltivec)
2434e4a4b75SJames Clarkecpu-as-$(CONFIG_E500)		+= -Wa,-me500
244960e3002SJoel Stanley
245960e3002SJoel Stanley# When using '-many -mpower4' gas will first try and find a matching power4
246960e3002SJoel Stanley# mnemonic and failing that it will allow any valid mnemonic that GAS knows
247960e3002SJoel Stanley# about. GCC will pass -many to GAS when assembling, clang does not.
248f5140cabSDaniel Axtens# LLVM IAS doesn't understand either flag: https://github.com/ClangBuiltLinux/linux/issues/675
249f5140cabSDaniel Axtens# but LLVM IAS only supports ISA >= 2.06 for Book3S 64 anyway...
250f5140cabSDaniel Axtenscpu-as-$(CONFIG_PPC_BOOK3S_64)	+= $(call as-option,-Wa$(comma)-mpower4) $(call as-option,-Wa$(comma)-many)
25169a84059SMichael Jeansoncpu-as-$(CONFIG_PPC_E500MC)	+= $(call as-option,-Wa$(comma)-me500mc)
25214cf11afSPaul Mackerras
253222d394dSSam RavnborgKBUILD_AFLAGS += $(cpu-as-y)
254a0f97e06SSam RavnborgKBUILD_CFLAGS += $(cpu-as-y)
25514cf11afSPaul Mackerras
256164af597SMichael EllermanKBUILD_AFLAGS += $(aflags-y)
257164af597SMichael EllermanKBUILD_CFLAGS += $(cflags-y)
258164af597SMichael Ellerman
259533090e5SChristophe Leroyhead-$(CONFIG_PPC64)		:= arch/powerpc/kernel/head_64.o
260533090e5SChristophe Leroyhead-$(CONFIG_PPC_BOOK3S_32)	:= arch/powerpc/kernel/head_book3s_32.o
261968159c0SChristophe Leroyhead-$(CONFIG_PPC_8xx)		:= arch/powerpc/kernel/head_8xx.o
26215f6527eSJosh Boyerhead-$(CONFIG_40x)		:= arch/powerpc/kernel/head_40x.o
26314cf11afSPaul Mackerrashead-$(CONFIG_44x)		:= arch/powerpc/kernel/head_44x.o
26414cf11afSPaul Mackerrashead-$(CONFIG_FSL_BOOKE)	:= arch/powerpc/kernel/head_fsl_booke.o
26514cf11afSPaul Mackerras
2669994a338SPaul Mackerrashead-$(CONFIG_PPC64)		+= arch/powerpc/kernel/entry_64.o
26714cf11afSPaul Mackerrashead-$(CONFIG_PPC_FPU)		+= arch/powerpc/kernel/fpu.o
268e821ea70SBenjamin Herrenschmidthead-$(CONFIG_ALTIVEC)		+= arch/powerpc/kernel/vector.o
2695ac47f7aSAnton Blanchardhead-$(CONFIG_PPC_OF_BOOT_TRAMPOLINE)  += arch/powerpc/kernel/prom_init.o
27014cf11afSPaul Mackerras
271135f0b17STom Rini# Default to zImage, override when needed
27225431333SGrant Likelyall: zImage
27314cf11afSPaul Mackerras
274e32e78c5SSam Ravnborg# With make 3.82 we cannot mix normal and wildcard targets
275c686ecf5SAnatolij GustschinBOOT_TARGETS1 := zImage zImage.initrd uImage
27611eab297SBenjamin HerrenschmidtBOOT_TARGETS2 := zImage% dtbImage% treeImage.% cuImage.% simpleImage.% uImage.%
277cabb5587SStephen Rothwell
278e32e78c5SSam RavnborgPHONY += $(BOOT_TARGETS1) $(BOOT_TARGETS2)
279cabb5587SStephen Rothwell
28094b212c2SPaul Mackerrasboot := arch/$(ARCH)/boot
28114cf11afSPaul Mackerras
282e32e78c5SSam Ravnborg$(BOOT_TARGETS1): vmlinux
2831196d7aaSMichael Ellerman	$(Q)$(MAKE) $(build)=$(boot) $(patsubst %,$(boot)/%,$@)
284e32e78c5SSam Ravnborg$(BOOT_TARGETS2): vmlinux
2851196d7aaSMichael Ellerman	$(Q)$(MAKE) $(build)=$(boot) $(patsubst %,$(boot)/%,$@)
28614cf11afSPaul Mackerras
287e32e78c5SSam Ravnborg
288d42c6d0fSMichael EllermanPHONY += bootwrapper_install
289e32e78c5SSam Ravnborgbootwrapper_install:
2901196d7aaSMichael Ellerman	$(Q)$(MAKE) $(build)=$(boot) $(patsubst %,$(boot)/%,$@)
291e32e78c5SSam Ravnborg
292ea4d1a87SCyril Bur# Used to create 'merged defconfigs'
293ea4d1a87SCyril Bur# To use it $(call) it with the first argument as the base defconfig
294ea4d1a87SCyril Bur# and the second argument as a space separated list of .config files to merge,
295ea4d1a87SCyril Bur# without the .config suffix.
296ea4d1a87SCyril Burdefine merge_into_defconfig
297ea4d1a87SCyril Bur	$(Q)$(CONFIG_SHELL) $(srctree)/scripts/kconfig/merge_config.sh \
298ea4d1a87SCyril Bur		-m -O $(objtree) $(srctree)/arch/$(ARCH)/configs/$(1) \
299ea4d1a87SCyril Bur		$(foreach config,$(2),$(srctree)/arch/$(ARCH)/configs/$(config).config)
300ea4d1a87SCyril Bur	+$(Q)$(MAKE) -f $(srctree)/Makefile olddefconfig
301ea4d1a87SCyril Burendef
302ea4d1a87SCyril Bur
303ea4d1a87SCyril BurPHONY += pseries_le_defconfig
304ea4d1a87SCyril Burpseries_le_defconfig:
305ea4d1a87SCyril Bur	$(call merge_into_defconfig,pseries_defconfig,le)
306ea4d1a87SCyril Bur
3072adc48a6SMichael EllermanPHONY += ppc64le_defconfig
3082adc48a6SMichael Ellermanppc64le_defconfig:
3092adc48a6SMichael Ellerman	$(call merge_into_defconfig,ppc64_defconfig,le)
3102adc48a6SMichael Ellerman
311721c01baSSatheesh RajendranPHONY += ppc64le_guest_defconfig
312721c01baSSatheesh Rajendranppc64le_guest_defconfig:
313721c01baSSatheesh Rajendran	$(call merge_into_defconfig,ppc64_defconfig,le guest)
314721c01baSSatheesh Rajendran
315721c01baSSatheesh RajendranPHONY += ppc64_guest_defconfig
316721c01baSSatheesh Rajendranppc64_guest_defconfig:
317721c01baSSatheesh Rajendran	$(call merge_into_defconfig,ppc64_defconfig,be guest)
318721c01baSSatheesh Rajendran
3193603c52fSMichael EllermanPHONY += powernv_be_defconfig
3203603c52fSMichael Ellermanpowernv_be_defconfig:
3213603c52fSMichael Ellerman	$(call merge_into_defconfig,powernv_defconfig,be)
3223603c52fSMichael Ellerman
32344d54014SScott WoodPHONY += mpc85xx_defconfig
32444d54014SScott Woodmpc85xx_defconfig:
32558b12eb2SMichael Ellerman	$(call merge_into_defconfig,mpc85xx_base.config,\
32644d54014SScott Wood		85xx-32bit 85xx-hw fsl-emb-nonhw)
32744d54014SScott Wood
32844d54014SScott WoodPHONY += mpc85xx_smp_defconfig
32944d54014SScott Woodmpc85xx_smp_defconfig:
33058b12eb2SMichael Ellerman	$(call merge_into_defconfig,mpc85xx_base.config,\
33144d54014SScott Wood		85xx-32bit 85xx-smp 85xx-hw fsl-emb-nonhw)
33244d54014SScott Wood
33344d54014SScott WoodPHONY += corenet32_smp_defconfig
33444d54014SScott Woodcorenet32_smp_defconfig:
33558b12eb2SMichael Ellerman	$(call merge_into_defconfig,corenet_base.config,\
336e0b80f00SClaudiu Manoil		85xx-32bit 85xx-smp 85xx-hw fsl-emb-nonhw dpaa)
33744d54014SScott Wood
33844d54014SScott WoodPHONY += corenet64_smp_defconfig
33944d54014SScott Woodcorenet64_smp_defconfig:
34058b12eb2SMichael Ellerman	$(call merge_into_defconfig,corenet_base.config,\
341e0b80f00SClaudiu Manoil		85xx-64bit 85xx-smp altivec 85xx-hw fsl-emb-nonhw dpaa)
34244d54014SScott Wood
34343de32c5SAlessio Igor BoganiPHONY += mpc86xx_defconfig
34443de32c5SAlessio Igor Boganimpc86xx_defconfig:
34558b12eb2SMichael Ellerman	$(call merge_into_defconfig,mpc86xx_base.config,\
34643de32c5SAlessio Igor Bogani		86xx-hw fsl-emb-nonhw)
34743de32c5SAlessio Igor Bogani
34843de32c5SAlessio Igor BoganiPHONY += mpc86xx_smp_defconfig
34943de32c5SAlessio Igor Boganimpc86xx_smp_defconfig:
35058b12eb2SMichael Ellerman	$(call merge_into_defconfig,mpc86xx_base.config,\
35143de32c5SAlessio Igor Bogani		86xx-smp 86xx-hw fsl-emb-nonhw)
35243de32c5SAlessio Igor Bogani
3538db0c9d4SMichael EllermanPHONY += ppc32_allmodconfig
3548db0c9d4SMichael Ellermanppc32_allmodconfig:
3558db0c9d4SMichael Ellerman	$(Q)$(MAKE) KCONFIG_ALLCONFIG=$(srctree)/arch/powerpc/configs/book3s_32.config \
3568db0c9d4SMichael Ellerman		-f $(srctree)/Makefile allmodconfig
3578db0c9d4SMichael Ellerman
358a273fa38SMichael EllermanPHONY += ppc_defconfig
359a273fa38SMichael Ellermanppc_defconfig:
360a273fa38SMichael Ellerman	$(call merge_into_defconfig,book3s_32.config,)
361a273fa38SMichael 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
3675d823447SMichael EllermanPHONY += ppc64le_allnoconfig
3685d823447SMichael Ellermanppc64le_allnoconfig:
3695d823447SMichael Ellerman	$(Q)$(MAKE) KCONFIG_ALLCONFIG=$(srctree)/arch/powerpc/configs/ppc64le.config \
3705d823447SMichael Ellerman		-f $(srctree)/Makefile allnoconfig
3715d823447SMichael Ellerman
37264de5d8dSMichael EllermanPHONY += ppc64_book3e_allmodconfig
37364de5d8dSMichael Ellermanppc64_book3e_allmodconfig:
37464de5d8dSMichael Ellerman	$(Q)$(MAKE) KCONFIG_ALLCONFIG=$(srctree)/arch/powerpc/configs/85xx-64bit.config \
37564de5d8dSMichael Ellerman		-f $(srctree)/Makefile allmodconfig
37664de5d8dSMichael Ellerman
377f259fb89SMichael EllermanPHONY += ppc32_randconfig
378f259fb89SMichael Ellermanppc32_randconfig:
379f259fb89SMichael Ellerman	$(Q)$(MAKE) KCONFIG_ALLCONFIG=$(srctree)/arch/powerpc/configs/32-bit.config \
380f259fb89SMichael Ellerman		-f $(srctree)/Makefile randconfig
381f259fb89SMichael Ellerman
382f259fb89SMichael EllermanPHONY += ppc64_randconfig
383f259fb89SMichael Ellermanppc64_randconfig:
384f259fb89SMichael Ellerman	$(Q)$(MAKE) KCONFIG_ALLCONFIG=$(srctree)/arch/powerpc/configs/64-bit.config \
385f259fb89SMichael Ellerman		-f $(srctree)/Makefile randconfig
386f259fb89SMichael Ellerman
38714cf11afSPaul Mackerrasdefine archhelp
38870bf0333SGrant Likely  @echo '* zImage          - Build default images selected by kernel config'
38970bf0333SGrant Likely  @echo '  zImage.*        - Compressed kernel image (arch/$(ARCH)/boot/zImage.*)'
39070bf0333SGrant Likely  @echo '  uImage          - U-Boot native image format'
39170bf0333SGrant Likely  @echo '  cuImage.<dt>    - Backwards compatible U-Boot image for older'
39270bf0333SGrant Likely  @echo '                    versions which do not support device trees'
39370bf0333SGrant Likely  @echo '  dtbImage.<dt>   - zImage with an embedded device tree blob'
39470bf0333SGrant Likely  @echo '  simpleImage.<dt> - Firmware independent image.'
39570bf0333SGrant Likely  @echo '  treeImage.<dt>  - Support for older IBM 4xx firmware (not U-Boot)'
39614cf11afSPaul Mackerras  @echo '  install         - Install kernel using'
397caa27b66SSam Ravnborg  @echo '                    (your) ~/bin/$(INSTALLKERNEL) or'
398caa27b66SSam Ravnborg  @echo '                    (distribution) /sbin/$(INSTALLKERNEL) or'
39914cf11afSPaul Mackerras  @echo '                    install to $$(INSTALL_PATH) and run lilo'
400437a58dbSPaul Mackerras  @echo '  *_defconfig     - Select default config from arch/$(ARCH)/configs'
40170bf0333SGrant Likely  @echo ''
40270bf0333SGrant Likely  @echo '  Targets with <dt> embed a device tree blob inside the image'
40370bf0333SGrant Likely  @echo '  These targets support board with firmware that does not'
40470bf0333SGrant Likely  @echo '  support passing a device tree directly.  Replace <dt> with the'
40570bf0333SGrant Likely  @echo '  name of a dts file from the arch/$(ARCH)/boot/dts/ directory'
40670bf0333SGrant Likely  @echo '  (minus the .dts extension).'
40714cf11afSPaul Mackerrasendef
40814cf11afSPaul Mackerras
409d42c6d0fSMichael EllermanPHONY += install
4103f85d63eSSam Ravnborginstall:
41186ff0bceSMasahiro Yamada	sh -x $(srctree)/$(boot)/install.sh "$(KERNELRELEASE)" vmlinux \
41286ff0bceSMasahiro Yamada	System.map "$(INSTALL_PATH)"
413928370c6SAkinobu Mita
41491bf6955SChristophe Leroyifeq ($(KBUILD_EXTMOD),)
41591bf6955SChristophe Leroy# We need to generate vdso-offsets.h before compiling certain files in kernel/.
41691bf6955SChristophe Leroy# In order to do that, we should use the archprepare target, but we can't since
41791bf6955SChristophe Leroy# asm-offsets.h is included in some files used to generate vdso-offsets.h, and
41891bf6955SChristophe Leroy# asm-offsets.h is built in prepare0, for which archprepare is a dependency.
41991bf6955SChristophe Leroy# Therefore we need to generate the header after prepare0 has been made, hence
42091bf6955SChristophe Leroy# this hack.
42191bf6955SChristophe Leroyprepare: vdso_prepare
42291bf6955SChristophe Leroyvdso_prepare: prepare0
42391bf6955SChristophe Leroy	$(if $(CONFIG_VDSO32),$(Q)$(MAKE) \
424fd1feadeSChristophe Leroy		$(build)=arch/powerpc/kernel/vdso include/generated/vdso32-offsets.h)
42591bf6955SChristophe Leroy	$(if $(CONFIG_PPC64),$(Q)$(MAKE) \
426fd1feadeSChristophe Leroy		$(build)=arch/powerpc/kernel/vdso include/generated/vdso64-offsets.h)
42791bf6955SChristophe Leroyendif
42891bf6955SChristophe Leroy
42914cf11afSPaul Mackerrasarchprepare: checkbin
43014cf11afSPaul Mackerras
431ab66dcc7SFiroz Khanarchheaders:
432ab66dcc7SFiroz Khan	$(Q)$(MAKE) $(build)=arch/powerpc/kernel/syscalls all
433ab66dcc7SFiroz Khan
434c3ff2a51SChristophe Leroyifdef CONFIG_STACKPROTECTOR
435c3ff2a51SChristophe Leroyprepare: stack_protector_prepare
43614cf11afSPaul Mackerras
437d42c6d0fSMichael EllermanPHONY += stack_protector_prepare
438c3ff2a51SChristophe Leroystack_protector_prepare: prepare0
43906ec27aeSChristophe Leroyifdef CONFIG_PPC64
44006ec27aeSChristophe Leroy	$(eval KBUILD_CFLAGS += -mstack-protector-guard-offset=$(shell awk '{if ($$2 == "PACA_CANARY") print $$3;}' include/generated/asm-offsets.h))
44106ec27aeSChristophe Leroyelse
442c3ff2a51SChristophe Leroy	$(eval KBUILD_CFLAGS += -mstack-protector-guard-offset=$(shell awk '{if ($$2 == "TASK_CANARY") print $$3;}' include/generated/asm-offsets.h))
443c3ff2a51SChristophe Leroyendif
44406ec27aeSChristophe Leroyendif
445c3ff2a51SChristophe Leroy
446d42c6d0fSMichael EllermanPHONY += checkbin
447f2910f0eSNicholas Piggin# Check toolchain versions:
448f2910f0eSNicholas Piggin# - gcc-4.6 is the minimum kernel-wide version so nothing required.
44914cf11afSPaul Mackerrascheckbin:
450a3ad84daSAlan Modra	@if test "x${CONFIG_LD_IS_LLD}" != "xy" -a \
451a3ad84daSAlan Modra		"x$(call ld-ifversion, -le, 22400, y)" = "xy" ; then \
45260e065f7SMichael Ellerman		echo -n '*** binutils 2.24 miscompiles weak symbols ' ; \
45360e065f7SMichael Ellerman		echo 'in some circumstances.' ; \
454a3ad84daSAlan Modra		echo    '*** binutils 2.23 do not define the TOC symbol ' ; \
45560e065f7SMichael Ellerman		echo -n '*** Please use a different binutils version.' ; \
45660e065f7SMichael Ellerman		false ; \
45760e065f7SMichael Ellerman	fi
458