blob: 051247027da0bafa728f98e2e858aef0b05d8fdf [file] [log] [blame]
Paul Mackerras14cf11a2005-09-26 16:04:21 +10001# This file is included by the global makefile so that you can add your own
Masahiro Yamada8212f892021-10-13 15:36:22 +09002# architecture-specific flags and dependencies.
Paul Mackerras14cf11a2005-09-26 16:04:21 +10003#
4# This file is subject to the terms and conditions of the GNU General Public
5# License. See the file "COPYING" in the main directory of this archive
6# for more details.
7#
8# Copyright (C) 1994 by Linus Torvalds
9# Changes for PPC by Gary Thomas
10# Rewritten by Cort Dougan and Paul Mackerras
11#
12
Michael Ellerman402928b52023-12-06 22:55:48 +110013ifdef cross_compiling
14 ifeq ($(CROSS_COMPILE),)
15 # Auto detect cross compiler prefix.
16 # Look for: (powerpc(64(le)?)?)(-unknown)?-linux(-gnu)?-
17 CC_ARCHES := powerpc powerpc64 powerpc64le
18 CC_SUFFIXES := linux linux-gnu unknown-linux-gnu
19 CROSS_COMPILE := $(call cc-cross-prefix, $(foreach a,$(CC_ARCHES), \
20 $(foreach s,$(CC_SUFFIXES),$(a)-$(s)-)))
21 endif
22endif
23
Paul Mackerras14cf11a2005-09-26 16:04:21 +100024HAS_BIARCH := $(call cc-option-yn, -m32)
25
Paul Mackerras14cf11a2005-09-26 16:04:21 +100026# Set default 32 bits cross compilers for vdso and boot wrapper
27CROSS32_COMPILE ?=
28
Michael Ellermanaf5cd052019-02-07 16:16:52 +110029# If we're on a ppc/ppc64/ppc64le machine use that defconfig, otherwise just use
Michael Ellerman22f17b02023-12-06 22:55:47 +110030# ppc64le_defconfig because we have nothing better to go on.
Michael Ellermanaf5cd052019-02-07 16:16:52 +110031uname := $(shell uname -m)
Michael Ellerman22f17b02023-12-06 22:55:47 +110032KBUILD_DEFCONFIG := $(if $(filter ppc%,$(uname)),$(uname),ppc64le)_defconfig
Paul Mackerras8a5abdf2005-11-18 16:39:08 +110033
Paul Mackerras14cf11a2005-09-26 16:04:21 +100034new_nm := $(shell if $(NM) --help 2>&1 | grep -- '--synthetic' > /dev/null; then echo y; else echo n; fi)
35
36ifeq ($(new_nm),y)
37NM := $(NM) --synthetic
38endif
39
Michael Ellerman68201fb2016-08-11 16:03:14 +100040# BITS is used as extension for files which are available in a 32 bit
41# and a 64 bit version to simplify shared Makefiles.
42# e.g.: obj-y += foo_$(BITS).o
43export BITS
44
45ifdef CONFIG_PPC64
46 BITS := 64
47else
48 BITS := 32
Paul Mackerras14cf11a2005-09-26 16:04:21 +100049endif
50
Michael Ellerman57073e22016-08-11 16:03:15 +100051machine-y = ppc
52machine-$(CONFIG_PPC64) += 64
53machine-$(CONFIG_CPU_LITTLE_ENDIAN) += le
54UTS_MACHINE := $(subst $(space),,$(machine-y))
Stephen Rothwell190554d2005-10-13 16:14:15 +100055
Masahiro Yamada54a11652023-01-19 17:22:50 +090056ifeq ($(CONFIG_PPC64)$(CONFIG_LD_IS_BFD),yy)
Michael Ellermanb40b2382017-07-26 15:00:42 +100057# Have the linker provide sfpr if possible.
58# There is a corresponding test in arch/powerpc/lib/Makefile
59KBUILD_LDFLAGS_MODULE += --save-restore-funcs
60else
61KBUILD_LDFLAGS_MODULE += arch/powerpc/lib/crtsavres.o
62endif
Michael Ellermanb40b2382017-07-26 15:00:42 +100063
Rodrigo R. Galvaobadf4362018-08-06 13:42:03 -030064ifdef CONFIG_CPU_LITTLE_ENDIAN
Nicholas Piggin1421dc62018-05-30 22:19:21 +100065KBUILD_CFLAGS += -mlittle-endian
Masahiro Yamadad503ac52018-08-24 08:20:39 +090066KBUILD_LDFLAGS += -EL
Ian Munsied72b0802013-09-23 12:05:11 +100067LDEMULATION := lppc
68GNUTARGET := powerpcle
69MULTIPLEWORD := -mno-multiple
Tony Breedsd3d35d92014-03-12 15:12:01 +110070KBUILD_CFLAGS_MODULE += $(call cc-option,-mno-save-toc-indirect)
Ian Munsied72b0802013-09-23 12:05:11 +100071else
Nicholas Piggin1421dc62018-05-30 22:19:21 +100072KBUILD_CFLAGS += $(call cc-option,-mbig-endian)
Masahiro Yamadad503ac52018-08-24 08:20:39 +090073KBUILD_LDFLAGS += -EB
Ian Munsied72b0802013-09-23 12:05:11 +100074LDEMULATION := ppc
75GNUTARGET := powerpc
76MULTIPLEWORD := -mmultiple
77endif
78
Nicholas Piggin4dc831a2016-11-27 13:46:20 +110079ifdef CONFIG_PPC64
Nathan Chancellor465bfd92019-11-18 21:57:10 -070080ifndef CONFIG_CC_IS_CLANG
Christophe Leroy661aa882022-05-09 07:36:06 +020081cflags-$(CONFIG_PPC64_ELF_ABI_V1) += $(call cc-option,-mabi=elfv1)
82cflags-$(CONFIG_PPC64_ELF_ABI_V1) += $(call cc-option,-mcall-aixdesc)
83aflags-$(CONFIG_PPC64_ELF_ABI_V1) += $(call cc-option,-mabi=elfv1)
84aflags-$(CONFIG_PPC64_ELF_ABI_V2) += -mabi=elfv2
Nicholas Piggin4dc831a2016-11-27 13:46:20 +110085endif
Nathan Chancellor465bfd92019-11-18 21:57:10 -070086endif
Nicholas Piggin4dc831a2016-11-27 13:46:20 +110087
Masahiro Yamada076f4212018-10-30 22:26:33 +090088ifndef CONFIG_CC_IS_CLANG
Michael Ellerman164af592016-08-09 22:43:46 +100089 cflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mno-strict-align
90endif
91
Nicholas Piggin1421dc62018-05-30 22:19:21 +100092cflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mbig-endian)
93cflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mlittle-endian
Michael Ellerman164af592016-08-09 22:43:46 +100094aflags-$(CONFIG_CPU_BIG_ENDIAN) += $(call cc-option,-mbig-endian)
95aflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -mlittle-endian
96
Paul Mackerras14cf11a2005-09-26 16:04:21 +100097ifeq ($(HAS_BIARCH),y)
Nicholas Piggin1421dc62018-05-30 22:19:21 +100098KBUILD_CFLAGS += -m$(BITS)
Nathan Chancellor31f48f12023-01-11 20:05:02 -070099KBUILD_AFLAGS += -m$(BITS)
Masahiro Yamadad503ac52018-08-24 08:20:39 +0900100KBUILD_LDFLAGS += -m elf$(BITS)$(LDEMULATION)
Paul Mackerras14cf11a2005-09-26 16:04:21 +1000101endif
102
Christophe Leroyc3ff2a52018-09-27 07:05:53 +0000103cflags-$(CONFIG_STACKPROTECTOR) += -mstack-protector-guard=tls
Christophe Leroy06ec27ae2018-09-27 07:05:55 +0000104ifdef CONFIG_PPC64
105cflags-$(CONFIG_STACKPROTECTOR) += -mstack-protector-guard-reg=r13
106else
Christophe Leroyc3ff2a52018-09-27 07:05:53 +0000107cflags-$(CONFIG_STACKPROTECTOR) += -mstack-protector-guard-reg=r2
Christophe Leroy06ec27ae2018-09-27 07:05:55 +0000108endif
Christophe Leroyc3ff2a52018-09-27 07:05:53 +0000109
Suzuki Poulose9c5f7d32011-12-14 22:58:12 +0000110LDFLAGS_vmlinux-y := -Bstatic
111LDFLAGS_vmlinux-$(CONFIG_RELOCATABLE) := -pie
Fangrui Song03557852021-08-13 13:05:11 -0700112LDFLAGS_vmlinux-$(CONFIG_RELOCATABLE) += -z notext
Suzuki Poulose9c5f7d32011-12-14 22:58:12 +0000113LDFLAGS_vmlinux := $(LDFLAGS_vmlinux-y)
Paul Mackerras14cf11a2005-09-26 16:04:21 +1000114
Rodrigo R. Galvaobadf4362018-08-06 13:42:03 -0300115ifdef CONFIG_PPC64
Nicholas Piggin77e69ee2023-04-08 12:17:52 +1000116ifndef CONFIG_PPC_KERNEL_PCREL
Anton Blanchard1fbe9cf2012-11-26 17:41:08 +0000117ifeq ($(call cc-option-yn,-mcmodel=medium),y)
118 # -mcmodel=medium breaks modules because it uses 32bit offsets from
119 # the TOC pointer to create pointers where possible. Pointers into the
120 # percpu data area are created by this method.
121 #
122 # The kernel module loader relocates the percpu data section from the
123 # original location (starting with 0xd...) to somewhere in the base
124 # kernel percpu data space (starting with 0xc...). We need a full
125 # 64bit relocation for this to work, hence -mcmodel=large.
126 KBUILD_CFLAGS_MODULE += -mcmodel=large
127else
128 export NO_MINIMAL_TOC := -mno-minimal-toc
129endif
130endif
Nicholas Piggin77e69ee2023-04-08 12:17:52 +1000131endif
Anton Blanchard1fbe9cf2012-11-26 17:41:08 +0000132
Anton Blancharda50a8622015-05-26 08:53:27 +1000133CFLAGS-$(CONFIG_PPC64) := $(call cc-option,-mtraceback=no)
Christophe Leroy661aa882022-05-09 07:36:06 +0200134ifdef CONFIG_PPC64_ELF_ABI_V2
Anton Blanchard238abec2015-05-26 08:53:29 +1000135CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mabi=elfv2,$(call cc-option,-mcall-aixdesc))
Anton Blanchard721aeaa2014-03-10 21:06:12 +1100136else
Nathan Chancellor7c3bd832023-02-15 11:41:16 -0700137ifndef CONFIG_CC_IS_CLANG
Nicholas Piggin4dc831a2016-11-27 13:46:20 +1100138CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mabi=elfv1)
Anton Blanchard238abec2015-05-26 08:53:29 +1000139CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mcall-aixdesc)
Anton Blanchard721aeaa2014-03-10 21:06:12 +1100140endif
Nathan Chancellor465bfd92019-11-18 21:57:10 -0700141endif
Anton Blanchard238abec2015-05-26 08:53:29 +1000142CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mcmodel=medium,$(call cc-option,-mminimal-toc))
Anton Blanchard98679fb2012-12-12 14:43:12 +0000143CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mno-pointers-to-nested-functions)
Michael Ellerman78f09292023-04-04 20:28:47 +1000144CFLAGS-$(CONFIG_PPC64) += $(call cc-option,-mlong-double-128)
Segher Boessenkool51d42f02018-02-28 17:02:49 -0800145
Joel Stanley72e7bcc2018-11-12 15:58:06 +1030146# Clang unconditionally reserves r2 on ppc32 and does not support the flag
147# https://bugs.llvm.org/show_bug.cgi?id=39555
148CFLAGS-$(CONFIG_PPC32) := $(call cc-option, -ffixed-r2)
149
150# Clang doesn't support -mmultiple / -mno-multiple
151# https://bugs.llvm.org/show_bug.cgi?id=39556
152CFLAGS-$(CONFIG_PPC32) += $(call cc-option, $(MULTIPLEWORD))
153
Segher Boessenkool51d42f02018-02-28 17:02:49 -0800154CFLAGS-$(CONFIG_PPC32) += $(call cc-option,-mno-readonly-in-sdata)
Anton Blanchardd23c6fb2012-04-17 18:45:28 +0000155
Nicholas Piggin2a056f52018-09-14 15:08:53 +1000156ifdef CONFIG_FUNCTION_TRACER
Naveen N Rao0f71dcf2023-06-19 15:17:34 +0530157ifdef CONFIG_ARCH_USING_PATCHABLE_FUNCTION_ENTRY
158KBUILD_CPPFLAGS += -DCC_USING_PATCHABLE_FUNCTION_ENTRY
159CC_FLAGS_FTRACE := -fpatchable-function-entry=2
160else
Nicholas Piggin2a056f52018-09-14 15:08:53 +1000161CC_FLAGS_FTRACE := -pg
Torsten Duwe8c50b722016-03-03 15:27:00 +1100162ifdef CONFIG_MPROFILE_KERNEL
Nicholas Piggin2a056f52018-09-14 15:08:53 +1000163CC_FLAGS_FTRACE += -mprofile-kernel
164endif
Torsten Duwe8c50b722016-03-03 15:27:00 +1100165endif
Naveen N Rao0f71dcf2023-06-19 15:17:34 +0530166endif
Torsten Duwe8c50b722016-03-03 15:27:00 +1100167
Christophe Leroy45f70912023-01-25 08:38:59 +0100168CFLAGS-$(CONFIG_TARGET_CPU_BOOL) += -mcpu=$(CONFIG_TARGET_CPU)
169AFLAGS-$(CONFIG_TARGET_CPU_BOOL) += -mcpu=$(CONFIG_TARGET_CPU)
Anton Blanchardd23c6fb2012-04-17 18:45:28 +0000170
Michael Ellerman50832722023-03-30 10:43:08 +1100171CFLAGS-y += $(CONFIG_TUNE_CPU)
Scott Wood01718ba2013-08-20 19:55:36 -0500172
Guenter Roeck7998eb32014-05-15 09:33:42 -0700173asinstr := $(call as-instr,lis 9$(comma)foo@high,-DHAVE_AS_ATHIGH=1)
174
Michael Ellermandc420872023-12-06 22:55:45 +1100175KBUILD_CPPFLAGS += -I $(srctree)/arch/powerpc $(asinstr)
Masahiro Yamadab00899b2019-01-11 12:22:32 +0900176KBUILD_AFLAGS += $(AFLAGS-y)
Anton Blancharda50a8622015-05-26 08:53:27 +1000177KBUILD_CFLAGS += $(call cc-option,-msoft-float)
Nicholas Pigginf5df87b2023-06-06 16:48:30 +1000178KBUILD_CFLAGS += $(CFLAGS-y)
Sam Ravnborga0f97e02007-10-14 22:21:35 +0200179CPP = $(CC) -E $(KBUILD_CFLAGS)
Paul Mackerras14cf11a2005-09-26 16:04:21 +1000180
Michael Ellerman68201fb2016-08-11 16:03:14 +1000181CHECKFLAGS += -m$(BITS) -D__powerpc__ -D__powerpc$(BITS)__
Daniel Axtens62c2c5c2016-07-12 10:54:51 +1000182ifdef CONFIG_CPU_BIG_ENDIAN
183CHECKFLAGS += -D__BIG_ENDIAN__
184else
Christophe Leroy5b894922022-05-09 07:36:08 +0200185CHECKFLAGS += -D__LITTLE_ENDIAN__
Daniel Axtens62c2c5c2016-07-12 10:54:51 +1000186endif
Paul Mackerras14cf11a2005-09-26 16:04:21 +1000187
Rodrigo R. Galvaobadf4362018-08-06 13:42:03 -0300188ifdef CONFIG_476FPE_ERR46
Alistair Poppled5b35cf2014-02-24 18:00:56 +1100189 KBUILD_LDFLAGS_MODULE += --ppc476-workaround \
190 -T $(srctree)/arch/powerpc/platforms/44x/ppc476_modules.lds
191endif
192
Nicholas Piggin4b2a9312022-09-23 13:30:04 +1000193# No prefix or pcrel
Nicholas Piggindc5dac72023-04-08 12:17:49 +1000194ifdef CONFIG_PPC_KERNEL_PREFIXED
195KBUILD_CFLAGS += $(call cc-option,-mprefixed)
196else
Nicholas Piggin4b2a9312022-09-23 13:30:04 +1000197KBUILD_CFLAGS += $(call cc-option,-mno-prefixed)
Nicholas Piggindc5dac72023-04-08 12:17:49 +1000198endif
Nicholas Piggin7e3a68b2023-04-08 12:17:51 +1000199ifdef CONFIG_PPC_KERNEL_PCREL
200KBUILD_CFLAGS += $(call cc-option,-mpcrel)
201else
Nicholas Piggin4b2a9312022-09-23 13:30:04 +1000202KBUILD_CFLAGS += $(call cc-option,-mno-pcrel)
Nicholas Piggin7e3a68b2023-04-08 12:17:51 +1000203endif
Nicholas Piggin4b2a9312022-09-23 13:30:04 +1000204
205# No AltiVec or VSX or MMA instructions when building kernel
Sam Ravnborga0f97e02007-10-14 22:21:35 +0200206KBUILD_CFLAGS += $(call cc-option,-mno-altivec)
Anton Blanchardd23c6fb2012-04-17 18:45:28 +0000207KBUILD_CFLAGS += $(call cc-option,-mno-vsx)
Nicholas Piggin4b2a9312022-09-23 13:30:04 +1000208KBUILD_CFLAGS += $(call cc-option,-mno-mma)
Paul Mackerrasd3f67fb2005-10-29 15:31:17 +1000209
Kumar Gala0197cd22007-10-18 16:53:19 -0500210# No SPE instruction when building kernel
Thiemo Seuferce400c02008-09-02 00:23:02 +1000211# (We use all available options to help semi-broken compilers)
Kumar Gala0197cd22007-10-18 16:53:19 -0500212KBUILD_CFLAGS += $(call cc-option,-mno-spe)
Thiemo Seuferce400c02008-09-02 00:23:02 +1000213KBUILD_CFLAGS += $(call cc-option,-mspe=no)
Kumar Gala0197cd22007-10-18 16:53:19 -0500214
Naveen N. Raoba963012020-03-05 20:05:30 +0530215# Don't emit .eh_frame since we have no use for it
216KBUILD_CFLAGS += -fno-asynchronous-unwind-tables
217
Benjamin Herrenschmidt57647a42007-03-22 17:23:44 +1100218# Never use string load/store instructions as they are
219# often slow when they are implemented at all
Anton Blancharda50a8622015-05-26 08:53:27 +1000220KBUILD_CFLAGS += $(call cc-option,-mno-string)
Paul Mackerras14cf11a2005-09-26 16:04:21 +1000221
Anton Blanchard9ddf0072015-11-26 10:45:49 +1100222cpu-as-$(CONFIG_ALTIVEC) += $(call as-option,-Wa$(comma)-maltivec)
Joel Stanley960e3002018-10-11 13:13:03 +1030223
224# When using '-many -mpower4' gas will first try and find a matching power4
225# mnemonic and failing that it will allow any valid mnemonic that GAS knows
226# about. GCC will pass -many to GAS when assembling, clang does not.
Daniel Axtensf5140ca2021-12-21 16:59:00 +1100227# LLVM IAS doesn't understand either flag: https://github.com/ClangBuiltLinux/linux/issues/675
228# but LLVM IAS only supports ISA >= 2.06 for Book3S 64 anyway...
229cpu-as-$(CONFIG_PPC_BOOK3S_64) += $(call as-option,-Wa$(comma)-mpower4) $(call as-option,-Wa$(comma)-many)
Paul Mackerras14cf11a2005-09-26 16:04:21 +1000230
Sam Ravnborg222d3942007-10-15 21:59:31 +0200231KBUILD_AFLAGS += $(cpu-as-y)
Sam Ravnborga0f97e02007-10-14 22:21:35 +0200232KBUILD_CFLAGS += $(cpu-as-y)
Paul Mackerras14cf11a2005-09-26 16:04:21 +1000233
Michael Ellerman164af592016-08-09 22:43:46 +1000234KBUILD_AFLAGS += $(aflags-y)
235KBUILD_CFLAGS += $(cflags-y)
236
Tom Rini135f0b12006-01-12 16:55:58 -0700237# Default to zImage, override when needed
Grant Likely254313332008-02-07 05:18:34 +1100238all: zImage
Paul Mackerras14cf11a2005-09-26 16:04:21 +1000239
Sam Ravnborge32e78c2010-08-02 20:47:48 +0000240# With make 3.82 we cannot mix normal and wildcard targets
Anatolij Gustschinc686ecf2010-08-15 22:26:56 +0000241BOOT_TARGETS1 := zImage zImage.initrd uImage
Benjamin Herrenschmidt11eab2972011-12-01 19:35:08 +0000242BOOT_TARGETS2 := zImage% dtbImage% treeImage.% cuImage.% simpleImage.% uImage.%
Stephen Rothwellcabb55872005-09-30 16:16:52 +1000243
Sam Ravnborge32e78c2010-08-02 20:47:48 +0000244PHONY += $(BOOT_TARGETS1) $(BOOT_TARGETS2)
Stephen Rothwellcabb55872005-09-30 16:16:52 +1000245
Michael Ellermandc420872023-12-06 22:55:45 +1100246boot := arch/powerpc/boot
Paul Mackerras14cf11a2005-09-26 16:04:21 +1000247
Sam Ravnborge32e78c2010-08-02 20:47:48 +0000248$(BOOT_TARGETS1): vmlinux
Michael Ellerman1196d7a2016-11-21 21:14:33 +1100249 $(Q)$(MAKE) $(build)=$(boot) $(patsubst %,$(boot)/%,$@)
Sam Ravnborge32e78c2010-08-02 20:47:48 +0000250$(BOOT_TARGETS2): vmlinux
Michael Ellerman1196d7a2016-11-21 21:14:33 +1100251 $(Q)$(MAKE) $(build)=$(boot) $(patsubst %,$(boot)/%,$@)
Paul Mackerras14cf11a2005-09-26 16:04:21 +1000252
Sam Ravnborge32e78c2010-08-02 20:47:48 +0000253
Michael Ellermand42c6d02020-02-19 11:04:34 +1100254PHONY += bootwrapper_install
Sam Ravnborge32e78c2010-08-02 20:47:48 +0000255bootwrapper_install:
Michael Ellerman1196d7a2016-11-21 21:14:33 +1100256 $(Q)$(MAKE) $(build)=$(boot) $(patsubst %,$(boot)/%,$@)
Sam Ravnborge32e78c2010-08-02 20:47:48 +0000257
Nicolas Saenz Juliennea400c282023-01-24 12:02:12 +0100258include $(srctree)/scripts/Makefile.defconf
Michael Ellerman22db99d2023-03-29 18:23:34 +1100259
Michael Ellerman22db99d2023-03-29 18:23:34 +1100260generated_configs += ppc64le_defconfig
Michael Ellerman2adc48a2015-09-23 15:40:35 +1000261ppc64le_defconfig:
262 $(call merge_into_defconfig,ppc64_defconfig,le)
263
Michael Ellerman22db99d2023-03-29 18:23:34 +1100264generated_configs += ppc64le_guest_defconfig
Satheesh Rajendran721c01b2018-11-15 12:19:50 +0530265ppc64le_guest_defconfig:
Michael Ellermanbac94962023-04-14 23:24:13 +1000266 $(call merge_into_defconfig,ppc64_defconfig,le guest kvm_guest)
Satheesh Rajendran721c01b2018-11-15 12:19:50 +0530267
Michael Ellerman22db99d2023-03-29 18:23:34 +1100268generated_configs += ppc64_guest_defconfig
Satheesh Rajendran721c01b2018-11-15 12:19:50 +0530269ppc64_guest_defconfig:
Michael Ellermanbac94962023-04-14 23:24:13 +1000270 $(call merge_into_defconfig,ppc64_defconfig,be guest kvm_guest)
Satheesh Rajendran721c01b2018-11-15 12:19:50 +0530271
Michael Ellerman596ddea2023-04-14 23:24:14 +1000272generated_configs += pseries_le_defconfig
273pseries_le_defconfig: ppc64le_guest_defconfig
274
Michael Ellerman9ecda932023-04-14 23:24:15 +1000275generated_configs += pseries_defconfig
276pseries_defconfig: ppc64le_guest_defconfig
277
Michael Ellerman22db99d2023-03-29 18:23:34 +1100278generated_configs += powernv_be_defconfig
Michael Ellerman3603c522017-07-24 22:50:45 +1000279powernv_be_defconfig:
280 $(call merge_into_defconfig,powernv_defconfig,be)
281
Michael Ellerman22db99d2023-03-29 18:23:34 +1100282generated_configs += mpc85xx_defconfig
Scott Wood44d54012015-07-29 18:14:04 -0500283mpc85xx_defconfig:
Michael Ellerman58b12eb2019-05-28 18:16:14 +1000284 $(call merge_into_defconfig,mpc85xx_base.config,\
Scott Wood44d54012015-07-29 18:14:04 -0500285 85xx-32bit 85xx-hw fsl-emb-nonhw)
286
Michael Ellerman22db99d2023-03-29 18:23:34 +1100287generated_configs += mpc85xx_smp_defconfig
Scott Wood44d54012015-07-29 18:14:04 -0500288mpc85xx_smp_defconfig:
Michael Ellerman58b12eb2019-05-28 18:16:14 +1000289 $(call merge_into_defconfig,mpc85xx_base.config,\
Scott Wood44d54012015-07-29 18:14:04 -0500290 85xx-32bit 85xx-smp 85xx-hw fsl-emb-nonhw)
291
Michael Ellerman22db99d2023-03-29 18:23:34 +1100292generated_configs += corenet32_smp_defconfig
Scott Wood44d54012015-07-29 18:14:04 -0500293corenet32_smp_defconfig:
Michael Ellerman58b12eb2019-05-28 18:16:14 +1000294 $(call merge_into_defconfig,corenet_base.config,\
Claudiu Manoile0b80f02016-09-22 18:04:12 +0300295 85xx-32bit 85xx-smp 85xx-hw fsl-emb-nonhw dpaa)
Scott Wood44d54012015-07-29 18:14:04 -0500296
Michael Ellerman22db99d2023-03-29 18:23:34 +1100297generated_configs += corenet64_smp_defconfig
Scott Wood44d54012015-07-29 18:14:04 -0500298corenet64_smp_defconfig:
Michael Ellerman58b12eb2019-05-28 18:16:14 +1000299 $(call merge_into_defconfig,corenet_base.config,\
Claudiu Manoile0b80f02016-09-22 18:04:12 +0300300 85xx-64bit 85xx-smp altivec 85xx-hw fsl-emb-nonhw dpaa)
Scott Wood44d54012015-07-29 18:14:04 -0500301
Michael Ellerman22db99d2023-03-29 18:23:34 +1100302generated_configs += mpc86xx_defconfig
Alessio Igor Bogani43de32c2016-02-22 10:26:14 +0100303mpc86xx_defconfig:
Michael Ellerman58b12eb2019-05-28 18:16:14 +1000304 $(call merge_into_defconfig,mpc86xx_base.config,\
Alessio Igor Bogani43de32c2016-02-22 10:26:14 +0100305 86xx-hw fsl-emb-nonhw)
306
Michael Ellerman22db99d2023-03-29 18:23:34 +1100307generated_configs += mpc86xx_smp_defconfig
Alessio Igor Bogani43de32c2016-02-22 10:26:14 +0100308mpc86xx_smp_defconfig:
Michael Ellerman58b12eb2019-05-28 18:16:14 +1000309 $(call merge_into_defconfig,mpc86xx_base.config,\
Alessio Igor Bogani43de32c2016-02-22 10:26:14 +0100310 86xx-smp 86xx-hw fsl-emb-nonhw)
311
Michael Ellerman22db99d2023-03-29 18:23:34 +1100312generated_configs += ppc32_allmodconfig
Michael Ellerman8db0c9d2018-07-10 00:24:25 +1000313ppc32_allmodconfig:
314 $(Q)$(MAKE) KCONFIG_ALLCONFIG=$(srctree)/arch/powerpc/configs/book3s_32.config \
315 -f $(srctree)/Makefile allmodconfig
316
Michael Ellerman22db99d2023-03-29 18:23:34 +1100317generated_configs += ppc_defconfig
Michael Ellermana273fa32019-02-07 16:16:51 +1100318ppc_defconfig:
319 $(call merge_into_defconfig,book3s_32.config,)
320
Michael Ellerman22db99d2023-03-29 18:23:34 +1100321generated_configs += ppc64le_allmodconfig
Michael Ellerman64de5d82018-07-10 00:24:26 +1000322ppc64le_allmodconfig:
323 $(Q)$(MAKE) KCONFIG_ALLCONFIG=$(srctree)/arch/powerpc/configs/le.config \
324 -f $(srctree)/Makefile allmodconfig
325
Michael Ellerman22db99d2023-03-29 18:23:34 +1100326generated_configs += ppc64le_allnoconfig
Michael Ellerman5d8234472020-11-25 14:15:51 +1100327ppc64le_allnoconfig:
328 $(Q)$(MAKE) KCONFIG_ALLCONFIG=$(srctree)/arch/powerpc/configs/ppc64le.config \
329 -f $(srctree)/Makefile allnoconfig
330
Michael Ellerman22db99d2023-03-29 18:23:34 +1100331generated_configs += ppc64_book3e_allmodconfig
Michael Ellerman64de5d82018-07-10 00:24:26 +1000332ppc64_book3e_allmodconfig:
333 $(Q)$(MAKE) KCONFIG_ALLCONFIG=$(srctree)/arch/powerpc/configs/85xx-64bit.config \
334 -f $(srctree)/Makefile allmodconfig
335
Michael Ellerman22db99d2023-03-29 18:23:34 +1100336generated_configs += ppc32_randconfig
Michael Ellermanf259fb82021-04-28 23:27:00 +1000337ppc32_randconfig:
338 $(Q)$(MAKE) KCONFIG_ALLCONFIG=$(srctree)/arch/powerpc/configs/32-bit.config \
339 -f $(srctree)/Makefile randconfig
340
Michael Ellerman22db99d2023-03-29 18:23:34 +1100341generated_configs += ppc64_randconfig
Michael Ellermanf259fb82021-04-28 23:27:00 +1000342ppc64_randconfig:
343 $(Q)$(MAKE) KCONFIG_ALLCONFIG=$(srctree)/arch/powerpc/configs/64-bit.config \
344 -f $(srctree)/Makefile randconfig
345
Michael Ellerman22db99d2023-03-29 18:23:34 +1100346PHONY += $(generated_configs)
347
Paul Mackerras14cf11a2005-09-26 16:04:21 +1000348define archhelp
Michael Ellerman228c7a92023-03-29 18:23:33 +1100349 echo '* zImage - Build default images selected by kernel config'
Michael Ellermandc420872023-12-06 22:55:45 +1100350 echo ' zImage.* - Compressed kernel image (arch/powerpc/boot/zImage.*)'
Michael Ellerman228c7a92023-03-29 18:23:33 +1100351 echo ' uImage - U-Boot native image format'
352 echo ' cuImage.<dt> - Backwards compatible U-Boot image for older'
353 echo ' versions which do not support device trees'
354 echo ' dtbImage.<dt> - zImage with an embedded device tree blob'
355 echo ' simpleImage.<dt> - Firmware independent image.'
356 echo ' treeImage.<dt> - Support for older IBM 4xx firmware (not U-Boot)'
357 echo ' install - Install kernel using'
358 echo ' (your) ~/bin/$(INSTALLKERNEL) or'
359 echo ' (distribution) /sbin/$(INSTALLKERNEL) or'
360 echo ' install to $$(INSTALL_PATH) and run lilo'
Michael Ellermandc420872023-12-06 22:55:45 +1100361 echo ' *_defconfig - Select default config from arch/powerpc/configs'
Michael Ellerman228c7a92023-03-29 18:23:33 +1100362 echo ''
363 echo ' Targets with <dt> embed a device tree blob inside the image'
364 echo ' These targets support board with firmware that does not'
365 echo ' support passing a device tree directly. Replace <dt> with the'
Michael Ellermandc420872023-12-06 22:55:45 +1100366 echo ' name of a dts file from the arch/powerpc/boot/dts/ directory'
Michael Ellerman228c7a92023-03-29 18:23:33 +1100367 echo ' (minus the .dts extension).'
Michael Ellerman22db99d2023-03-29 18:23:34 +1100368 echo
369 $(foreach cfg,$(generated_configs),
370 printf " %-27s - Build for %s\\n" $(cfg) $(subst _defconfig,,$(cfg));)
Paul Mackerras14cf11a2005-09-26 16:04:21 +1000371endef
372
Michael Ellermand42c6d02020-02-19 11:04:34 +1100373PHONY += install
Sam Ravnborg3f85d632008-02-16 12:36:10 +0100374install:
Masahiro Yamadaf774f5b2022-05-03 11:47:16 +0900375 $(call cmd,install)
Akinobu Mita928370c2007-04-10 21:05:31 +1000376
Christophe Leroy91bf6952020-09-27 09:16:33 +0000377ifeq ($(KBUILD_EXTMOD),)
378# We need to generate vdso-offsets.h before compiling certain files in kernel/.
379# In order to do that, we should use the archprepare target, but we can't since
380# asm-offsets.h is included in some files used to generate vdso-offsets.h, and
381# asm-offsets.h is built in prepare0, for which archprepare is a dependency.
382# Therefore we need to generate the header after prepare0 has been made, hence
383# this hack.
384prepare: vdso_prepare
385vdso_prepare: prepare0
386 $(if $(CONFIG_VDSO32),$(Q)$(MAKE) \
Christophe Leroyfd1feade2022-01-21 16:30:27 +0000387 $(build)=arch/powerpc/kernel/vdso include/generated/vdso32-offsets.h)
Christophe Leroy91bf6952020-09-27 09:16:33 +0000388 $(if $(CONFIG_PPC64),$(Q)$(MAKE) \
Christophe Leroyfd1feade2022-01-21 16:30:27 +0000389 $(build)=arch/powerpc/kernel/vdso include/generated/vdso64-offsets.h)
Christophe Leroy91bf6952020-09-27 09:16:33 +0000390endif
391
Paul Mackerras14cf11a2005-09-26 16:04:21 +1000392archprepare: checkbin
393
Firoz Khanab66dcc2018-12-17 16:10:36 +0530394archheaders:
395 $(Q)$(MAKE) $(build)=arch/powerpc/kernel/syscalls all
396
Christophe Leroyc3ff2a52018-09-27 07:05:53 +0000397ifdef CONFIG_STACKPROTECTOR
398prepare: stack_protector_prepare
Paul Mackerras14cf11a2005-09-26 16:04:21 +1000399
Michael Ellermand42c6d02020-02-19 11:04:34 +1100400PHONY += stack_protector_prepare
Christophe Leroyc3ff2a52018-09-27 07:05:53 +0000401stack_protector_prepare: prepare0
Christophe Leroy06ec27ae2018-09-27 07:05:55 +0000402ifdef CONFIG_PPC64
403 $(eval KBUILD_CFLAGS += -mstack-protector-guard-offset=$(shell awk '{if ($$2 == "PACA_CANARY") print $$3;}' include/generated/asm-offsets.h))
404else
Christophe Leroyc3ff2a52018-09-27 07:05:53 +0000405 $(eval KBUILD_CFLAGS += -mstack-protector-guard-offset=$(shell awk '{if ($$2 == "TASK_CANARY") print $$3;}' include/generated/asm-offsets.h))
406endif
Christophe Leroy06ec27ae2018-09-27 07:05:55 +0000407endif
Christophe Leroyc3ff2a52018-09-27 07:05:53 +0000408
Michael Ellermand42c6d02020-02-19 11:04:34 +1100409PHONY += checkbin
Paul Mackerras14cf11a2005-09-26 16:04:21 +1000410checkbin:
Naveen N Rao25ea7392023-05-30 11:44:36 +0530411 @if test "x${CONFIG_FTRACE_MCOUNT_USE_RECORDMCOUNT}" = "xy" -a \
412 "x${CONFIG_LD_IS_BFD}" = "xy" -a \
413 "${CONFIG_LD_VERSION}" = "23700" ; then \
414 echo -n '*** binutils 2.37 drops unused section symbols, which recordmcount ' ; \
415 echo 'is unable to handle.' ; \
416 echo '*** Please use a different binutils version.' ; \
417 false ; \
418 fi