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 ifeq ($(HAS_BIARCH),y)
21 ifeq ($(CROSS32_COMPILE),)
23 # These options will be overridden by any -mcpu option that the CPU
24 # or platform code sets later on the command line, but they are needed
25 # to set a sane 32-bit cpu target for the 64-bit cross compiler which
26 # may default to the wrong ISA.
27 KBUILD_CFLAGS += -mcpu=powerpc
28 KBUILD_AFLAGS += -mcpu=powerpc
33 # If we're on a ppc/ppc64/ppc64le machine use that defconfig, otherwise just use
34 # ppc64_defconfig because we have nothing better to go on.
35 uname := $(shell uname -m)
36 KBUILD_DEFCONFIG := $(if $(filter ppc%,$(uname)),$(uname),ppc64)_defconfig
39 new_nm := $(shell if $(NM) --help 2>&1 | grep -- '--synthetic' > /dev/null; then echo y; else echo n; fi)
42 NM := $(NM) --synthetic
46 # BITS is used as extension for files which are available in a 32 bit
47 # and a 64 bit version to simplify shared Makefiles.
48 # e.g.: obj-y += foo_$(BITS).o
58 machine-$(CONFIG_PPC64) += 64
59 machine-$(CONFIG_CPU_LITTLE_ENDIAN) += le
60 UTS_MACHINE := $(subst $(space),,$(machine-y))
62 # XXX This needs to be before we override LD below
64 KBUILD_LDFLAGS_MODULE += arch/powerpc/lib/crtsavres.o
66 KBUILD_LDFLAGS_MODULE += -T $(srctree)/arch/powerpc/kernel/module.lds
67 ifeq ($(call ld-ifversion, -ge, 225000000, y),y)
68 # Have the linker provide sfpr if possible.
69 # There is a corresponding test in arch/powerpc/lib/Makefile
70 KBUILD_LDFLAGS_MODULE += --save-restore-funcs
72 KBUILD_LDFLAGS_MODULE += arch/powerpc/lib/crtsavres.o
76 ifdef CONFIG_CPU_LITTLE_ENDIAN
77 KBUILD_CFLAGS += -mlittle-endian
80 GNUTARGET := powerpcle
81 MULTIPLEWORD := -mno-multiple
82 KBUILD_CFLAGS_MODULE += $(call cc-option,-mno-save-toc-indirect)
84 KBUILD_CFLAGS += $(call cc-option,-mbig-endian)
88 MULTIPLEWORD := -mmultiple
92 ifndef CONFIG_CC_IS_CLANG
93 cflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mabi=elfv1)
94 cflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mcall-aixdesc)
95 aflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mabi=elfv1)
96 aflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mabi=elfv2
100 ifneq ($(cc-name),clang)
101 cflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mno-strict-align
104 cflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mbig-endian)
105 cflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mlittle-endian
106 aflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mbig-endian)
107 aflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mlittle-endian
109 ifeq ($(HAS_BIARCH),y)
110 KBUILD_CFLAGS += -m$(BITS)
111 KBUILD_AFLAGS += -m$(BITS)
112 KBUILD_LDFLAGS += -m elf$(BITS)$(LDEMULATION)
113 KBUILD_ARFLAGS += --target=elf$(BITS)-$(GNUTARGET)
116 cflags-$(CONFIG_STACKPROTECTOR) += -mstack-protector-guard=tls
117 cflags-$(CONFIG_STACKPROTECTOR) += -mstack-protector-guard-reg=r2
119 LDFLAGS_vmlinux-y := -Bstatic
120 LDFLAGS_vmlinux-$(CONFIG_RELOCATABLE) := -pie
121 LDFLAGS_vmlinux := $(LDFLAGS_vmlinux-y)
122 LDFLAGS_vmlinux += $(call ld-option,--orphan-handling=warn)
125 ifeq ($(call cc-option-yn,-mcmodel=medium),y)
126 # -mcmodel=medium breaks modules because it uses 32bit offsets from
127 # the TOC pointer to create pointers where possible. Pointers into the
128 # percpu data area are created by this method.
130 # The kernel module loader relocates the percpu data section from the
131 # original location (starting with 0xd...) to somewhere in the base
132 # kernel percpu data space (starting with 0xc...). We need a full
133 # 64bit relocation for this to work, hence -mcmodel=large.
134 KBUILD_CFLAGS_MODULE += -mcmodel=large
136 export NO_MINIMAL_TOC := -mno-minimal-toc
140 CFLAGS-$(CONFIG_PPC64) := $(call cc-option,-mtraceback=no)
141 ifndef CONFIG_CC_IS_CLANG
142 ifdef CONFIG_CPU_LITTLE_ENDIAN
143 CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mabi=elfv2,$(call cc-option,-mcall-aixdesc))
144 AFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mabi=elfv2)
146 CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mabi=elfv1)
147 CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mcall-aixdesc)
148 AFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mabi=elfv1)
151 CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mcmodel=medium,$(call cc-option,-mminimal-toc))
152 CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mno-pointers-to-nested-functions)
154 # Clang unconditionally reserves r2 on ppc32 and does not support the flag
155 # https://bugs.llvm.org/show_bug.cgi?id=39555
156 CFLAGS-$(CONFIG_PPC32) := $(call cc-option, -ffixed-r2)
158 # Clang doesn't support -mmultiple / -mno-multiple
159 # https://bugs.llvm.org/show_bug.cgi?id=39556
160 CFLAGS-$(CONFIG_PPC32) += $(call cc-option, $(MULTIPLEWORD))
162 CFLAGS-$(CONFIG_PPC32) += $(call cc-option,-mno-readonly-in-sdata)
164 ifdef CONFIG_PPC_BOOK3S_64
165 ifdef CONFIG_CPU_LITTLE_ENDIAN
166 CFLAGS-$(CONFIG_GENERIC_CPU) += -mcpu=power8
167 CFLAGS-$(CONFIG_GENERIC_CPU) += $(call cc-option,-mtune=power9,-mtune=power8)
169 CFLAGS-$(CONFIG_GENERIC_CPU) += $(call cc-option,-mtune=power7,$(call cc-option,-mtune=power5))
170 CFLAGS-$(CONFIG_GENERIC_CPU) += -mcpu=power4
172 else ifdef CONFIG_PPC_BOOK3E_64
173 CFLAGS-$(CONFIG_GENERIC_CPU) += -mcpu=powerpc64
176 ifdef CONFIG_FUNCTION_TRACER
177 CC_FLAGS_FTRACE := -pg
178 ifdef CONFIG_MPROFILE_KERNEL
179 CC_FLAGS_FTRACE += -mprofile-kernel
181 # Work around gcc code-gen bugs with -pg / -fno-omit-frame-pointer in gcc <= 4.8
182 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=44199
183 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52828
184 ifneq ($(cc-name),clang)
185 CC_FLAGS_FTRACE += $(call cc-ifversion, -lt, 0409, -mno-sched-epilog)
189 CFLAGS-$(CONFIG_TARGET_CPU_BOOL) += $(call cc-option,-mcpu=$(CONFIG_TARGET_CPU))
191 # Altivec option not allowed with e500mc64 in GCC.
193 E5500_CPU := -mcpu=powerpc64
195 E5500_CPU := $(call cc-option,-mcpu=e500mc64,-mcpu=powerpc64)
197 CFLAGS-$(CONFIG_E5500_CPU) += $(E5500_CPU)
198 CFLAGS-$(CONFIG_E6500_CPU) += $(call cc-option,-mcpu=e6500,$(E5500_CPU))
201 ifdef CONFIG_PPC_E500MC
202 CFLAGS-y += $(call cc-option,-mcpu=e500mc,-mcpu=powerpc)
204 CFLAGS-$(CONFIG_E500) += $(call cc-option,-mcpu=8540 -msoft-float,-mcpu=powerpc)
208 asinstr := $(call as-instr,lis 9$(comma)foo@high,-DHAVE_AS_ATHIGH=1)
210 KBUILD_CPPFLAGS += -Iarch/$(ARCH) $(asinstr)
211 KBUILD_AFLAGS += -Iarch/$(ARCH) $(AFLAGS-y)
212 KBUILD_CFLAGS += $(call cc-option,-msoft-float)
213 KBUILD_CFLAGS += -pipe -Iarch/$(ARCH) $(CFLAGS-y)
214 CPP = $(CC) -E $(KBUILD_CFLAGS)
216 CHECKFLAGS += -m$(BITS) -D__powerpc__ -D__powerpc$(BITS)__
217 ifdef CONFIG_CPU_BIG_ENDIAN
218 CHECKFLAGS += -D__BIG_ENDIAN__
220 CHECKFLAGS += -D__LITTLE_ENDIAN__
223 ifdef CONFIG_476FPE_ERR46
224 KBUILD_LDFLAGS_MODULE += --ppc476-workaround \
225 -T $(srctree)/arch/powerpc/platforms/44x/ppc476_modules.lds
228 # No AltiVec or VSX instructions when building kernel
229 KBUILD_CFLAGS += $(call cc-option,-mno-altivec)
230 KBUILD_CFLAGS += $(call cc-option,-mno-vsx)
232 # No SPE instruction when building kernel
233 # (We use all available options to help semi-broken compilers)
234 KBUILD_CFLAGS += $(call cc-option,-mno-spe)
235 KBUILD_CFLAGS += $(call cc-option,-mspe=no)
237 # Enable unit-at-a-time mode when possible. It shrinks the
238 # kernel considerably.
239 KBUILD_CFLAGS += $(call cc-option,-funit-at-a-time)
241 # FIXME: the module load should be taught about the additional relocs
243 # revert to pre-gcc-4.4 behaviour of .eh_frame
244 KBUILD_CFLAGS += $(call cc-option,-fno-dwarf2-cfi-asm)
246 # Never use string load/store instructions as they are
247 # often slow when they are implemented at all
248 KBUILD_CFLAGS += $(call cc-option,-mno-string)
251 KBUILD_CFLAGS += -mcpu=powerpc
254 cpu-as-$(CONFIG_4xx) += -Wa,-m405
255 cpu-as-$(CONFIG_ALTIVEC) += $(call as-option,-Wa$(comma)-maltivec)
256 cpu-as-$(CONFIG_E500) += -Wa,-me500
258 # When using '-many -mpower4' gas will first try and find a matching power4
259 # mnemonic and failing that it will allow any valid mnemonic that GAS knows
260 # about. GCC will pass -many to GAS when assembling, clang does not.
261 cpu-as-$(CONFIG_PPC_BOOK3S_64) += -Wa,-mpower4 -Wa,-many
262 cpu-as-$(CONFIG_PPC_E500MC) += $(call as-option,-Wa$(comma)-me500mc)
264 KBUILD_AFLAGS += $(cpu-as-y)
265 KBUILD_CFLAGS += $(cpu-as-y)
267 KBUILD_AFLAGS += $(aflags-y)
268 KBUILD_CFLAGS += $(cflags-y)
270 head-y := arch/powerpc/kernel/head_$(BITS).o
271 head-$(CONFIG_PPC_8xx) := arch/powerpc/kernel/head_8xx.o
272 head-$(CONFIG_40x) := arch/powerpc/kernel/head_40x.o
273 head-$(CONFIG_44x) := arch/powerpc/kernel/head_44x.o
274 head-$(CONFIG_FSL_BOOKE) := arch/powerpc/kernel/head_fsl_booke.o
276 head-$(CONFIG_PPC64) += arch/powerpc/kernel/entry_64.o
277 head-$(CONFIG_PPC_FPU) += arch/powerpc/kernel/fpu.o
278 head-$(CONFIG_ALTIVEC) += arch/powerpc/kernel/vector.o
279 head-$(CONFIG_PPC_OF_BOOT_TRAMPOLINE) += arch/powerpc/kernel/prom_init.o
281 core-y += arch/powerpc/kernel/ \
284 arch/powerpc/sysdev/ \
285 arch/powerpc/platforms/ \
286 arch/powerpc/math-emu/ \
287 arch/powerpc/crypto/ \
289 core-$(CONFIG_XMON) += arch/powerpc/xmon/
290 core-$(CONFIG_KVM) += arch/powerpc/kvm/
291 core-$(CONFIG_PERF_EVENTS) += arch/powerpc/perf/
292 core-$(CONFIG_KEXEC_FILE) += arch/powerpc/purgatory/
294 drivers-$(CONFIG_OPROFILE) += arch/powerpc/oprofile/
296 # Default to zImage, override when needed
299 # With make 3.82 we cannot mix normal and wildcard targets
300 BOOT_TARGETS1 := zImage zImage.initrd uImage
301 BOOT_TARGETS2 := zImage% dtbImage% treeImage.% cuImage.% simpleImage.% uImage.%
303 PHONY += $(BOOT_TARGETS1) $(BOOT_TARGETS2)
305 boot := arch/$(ARCH)/boot
307 $(BOOT_TARGETS1): vmlinux
308 $(Q)$(MAKE) $(build)=$(boot) $(patsubst %,$(boot)/%,$@)
309 $(BOOT_TARGETS2): vmlinux
310 $(Q)$(MAKE) $(build)=$(boot) $(patsubst %,$(boot)/%,$@)
314 $(Q)$(MAKE) $(build)=$(boot) $(patsubst %,$(boot)/%,$@)
317 $(Q)$(MAKE) $(build)=$(boot) $(patsubst %,$(boot)/%,$@)
319 # Used to create 'merged defconfigs'
320 # To use it $(call) it with the first argument as the base defconfig
321 # and the second argument as a space separated list of .config files to merge,
322 # without the .config suffix.
323 define merge_into_defconfig
324 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/kconfig/merge_config.sh \
325 -m -O $(objtree) $(srctree)/arch/$(ARCH)/configs/$(1) \
326 $(foreach config,$(2),$(srctree)/arch/$(ARCH)/configs/$(config).config)
327 +$(Q)$(MAKE) -f $(srctree)/Makefile olddefconfig
330 PHONY += pseries_le_defconfig
331 pseries_le_defconfig:
332 $(call merge_into_defconfig,pseries_defconfig,le)
334 PHONY += ppc64le_defconfig
336 $(call merge_into_defconfig,ppc64_defconfig,le)
338 PHONY += powernv_be_defconfig
339 powernv_be_defconfig:
340 $(call merge_into_defconfig,powernv_defconfig,be)
342 PHONY += mpc85xx_defconfig
344 $(call merge_into_defconfig,mpc85xx_basic_defconfig,\
345 85xx-32bit 85xx-hw fsl-emb-nonhw)
347 PHONY += mpc85xx_smp_defconfig
348 mpc85xx_smp_defconfig:
349 $(call merge_into_defconfig,mpc85xx_basic_defconfig,\
350 85xx-32bit 85xx-smp 85xx-hw fsl-emb-nonhw)
352 PHONY += corenet32_smp_defconfig
353 corenet32_smp_defconfig:
354 $(call merge_into_defconfig,corenet_basic_defconfig,\
355 85xx-32bit 85xx-smp 85xx-hw fsl-emb-nonhw dpaa)
357 PHONY += corenet64_smp_defconfig
358 corenet64_smp_defconfig:
359 $(call merge_into_defconfig,corenet_basic_defconfig,\
360 85xx-64bit 85xx-smp altivec 85xx-hw fsl-emb-nonhw dpaa)
362 PHONY += mpc86xx_defconfig
364 $(call merge_into_defconfig,mpc86xx_basic_defconfig,\
365 86xx-hw fsl-emb-nonhw)
367 PHONY += mpc86xx_smp_defconfig
368 mpc86xx_smp_defconfig:
369 $(call merge_into_defconfig,mpc86xx_basic_defconfig,\
370 86xx-smp 86xx-hw fsl-emb-nonhw)
372 PHONY += ppc32_allmodconfig
374 $(Q)$(MAKE) KCONFIG_ALLCONFIG=$(srctree)/arch/powerpc/configs/book3s_32.config \
375 -f $(srctree)/Makefile allmodconfig
377 PHONY += ppc64le_allmodconfig
378 ppc64le_allmodconfig:
379 $(Q)$(MAKE) KCONFIG_ALLCONFIG=$(srctree)/arch/powerpc/configs/le.config \
380 -f $(srctree)/Makefile allmodconfig
382 PHONY += ppc64_book3e_allmodconfig
383 ppc64_book3e_allmodconfig:
384 $(Q)$(MAKE) KCONFIG_ALLCONFIG=$(srctree)/arch/powerpc/configs/85xx-64bit.config \
385 -f $(srctree)/Makefile allmodconfig
388 @echo '* zImage - Build default images selected by kernel config'
389 @echo ' zImage.* - Compressed kernel image (arch/$(ARCH)/boot/zImage.*)'
390 @echo ' uImage - U-Boot native image format'
391 @echo ' cuImage.<dt> - Backwards compatible U-Boot image for older'
392 @echo ' versions which do not support device trees'
393 @echo ' dtbImage.<dt> - zImage with an embedded device tree blob'
394 @echo ' simpleImage.<dt> - Firmware independent image.'
395 @echo ' treeImage.<dt> - Support for older IBM 4xx firmware (not U-Boot)'
396 @echo ' install - Install kernel using'
397 @echo ' (your) ~/bin/$(INSTALLKERNEL) or'
398 @echo ' (distribution) /sbin/$(INSTALLKERNEL) or'
399 @echo ' install to $$(INSTALL_PATH) and run lilo'
400 @echo ' *_defconfig - Select default config from arch/$(ARCH)/configs'
402 @echo ' Targets with <dt> embed a device tree blob inside the image'
403 @echo ' These targets support board with firmware that does not'
404 @echo ' support passing a device tree directly. Replace <dt> with the'
405 @echo ' name of a dts file from the arch/$(ARCH)/boot/dts/ directory'
406 @echo ' (minus the .dts extension).'
410 $(Q)$(MAKE) $(build)=$(boot) install
414 $(Q)$(MAKE) $(build)=arch/$(ARCH)/kernel/vdso64 $@
417 $(Q)$(MAKE) $(build)=arch/$(ARCH)/kernel/vdso32 $@
421 $(Q)$(MAKE) $(clean)=$(boot)
423 archprepare: checkbin
425 ifdef CONFIG_STACKPROTECTOR
426 prepare: stack_protector_prepare
428 stack_protector_prepare: prepare0
429 $(eval KBUILD_CFLAGS += -mstack-protector-guard-offset=$(shell awk '{if ($$2 == "TASK_CANARY") print $$3;}' include/generated/asm-offsets.h))
432 # Check toolchain versions:
433 # - gcc-4.6 is the minimum kernel-wide version so nothing required.
435 @if test "x${CONFIG_CPU_LITTLE_ENDIAN}" = "xy" \
436 && $(LD) --version | head -1 | grep ' 2\.24$$' >/dev/null ; then \
437 echo -n '*** binutils 2.24 miscompiles weak symbols ' ; \
438 echo 'in some circumstances.' ; \
439 echo -n '*** Please use a different binutils version.' ; \
442 @if test "x${CONFIG_FTRACE_MCOUNT_USE_RECORDMCOUNT}" = "xy" -a \
443 "x${CONFIG_LD_IS_BFD}" = "xy" -a \
444 "${CONFIG_LD_VERSION}" = "23700" ; then \
445 echo -n '*** binutils 2.37 drops unused section symbols, which recordmcount ' ; \
446 echo 'is unable to handle.' ; \
447 echo '*** Please use a different binutils version.' ; \