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 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
99 ifndef CONFIG_CC_IS_CLANG
100 cflags-
$(CONFIG_CPU_LITTLE_ENDIAN
) += -mno-strict-align
103 cflags-
$(CONFIG_CPU_BIG_ENDIAN
) += $(call cc-option
,-mbig-endian
)
104 cflags-
$(CONFIG_CPU_LITTLE_ENDIAN
) += -mlittle-endian
105 aflags-
$(CONFIG_CPU_BIG_ENDIAN
) += $(call cc-option
,-mbig-endian
)
106 aflags-
$(CONFIG_CPU_LITTLE_ENDIAN
) += -mlittle-endian
108 ifeq ($(HAS_BIARCH
),y
)
109 KBUILD_CFLAGS
+= -m
$(BITS
)
110 KBUILD_AFLAGS
+= -m
$(BITS
) -Wl
,-a
$(BITS
)
111 KBUILD_LDFLAGS
+= -m elf
$(BITS
)$(LDEMULATION
)
112 KBUILD_ARFLAGS
+= --target
=elf
$(BITS
)-$(GNUTARGET
)
115 cflags-
$(CONFIG_STACKPROTECTOR
) += -mstack-protector-guard
=tls
117 cflags-
$(CONFIG_STACKPROTECTOR
) += -mstack-protector-guard-reg
=r13
119 cflags-
$(CONFIG_STACKPROTECTOR
) += -mstack-protector-guard-reg
=r2
122 LDFLAGS_vmlinux-y
:= -Bstatic
123 LDFLAGS_vmlinux-
$(CONFIG_RELOCATABLE
) := -pie
124 LDFLAGS_vmlinux
:= $(LDFLAGS_vmlinux-y
)
125 LDFLAGS_vmlinux
+= $(call ld-option
,--orphan-handling
=warn
)
128 ifeq ($(call cc-option-yn
,-mcmodel
=medium
),y
)
129 # -mcmodel=medium breaks modules because it uses 32bit offsets from
130 # the TOC pointer to create pointers where possible. Pointers into the
131 # percpu data area are created by this method.
133 # The kernel module loader relocates the percpu data section from the
134 # original location (starting with 0xd...) to somewhere in the base
135 # kernel percpu data space (starting with 0xc...). We need a full
136 # 64bit relocation for this to work, hence -mcmodel=large.
137 KBUILD_CFLAGS_MODULE
+= -mcmodel
=large
139 export NO_MINIMAL_TOC
:= -mno-minimal-toc
143 CFLAGS-
$(CONFIG_PPC64
) := $(call cc-option
,-mtraceback
=no
)
144 ifdef CONFIG_CPU_LITTLE_ENDIAN
145 CFLAGS-
$(CONFIG_PPC64
) += $(call cc-option
,-mabi
=elfv2
,$(call cc-option
,-mcall-aixdesc
))
146 AFLAGS-
$(CONFIG_PPC64
) += $(call cc-option
,-mabi
=elfv2
)
148 CFLAGS-
$(CONFIG_PPC64
) += $(call cc-option
,-mabi
=elfv1
)
149 CFLAGS-
$(CONFIG_PPC64
) += $(call cc-option
,-mcall-aixdesc
)
150 AFLAGS-
$(CONFIG_PPC64
) += $(call cc-option
,-mabi
=elfv1
)
152 CFLAGS-
$(CONFIG_PPC64
) += $(call cc-option
,-mcmodel
=medium
,$(call cc-option
,-mminimal-toc
))
153 CFLAGS-
$(CONFIG_PPC64
) += $(call cc-option
,-mno-pointers-to-nested-functions
)
155 CFLAGS-
$(CONFIG_PPC32
) := -ffixed-r2
$(MULTIPLEWORD
)
156 CFLAGS-
$(CONFIG_PPC32
) += $(call cc-option
,-mno-readonly-in-sdata
)
158 ifdef CONFIG_PPC_BOOK3S_64
159 ifdef CONFIG_CPU_LITTLE_ENDIAN
160 CFLAGS-
$(CONFIG_GENERIC_CPU
) += -mcpu
=power8
161 CFLAGS-
$(CONFIG_GENERIC_CPU
) += $(call cc-option
,-mtune
=power9
,-mtune
=power8
)
163 CFLAGS-
$(CONFIG_GENERIC_CPU
) += $(call cc-option
,-mtune
=power7
,$(call cc-option
,-mtune
=power5
))
164 CFLAGS-
$(CONFIG_GENERIC_CPU
) += $(call cc-option
,-mcpu
=power5
,-mcpu
=power4
)
167 CFLAGS-
$(CONFIG_GENERIC_CPU
) += -mcpu
=powerpc64
170 ifdef CONFIG_FUNCTION_TRACER
171 CC_FLAGS_FTRACE
:= -pg
172 ifdef CONFIG_MPROFILE_KERNEL
173 CC_FLAGS_FTRACE
+= -mprofile-kernel
175 # Work around gcc code-gen bugs with -pg / -fno-omit-frame-pointer in gcc <= 4.8
176 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=44199
177 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52828
178 ifndef CONFIG_CC_IS_CLANG
179 CC_FLAGS_FTRACE
+= $(call cc-ifversion
, -lt
, 0409, -mno-sched-epilog
)
183 CFLAGS-
$(CONFIG_TARGET_CPU_BOOL
) += $(call cc-option
,-mcpu
=$(CONFIG_TARGET_CPU
))
185 # Altivec option not allowed with e500mc64 in GCC.
187 E5500_CPU
:= -mcpu
=powerpc64
189 E5500_CPU
:= $(call cc-option
,-mcpu
=e500mc64
,-mcpu
=powerpc64
)
191 CFLAGS-
$(CONFIG_E5500_CPU
) += $(E5500_CPU
)
192 CFLAGS-
$(CONFIG_E6500_CPU
) += $(call cc-option
,-mcpu
=e6500
,$(E5500_CPU
))
195 ifdef CONFIG_PPC_E500MC
196 CFLAGS-y
+= $(call cc-option
,-mcpu
=e500mc
,-mcpu
=powerpc
)
198 CFLAGS-
$(CONFIG_E500
) += $(call cc-option
,-mcpu
=8540 -msoft-float
,-mcpu
=powerpc
)
202 asinstr
:= $(call as-instr
,lis
9$(comma
)foo@high
,-DHAVE_AS_ATHIGH
=1)
204 KBUILD_CPPFLAGS
+= -Iarch
/$(ARCH
) $(asinstr
)
205 KBUILD_AFLAGS
+= -Iarch
/$(ARCH
) $(AFLAGS-y
)
206 KBUILD_CFLAGS
+= $(call cc-option
,-msoft-float
)
207 KBUILD_CFLAGS
+= -pipe
-Iarch
/$(ARCH
) $(CFLAGS-y
)
208 CPP
= $(CC
) -E
$(KBUILD_CFLAGS
)
210 CHECKFLAGS
+= -m
$(BITS
) -D__powerpc__
-D__powerpc
$(BITS
)__
211 ifdef CONFIG_CPU_BIG_ENDIAN
212 CHECKFLAGS
+= -D__BIG_ENDIAN__
214 CHECKFLAGS
+= -D__LITTLE_ENDIAN__
217 ifdef CONFIG_476FPE_ERR46
218 KBUILD_LDFLAGS_MODULE
+= --ppc476-workaround \
219 -T
$(srctree
)/arch
/powerpc
/platforms
/44x
/ppc476_modules.lds
222 # No AltiVec or VSX instructions when building kernel
223 KBUILD_CFLAGS
+= $(call cc-option
,-mno-altivec
)
224 KBUILD_CFLAGS
+= $(call cc-option
,-mno-vsx
)
226 # No SPE instruction when building kernel
227 # (We use all available options to help semi-broken compilers)
228 KBUILD_CFLAGS
+= $(call cc-option
,-mno-spe
)
229 KBUILD_CFLAGS
+= $(call cc-option
,-mspe
=no
)
231 # Enable unit-at-a-time mode when possible. It shrinks the
232 # kernel considerably.
233 KBUILD_CFLAGS
+= $(call cc-option
,-funit-at-a-time
)
235 # FIXME: the module load should be taught about the additional relocs
237 # revert to pre-gcc-4.4 behaviour of .eh_frame
238 KBUILD_CFLAGS
+= $(call cc-option
,-fno-dwarf2-cfi-asm
)
240 # Never use string load/store instructions as they are
241 # often slow when they are implemented at all
242 KBUILD_CFLAGS
+= $(call cc-option
,-mno-string
)
245 KBUILD_CFLAGS
+= -mcpu
=powerpc
248 cpu-as-
$(CONFIG_4xx
) += -Wa
,-m405
249 cpu-as-
$(CONFIG_ALTIVEC
) += $(call as-option
,-Wa
$(comma
)-maltivec
)
250 cpu-as-
$(CONFIG_E200
) += -Wa
,-me200
251 cpu-as-
$(CONFIG_E500
) += -Wa
,-me500
253 # When using '-many -mpower4' gas will first try and find a matching power4
254 # mnemonic and failing that it will allow any valid mnemonic that GAS knows
255 # about. GCC will pass -many to GAS when assembling, clang does not.
256 cpu-as-
$(CONFIG_PPC_BOOK3S_64
) += -Wa
,-mpower4
-Wa
,-many
257 cpu-as-
$(CONFIG_PPC_E500MC
) += $(call as-option
,-Wa
$(comma
)-me500mc
)
259 KBUILD_AFLAGS
+= $(cpu-as-y
)
260 KBUILD_CFLAGS
+= $(cpu-as-y
)
262 KBUILD_AFLAGS
+= $(aflags-y
)
263 KBUILD_CFLAGS
+= $(cflags-y
)
265 head-y
:= arch
/powerpc
/kernel
/head_
$(BITS
).o
266 head-
$(CONFIG_PPC_8xx
) := arch
/powerpc
/kernel
/head_8xx.o
267 head-
$(CONFIG_40x
) := arch
/powerpc
/kernel
/head_40x.o
268 head-
$(CONFIG_44x
) := arch
/powerpc
/kernel
/head_44x.o
269 head-
$(CONFIG_FSL_BOOKE
) := arch
/powerpc
/kernel
/head_fsl_booke.o
271 head-
$(CONFIG_PPC64
) += arch
/powerpc
/kernel
/entry_64.o
272 head-
$(CONFIG_PPC_FPU
) += arch
/powerpc
/kernel
/fpu.o
273 head-
$(CONFIG_ALTIVEC
) += arch
/powerpc
/kernel
/vector.o
274 head-
$(CONFIG_PPC_OF_BOOT_TRAMPOLINE
) += arch
/powerpc
/kernel
/prom_init.o
276 # See arch/powerpc/Kbuild for content of core part of the kernel
277 core-y
+= arch
/powerpc
/
279 drivers-
$(CONFIG_OPROFILE
) += arch
/powerpc
/oprofile
/
281 # Default to zImage, override when needed
284 # With make 3.82 we cannot mix normal and wildcard targets
285 BOOT_TARGETS1
:= zImage zImage.initrd uImage
286 BOOT_TARGETS2
:= zImage
% dtbImage
% treeImage.
% cuImage.
% simpleImage.
% uImage.
%
288 PHONY
+= $(BOOT_TARGETS1
) $(BOOT_TARGETS2
)
290 boot
:= arch
/$(ARCH
)/boot
292 $(BOOT_TARGETS1
): vmlinux
293 $(Q
)$(MAKE
) $(build
)=$(boot
) $(patsubst %,$(boot
)/%,$@
)
294 $(BOOT_TARGETS2
): vmlinux
295 $(Q
)$(MAKE
) $(build
)=$(boot
) $(patsubst %,$(boot
)/%,$@
)
299 $(Q
)$(MAKE
) $(build
)=$(boot
) $(patsubst %,$(boot
)/%,$@
)
301 # Used to create 'merged defconfigs'
302 # To use it $(call) it with the first argument as the base defconfig
303 # and the second argument as a space separated list of .config files to merge,
304 # without the .config suffix.
305 define merge_into_defconfig
306 $(Q
)$(CONFIG_SHELL
) $(srctree
)/scripts
/kconfig
/merge_config.sh \
307 -m
-O
$(objtree
) $(srctree
)/arch
/$(ARCH
)/configs
/$(1) \
308 $(foreach config
,$(2),$(srctree
)/arch
/$(ARCH
)/configs
/$(config
).config
)
309 +$(Q
)$(MAKE
) -f
$(srctree
)/Makefile olddefconfig
312 PHONY
+= pseries_le_defconfig
313 pseries_le_defconfig
:
314 $(call merge_into_defconfig
,pseries_defconfig
,le
)
316 PHONY
+= ppc64le_defconfig
318 $(call merge_into_defconfig
,ppc64_defconfig
,le
)
320 PHONY
+= powernv_be_defconfig
321 powernv_be_defconfig
:
322 $(call merge_into_defconfig
,powernv_defconfig
,be
)
324 PHONY
+= mpc85xx_defconfig
326 $(call merge_into_defconfig
,mpc85xx_basic_defconfig
,\
327 85xx-32bit
85xx-hw fsl-emb-nonhw
)
329 PHONY
+= mpc85xx_smp_defconfig
330 mpc85xx_smp_defconfig
:
331 $(call merge_into_defconfig
,mpc85xx_basic_defconfig
,\
332 85xx-32bit
85xx-smp
85xx-hw fsl-emb-nonhw
)
334 PHONY
+= corenet32_smp_defconfig
335 corenet32_smp_defconfig
:
336 $(call merge_into_defconfig
,corenet_basic_defconfig
,\
337 85xx-32bit
85xx-smp
85xx-hw fsl-emb-nonhw dpaa
)
339 PHONY
+= corenet64_smp_defconfig
340 corenet64_smp_defconfig
:
341 $(call merge_into_defconfig
,corenet_basic_defconfig
,\
342 85xx-64bit
85xx-smp altivec
85xx-hw fsl-emb-nonhw dpaa
)
344 PHONY
+= mpc86xx_defconfig
346 $(call merge_into_defconfig
,mpc86xx_basic_defconfig
,\
347 86xx-hw fsl-emb-nonhw
)
349 PHONY
+= mpc86xx_smp_defconfig
350 mpc86xx_smp_defconfig
:
351 $(call merge_into_defconfig
,mpc86xx_basic_defconfig
,\
352 86xx-smp
86xx-hw fsl-emb-nonhw
)
354 PHONY
+= ppc32_allmodconfig
356 $(Q
)$(MAKE
) KCONFIG_ALLCONFIG
=$(srctree
)/arch
/powerpc
/configs
/book3s_32.config \
357 -f
$(srctree
)/Makefile allmodconfig
359 PHONY
+= ppc64le_allmodconfig
360 ppc64le_allmodconfig
:
361 $(Q
)$(MAKE
) KCONFIG_ALLCONFIG
=$(srctree
)/arch
/powerpc
/configs
/le.config \
362 -f
$(srctree
)/Makefile allmodconfig
364 PHONY
+= ppc64_book3e_allmodconfig
365 ppc64_book3e_allmodconfig
:
366 $(Q
)$(MAKE
) KCONFIG_ALLCONFIG
=$(srctree
)/arch
/powerpc
/configs
/85xx-64bit.config \
367 -f
$(srctree
)/Makefile allmodconfig
370 @echo
'* zImage - Build default images selected by kernel config'
371 @echo
' zImage.* - Compressed kernel image (arch/$(ARCH)/boot/zImage.*)'
372 @echo
' uImage - U-Boot native image format'
373 @echo
' cuImage.<dt> - Backwards compatible U-Boot image for older'
374 @echo
' versions which do not support device trees'
375 @echo
' dtbImage.<dt> - zImage with an embedded device tree blob'
376 @echo
' simpleImage.<dt> - Firmware independent image.'
377 @echo
' treeImage.<dt> - Support for older IBM 4xx firmware (not U-Boot)'
378 @echo
' install - Install kernel using'
379 @echo
' (your) ~/bin/$(INSTALLKERNEL) or'
380 @echo
' (distribution) /sbin/$(INSTALLKERNEL) or'
381 @echo
' install to $$(INSTALL_PATH) and run lilo'
382 @echo
' *_defconfig - Select default config from arch/$(ARCH)/configs'
384 @echo
' Targets with <dt> embed a device tree blob inside the image'
385 @echo
' These targets support board with firmware that does not'
386 @echo
' support passing a device tree directly. Replace <dt> with the'
387 @echo
' name of a dts file from the arch/$(ARCH)/boot/dts/ directory'
388 @echo
' (minus the .dts extension).'
392 $(Q
)$(MAKE
) $(build
)=$(boot
) install
396 $(Q
)$(MAKE
) $(build
)=arch
/$(ARCH
)/kernel
/vdso64
$@
398 $(Q
)$(MAKE
) $(build
)=arch
/$(ARCH
)/kernel
/vdso32
$@
401 $(Q
)$(MAKE
) $(clean)=$(boot
)
403 archprepare
: checkbin
405 ifdef CONFIG_STACKPROTECTOR
406 prepare
: stack_protector_prepare
408 stack_protector_prepare
: prepare0
410 $(eval KBUILD_CFLAGS
+= -mstack-protector-guard-offset
=$(shell awk
'{if ($$2 == "PACA_CANARY") print $$3;}' include/generated
/asm-offsets.h
))
412 $(eval KBUILD_CFLAGS
+= -mstack-protector-guard-offset
=$(shell awk
'{if ($$2 == "TASK_CANARY") print $$3;}' include/generated
/asm-offsets.h
))
416 # Check toolchain versions:
417 # - gcc-4.6 is the minimum kernel-wide version so nothing required.
419 @if
test "x${CONFIG_CPU_LITTLE_ENDIAN}" = "xy" \
420 && $(LD
) --version | head
-1 | grep
' 2\.24$$' >/dev
/null
; then \
421 echo
-n
'*** binutils 2.24 miscompiles weak symbols ' ; \
422 echo
'in some circumstances.' ; \
423 echo
-n
'*** Please use a different binutils version.' ; \