Makefile 8.0 KB

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