xref: /linux/arch/powerpc/Makefile (revision 3027a37c06be364e6443d3df3adf45576fba50cb)
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
33ebd1d3b7SMathieu Malaterreifdef CONFIG_PPC_BOOK3S_32
34ebd1d3b7SMathieu MalaterreKBUILD_CFLAGS		+= -mcpu=powerpc
35ebd1d3b7SMathieu Malaterreendif
36ebd1d3b7SMathieu Malaterre
37af5cd05dSMichael Ellerman# If we're on a ppc/ppc64/ppc64le machine use that defconfig, otherwise just use
38af5cd05dSMichael Ellerman# ppc64_defconfig because we have nothing better to go on.
39af5cd05dSMichael Ellermanuname := $(shell uname -m)
40af5cd05dSMichael EllermanKBUILD_DEFCONFIG := $(if $(filter ppc%,$(uname)),$(uname),ppc64)_defconfig
418a5abdf8SPaul Mackerras
4214cf11afSPaul Mackerrasnew_nm := $(shell if $(NM) --help 2>&1 | grep -- '--synthetic' > /dev/null; then echo y; else echo n; fi)
4314cf11afSPaul Mackerras
4414cf11afSPaul Mackerrasifeq ($(new_nm),y)
4514cf11afSPaul MackerrasNM		:= $(NM) --synthetic
4614cf11afSPaul Mackerrasendif
4714cf11afSPaul Mackerras
4868201fbbSMichael Ellerman# BITS is used as extension for files which are available in a 32 bit
4968201fbbSMichael Ellerman# and a 64 bit version to simplify shared Makefiles.
5068201fbbSMichael Ellerman# e.g.: obj-y += foo_$(BITS).o
5168201fbbSMichael Ellermanexport BITS
5268201fbbSMichael Ellerman
5368201fbbSMichael Ellermanifdef CONFIG_PPC64
5468201fbbSMichael Ellerman        BITS := 64
5568201fbbSMichael Ellermanelse
5668201fbbSMichael Ellerman        BITS := 32
5714cf11afSPaul Mackerrasendif
5814cf11afSPaul Mackerras
5957073e27SMichael Ellermanmachine-y = ppc
6057073e27SMichael Ellermanmachine-$(CONFIG_PPC64) += 64
6157073e27SMichael Ellermanmachine-$(CONFIG_CPU_LITTLE_ENDIAN) += le
6257073e27SMichael EllermanUTS_MACHINE := $(subst $(space),,$(machine-y))
63190554dbSStephen Rothwell
64b40b2386SMichael Ellerman# XXX This needs to be before we override LD below
65b40b2386SMichael Ellermanifdef CONFIG_PPC32
66b40b2386SMichael EllermanKBUILD_LDFLAGS_MODULE += arch/powerpc/lib/crtsavres.o
67b40b2386SMichael Ellermanelse
68052c805aSMasahiro Yamadaifeq ($(call ld-ifversion, -ge, 22500, 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
93465bfd9cSNathan Chancellorifndef CONFIG_CC_IS_CLANG
944dc831aaSNicholas Piggincflags-$(CONFIG_CPU_BIG_ENDIAN)		+= $(call cc-option,-mabi=elfv1)
954dc831aaSNicholas Piggincflags-$(CONFIG_CPU_BIG_ENDIAN)		+= $(call cc-option,-mcall-aixdesc)
964dc831aaSNicholas Pigginaflags-$(CONFIG_CPU_BIG_ENDIAN)		+= $(call cc-option,-mabi=elfv1)
974dc831aaSNicholas Pigginaflags-$(CONFIG_CPU_LITTLE_ENDIAN)	+= -mabi=elfv2
984dc831aaSNicholas Pigginendif
99465bfd9cSNathan Chancellorendif
1004dc831aaSNicholas Piggin
101076f421dSMasahiro Yamadaifndef CONFIG_CC_IS_CLANG
102164af597SMichael Ellerman  cflags-$(CONFIG_CPU_LITTLE_ENDIAN)	+= -mno-strict-align
103164af597SMichael Ellermanendif
104164af597SMichael Ellerman
1051421dc6dSNicholas Piggincflags-$(CONFIG_CPU_BIG_ENDIAN)		+= $(call cc-option,-mbig-endian)
1061421dc6dSNicholas Piggincflags-$(CONFIG_CPU_LITTLE_ENDIAN)	+= -mlittle-endian
107164af597SMichael Ellermanaflags-$(CONFIG_CPU_BIG_ENDIAN)		+= $(call cc-option,-mbig-endian)
108164af597SMichael Ellermanaflags-$(CONFIG_CPU_LITTLE_ENDIAN)	+= -mlittle-endian
109164af597SMichael Ellerman
11014cf11afSPaul Mackerrasifeq ($(HAS_BIARCH),y)
1111421dc6dSNicholas PigginKBUILD_CFLAGS	+= -m$(BITS)
1121421dc6dSNicholas PigginKBUILD_AFLAGS	+= -m$(BITS) -Wl,-a$(BITS)
113d503ac53SMasahiro YamadaKBUILD_LDFLAGS	+= -m elf$(BITS)$(LDEMULATION)
11414cf11afSPaul Mackerrasendif
11514cf11afSPaul Mackerras
116c3ff2a51SChristophe Leroycflags-$(CONFIG_STACKPROTECTOR)	+= -mstack-protector-guard=tls
11706ec27aeSChristophe Leroyifdef CONFIG_PPC64
11806ec27aeSChristophe Leroycflags-$(CONFIG_STACKPROTECTOR)	+= -mstack-protector-guard-reg=r13
11906ec27aeSChristophe Leroyelse
120c3ff2a51SChristophe Leroycflags-$(CONFIG_STACKPROTECTOR)	+= -mstack-protector-guard-reg=r2
12106ec27aeSChristophe Leroyendif
122c3ff2a51SChristophe Leroy
1239c5f7d39SSuzuki PouloseLDFLAGS_vmlinux-y := -Bstatic
1249c5f7d39SSuzuki PouloseLDFLAGS_vmlinux-$(CONFIG_RELOCATABLE) := -pie
1259c5f7d39SSuzuki PouloseLDFLAGS_vmlinux	:= $(LDFLAGS_vmlinux-y)
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)
144465bfd9cSNathan Chancellorifndef CONFIG_CC_IS_CLANG
145badf436fSRodrigo R. Galvaoifdef CONFIG_CPU_LITTLE_ENDIAN
146238abecdSAnton BlanchardCFLAGS-$(CONFIG_PPC64)	+= $(call cc-option,-mabi=elfv2,$(call cc-option,-mcall-aixdesc))
147721aeaa9SAnton BlanchardAFLAGS-$(CONFIG_PPC64)	+= $(call cc-option,-mabi=elfv2)
148721aeaa9SAnton Blanchardelse
1494dc831aaSNicholas PigginCFLAGS-$(CONFIG_PPC64)	+= $(call cc-option,-mabi=elfv1)
150238abecdSAnton BlanchardCFLAGS-$(CONFIG_PPC64)	+= $(call cc-option,-mcall-aixdesc)
1514dc831aaSNicholas PigginAFLAGS-$(CONFIG_PPC64)	+= $(call cc-option,-mabi=elfv1)
152721aeaa9SAnton Blanchardendif
153465bfd9cSNathan Chancellorendif
154238abecdSAnton BlanchardCFLAGS-$(CONFIG_PPC64)	+= $(call cc-option,-mcmodel=medium,$(call cc-option,-mminimal-toc))
15598679fb0SAnton BlanchardCFLAGS-$(CONFIG_PPC64)	+= $(call cc-option,-mno-pointers-to-nested-functions)
15651d42f0fSSegher Boessenkool
15772e7bcc2SJoel Stanley# Clang unconditionally reserves r2 on ppc32 and does not support the flag
15872e7bcc2SJoel Stanley# https://bugs.llvm.org/show_bug.cgi?id=39555
15972e7bcc2SJoel StanleyCFLAGS-$(CONFIG_PPC32)	:= $(call cc-option, -ffixed-r2)
16072e7bcc2SJoel Stanley
16172e7bcc2SJoel Stanley# Clang doesn't support -mmultiple / -mno-multiple
16272e7bcc2SJoel Stanley# https://bugs.llvm.org/show_bug.cgi?id=39556
16372e7bcc2SJoel StanleyCFLAGS-$(CONFIG_PPC32)	+= $(call cc-option, $(MULTIPLEWORD))
16472e7bcc2SJoel Stanley
16551d42f0fSSegher BoessenkoolCFLAGS-$(CONFIG_PPC32)	+= $(call cc-option,-mno-readonly-in-sdata)
166d23c6fb4SAnton Blanchard
167badf436fSRodrigo R. Galvaoifdef CONFIG_PPC_BOOK3S_64
168badf436fSRodrigo R. Galvaoifdef CONFIG_CPU_LITTLE_ENDIAN
169a73657eaSNicholas PigginCFLAGS-$(CONFIG_GENERIC_CPU) += -mcpu=power8
1704b7e5532SNicholas PigginCFLAGS-$(CONFIG_GENERIC_CPU) += $(call cc-option,-mtune=power9,-mtune=power8)
171a73657eaSNicholas Pigginelse
172471d7ff8SNicholas PigginCFLAGS-$(CONFIG_GENERIC_CPU) += $(call cc-option,-mtune=power7,$(call cc-option,-mtune=power5))
173471d7ff8SNicholas PigginCFLAGS-$(CONFIG_GENERIC_CPU) += $(call cc-option,-mcpu=power5,-mcpu=power4)
174a73657eaSNicholas Pigginendif
17501718ba6SScott Woodelse
17601718ba6SScott WoodCFLAGS-$(CONFIG_GENERIC_CPU) += -mcpu=powerpc64
17701718ba6SScott Woodendif
17801718ba6SScott Wood
1792a056f58SNicholas Pigginifdef CONFIG_FUNCTION_TRACER
1802a056f58SNicholas PigginCC_FLAGS_FTRACE := -pg
1818c50b72aSTorsten Duweifdef CONFIG_MPROFILE_KERNEL
1822a056f58SNicholas PigginCC_FLAGS_FTRACE += -mprofile-kernel
1832a056f58SNicholas Pigginendif
1848c50b72aSTorsten Duweendif
1858c50b72aSTorsten Duwe
186cc62d20cSChristophe LeroyCFLAGS-$(CONFIG_TARGET_CPU_BOOL) += $(call cc-option,-mcpu=$(CONFIG_TARGET_CPU))
187d23c6fb4SAnton Blanchard
188cbf8a358STiejun Chen# Altivec option not allowed with e500mc64 in GCC.
189badf436fSRodrigo R. Galvaoifdef CONFIG_ALTIVEC
190cbf8a358STiejun ChenE5500_CPU := -mcpu=powerpc64
191cbf8a358STiejun Chenelse
19201718ba6SScott WoodE5500_CPU := $(call cc-option,-mcpu=e500mc64,-mcpu=powerpc64)
193cbf8a358STiejun Chenendif
19401718ba6SScott WoodCFLAGS-$(CONFIG_E5500_CPU) += $(E5500_CPU)
19501718ba6SScott WoodCFLAGS-$(CONFIG_E6500_CPU) += $(call cc-option,-mcpu=e6500,$(E5500_CPU))
19601718ba6SScott Wood
197badf436fSRodrigo R. Galvaoifdef CONFIG_PPC32
198badf436fSRodrigo R. Galvaoifdef CONFIG_PPC_E500MC
199847f56b0SScott WoodCFLAGS-y += $(call cc-option,-mcpu=e500mc,-mcpu=powerpc)
200847f56b0SScott Woodelse
201847f56b0SScott WoodCFLAGS-$(CONFIG_E500) += $(call cc-option,-mcpu=8540 -msoft-float,-mcpu=powerpc)
202847f56b0SScott Woodendif
203847f56b0SScott Woodendif
204847f56b0SScott Wood
2057998eb3dSGuenter Roeckasinstr := $(call as-instr,lis 9$(comma)foo@high,-DHAVE_AS_ATHIGH=1)
2067998eb3dSGuenter Roeck
2079cc342f6SMasahiro YamadaKBUILD_CPPFLAGS	+= -I $(srctree)/arch/$(ARCH) $(asinstr)
208b00899b8SMasahiro YamadaKBUILD_AFLAGS	+= $(AFLAGS-y)
209a50a862eSAnton BlanchardKBUILD_CFLAGS	+= $(call cc-option,-msoft-float)
210b00899b8SMasahiro YamadaKBUILD_CFLAGS	+= -pipe $(CFLAGS-y)
211a0f97e06SSam RavnborgCPP		= $(CC) -E $(KBUILD_CFLAGS)
21214cf11afSPaul Mackerras
21368201fbbSMichael EllermanCHECKFLAGS	+= -m$(BITS) -D__powerpc__ -D__powerpc$(BITS)__
21462c2c5cfSDaniel Axtensifdef CONFIG_CPU_BIG_ENDIAN
21562c2c5cfSDaniel AxtensCHECKFLAGS	+= -D__BIG_ENDIAN__
21662c2c5cfSDaniel Axtenselse
21762c2c5cfSDaniel AxtensCHECKFLAGS	+= -D__LITTLE_ENDIAN__
21862c2c5cfSDaniel Axtensendif
21914cf11afSPaul Mackerras
220badf436fSRodrigo R. Galvaoifdef CONFIG_476FPE_ERR46
221d5b35cffSAlistair Popple	KBUILD_LDFLAGS_MODULE += --ppc476-workaround \
222d5b35cffSAlistair Popple		-T $(srctree)/arch/powerpc/platforms/44x/ppc476_modules.lds
223d5b35cffSAlistair Poppleendif
224d5b35cffSAlistair Popple
225d23c6fb4SAnton Blanchard# No AltiVec or VSX instructions when building kernel
226a0f97e06SSam RavnborgKBUILD_CFLAGS += $(call cc-option,-mno-altivec)
227d23c6fb4SAnton BlanchardKBUILD_CFLAGS += $(call cc-option,-mno-vsx)
228d3f67fbbSPaul Mackerras
2290197cd2eSKumar Gala# No SPE instruction when building kernel
230ce400c01SThiemo Seufer# (We use all available options to help semi-broken compilers)
2310197cd2eSKumar GalaKBUILD_CFLAGS += $(call cc-option,-mno-spe)
232ce400c01SThiemo SeuferKBUILD_CFLAGS += $(call cc-option,-mspe=no)
2330197cd2eSKumar Gala
234ba96301cSNaveen N. Rao# Don't emit .eh_frame since we have no use for it
235ba96301cSNaveen N. RaoKBUILD_CFLAGS += -fno-asynchronous-unwind-tables
236ba96301cSNaveen N. Rao
23757647a4dSBenjamin Herrenschmidt# Never use string load/store instructions as they are
23857647a4dSBenjamin Herrenschmidt# often slow when they are implemented at all
239a50a862eSAnton BlanchardKBUILD_CFLAGS		+= $(call cc-option,-mno-string)
24014cf11afSPaul Mackerras
241548ad77dSImre Kalozcpu-as-$(CONFIG_40x)		+= -Wa,-m405
242548ad77dSImre Kalozcpu-as-$(CONFIG_44x)		+= -Wa,-m440
2439ddf0075SAnton Blanchardcpu-as-$(CONFIG_ALTIVEC)	+= $(call as-option,-Wa$(comma)-maltivec)
2444e4a4b75SJames Clarkecpu-as-$(CONFIG_E500)		+= -Wa,-me500
245960e3002SJoel Stanley
246960e3002SJoel Stanley# When using '-many -mpower4' gas will first try and find a matching power4
247960e3002SJoel Stanley# mnemonic and failing that it will allow any valid mnemonic that GAS knows
248960e3002SJoel Stanley# about. GCC will pass -many to GAS when assembling, clang does not.
249960e3002SJoel Stanleycpu-as-$(CONFIG_PPC_BOOK3S_64)	+= -Wa,-mpower4 -Wa,-many
25069a84059SMichael Jeansoncpu-as-$(CONFIG_PPC_E500MC)	+= $(call as-option,-Wa$(comma)-me500mc)
25114cf11afSPaul Mackerras
252222d394dSSam RavnborgKBUILD_AFLAGS += $(cpu-as-y)
253a0f97e06SSam RavnborgKBUILD_CFLAGS += $(cpu-as-y)
25414cf11afSPaul Mackerras
255164af597SMichael EllermanKBUILD_AFLAGS += $(aflags-y)
256164af597SMichael EllermanKBUILD_CFLAGS += $(cflags-y)
257164af597SMichael Ellerman
258533090e5SChristophe Leroyhead-$(CONFIG_PPC64)		:= arch/powerpc/kernel/head_64.o
259533090e5SChristophe Leroyhead-$(CONFIG_PPC_BOOK3S_32)	:= arch/powerpc/kernel/head_book3s_32.o
260968159c0SChristophe Leroyhead-$(CONFIG_PPC_8xx)		:= arch/powerpc/kernel/head_8xx.o
26115f6527eSJosh Boyerhead-$(CONFIG_40x)		:= arch/powerpc/kernel/head_40x.o
26214cf11afSPaul Mackerrashead-$(CONFIG_44x)		:= arch/powerpc/kernel/head_44x.o
26314cf11afSPaul Mackerrashead-$(CONFIG_FSL_BOOKE)	:= arch/powerpc/kernel/head_fsl_booke.o
26414cf11afSPaul Mackerras
2659994a338SPaul Mackerrashead-$(CONFIG_PPC64)		+= arch/powerpc/kernel/entry_64.o
26614cf11afSPaul Mackerrashead-$(CONFIG_PPC_FPU)		+= arch/powerpc/kernel/fpu.o
267e821ea70SBenjamin Herrenschmidthead-$(CONFIG_ALTIVEC)		+= arch/powerpc/kernel/vector.o
2685ac47f7aSAnton Blanchardhead-$(CONFIG_PPC_OF_BOOT_TRAMPOLINE)  += arch/powerpc/kernel/prom_init.o
26914cf11afSPaul Mackerras
270c47ca98dSMichael Ellerman# See arch/powerpc/Kbuild for content of core part of the kernel
271c47ca98dSMichael Ellermancore-y += arch/powerpc/
27214cf11afSPaul Mackerras
273135f0b17STom Rini# Default to zImage, override when needed
27425431333SGrant Likelyall: zImage
27514cf11afSPaul Mackerras
276e32e78c5SSam Ravnborg# With make 3.82 we cannot mix normal and wildcard targets
277c686ecf5SAnatolij GustschinBOOT_TARGETS1 := zImage zImage.initrd uImage
27811eab297SBenjamin HerrenschmidtBOOT_TARGETS2 := zImage% dtbImage% treeImage.% cuImage.% simpleImage.% uImage.%
279cabb5587SStephen Rothwell
280e32e78c5SSam RavnborgPHONY += $(BOOT_TARGETS1) $(BOOT_TARGETS2)
281cabb5587SStephen Rothwell
28294b212c2SPaul Mackerrasboot := arch/$(ARCH)/boot
28314cf11afSPaul Mackerras
284e32e78c5SSam Ravnborg$(BOOT_TARGETS1): vmlinux
2851196d7aaSMichael Ellerman	$(Q)$(MAKE) $(build)=$(boot) $(patsubst %,$(boot)/%,$@)
286e32e78c5SSam Ravnborg$(BOOT_TARGETS2): vmlinux
2871196d7aaSMichael Ellerman	$(Q)$(MAKE) $(build)=$(boot) $(patsubst %,$(boot)/%,$@)
28814cf11afSPaul Mackerras
289e32e78c5SSam Ravnborg
290d42c6d0fSMichael EllermanPHONY += bootwrapper_install
291e32e78c5SSam Ravnborgbootwrapper_install:
2921196d7aaSMichael Ellerman	$(Q)$(MAKE) $(build)=$(boot) $(patsubst %,$(boot)/%,$@)
293e32e78c5SSam Ravnborg
294ea4d1a87SCyril Bur# Used to create 'merged defconfigs'
295ea4d1a87SCyril Bur# To use it $(call) it with the first argument as the base defconfig
296ea4d1a87SCyril Bur# and the second argument as a space separated list of .config files to merge,
297ea4d1a87SCyril Bur# without the .config suffix.
298ea4d1a87SCyril Burdefine merge_into_defconfig
299ea4d1a87SCyril Bur	$(Q)$(CONFIG_SHELL) $(srctree)/scripts/kconfig/merge_config.sh \
300ea4d1a87SCyril Bur		-m -O $(objtree) $(srctree)/arch/$(ARCH)/configs/$(1) \
301ea4d1a87SCyril Bur		$(foreach config,$(2),$(srctree)/arch/$(ARCH)/configs/$(config).config)
302ea4d1a87SCyril Bur	+$(Q)$(MAKE) -f $(srctree)/Makefile olddefconfig
303ea4d1a87SCyril Burendef
304ea4d1a87SCyril Bur
305ea4d1a87SCyril BurPHONY += pseries_le_defconfig
306ea4d1a87SCyril Burpseries_le_defconfig:
307ea4d1a87SCyril Bur	$(call merge_into_defconfig,pseries_defconfig,le)
308ea4d1a87SCyril Bur
3092adc48a6SMichael EllermanPHONY += ppc64le_defconfig
3102adc48a6SMichael Ellermanppc64le_defconfig:
3112adc48a6SMichael Ellerman	$(call merge_into_defconfig,ppc64_defconfig,le)
3122adc48a6SMichael Ellerman
313721c01baSSatheesh RajendranPHONY += ppc64le_guest_defconfig
314721c01baSSatheesh Rajendranppc64le_guest_defconfig:
315721c01baSSatheesh Rajendran	$(call merge_into_defconfig,ppc64_defconfig,le guest)
316721c01baSSatheesh Rajendran
317721c01baSSatheesh RajendranPHONY += ppc64_guest_defconfig
318721c01baSSatheesh Rajendranppc64_guest_defconfig:
319721c01baSSatheesh Rajendran	$(call merge_into_defconfig,ppc64_defconfig,be guest)
320721c01baSSatheesh Rajendran
3213603c52fSMichael EllermanPHONY += powernv_be_defconfig
3223603c52fSMichael Ellermanpowernv_be_defconfig:
3233603c52fSMichael Ellerman	$(call merge_into_defconfig,powernv_defconfig,be)
3243603c52fSMichael Ellerman
32544d54014SScott WoodPHONY += mpc85xx_defconfig
32644d54014SScott Woodmpc85xx_defconfig:
32758b12eb2SMichael Ellerman	$(call merge_into_defconfig,mpc85xx_base.config,\
32844d54014SScott Wood		85xx-32bit 85xx-hw fsl-emb-nonhw)
32944d54014SScott Wood
33044d54014SScott WoodPHONY += mpc85xx_smp_defconfig
33144d54014SScott Woodmpc85xx_smp_defconfig:
33258b12eb2SMichael Ellerman	$(call merge_into_defconfig,mpc85xx_base.config,\
33344d54014SScott Wood		85xx-32bit 85xx-smp 85xx-hw fsl-emb-nonhw)
33444d54014SScott Wood
33544d54014SScott WoodPHONY += corenet32_smp_defconfig
33644d54014SScott Woodcorenet32_smp_defconfig:
33758b12eb2SMichael Ellerman	$(call merge_into_defconfig,corenet_base.config,\
338e0b80f00SClaudiu Manoil		85xx-32bit 85xx-smp 85xx-hw fsl-emb-nonhw dpaa)
33944d54014SScott Wood
34044d54014SScott WoodPHONY += corenet64_smp_defconfig
34144d54014SScott Woodcorenet64_smp_defconfig:
34258b12eb2SMichael Ellerman	$(call merge_into_defconfig,corenet_base.config,\
343e0b80f00SClaudiu Manoil		85xx-64bit 85xx-smp altivec 85xx-hw fsl-emb-nonhw dpaa)
34444d54014SScott Wood
34543de32c5SAlessio Igor BoganiPHONY += mpc86xx_defconfig
34643de32c5SAlessio Igor Boganimpc86xx_defconfig:
34758b12eb2SMichael Ellerman	$(call merge_into_defconfig,mpc86xx_base.config,\
34843de32c5SAlessio Igor Bogani		86xx-hw fsl-emb-nonhw)
34943de32c5SAlessio Igor Bogani
35043de32c5SAlessio Igor BoganiPHONY += mpc86xx_smp_defconfig
35143de32c5SAlessio Igor Boganimpc86xx_smp_defconfig:
35258b12eb2SMichael Ellerman	$(call merge_into_defconfig,mpc86xx_base.config,\
35343de32c5SAlessio Igor Bogani		86xx-smp 86xx-hw fsl-emb-nonhw)
35443de32c5SAlessio Igor Bogani
3558db0c9d4SMichael EllermanPHONY += ppc32_allmodconfig
3568db0c9d4SMichael Ellermanppc32_allmodconfig:
3578db0c9d4SMichael Ellerman	$(Q)$(MAKE) KCONFIG_ALLCONFIG=$(srctree)/arch/powerpc/configs/book3s_32.config \
3588db0c9d4SMichael Ellerman		-f $(srctree)/Makefile allmodconfig
3598db0c9d4SMichael Ellerman
360a273fa38SMichael EllermanPHONY += ppc_defconfig
361a273fa38SMichael Ellermanppc_defconfig:
362a273fa38SMichael Ellerman	$(call merge_into_defconfig,book3s_32.config,)
363a273fa38SMichael Ellerman
36464de5d8dSMichael EllermanPHONY += ppc64le_allmodconfig
36564de5d8dSMichael Ellermanppc64le_allmodconfig:
36664de5d8dSMichael Ellerman	$(Q)$(MAKE) KCONFIG_ALLCONFIG=$(srctree)/arch/powerpc/configs/le.config \
36764de5d8dSMichael Ellerman		-f $(srctree)/Makefile allmodconfig
36864de5d8dSMichael Ellerman
3695d823447SMichael EllermanPHONY += ppc64le_allnoconfig
3705d823447SMichael Ellermanppc64le_allnoconfig:
3715d823447SMichael Ellerman	$(Q)$(MAKE) KCONFIG_ALLCONFIG=$(srctree)/arch/powerpc/configs/ppc64le.config \
3725d823447SMichael Ellerman		-f $(srctree)/Makefile allnoconfig
3735d823447SMichael Ellerman
37464de5d8dSMichael EllermanPHONY += ppc64_book3e_allmodconfig
37564de5d8dSMichael Ellermanppc64_book3e_allmodconfig:
37664de5d8dSMichael Ellerman	$(Q)$(MAKE) KCONFIG_ALLCONFIG=$(srctree)/arch/powerpc/configs/85xx-64bit.config \
37764de5d8dSMichael Ellerman		-f $(srctree)/Makefile allmodconfig
37864de5d8dSMichael Ellerman
37914cf11afSPaul Mackerrasdefine archhelp
38070bf0333SGrant Likely  @echo '* zImage          - Build default images selected by kernel config'
38170bf0333SGrant Likely  @echo '  zImage.*        - Compressed kernel image (arch/$(ARCH)/boot/zImage.*)'
38270bf0333SGrant Likely  @echo '  uImage          - U-Boot native image format'
38370bf0333SGrant Likely  @echo '  cuImage.<dt>    - Backwards compatible U-Boot image for older'
38470bf0333SGrant Likely  @echo '                    versions which do not support device trees'
38570bf0333SGrant Likely  @echo '  dtbImage.<dt>   - zImage with an embedded device tree blob'
38670bf0333SGrant Likely  @echo '  simpleImage.<dt> - Firmware independent image.'
38770bf0333SGrant Likely  @echo '  treeImage.<dt>  - Support for older IBM 4xx firmware (not U-Boot)'
38814cf11afSPaul Mackerras  @echo '  install         - Install kernel using'
389caa27b66SSam Ravnborg  @echo '                    (your) ~/bin/$(INSTALLKERNEL) or'
390caa27b66SSam Ravnborg  @echo '                    (distribution) /sbin/$(INSTALLKERNEL) or'
39114cf11afSPaul Mackerras  @echo '                    install to $$(INSTALL_PATH) and run lilo'
392437a58dbSPaul Mackerras  @echo '  *_defconfig     - Select default config from arch/$(ARCH)/configs'
39370bf0333SGrant Likely  @echo ''
39470bf0333SGrant Likely  @echo '  Targets with <dt> embed a device tree blob inside the image'
39570bf0333SGrant Likely  @echo '  These targets support board with firmware that does not'
39670bf0333SGrant Likely  @echo '  support passing a device tree directly.  Replace <dt> with the'
39770bf0333SGrant Likely  @echo '  name of a dts file from the arch/$(ARCH)/boot/dts/ directory'
39870bf0333SGrant Likely  @echo '  (minus the .dts extension).'
39914cf11afSPaul Mackerrasendef
40014cf11afSPaul Mackerras
401d42c6d0fSMichael EllermanPHONY += install
4023f85d63eSSam Ravnborginstall:
40325431333SGrant Likely	$(Q)$(MAKE) $(build)=$(boot) install
404928370c6SAkinobu Mita
40514cf11afSPaul Mackerrasarchclean:
406a3a9e99eSPaul Mackerras	$(Q)$(MAKE) $(clean)=$(boot)
40770567293SAndreas Gruenbacher
40891bf6955SChristophe Leroyifeq ($(KBUILD_EXTMOD),)
40991bf6955SChristophe Leroy# We need to generate vdso-offsets.h before compiling certain files in kernel/.
41091bf6955SChristophe Leroy# In order to do that, we should use the archprepare target, but we can't since
41191bf6955SChristophe Leroy# asm-offsets.h is included in some files used to generate vdso-offsets.h, and
41291bf6955SChristophe Leroy# asm-offsets.h is built in prepare0, for which archprepare is a dependency.
41391bf6955SChristophe Leroy# Therefore we need to generate the header after prepare0 has been made, hence
41491bf6955SChristophe Leroy# this hack.
41591bf6955SChristophe Leroyprepare: vdso_prepare
41691bf6955SChristophe Leroyvdso_prepare: prepare0
41791bf6955SChristophe Leroy	$(if $(CONFIG_VDSO32),$(Q)$(MAKE) \
41891bf6955SChristophe Leroy		$(build)=arch/powerpc/kernel/vdso32 include/generated/vdso32-offsets.h)
41991bf6955SChristophe Leroy	$(if $(CONFIG_PPC64),$(Q)$(MAKE) \
42091bf6955SChristophe Leroy		$(build)=arch/powerpc/kernel/vdso64 include/generated/vdso64-offsets.h)
42191bf6955SChristophe Leroyendif
42291bf6955SChristophe Leroy
42314cf11afSPaul Mackerrasarchprepare: checkbin
42414cf11afSPaul Mackerras
425ab66dcc7SFiroz Khanarchheaders:
426ab66dcc7SFiroz Khan	$(Q)$(MAKE) $(build)=arch/powerpc/kernel/syscalls all
427ab66dcc7SFiroz Khan
428c3ff2a51SChristophe Leroyifdef CONFIG_STACKPROTECTOR
429c3ff2a51SChristophe Leroyprepare: stack_protector_prepare
43014cf11afSPaul Mackerras
431d42c6d0fSMichael EllermanPHONY += stack_protector_prepare
432c3ff2a51SChristophe Leroystack_protector_prepare: prepare0
43306ec27aeSChristophe Leroyifdef CONFIG_PPC64
43406ec27aeSChristophe Leroy	$(eval KBUILD_CFLAGS += -mstack-protector-guard-offset=$(shell awk '{if ($$2 == "PACA_CANARY") print $$3;}' include/generated/asm-offsets.h))
43506ec27aeSChristophe Leroyelse
436c3ff2a51SChristophe Leroy	$(eval KBUILD_CFLAGS += -mstack-protector-guard-offset=$(shell awk '{if ($$2 == "TASK_CANARY") print $$3;}' include/generated/asm-offsets.h))
437c3ff2a51SChristophe Leroyendif
43806ec27aeSChristophe Leroyendif
439c3ff2a51SChristophe Leroy
440ed1cd6deSChristophe Leroyifdef CONFIG_SMP
441*3027a37cSMichael Ellermanifdef CONFIG_PPC32
442ed1cd6deSChristophe Leroyprepare: task_cpu_prepare
443ed1cd6deSChristophe Leroy
444d42c6d0fSMichael EllermanPHONY += task_cpu_prepare
445ed1cd6deSChristophe Leroytask_cpu_prepare: prepare0
446f7354ccaSChristophe Leroy	$(eval KBUILD_CFLAGS += -D_TASK_CPU=$(shell awk '{if ($$2 == "TASK_CPU") print $$3;}' include/generated/asm-offsets.h))
447*3027a37cSMichael Ellerman
448*3027a37cSMichael Ellermanendif # CONFIG_PPC32
449*3027a37cSMichael Ellermanendif # CONFIG_SMP
450ed1cd6deSChristophe Leroy
451d42c6d0fSMichael EllermanPHONY += checkbin
452f2910f0eSNicholas Piggin# Check toolchain versions:
453f2910f0eSNicholas Piggin# - gcc-4.6 is the minimum kernel-wide version so nothing required.
45414cf11afSPaul Mackerrascheckbin:
45560e065f7SMichael Ellerman	@if test "x${CONFIG_CPU_LITTLE_ENDIAN}" = "xy" \
45660e065f7SMichael Ellerman	    && $(LD) --version | head -1 | grep ' 2\.24$$' >/dev/null ; then \
45760e065f7SMichael Ellerman		echo -n '*** binutils 2.24 miscompiles weak symbols ' ; \
45860e065f7SMichael Ellerman		echo 'in some circumstances.' ; \
45960e065f7SMichael Ellerman		echo -n '*** Please use a different binutils version.' ; \
46060e065f7SMichael Ellerman		false ; \
46160e065f7SMichael Ellerman	fi
462