Makefile 15 KB

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