Makefile 14 KB

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