Makefile 8.1 KB

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