1 # This file is included by the global makefile so that you can add your own
2 # architecture-specific flags and dependencies. Remember to do have actions
3 # for "archclean" and "archdep" for cleaning up and making dependencies for
6 # This file is subject to the terms and conditions of the GNU General Public
7 # License. See the file "COPYING" in the main directory of this archive
10 # Copyright (C) 1994 by Linus Torvalds
11 # Changes for PPC by Gary Thomas
12 # Rewritten by Cort Dougan and Paul Mackerras
15 HAS_BIARCH := $(call cc-option-yn, -m32)
17 # Set default 32 bits cross compilers for vdso and boot wrapper
20 # If we're on a ppc/ppc64/ppc64le machine use that defconfig, otherwise just use
21 # ppc64_defconfig because we have nothing better to go on.
22 uname := $(shell uname -m)
23 KBUILD_DEFCONFIG := $(if $(filter ppc%,$(uname)),$(uname),ppc64)_defconfig
25 new_nm := $(shell if $(NM) --help 2>&1 | grep -- '--synthetic' > /dev/null; then echo y; else echo n; fi)
28 NM := $(NM) --synthetic
31 # BITS is used as extension for files which are available in a 32 bit
32 # and a 64 bit version to simplify shared Makefiles.
33 # e.g.: obj-y += foo_$(BITS).o
43 machine-$(CONFIG_PPC64) += 64
44 machine-$(CONFIG_CPU_LITTLE_ENDIAN) += le
45 UTS_MACHINE := $(subst $(space),,$(machine-y))
47 # XXX This needs to be before we override LD below
49 KBUILD_LDFLAGS_MODULE += arch/powerpc/lib/crtsavres.o
51 KBUILD_LDS_MODULE += $(srctree)/arch/powerpc/kernel/module.lds
52 ifeq ($(call ld-ifversion, -ge, 225000000, y),y)
53 # Have the linker provide sfpr if possible.
54 # There is a corresponding test in arch/powerpc/lib/Makefile
55 KBUILD_LDFLAGS_MODULE += --save-restore-funcs
57 KBUILD_LDFLAGS_MODULE += arch/powerpc/lib/crtsavres.o
61 ifdef CONFIG_CPU_LITTLE_ENDIAN
62 KBUILD_CFLAGS += -mlittle-endian
65 GNUTARGET := powerpcle
66 MULTIPLEWORD := -mno-multiple
67 KBUILD_CFLAGS_MODULE += $(call cc-option,-mno-save-toc-indirect)
69 KBUILD_CFLAGS += $(call cc-option,-mbig-endian)
73 MULTIPLEWORD := -mmultiple
77 ifndef CONFIG_CC_IS_CLANG
78 cflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mabi=elfv1)
79 cflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mcall-aixdesc)
80 aflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mabi=elfv1)
81 aflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mabi=elfv2
85 ifndef CONFIG_CC_IS_CLANG
86 cflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mno-strict-align
89 cflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mbig-endian)
90 cflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mlittle-endian
91 aflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mbig-endian)
92 aflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mlittle-endian
94 ifeq ($(HAS_BIARCH),y)
95 KBUILD_CFLAGS += -m$(BITS)
96 KBUILD_AFLAGS += -m$(BITS)
97 KBUILD_LDFLAGS += -m elf$(BITS)$(LDEMULATION)
100 cflags-$(CONFIG_STACKPROTECTOR) += -mstack-protector-guard=tls
102 cflags-$(CONFIG_STACKPROTECTOR) += -mstack-protector-guard-reg=r13
104 cflags-$(CONFIG_STACKPROTECTOR) += -mstack-protector-guard-reg=r2
107 LDFLAGS_vmlinux-y := -Bstatic
108 LDFLAGS_vmlinux-$(CONFIG_RELOCATABLE) := -pie
109 LDFLAGS_vmlinux := $(LDFLAGS_vmlinux-y)
110 LDFLAGS_vmlinux += $(call ld-option,--orphan-handling=warn)
113 ifeq ($(call cc-option-yn,-mcmodel=medium),y)
114 # -mcmodel=medium breaks modules because it uses 32bit offsets from
115 # the TOC pointer to create pointers where possible. Pointers into the
116 # percpu data area are created by this method.
118 # The kernel module loader relocates the percpu data section from the
119 # original location (starting with 0xd...) to somewhere in the base
120 # kernel percpu data space (starting with 0xc...). We need a full
121 # 64bit relocation for this to work, hence -mcmodel=large.
122 KBUILD_CFLAGS_MODULE += -mcmodel=large
124 export NO_MINIMAL_TOC := -mno-minimal-toc
128 CFLAGS-$(CONFIG_PPC64) := $(call cc-option,-mtraceback=no)
129 ifndef CONFIG_CC_IS_CLANG
130 ifdef CONFIG_CPU_LITTLE_ENDIAN
131 CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mabi=elfv2,$(call cc-option,-mcall-aixdesc))
132 AFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mabi=elfv2)
134 CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mabi=elfv1)
135 CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mcall-aixdesc)
136 AFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mabi=elfv1)
139 CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mcmodel=medium,$(call cc-option,-mminimal-toc))
140 CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mno-pointers-to-nested-functions)
142 # Clang unconditionally reserves r2 on ppc32 and does not support the flag
143 # https://bugs.llvm.org/show_bug.cgi?id=39555
144 CFLAGS-$(CONFIG_PPC32) := $(call cc-option, -ffixed-r2)
146 # Clang doesn't support -mmultiple / -mno-multiple
147 # https://bugs.llvm.org/show_bug.cgi?id=39556
148 CFLAGS-$(CONFIG_PPC32) += $(call cc-option, $(MULTIPLEWORD))
150 CFLAGS-$(CONFIG_PPC32) += $(call cc-option,-mno-readonly-in-sdata)
152 ifdef CONFIG_PPC_BOOK3S_64
153 ifdef CONFIG_CPU_LITTLE_ENDIAN
154 CFLAGS-$(CONFIG_GENERIC_CPU) += -mcpu=power8
155 CFLAGS-$(CONFIG_GENERIC_CPU) += $(call cc-option,-mtune=power9,-mtune=power8)
157 CFLAGS-$(CONFIG_GENERIC_CPU) += $(call cc-option,-mtune=power7,$(call cc-option,-mtune=power5))
158 CFLAGS-$(CONFIG_GENERIC_CPU) += -mcpu=power4
160 else ifdef CONFIG_PPC_BOOK3E_64
161 CFLAGS-$(CONFIG_GENERIC_CPU) += -mcpu=powerpc64
164 ifdef CONFIG_FUNCTION_TRACER
165 CC_FLAGS_FTRACE := -pg
166 ifdef CONFIG_MPROFILE_KERNEL
167 CC_FLAGS_FTRACE += -mprofile-kernel
169 # Work around gcc code-gen bugs with -pg / -fno-omit-frame-pointer in gcc <= 4.8
170 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=44199
171 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52828
172 ifndef CONFIG_CC_IS_CLANG
173 CC_FLAGS_FTRACE += $(call cc-ifversion, -lt, 0409, -mno-sched-epilog)
177 CFLAGS-$(CONFIG_TARGET_CPU_BOOL) += $(call cc-option,-mcpu=$(CONFIG_TARGET_CPU))
178 AFLAGS-$(CONFIG_TARGET_CPU_BOOL) += $(call cc-option,-mcpu=$(CONFIG_TARGET_CPU))
180 # Altivec option not allowed with e500mc64 in GCC.
182 E5500_CPU := -mcpu=powerpc64
184 E5500_CPU := $(call cc-option,-mcpu=e500mc64,-mcpu=powerpc64)
186 CFLAGS-$(CONFIG_E5500_CPU) += $(E5500_CPU)
187 CFLAGS-$(CONFIG_E6500_CPU) += $(call cc-option,-mcpu=e6500,$(E5500_CPU))
189 asinstr := $(call as-instr,lis 9$(comma)foo@high,-DHAVE_AS_ATHIGH=1)
191 KBUILD_CPPFLAGS += -I $(srctree)/arch/$(ARCH) $(asinstr)
192 KBUILD_AFLAGS += $(AFLAGS-y)
193 KBUILD_CFLAGS += $(call cc-option,-msoft-float)
194 KBUILD_CFLAGS += -pipe $(CFLAGS-y)
195 CPP = $(CC) -E $(KBUILD_CFLAGS)
197 CHECKFLAGS += -m$(BITS) -D__powerpc__ -D__powerpc$(BITS)__
198 ifdef CONFIG_CPU_BIG_ENDIAN
199 CHECKFLAGS += -D__BIG_ENDIAN__
201 CHECKFLAGS += -D__LITTLE_ENDIAN__
204 ifdef CONFIG_476FPE_ERR46
205 KBUILD_LDFLAGS_MODULE += --ppc476-workaround \
206 -T $(srctree)/arch/powerpc/platforms/44x/ppc476_modules.lds
209 # No AltiVec or VSX instructions when building kernel
210 KBUILD_CFLAGS += $(call cc-option,-mno-altivec)
211 KBUILD_CFLAGS += $(call cc-option,-mno-vsx)
213 # No SPE instruction when building kernel
214 # (We use all available options to help semi-broken compilers)
215 KBUILD_CFLAGS += $(call cc-option,-mno-spe)
216 KBUILD_CFLAGS += $(call cc-option,-mspe=no)
218 # FIXME: the module load should be taught about the additional relocs
220 # revert to pre-gcc-4.4 behaviour of .eh_frame
221 KBUILD_CFLAGS += $(call cc-option,-fno-dwarf2-cfi-asm)
223 # Never use string load/store instructions as they are
224 # often slow when they are implemented at all
225 KBUILD_CFLAGS += $(call cc-option,-mno-string)
227 cpu-as-$(CONFIG_4xx) += -Wa,-m405
228 cpu-as-$(CONFIG_ALTIVEC) += $(call as-option,-Wa$(comma)-maltivec)
229 cpu-as-$(CONFIG_E500) += -Wa,-me500
231 # When using '-many -mpower4' gas will first try and find a matching power4
232 # mnemonic and failing that it will allow any valid mnemonic that GAS knows
233 # about. GCC will pass -many to GAS when assembling, clang does not.
234 cpu-as-$(CONFIG_PPC_BOOK3S_64) += -Wa,-mpower4 -Wa,-many
235 cpu-as-$(CONFIG_PPC_E500MC) += $(call as-option,-Wa$(comma)-me500mc)
237 KBUILD_AFLAGS += $(cpu-as-y)
238 KBUILD_CFLAGS += $(cpu-as-y)
240 KBUILD_AFLAGS += $(aflags-y)
241 KBUILD_CFLAGS += $(cflags-y)
243 head-y := arch/powerpc/kernel/head_$(BITS).o
244 head-$(CONFIG_PPC_8xx) := arch/powerpc/kernel/head_8xx.o
245 head-$(CONFIG_40x) := arch/powerpc/kernel/head_40x.o
246 head-$(CONFIG_44x) := arch/powerpc/kernel/head_44x.o
247 head-$(CONFIG_FSL_BOOKE) := arch/powerpc/kernel/head_fsl_booke.o
249 head-$(CONFIG_PPC64) += arch/powerpc/kernel/entry_64.o
250 head-$(CONFIG_PPC_FPU) += arch/powerpc/kernel/fpu.o
251 head-$(CONFIG_ALTIVEC) += arch/powerpc/kernel/vector.o
252 head-$(CONFIG_PPC_OF_BOOT_TRAMPOLINE) += arch/powerpc/kernel/prom_init.o
254 # See arch/powerpc/Kbuild for content of core part of the kernel
255 core-y += arch/powerpc/
257 drivers-$(CONFIG_OPROFILE) += arch/powerpc/oprofile/
259 # Default to zImage, override when needed
262 # With make 3.82 we cannot mix normal and wildcard targets
263 BOOT_TARGETS1 := zImage zImage.initrd uImage
264 BOOT_TARGETS2 := zImage% dtbImage% treeImage.% cuImage.% simpleImage.% uImage.%
266 PHONY += $(BOOT_TARGETS1) $(BOOT_TARGETS2)
268 boot := arch/$(ARCH)/boot
270 $(BOOT_TARGETS1): vmlinux
271 $(Q)$(MAKE) $(build)=$(boot) $(patsubst %,$(boot)/%,$@)
272 $(BOOT_TARGETS2): vmlinux
273 $(Q)$(MAKE) $(build)=$(boot) $(patsubst %,$(boot)/%,$@)
277 $(Q)$(MAKE) $(build)=$(boot) $(patsubst %,$(boot)/%,$@)
279 # Used to create 'merged defconfigs'
280 # To use it $(call) it with the first argument as the base defconfig
281 # and the second argument as a space separated list of .config files to merge,
282 # without the .config suffix.
283 define merge_into_defconfig
284 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/kconfig/merge_config.sh \
285 -m -O $(objtree) $(srctree)/arch/$(ARCH)/configs/$(1) \
286 $(foreach config,$(2),$(srctree)/arch/$(ARCH)/configs/$(config).config)
287 +$(Q)$(MAKE) -f $(srctree)/Makefile olddefconfig
290 PHONY += pseries_le_defconfig
291 pseries_le_defconfig:
292 $(call merge_into_defconfig,pseries_defconfig,le)
294 PHONY += ppc64le_defconfig
296 $(call merge_into_defconfig,ppc64_defconfig,le)
298 PHONY += ppc64le_guest_defconfig
299 ppc64le_guest_defconfig:
300 $(call merge_into_defconfig,ppc64_defconfig,le guest)
302 PHONY += ppc64_guest_defconfig
303 ppc64_guest_defconfig:
304 $(call merge_into_defconfig,ppc64_defconfig,be guest)
306 PHONY += powernv_be_defconfig
307 powernv_be_defconfig:
308 $(call merge_into_defconfig,powernv_defconfig,be)
310 PHONY += mpc85xx_defconfig
312 $(call merge_into_defconfig,mpc85xx_basic_defconfig,\
313 85xx-32bit 85xx-hw fsl-emb-nonhw)
315 PHONY += mpc85xx_smp_defconfig
316 mpc85xx_smp_defconfig:
317 $(call merge_into_defconfig,mpc85xx_basic_defconfig,\
318 85xx-32bit 85xx-smp 85xx-hw fsl-emb-nonhw)
320 PHONY += corenet32_smp_defconfig
321 corenet32_smp_defconfig:
322 $(call merge_into_defconfig,corenet_basic_defconfig,\
323 85xx-32bit 85xx-smp 85xx-hw fsl-emb-nonhw dpaa)
325 PHONY += corenet64_smp_defconfig
326 corenet64_smp_defconfig:
327 $(call merge_into_defconfig,corenet_basic_defconfig,\
328 85xx-64bit 85xx-smp altivec 85xx-hw fsl-emb-nonhw dpaa)
330 PHONY += mpc86xx_defconfig
332 $(call merge_into_defconfig,mpc86xx_basic_defconfig,\
333 86xx-hw fsl-emb-nonhw)
335 PHONY += mpc86xx_smp_defconfig
336 mpc86xx_smp_defconfig:
337 $(call merge_into_defconfig,mpc86xx_basic_defconfig,\
338 86xx-smp 86xx-hw fsl-emb-nonhw)
340 PHONY += ppc32_allmodconfig
342 $(Q)$(MAKE) KCONFIG_ALLCONFIG=$(srctree)/arch/powerpc/configs/book3s_32.config \
343 -f $(srctree)/Makefile allmodconfig
345 PHONY += ppc_defconfig
347 $(call merge_into_defconfig,book3s_32.config,)
349 PHONY += ppc64le_allmodconfig
350 ppc64le_allmodconfig:
351 $(Q)$(MAKE) KCONFIG_ALLCONFIG=$(srctree)/arch/powerpc/configs/le.config \
352 -f $(srctree)/Makefile allmodconfig
354 PHONY += ppc64_book3e_allmodconfig
355 ppc64_book3e_allmodconfig:
356 $(Q)$(MAKE) KCONFIG_ALLCONFIG=$(srctree)/arch/powerpc/configs/85xx-64bit.config \
357 -f $(srctree)/Makefile allmodconfig
360 @echo '* zImage - Build default images selected by kernel config'
361 @echo ' zImage.* - Compressed kernel image (arch/$(ARCH)/boot/zImage.*)'
362 @echo ' uImage - U-Boot native image format'
363 @echo ' cuImage.<dt> - Backwards compatible U-Boot image for older'
364 @echo ' versions which do not support device trees'
365 @echo ' dtbImage.<dt> - zImage with an embedded device tree blob'
366 @echo ' simpleImage.<dt> - Firmware independent image.'
367 @echo ' treeImage.<dt> - Support for older IBM 4xx firmware (not U-Boot)'
368 @echo ' install - Install kernel using'
369 @echo ' (your) ~/bin/$(INSTALLKERNEL) or'
370 @echo ' (distribution) /sbin/$(INSTALLKERNEL) or'
371 @echo ' install to $$(INSTALL_PATH) and run lilo'
372 @echo ' *_defconfig - Select default config from arch/$(ARCH)/configs'
374 @echo ' Targets with <dt> embed a device tree blob inside the image'
375 @echo ' These targets support board with firmware that does not'
376 @echo ' support passing a device tree directly. Replace <dt> with the'
377 @echo ' name of a dts file from the arch/$(ARCH)/boot/dts/ directory'
378 @echo ' (minus the .dts extension).'
382 $(Q)$(MAKE) $(build)=$(boot) install
386 $(Q)$(MAKE) $(build)=arch/$(ARCH)/kernel/vdso64 $@
389 $(Q)$(MAKE) $(build)=arch/$(ARCH)/kernel/vdso32 $@
393 $(Q)$(MAKE) $(clean)=$(boot)
395 archprepare: checkbin
398 $(Q)$(MAKE) $(build)=arch/powerpc/kernel/syscalls all
400 ifdef CONFIG_STACKPROTECTOR
401 prepare: stack_protector_prepare
403 stack_protector_prepare: prepare0
405 $(eval KBUILD_CFLAGS += -mstack-protector-guard-offset=$(shell awk '{if ($$2 == "PACA_CANARY") print $$3;}' include/generated/asm-offsets.h))
407 $(eval KBUILD_CFLAGS += -mstack-protector-guard-offset=$(shell awk '{if ($$2 == "TASK_CANARY") print $$3;}' include/generated/asm-offsets.h))
412 prepare: task_cpu_prepare
414 task_cpu_prepare: prepare0
415 $(eval KBUILD_CFLAGS += -D_TASK_CPU=$(shell awk '{if ($$2 == "TASK_CPU") print $$3;}' include/generated/asm-offsets.h))
418 # Check toolchain versions:
419 # - gcc-4.6 is the minimum kernel-wide version so nothing required.
421 @if test "x${CONFIG_CPU_LITTLE_ENDIAN}" = "xy" \
422 && $(LD) --version | head -1 | grep ' 2\.24$$' >/dev/null ; then \
423 echo -n '*** binutils 2.24 miscompiles weak symbols ' ; \
424 echo 'in some circumstances.' ; \
425 echo -n '*** Please use a different binutils version.' ; \