Makefile 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. #
  2. # arch/sh/Makefile
  3. #
  4. # Copyright (C) 1999 Kaz Kojima
  5. # Copyright (C) 2002 - 2008 Paul Mundt
  6. # Copyright (C) 2002 M. R. Brown
  7. #
  8. # This file is subject to the terms and conditions of the GNU General Public
  9. # License. See the file "COPYING" in the main directory of this archive
  10. # for more details.
  11. #
  12. isa-y := any
  13. isa-$(CONFIG_SH_DSP) := sh
  14. isa-$(CONFIG_CPU_SH2) := sh2
  15. isa-$(CONFIG_CPU_SH2A) := sh2a
  16. isa-$(CONFIG_CPU_SH3) := sh3
  17. isa-$(CONFIG_CPU_SH4) := sh4
  18. isa-$(CONFIG_CPU_SH4A) := sh4a
  19. isa-$(CONFIG_CPU_SH4AL_DSP) := sh4al
  20. isa-$(CONFIG_CPU_SH5) := shmedia
  21. ifeq ($(CONFIG_SUPERH32),y)
  22. isa-$(CONFIG_SH_DSP) := $(isa-y)-dsp
  23. isa-y := $(isa-y)-up
  24. endif
  25. cflags-$(CONFIG_CPU_SH2) := $(call cc-option,-m2,)
  26. cflags-$(CONFIG_CPU_SH2A) += $(call cc-option,-m2a,) \
  27. $(call cc-option,-m2a-nofpu,)
  28. cflags-$(CONFIG_CPU_SH3) := $(call cc-option,-m3,)
  29. cflags-$(CONFIG_CPU_SH4) := $(call cc-option,-m4,) \
  30. $(call cc-option,-mno-implicit-fp,-m4-nofpu)
  31. cflags-$(CONFIG_CPU_SH4A) += $(call cc-option,-m4a,) \
  32. $(call cc-option,-m4a-nofpu,)
  33. cflags-$(CONFIG_CPU_SH4AL_DSP) += $(call cc-option,-m4al,)
  34. cflags-$(CONFIG_CPU_SH5) := $(call cc-option,-m5-32media-nofpu,)
  35. ifeq ($(cflags-y),)
  36. #
  37. # In the case where we are stuck with a compiler that has been uselessly
  38. # restricted to a particular ISA, a favourite default of newer GCCs when
  39. # extensive multilib targets are not provided, ensure we get the best fit
  40. # regarding FP generation. This is intentionally stupid (albeit many
  41. # orders of magnitude less than GCC's default behaviour), as anything
  42. # with a large number of multilib targets better have been built
  43. # correctly for the target in mind.
  44. #
  45. cflags-y += $(shell $(CC) $(KBUILD_CFLAGS) -print-multi-lib | \
  46. grep nofpu | sed q | sed -e 's/^/-/;s/;.*$$//')
  47. # At this point, anything goes.
  48. isaflags-y := $(call as-option,-Wa$(comma)-isa=any,)
  49. else
  50. #
  51. # -Wa,-isa= tuning implies -Wa,-dsp for the versions of binutils that
  52. # support it, while -Wa,-dsp by itself limits the range of usable opcodes
  53. # on certain CPU subtypes. Try the ISA variant first, and if that fails,
  54. # fall back on -Wa,-dsp for the old binutils versions. Even without DSP
  55. # opcodes, we always want the best ISA tuning the version of binutils
  56. # will provide.
  57. #
  58. isaflags-y := $(call as-option,-Wa$(comma)-isa=$(isa-y),)
  59. isaflags-$(CONFIG_SH_DSP) := \
  60. $(call as-option,-Wa$(comma)-isa=$(isa-y),-Wa$(comma)-dsp)
  61. endif
  62. cflags-$(CONFIG_CPU_BIG_ENDIAN) += -mb
  63. cflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -ml
  64. cflags-y += $(call cc-option,-mno-fdpic)
  65. cflags-y += $(isaflags-y) -ffreestanding
  66. OBJCOPYFLAGS := -O binary -R .note -R .note.gnu.build-id -R .comment \
  67. -R .stab -R .stabstr -S
  68. # Give the various platforms the opportunity to set default image types
  69. defaultimage-$(CONFIG_SUPERH32) := zImage
  70. defaultimage-$(CONFIG_SH_SH7785LCR) := uImage
  71. defaultimage-$(CONFIG_SH_RSK) := uImage
  72. defaultimage-$(CONFIG_SH_URQUELL) := uImage
  73. defaultimage-$(CONFIG_SH_MIGOR) := uImage
  74. defaultimage-$(CONFIG_SH_AP325RXA) := uImage
  75. defaultimage-$(CONFIG_SH_7724_SOLUTION_ENGINE) := uImage
  76. defaultimage-$(CONFIG_SH_7206_SOLUTION_ENGINE) := vmlinux
  77. defaultimage-$(CONFIG_SH_7619_SOLUTION_ENGINE) := vmlinux
  78. # Set some sensible Kbuild defaults
  79. KBUILD_IMAGE := $(defaultimage-y)
  80. #
  81. # Choosing incompatible machines durings configuration will result in
  82. # error messages during linking.
  83. #
  84. ifdef CONFIG_SUPERH32
  85. UTS_MACHINE := sh
  86. BITS := 32
  87. LDFLAGS_vmlinux += -e _stext
  88. KBUILD_DEFCONFIG := shx3_defconfig
  89. else
  90. UTS_MACHINE := sh64
  91. BITS := 64
  92. LDFLAGS_vmlinux += --defsym phys_stext=_stext-$(CONFIG_PAGE_OFFSET) \
  93. --defsym phys_stext_shmedia=phys_stext+1 \
  94. -e phys_stext_shmedia
  95. KBUILD_DEFCONFIG := cayman_defconfig
  96. endif
  97. ifneq ($(SUBARCH),$(ARCH))
  98. ifeq ($(CROSS_COMPILE),)
  99. CROSS_COMPILE := $(call cc-cross-prefix, $(UTS_MACHINE)-linux- $(UTS_MACHINE)-linux-gnu- $(UTS_MACHINE)-unknown-linux-gnu-)
  100. endif
  101. endif
  102. ifdef CONFIG_CPU_LITTLE_ENDIAN
  103. ld-bfd := elf32-$(UTS_MACHINE)-linux
  104. LDFLAGS_vmlinux += --defsym 'jiffies=jiffies_64' --oformat $(ld-bfd)
  105. LDFLAGS += -EL
  106. else
  107. ld-bfd := elf32-$(UTS_MACHINE)big-linux
  108. LDFLAGS_vmlinux += --defsym 'jiffies=jiffies_64+4' --oformat $(ld-bfd)
  109. LDFLAGS += -EB
  110. endif
  111. export ld-bfd BITS
  112. head-y := arch/sh/kernel/init_task.o arch/sh/kernel/head_$(BITS).o
  113. core-y += arch/sh/kernel/ arch/sh/mm/ arch/sh/boards/
  114. core-$(CONFIG_SH_FPU_EMU) += arch/sh/math-emu/
  115. # Mach groups
  116. machdir-$(CONFIG_SOLUTION_ENGINE) += mach-se
  117. machdir-$(CONFIG_SH_HP6XX) += mach-hp6xx
  118. machdir-$(CONFIG_SH_DREAMCAST) += mach-dreamcast
  119. machdir-$(CONFIG_SH_SH03) += mach-sh03
  120. machdir-$(CONFIG_SH_RTS7751R2D) += mach-r2d
  121. machdir-$(CONFIG_SH_HIGHLANDER) += mach-highlander
  122. machdir-$(CONFIG_SH_MIGOR) += mach-migor
  123. machdir-$(CONFIG_SH_AP325RXA) += mach-ap325rxa
  124. machdir-$(CONFIG_SH_KFR2R09) += mach-kfr2r09
  125. machdir-$(CONFIG_SH_ECOVEC) += mach-ecovec24
  126. machdir-$(CONFIG_SH_SDK7780) += mach-sdk7780
  127. machdir-$(CONFIG_SH_SDK7786) += mach-sdk7786
  128. machdir-$(CONFIG_SH_X3PROTO) += mach-x3proto
  129. machdir-$(CONFIG_SH_SH7763RDP) += mach-sh7763rdp
  130. machdir-$(CONFIG_SH_SH4202_MICRODEV) += mach-microdev
  131. machdir-$(CONFIG_SH_LANDISK) += mach-landisk
  132. machdir-$(CONFIG_SH_LBOX_RE2) += mach-lboxre2
  133. machdir-$(CONFIG_SH_CAYMAN) += mach-cayman
  134. machdir-$(CONFIG_SH_RSK) += mach-rsk
  135. ifneq ($(machdir-y),)
  136. core-y += $(addprefix arch/sh/boards/, \
  137. $(filter-out ., $(patsubst %,%/,$(machdir-y))))
  138. endif
  139. # Common machine type headers. Not part of the arch/sh/boards/ hierarchy.
  140. machdir-y += mach-common
  141. # Companion chips
  142. core-$(CONFIG_HD6446X_SERIES) += arch/sh/cchips/hd6446x/
  143. #
  144. # CPU header paths
  145. #
  146. # These are ordered by optimization level. A CPU family that is a subset
  147. # of another (ie, SH-2A / SH-2), is picked up first, with increasing
  148. # levels of genericness if nothing more suitable is situated in the
  149. # hierarchy.
  150. #
  151. # As an example, in order of preference, SH-2A > SH-2 > common definitions.
  152. #
  153. cpuincdir-$(CONFIG_CPU_SH2A) += cpu-sh2a
  154. cpuincdir-$(CONFIG_CPU_SH2) += cpu-sh2
  155. cpuincdir-$(CONFIG_CPU_SH3) += cpu-sh3
  156. cpuincdir-$(CONFIG_CPU_SH4) += cpu-sh4
  157. cpuincdir-$(CONFIG_CPU_SH5) += cpu-sh5
  158. cpuincdir-y += cpu-common # Must be last
  159. drivers-y += arch/sh/drivers/
  160. drivers-$(CONFIG_OPROFILE) += arch/sh/oprofile/
  161. boot := arch/sh/boot
  162. cflags-y += $(foreach d, $(cpuincdir-y), -Iarch/sh/include/$(d)) \
  163. $(foreach d, $(machdir-y), -Iarch/sh/include/$(d))
  164. KBUILD_CFLAGS += -pipe $(cflags-y)
  165. KBUILD_CPPFLAGS += $(cflags-y)
  166. KBUILD_AFLAGS += $(cflags-y)
  167. ifeq ($(CONFIG_MCOUNT),y)
  168. KBUILD_CFLAGS += -pg
  169. endif
  170. ifeq ($(CONFIG_DWARF_UNWINDER),y)
  171. KBUILD_CFLAGS += -fasynchronous-unwind-tables
  172. endif
  173. libs-$(CONFIG_SUPERH32) := arch/sh/lib/ $(libs-y)
  174. libs-$(CONFIG_SUPERH64) := arch/sh/lib64/ $(libs-y)
  175. BOOT_TARGETS = uImage uImage.bz2 uImage.gz uImage.lzma uImage.xz uImage.lzo \
  176. uImage.srec uImage.bin zImage vmlinux.bin vmlinux.srec \
  177. romImage
  178. PHONY += $(BOOT_TARGETS)
  179. all: $(KBUILD_IMAGE)
  180. $(BOOT_TARGETS): vmlinux
  181. $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
  182. compressed: zImage
  183. archprepare:
  184. $(Q)$(MAKE) $(build)=arch/sh/tools include/generated/machtypes.h
  185. archclean:
  186. $(Q)$(MAKE) $(clean)=$(boot)
  187. $(Q)$(MAKE) $(clean)=arch/sh/kernel/vsyscall
  188. define archhelp
  189. @echo ' zImage - Compressed kernel image'
  190. @echo ' romImage - Compressed ROM image, if supported'
  191. @echo ' vmlinux.srec - Create an ELF S-record'
  192. @echo ' vmlinux.bin - Create an uncompressed binary image'
  193. @echo '* uImage - Alias to bootable U-Boot image'
  194. @echo ' uImage.srec - Create an S-record for U-Boot'
  195. @echo ' uImage.bin - Kernel-only image for U-Boot (bin)'
  196. @echo '* uImage.gz - Kernel-only image for U-Boot (gzip)'
  197. @echo ' uImage.bz2 - Kernel-only image for U-Boot (bzip2)'
  198. @echo ' uImage.lzma - Kernel-only image for U-Boot (lzma)'
  199. @echo ' uImage.xz - Kernel-only image for U-Boot (xz)'
  200. @echo ' uImage.lzo - Kernel-only image for U-Boot (lzo)'
  201. endef