Makefile 14 KB

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