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 4# this architecture. 5# 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 8# for more details. 9# 10# Copyright (C) 1994 by Linus Torvalds 11# Changes for PPC by Gary Thomas 12# Rewritten by Cort Dougan and Paul Mackerras 13# 14 15HAS_BIARCH := $(call cc-option-yn, -m32) 16 17# Set default 32 bits cross compilers for vdso and boot wrapper 18CROSS32_COMPILE ?= 19 20ifeq ($(HAS_BIARCH),y) 21ifeq ($(CROSS32_COMPILE),) 22ifdef CONFIG_PPC32 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. 27KBUILD_CFLAGS += -mcpu=powerpc 28KBUILD_AFLAGS += -mcpu=powerpc 29endif 30endif 31endif 32 33ifeq ($(CROSS_COMPILE),) 34KBUILD_DEFCONFIG := $(shell uname -m)_defconfig 35else 36KBUILD_DEFCONFIG := ppc64_defconfig 37endif 38 39ifdef CONFIG_PPC64 40new_nm := $(shell if $(NM) --help 2>&1 | grep -- '--synthetic' > /dev/null; then echo y; else echo n; fi) 41 42ifeq ($(new_nm),y) 43NM := $(NM) --synthetic 44endif 45endif 46 47# BITS is used as extension for files which are available in a 32 bit 48# and a 64 bit version to simplify shared Makefiles. 49# e.g.: obj-y += foo_$(BITS).o 50export BITS 51 52ifdef CONFIG_PPC64 53 BITS := 64 54else 55 BITS := 32 56endif 57 58machine-y = ppc 59machine-$(CONFIG_PPC64) += 64 60machine-$(CONFIG_CPU_LITTLE_ENDIAN) += le 61UTS_MACHINE := $(subst $(space),,$(machine-y)) 62 63# XXX This needs to be before we override LD below 64ifdef CONFIG_PPC32 65KBUILD_LDFLAGS_MODULE += arch/powerpc/lib/crtsavres.o 66else 67KBUILD_LDFLAGS_MODULE += -T $(srctree)/arch/powerpc/kernel/module.lds 68ifeq ($(call ld-ifversion, -ge, 225000000, y),y) 69# Have the linker provide sfpr if possible. 70# There is a corresponding test in arch/powerpc/lib/Makefile 71KBUILD_LDFLAGS_MODULE += --save-restore-funcs 72else 73KBUILD_LDFLAGS_MODULE += arch/powerpc/lib/crtsavres.o 74endif 75endif 76 77ifdef CONFIG_CPU_LITTLE_ENDIAN 78KBUILD_CFLAGS += -mlittle-endian 79KBUILD_LDFLAGS += -EL 80LDEMULATION := lppc 81GNUTARGET := powerpcle 82MULTIPLEWORD := -mno-multiple 83KBUILD_CFLAGS_MODULE += $(call cc-option,-mno-save-toc-indirect) 84else 85KBUILD_CFLAGS += $(call cc-option,-mbig-endian) 86KBUILD_LDFLAGS += -EB 87LDEMULATION := ppc 88GNUTARGET := powerpc 89MULTIPLEWORD := -mmultiple 90endif 91 92ifdef CONFIG_PPC64 93ifndef CONFIG_CC_IS_CLANG 94cflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mabi=elfv1) 95cflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mcall-aixdesc) 96aflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mabi=elfv1) 97aflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mabi=elfv2 98endif 99endif 100 101ifneq ($(cc-name),clang) 102 cflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mno-strict-align 103endif 104 105cflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mbig-endian) 106cflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mlittle-endian 107aflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mbig-endian) 108aflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mlittle-endian 109 110ifeq ($(HAS_BIARCH),y) 111KBUILD_CFLAGS += -m$(BITS) 112KBUILD_AFLAGS += -m$(BITS) -Wl,-a$(BITS) 113KBUILD_LDFLAGS += -m elf$(BITS)$(LDEMULATION) 114KBUILD_ARFLAGS += --target=elf$(BITS)-$(GNUTARGET) 115endif 116 117LDFLAGS_vmlinux-y := -Bstatic 118LDFLAGS_vmlinux-$(CONFIG_RELOCATABLE) := -pie 119LDFLAGS_vmlinux := $(LDFLAGS_vmlinux-y) 120LDFLAGS_vmlinux += $(call ld-option,--orphan-handling=warn) 121 122ifdef CONFIG_PPC64 123ifeq ($(call cc-option-yn,-mcmodel=medium),y) 124 # -mcmodel=medium breaks modules because it uses 32bit offsets from 125 # the TOC pointer to create pointers where possible. Pointers into the 126 # percpu data area are created by this method. 127 # 128 # The kernel module loader relocates the percpu data section from the 129 # original location (starting with 0xd...) to somewhere in the base 130 # kernel percpu data space (starting with 0xc...). We need a full 131 # 64bit relocation for this to work, hence -mcmodel=large. 132 KBUILD_CFLAGS_MODULE += -mcmodel=large 133else 134 export NO_MINIMAL_TOC := -mno-minimal-toc 135endif 136endif 137 138CFLAGS-$(CONFIG_PPC64) := $(call cc-option,-mtraceback=no) 139ifndef CONFIG_CC_IS_CLANG 140ifdef CONFIG_CPU_LITTLE_ENDIAN 141CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mabi=elfv2,$(call cc-option,-mcall-aixdesc)) 142AFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mabi=elfv2) 143else 144CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mabi=elfv1) 145CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mcall-aixdesc) 146AFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mabi=elfv1) 147endif 148endif 149CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mcmodel=medium,$(call cc-option,-mminimal-toc)) 150CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mno-pointers-to-nested-functions) 151 152# Clang unconditionally reserves r2 on ppc32 and does not support the flag 153# https://bugs.llvm.org/show_bug.cgi?id=39555 154CFLAGS-$(CONFIG_PPC32) := $(call cc-option, -ffixed-r2) 155 156# Clang doesn't support -mmultiple / -mno-multiple 157# https://bugs.llvm.org/show_bug.cgi?id=39556 158CFLAGS-$(CONFIG_PPC32) += $(call cc-option, $(MULTIPLEWORD)) 159 160CFLAGS-$(CONFIG_PPC32) += $(call cc-option,-mno-readonly-in-sdata) 161 162ifdef CONFIG_PPC_BOOK3S_64 163ifdef CONFIG_CPU_LITTLE_ENDIAN 164CFLAGS-$(CONFIG_GENERIC_CPU) += -mcpu=power8 165CFLAGS-$(CONFIG_GENERIC_CPU) += $(call cc-option,-mtune=power9,-mtune=power8) 166else 167CFLAGS-$(CONFIG_GENERIC_CPU) += $(call cc-option,-mtune=power7,$(call cc-option,-mtune=power5)) 168CFLAGS-$(CONFIG_GENERIC_CPU) += $(call cc-option,-mcpu=power5,-mcpu=power4) 169endif 170else 171CFLAGS-$(CONFIG_GENERIC_CPU) += -mcpu=powerpc64 172endif 173 174ifdef CONFIG_FUNCTION_TRACER 175CC_FLAGS_FTRACE := -pg 176ifdef CONFIG_MPROFILE_KERNEL 177CC_FLAGS_FTRACE += -mprofile-kernel 178endif 179# Work around gcc code-gen bugs with -pg / -fno-omit-frame-pointer in gcc <= 4.8 180# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=44199 181# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52828 182ifneq ($(cc-name),clang) 183CC_FLAGS_FTRACE += $(call cc-ifversion, -lt, 0409, -mno-sched-epilog) 184endif 185endif 186 187CFLAGS-$(CONFIG_TARGET_CPU_BOOL) += $(call cc-option,-mcpu=$(CONFIG_TARGET_CPU)) 188 189# Altivec option not allowed with e500mc64 in GCC. 190ifdef CONFIG_ALTIVEC 191E5500_CPU := -mcpu=powerpc64 192else 193E5500_CPU := $(call cc-option,-mcpu=e500mc64,-mcpu=powerpc64) 194endif 195CFLAGS-$(CONFIG_E5500_CPU) += $(E5500_CPU) 196CFLAGS-$(CONFIG_E6500_CPU) += $(call cc-option,-mcpu=e6500,$(E5500_CPU)) 197 198ifdef CONFIG_PPC32 199ifdef CONFIG_PPC_E500MC 200CFLAGS-y += $(call cc-option,-mcpu=e500mc,-mcpu=powerpc) 201else 202CFLAGS-$(CONFIG_E500) += $(call cc-option,-mcpu=8540 -msoft-float,-mcpu=powerpc) 203endif 204endif 205 206asinstr := $(call as-instr,lis 9$(comma)foo@high,-DHAVE_AS_ATHIGH=1) 207 208KBUILD_CPPFLAGS += -Iarch/$(ARCH) $(asinstr) 209KBUILD_AFLAGS += -Iarch/$(ARCH) $(AFLAGS-y) 210KBUILD_CFLAGS += $(call cc-option,-msoft-float) 211KBUILD_CFLAGS += -pipe -Iarch/$(ARCH) $(CFLAGS-y) 212CPP = $(CC) -E $(KBUILD_CFLAGS) 213 214CHECKFLAGS += -m$(BITS) -D__powerpc__ -D__powerpc$(BITS)__ 215ifdef CONFIG_CPU_BIG_ENDIAN 216CHECKFLAGS += -D__BIG_ENDIAN__ 217else 218CHECKFLAGS += -D__LITTLE_ENDIAN__ 219endif 220 221ifdef CONFIG_476FPE_ERR46 222 KBUILD_LDFLAGS_MODULE += --ppc476-workaround \ 223 -T $(srctree)/arch/powerpc/platforms/44x/ppc476_modules.lds 224endif 225 226# No AltiVec or VSX instructions when building kernel 227KBUILD_CFLAGS += $(call cc-option,-mno-altivec) 228KBUILD_CFLAGS += $(call cc-option,-mno-vsx) 229 230# No SPE instruction when building kernel 231# (We use all available options to help semi-broken compilers) 232KBUILD_CFLAGS += $(call cc-option,-mno-spe) 233KBUILD_CFLAGS += $(call cc-option,-mspe=no) 234 235# Enable unit-at-a-time mode when possible. It shrinks the 236# kernel considerably. 237KBUILD_CFLAGS += $(call cc-option,-funit-at-a-time) 238 239# FIXME: the module load should be taught about the additional relocs 240# generated by this. 241# revert to pre-gcc-4.4 behaviour of .eh_frame 242KBUILD_CFLAGS += $(call cc-option,-fno-dwarf2-cfi-asm) 243 244# Never use string load/store instructions as they are 245# often slow when they are implemented at all 246KBUILD_CFLAGS += $(call cc-option,-mno-string) 247 248ifdef CONFIG_6xx 249KBUILD_CFLAGS += -mcpu=powerpc 250endif 251 252cpu-as-$(CONFIG_4xx) += -Wa,-m405 253cpu-as-$(CONFIG_ALTIVEC) += $(call as-option,-Wa$(comma)-maltivec) 254cpu-as-$(CONFIG_E200) += -Wa,-me200 255cpu-as-$(CONFIG_E500) += -Wa,-me500 256 257# When using '-many -mpower4' gas will first try and find a matching power4 258# mnemonic and failing that it will allow any valid mnemonic that GAS knows 259# about. GCC will pass -many to GAS when assembling, clang does not. 260cpu-as-$(CONFIG_PPC_BOOK3S_64) += -Wa,-mpower4 -Wa,-many 261cpu-as-$(CONFIG_PPC_E500MC) += $(call as-option,-Wa$(comma)-me500mc) 262 263KBUILD_AFLAGS += $(cpu-as-y) 264KBUILD_CFLAGS += $(cpu-as-y) 265 266KBUILD_AFLAGS += $(aflags-y) 267KBUILD_CFLAGS += $(cflags-y) 268 269head-y := arch/powerpc/kernel/head_$(BITS).o 270head-$(CONFIG_PPC_8xx) := arch/powerpc/kernel/head_8xx.o 271head-$(CONFIG_40x) := arch/powerpc/kernel/head_40x.o 272head-$(CONFIG_44x) := arch/powerpc/kernel/head_44x.o 273head-$(CONFIG_FSL_BOOKE) := arch/powerpc/kernel/head_fsl_booke.o 274 275head-$(CONFIG_PPC64) += arch/powerpc/kernel/entry_64.o 276head-$(CONFIG_PPC_FPU) += arch/powerpc/kernel/fpu.o 277head-$(CONFIG_ALTIVEC) += arch/powerpc/kernel/vector.o 278head-$(CONFIG_PPC_OF_BOOT_TRAMPOLINE) += arch/powerpc/kernel/prom_init.o 279 280core-y += arch/powerpc/kernel/ \ 281 arch/powerpc/mm/ \ 282 arch/powerpc/lib/ \ 283 arch/powerpc/sysdev/ \ 284 arch/powerpc/platforms/ \ 285 arch/powerpc/math-emu/ \ 286 arch/powerpc/crypto/ \ 287 arch/powerpc/net/ 288core-$(CONFIG_XMON) += arch/powerpc/xmon/ 289core-$(CONFIG_KVM) += arch/powerpc/kvm/ 290core-$(CONFIG_PERF_EVENTS) += arch/powerpc/perf/ 291core-$(CONFIG_KEXEC_FILE) += arch/powerpc/purgatory/ 292 293drivers-$(CONFIG_OPROFILE) += arch/powerpc/oprofile/ 294 295# Default to zImage, override when needed 296all: zImage 297 298# With make 3.82 we cannot mix normal and wildcard targets 299BOOT_TARGETS1 := zImage zImage.initrd uImage 300BOOT_TARGETS2 := zImage% dtbImage% treeImage.% cuImage.% simpleImage.% uImage.% 301 302PHONY += $(BOOT_TARGETS1) $(BOOT_TARGETS2) 303 304boot := arch/$(ARCH)/boot 305 306$(BOOT_TARGETS1): vmlinux 307 $(Q)$(MAKE) $(build)=$(boot) $(patsubst %,$(boot)/%,$@) 308$(BOOT_TARGETS2): vmlinux 309 $(Q)$(MAKE) $(build)=$(boot) $(patsubst %,$(boot)/%,$@) 310 311 312bootwrapper_install: 313 $(Q)$(MAKE) $(build)=$(boot) $(patsubst %,$(boot)/%,$@) 314 315%.dtb: scripts 316 $(Q)$(MAKE) $(build)=$(boot) $(patsubst %,$(boot)/%,$@) 317 318# Used to create 'merged defconfigs' 319# To use it $(call) it with the first argument as the base defconfig 320# and the second argument as a space separated list of .config files to merge, 321# without the .config suffix. 322define merge_into_defconfig 323 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/kconfig/merge_config.sh \ 324 -m -O $(objtree) $(srctree)/arch/$(ARCH)/configs/$(1) \ 325 $(foreach config,$(2),$(srctree)/arch/$(ARCH)/configs/$(config).config) 326 +$(Q)$(MAKE) -f $(srctree)/Makefile olddefconfig 327endef 328 329PHONY += pseries_le_defconfig 330pseries_le_defconfig: 331 $(call merge_into_defconfig,pseries_defconfig,le) 332 333PHONY += ppc64le_defconfig 334ppc64le_defconfig: 335 $(call merge_into_defconfig,ppc64_defconfig,le) 336 337PHONY += powernv_be_defconfig 338powernv_be_defconfig: 339 $(call merge_into_defconfig,powernv_defconfig,be) 340 341PHONY += mpc85xx_defconfig 342mpc85xx_defconfig: 343 $(call merge_into_defconfig,mpc85xx_basic_defconfig,\ 344 85xx-32bit 85xx-hw fsl-emb-nonhw) 345 346PHONY += mpc85xx_smp_defconfig 347mpc85xx_smp_defconfig: 348 $(call merge_into_defconfig,mpc85xx_basic_defconfig,\ 349 85xx-32bit 85xx-smp 85xx-hw fsl-emb-nonhw) 350 351PHONY += corenet32_smp_defconfig 352corenet32_smp_defconfig: 353 $(call merge_into_defconfig,corenet_basic_defconfig,\ 354 85xx-32bit 85xx-smp 85xx-hw fsl-emb-nonhw dpaa) 355 356PHONY += corenet64_smp_defconfig 357corenet64_smp_defconfig: 358 $(call merge_into_defconfig,corenet_basic_defconfig,\ 359 85xx-64bit 85xx-smp altivec 85xx-hw fsl-emb-nonhw dpaa) 360 361PHONY += mpc86xx_defconfig 362mpc86xx_defconfig: 363 $(call merge_into_defconfig,mpc86xx_basic_defconfig,\ 364 86xx-hw fsl-emb-nonhw) 365 366PHONY += mpc86xx_smp_defconfig 367mpc86xx_smp_defconfig: 368 $(call merge_into_defconfig,mpc86xx_basic_defconfig,\ 369 86xx-smp 86xx-hw fsl-emb-nonhw) 370 371PHONY += ppc32_allmodconfig 372ppc32_allmodconfig: 373 $(Q)$(MAKE) KCONFIG_ALLCONFIG=$(srctree)/arch/powerpc/configs/book3s_32.config \ 374 -f $(srctree)/Makefile allmodconfig 375 376PHONY += ppc64le_allmodconfig 377ppc64le_allmodconfig: 378 $(Q)$(MAKE) KCONFIG_ALLCONFIG=$(srctree)/arch/powerpc/configs/le.config \ 379 -f $(srctree)/Makefile allmodconfig 380 381PHONY += ppc64_book3e_allmodconfig 382ppc64_book3e_allmodconfig: 383 $(Q)$(MAKE) KCONFIG_ALLCONFIG=$(srctree)/arch/powerpc/configs/85xx-64bit.config \ 384 -f $(srctree)/Makefile allmodconfig 385 386define archhelp 387 @echo '* zImage - Build default images selected by kernel config' 388 @echo ' zImage.* - Compressed kernel image (arch/$(ARCH)/boot/zImage.*)' 389 @echo ' uImage - U-Boot native image format' 390 @echo ' cuImage.<dt> - Backwards compatible U-Boot image for older' 391 @echo ' versions which do not support device trees' 392 @echo ' dtbImage.<dt> - zImage with an embedded device tree blob' 393 @echo ' simpleImage.<dt> - Firmware independent image.' 394 @echo ' treeImage.<dt> - Support for older IBM 4xx firmware (not U-Boot)' 395 @echo ' install - Install kernel using' 396 @echo ' (your) ~/bin/$(INSTALLKERNEL) or' 397 @echo ' (distribution) /sbin/$(INSTALLKERNEL) or' 398 @echo ' install to $$(INSTALL_PATH) and run lilo' 399 @echo ' *_defconfig - Select default config from arch/$(ARCH)/configs' 400 @echo '' 401 @echo ' Targets with <dt> embed a device tree blob inside the image' 402 @echo ' These targets support board with firmware that does not' 403 @echo ' support passing a device tree directly. Replace <dt> with the' 404 @echo ' name of a dts file from the arch/$(ARCH)/boot/dts/ directory' 405 @echo ' (minus the .dts extension).' 406endef 407 408install: 409 $(Q)$(MAKE) $(build)=$(boot) install 410 411vdso_install: 412ifdef CONFIG_PPC64 413 $(Q)$(MAKE) $(build)=arch/$(ARCH)/kernel/vdso64 $@ 414endif 415ifdef CONFIG_VDSO32 416 $(Q)$(MAKE) $(build)=arch/$(ARCH)/kernel/vdso32 $@ 417endif 418 419archclean: 420 $(Q)$(MAKE) $(clean)=$(boot) 421 422archprepare: checkbin 423 424# Use the file '.tmp_gas_check' for binutils tests, as gas won't output 425# to stdout and these checks are run even on install targets. 426TOUT := .tmp_gas_check 427 428# Check toolchain versions: 429# - gcc-4.6 is the minimum kernel-wide version so nothing required. 430checkbin: 431 @if test "x${CONFIG_CPU_LITTLE_ENDIAN}" = "xy" \ 432 && $(LD) --version | head -1 | grep ' 2\.24$$' >/dev/null ; then \ 433 echo -n '*** binutils 2.24 miscompiles weak symbols ' ; \ 434 echo 'in some circumstances.' ; \ 435 echo -n '*** Please use a different binutils version.' ; \ 436 false ; \ 437 fi 438 439 440CLEAN_FILES += $(TOUT) 441 442