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 ifeq ($(CROSS_COMPILE),)
34 KBUILD_DEFCONFIG := $(shell uname -m)_defconfig
36 KBUILD_DEFCONFIG := ppc64_defconfig
40 new_nm := $(shell if $(NM) --help 2>&1 | grep -- '--synthetic' > /dev/null; then echo y; else echo n; fi)
43 NM := $(NM) --synthetic
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
59 machine-$(CONFIG_PPC64) += 64
60 machine-$(CONFIG_CPU_LITTLE_ENDIAN) += le
61 UTS_MACHINE := $(subst $(space),,$(machine-y))
63 # XXX This needs to be before we override LD below
65 KBUILD_LDFLAGS_MODULE += arch/powerpc/lib/crtsavres.o
67 KBUILD_LDFLAGS_MODULE += -T $(srctree)/arch/powerpc/kernel/module.lds
68 ifeq ($(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
71 KBUILD_LDFLAGS_MODULE += --save-restore-funcs
73 KBUILD_LDFLAGS_MODULE += arch/powerpc/lib/crtsavres.o
77 ifdef CONFIG_CPU_LITTLE_ENDIAN
78 KBUILD_CFLAGS += -mlittle-endian
81 GNUTARGET := powerpcle
82 MULTIPLEWORD := -mno-multiple
83 KBUILD_CFLAGS_MODULE += $(call cc-option,-mno-save-toc-indirect)
85 KBUILD_CFLAGS += $(call cc-option,-mbig-endian)
89 MULTIPLEWORD := -mmultiple
93 ifndef CONFIG_CC_IS_CLANG
94 cflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mabi=elfv1)
95 cflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mcall-aixdesc)
96 aflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mabi=elfv1)
97 aflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mabi=elfv2
101 ifneq ($(cc-name),clang)
102 cflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mno-strict-align
105 cflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mbig-endian)
106 cflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mlittle-endian
107 aflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mbig-endian)
108 aflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mlittle-endian
110 ifeq ($(HAS_BIARCH),y)
111 KBUILD_CFLAGS += -m$(BITS)
112 KBUILD_AFLAGS += -m$(BITS) -Wl,-a$(BITS)
113 KBUILD_LDFLAGS += -m elf$(BITS)$(LDEMULATION)
114 KBUILD_ARFLAGS += --target=elf$(BITS)-$(GNUTARGET)
117 LDFLAGS_vmlinux-y := -Bstatic
118 LDFLAGS_vmlinux-$(CONFIG_RELOCATABLE) := -pie
119 LDFLAGS_vmlinux := $(LDFLAGS_vmlinux-y)
120 LDFLAGS_vmlinux += $(call ld-option,--orphan-handling=warn)
123 ifeq ($(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.
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
134 export NO_MINIMAL_TOC := -mno-minimal-toc
138 CFLAGS-$(CONFIG_PPC64) := $(call cc-option,-mtraceback=no)
139 ifndef CONFIG_CC_IS_CLANG
140 ifdef CONFIG_CPU_LITTLE_ENDIAN
141 CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mabi=elfv2,$(call cc-option,-mcall-aixdesc))
142 AFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mabi=elfv2)
144 CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mabi=elfv1)
145 CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mcall-aixdesc)
146 AFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mabi=elfv1)
149 CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mcmodel=medium,$(call cc-option,-mminimal-toc))
150 CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mno-pointers-to-nested-functions)
152 # Clang unconditionally reserves r2 on ppc32 and does not support the flag
153 # https://bugs.llvm.org/show_bug.cgi?id=39555
154 CFLAGS-$(CONFIG_PPC32) := $(call cc-option, -ffixed-r2)
156 # Clang doesn't support -mmultiple / -mno-multiple
157 # https://bugs.llvm.org/show_bug.cgi?id=39556
158 CFLAGS-$(CONFIG_PPC32) += $(call cc-option, $(MULTIPLEWORD))
160 CFLAGS-$(CONFIG_PPC32) += $(call cc-option,-mno-readonly-in-sdata)
162 ifdef CONFIG_PPC_BOOK3S_64
163 ifdef CONFIG_CPU_LITTLE_ENDIAN
164 CFLAGS-$(CONFIG_GENERIC_CPU) += -mcpu=power8
165 CFLAGS-$(CONFIG_GENERIC_CPU) += $(call cc-option,-mtune=power9,-mtune=power8)
167 CFLAGS-$(CONFIG_GENERIC_CPU) += $(call cc-option,-mtune=power7,$(call cc-option,-mtune=power5))
168 CFLAGS-$(CONFIG_GENERIC_CPU) += -mcpu=power4
170 else ifdef CONFIG_PPC_BOOK3E_64
171 CFLAGS-$(CONFIG_GENERIC_CPU) += -mcpu=powerpc64
174 ifdef CONFIG_FUNCTION_TRACER
175 CC_FLAGS_FTRACE := -pg
176 ifdef CONFIG_MPROFILE_KERNEL
177 CC_FLAGS_FTRACE += -mprofile-kernel
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
182 ifneq ($(cc-name),clang)
183 CC_FLAGS_FTRACE += $(call cc-ifversion, -lt, 0409, -mno-sched-epilog)
187 CFLAGS-$(CONFIG_TARGET_CPU_BOOL) += $(call cc-option,-mcpu=$(CONFIG_TARGET_CPU))
189 # Altivec option not allowed with e500mc64 in GCC.
191 E5500_CPU := -mcpu=powerpc64
193 E5500_CPU := $(call cc-option,-mcpu=e500mc64,-mcpu=powerpc64)
195 CFLAGS-$(CONFIG_E5500_CPU) += $(E5500_CPU)
196 CFLAGS-$(CONFIG_E6500_CPU) += $(call cc-option,-mcpu=e6500,$(E5500_CPU))
199 ifdef CONFIG_PPC_E500MC
200 CFLAGS-y += $(call cc-option,-mcpu=e500mc,-mcpu=powerpc)
202 CFLAGS-$(CONFIG_E500) += $(call cc-option,-mcpu=8540 -msoft-float,-mcpu=powerpc)
206 asinstr := $(call as-instr,lis 9$(comma)foo@high,-DHAVE_AS_ATHIGH=1)
208 KBUILD_CPPFLAGS += -Iarch/$(ARCH) $(asinstr)
209 KBUILD_AFLAGS += -Iarch/$(ARCH) $(AFLAGS-y)
210 KBUILD_CFLAGS += $(call cc-option,-msoft-float)
211 KBUILD_CFLAGS += -pipe -Iarch/$(ARCH) $(CFLAGS-y)
212 CPP = $(CC) -E $(KBUILD_CFLAGS)
214 CHECKFLAGS += -m$(BITS) -D__powerpc__ -D__powerpc$(BITS)__
215 ifdef CONFIG_CPU_BIG_ENDIAN
216 CHECKFLAGS += -D__BIG_ENDIAN__
218 CHECKFLAGS += -D__LITTLE_ENDIAN__
221 ifdef CONFIG_476FPE_ERR46
222 KBUILD_LDFLAGS_MODULE += --ppc476-workaround \
223 -T $(srctree)/arch/powerpc/platforms/44x/ppc476_modules.lds
226 # No AltiVec or VSX instructions when building kernel
227 KBUILD_CFLAGS += $(call cc-option,-mno-altivec)
228 KBUILD_CFLAGS += $(call cc-option,-mno-vsx)
230 # No SPE instruction when building kernel
231 # (We use all available options to help semi-broken compilers)
232 KBUILD_CFLAGS += $(call cc-option,-mno-spe)
233 KBUILD_CFLAGS += $(call cc-option,-mspe=no)
235 # Enable unit-at-a-time mode when possible. It shrinks the
236 # kernel considerably.
237 KBUILD_CFLAGS += $(call cc-option,-funit-at-a-time)
239 # FIXME: the module load should be taught about the additional relocs
241 # revert to pre-gcc-4.4 behaviour of .eh_frame
242 KBUILD_CFLAGS += $(call cc-option,-fno-dwarf2-cfi-asm)
244 # Never use string load/store instructions as they are
245 # often slow when they are implemented at all
246 KBUILD_CFLAGS += $(call cc-option,-mno-string)
249 KBUILD_CFLAGS += -mcpu=powerpc
252 cpu-as-$(CONFIG_4xx) += -Wa,-m405
253 cpu-as-$(CONFIG_ALTIVEC) += $(call as-option,-Wa$(comma)-maltivec)
254 cpu-as-$(CONFIG_E500) += -Wa,-me500
256 # When using '-many -mpower4' gas will first try and find a matching power4
257 # mnemonic and failing that it will allow any valid mnemonic that GAS knows
258 # about. GCC will pass -many to GAS when assembling, clang does not.
259 cpu-as-$(CONFIG_PPC_BOOK3S_64) += -Wa,-mpower4 -Wa,-many
260 cpu-as-$(CONFIG_PPC_E500MC) += $(call as-option,-Wa$(comma)-me500mc)
262 KBUILD_AFLAGS += $(cpu-as-y)
263 KBUILD_CFLAGS += $(cpu-as-y)
265 KBUILD_AFLAGS += $(aflags-y)
266 KBUILD_CFLAGS += $(cflags-y)
268 head-y := arch/powerpc/kernel/head_$(BITS).o
269 head-$(CONFIG_PPC_8xx) := arch/powerpc/kernel/head_8xx.o
270 head-$(CONFIG_40x) := arch/powerpc/kernel/head_40x.o
271 head-$(CONFIG_44x) := arch/powerpc/kernel/head_44x.o
272 head-$(CONFIG_FSL_BOOKE) := arch/powerpc/kernel/head_fsl_booke.o
274 head-$(CONFIG_PPC64) += arch/powerpc/kernel/entry_64.o
275 head-$(CONFIG_PPC_FPU) += arch/powerpc/kernel/fpu.o
276 head-$(CONFIG_ALTIVEC) += arch/powerpc/kernel/vector.o
277 head-$(CONFIG_PPC_OF_BOOT_TRAMPOLINE) += arch/powerpc/kernel/prom_init.o
279 core-y += arch/powerpc/kernel/ \
282 arch/powerpc/sysdev/ \
283 arch/powerpc/platforms/ \
284 arch/powerpc/math-emu/ \
285 arch/powerpc/crypto/ \
287 core-$(CONFIG_XMON) += arch/powerpc/xmon/
288 core-$(CONFIG_KVM) += arch/powerpc/kvm/
289 core-$(CONFIG_PERF_EVENTS) += arch/powerpc/perf/
290 core-$(CONFIG_KEXEC_FILE) += arch/powerpc/purgatory/
292 drivers-$(CONFIG_OPROFILE) += arch/powerpc/oprofile/
294 # Default to zImage, override when needed
297 # With make 3.82 we cannot mix normal and wildcard targets
298 BOOT_TARGETS1 := zImage zImage.initrd uImage
299 BOOT_TARGETS2 := zImage% dtbImage% treeImage.% cuImage.% simpleImage.% uImage.%
301 PHONY += $(BOOT_TARGETS1) $(BOOT_TARGETS2)
303 boot := arch/$(ARCH)/boot
305 $(BOOT_TARGETS1): vmlinux
306 $(Q)$(MAKE) $(build)=$(boot) $(patsubst %,$(boot)/%,$@)
307 $(BOOT_TARGETS2): vmlinux
308 $(Q)$(MAKE) $(build)=$(boot) $(patsubst %,$(boot)/%,$@)
312 $(Q)$(MAKE) $(build)=$(boot) $(patsubst %,$(boot)/%,$@)
315 $(Q)$(MAKE) $(build)=$(boot) $(patsubst %,$(boot)/%,$@)
317 # Used to create 'merged defconfigs'
318 # To use it $(call) it with the first argument as the base defconfig
319 # and the second argument as a space separated list of .config files to merge,
320 # without the .config suffix.
321 define merge_into_defconfig
322 $(Q)$(CONFIG_SHELL) $(srctree)/scripts/kconfig/merge_config.sh \
323 -m -O $(objtree) $(srctree)/arch/$(ARCH)/configs/$(1) \
324 $(foreach config,$(2),$(srctree)/arch/$(ARCH)/configs/$(config).config)
325 +$(Q)$(MAKE) -f $(srctree)/Makefile olddefconfig
328 PHONY += pseries_le_defconfig
329 pseries_le_defconfig:
330 $(call merge_into_defconfig,pseries_defconfig,le)
332 PHONY += ppc64le_defconfig
334 $(call merge_into_defconfig,ppc64_defconfig,le)
336 PHONY += powernv_be_defconfig
337 powernv_be_defconfig:
338 $(call merge_into_defconfig,powernv_defconfig,be)
340 PHONY += mpc85xx_defconfig
342 $(call merge_into_defconfig,mpc85xx_basic_defconfig,\
343 85xx-32bit 85xx-hw fsl-emb-nonhw)
345 PHONY += mpc85xx_smp_defconfig
346 mpc85xx_smp_defconfig:
347 $(call merge_into_defconfig,mpc85xx_basic_defconfig,\
348 85xx-32bit 85xx-smp 85xx-hw fsl-emb-nonhw)
350 PHONY += corenet32_smp_defconfig
351 corenet32_smp_defconfig:
352 $(call merge_into_defconfig,corenet_basic_defconfig,\
353 85xx-32bit 85xx-smp 85xx-hw fsl-emb-nonhw dpaa)
355 PHONY += corenet64_smp_defconfig
356 corenet64_smp_defconfig:
357 $(call merge_into_defconfig,corenet_basic_defconfig,\
358 85xx-64bit 85xx-smp altivec 85xx-hw fsl-emb-nonhw dpaa)
360 PHONY += mpc86xx_defconfig
362 $(call merge_into_defconfig,mpc86xx_basic_defconfig,\
363 86xx-hw fsl-emb-nonhw)
365 PHONY += mpc86xx_smp_defconfig
366 mpc86xx_smp_defconfig:
367 $(call merge_into_defconfig,mpc86xx_basic_defconfig,\
368 86xx-smp 86xx-hw fsl-emb-nonhw)
370 PHONY += ppc32_allmodconfig
372 $(Q)$(MAKE) KCONFIG_ALLCONFIG=$(srctree)/arch/powerpc/configs/book3s_32.config \
373 -f $(srctree)/Makefile allmodconfig
375 PHONY += ppc64le_allmodconfig
376 ppc64le_allmodconfig:
377 $(Q)$(MAKE) KCONFIG_ALLCONFIG=$(srctree)/arch/powerpc/configs/le.config \
378 -f $(srctree)/Makefile allmodconfig
380 PHONY += ppc64_book3e_allmodconfig
381 ppc64_book3e_allmodconfig:
382 $(Q)$(MAKE) KCONFIG_ALLCONFIG=$(srctree)/arch/powerpc/configs/85xx-64bit.config \
383 -f $(srctree)/Makefile allmodconfig
386 @echo '* zImage - Build default images selected by kernel config'
387 @echo ' zImage.* - Compressed kernel image (arch/$(ARCH)/boot/zImage.*)'
388 @echo ' uImage - U-Boot native image format'
389 @echo ' cuImage.<dt> - Backwards compatible U-Boot image for older'
390 @echo ' versions which do not support device trees'
391 @echo ' dtbImage.<dt> - zImage with an embedded device tree blob'
392 @echo ' simpleImage.<dt> - Firmware independent image.'
393 @echo ' treeImage.<dt> - Support for older IBM 4xx firmware (not U-Boot)'
394 @echo ' install - Install kernel using'
395 @echo ' (your) ~/bin/$(INSTALLKERNEL) or'
396 @echo ' (distribution) /sbin/$(INSTALLKERNEL) or'
397 @echo ' install to $$(INSTALL_PATH) and run lilo'
398 @echo ' *_defconfig - Select default config from arch/$(ARCH)/configs'
400 @echo ' Targets with <dt> embed a device tree blob inside the image'
401 @echo ' These targets support board with firmware that does not'
402 @echo ' support passing a device tree directly. Replace <dt> with the'
403 @echo ' name of a dts file from the arch/$(ARCH)/boot/dts/ directory'
404 @echo ' (minus the .dts extension).'
408 $(Q)$(MAKE) $(build)=$(boot) install
412 $(Q)$(MAKE) $(build)=arch/$(ARCH)/kernel/vdso64 $@
415 $(Q)$(MAKE) $(build)=arch/$(ARCH)/kernel/vdso32 $@
419 $(Q)$(MAKE) $(clean)=$(boot)
421 archprepare: checkbin
423 # Use the file '.tmp_gas_check' for binutils tests, as gas won't output
424 # to stdout and these checks are run even on install targets.
425 TOUT := .tmp_gas_check
427 # Check toolchain versions:
428 # - gcc-4.6 is the minimum kernel-wide version so nothing required.
430 @if test "x${CONFIG_CPU_LITTLE_ENDIAN}" = "xy" \
431 && $(LD) --version | head -1 | grep ' 2\.24$$' >/dev/null ; then \
432 echo -n '*** binutils 2.24 miscompiles weak symbols ' ; \
433 echo 'in some circumstances.' ; \
434 echo -n '*** Please use a different binutils version.' ; \
439 CLEAN_FILES += $(TOUT)