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. 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_SH7757LCR) := uImage
  76. defaultimage-$(CONFIG_SH_7724_SOLUTION_ENGINE) := uImage
  77. defaultimage-$(CONFIG_SH_7206_SOLUTION_ENGINE) := vmlinux
  78. defaultimage-$(CONFIG_SH_7619_SOLUTION_ENGINE) := vmlinux
  79. # Set some sensible Kbuild defaults
  80. KBUILD_IMAGE := $(defaultimage-y)
  81. #
  82. # Choosing incompatible machines durings configuration will result in
  83. # error messages during linking.
  84. #
  85. ifdef CONFIG_SUPERH32
  86. UTS_MACHINE := sh
  87. BITS := 32
  88. LDFLAGS_vmlinux += -e _stext
  89. KBUILD_DEFCONFIG := shx3_defconfig
  90. else
  91. UTS_MACHINE := sh64
  92. BITS := 64
  93. LDFLAGS_vmlinux += --defsym phys_stext=_stext-$(CONFIG_PAGE_OFFSET) \
  94. --defsym phys_stext_shmedia=phys_stext+1 \
  95. -e phys_stext_shmedia
  96. KBUILD_DEFCONFIG := cayman_defconfig
  97. endif
  98. ifneq ($(SUBARCH),$(ARCH))
  99. ifeq ($(CROSS_COMPILE),)
  100. CROSS_COMPILE := $(call cc-cross-prefix, $(UTS_MACHINE)-linux- $(UTS_MACHINE)-linux-gnu- $(UTS_MACHINE)-unknown-linux-gnu-)
  101. endif
  102. endif
  103. ifdef CONFIG_CPU_LITTLE_ENDIAN
  104. ld-bfd := elf32-$(UTS_MACHINE)-linux
  105. LDFLAGS_vmlinux += --defsym 'jiffies=jiffies_64' --oformat $(ld-bfd)
  106. LDFLAGS += -EL
  107. else
  108. ld-bfd := elf32-$(UTS_MACHINE)big-linux
  109. LDFLAGS_vmlinux += --defsym 'jiffies=jiffies_64+4' --oformat $(ld-bfd)
  110. LDFLAGS += -EB
  111. endif
  112. export ld-bfd BITS
  113. head-y := arch/sh/kernel/init_task.o arch/sh/kernel/head_$(BITS).o
  114. core-y += arch/sh/kernel/ arch/sh/mm/ arch/sh/boards/
  115. core-$(CONFIG_SH_FPU_EMU) += arch/sh/math-emu/
  116. # Mach groups
  117. machdir-$(CONFIG_SOLUTION_ENGINE) += mach-se
  118. machdir-$(CONFIG_SH_HP6XX) += mach-hp6xx
  119. machdir-$(CONFIG_SH_DREAMCAST) += mach-dreamcast
  120. machdir-$(CONFIG_SH_SH03) += mach-sh03
  121. machdir-$(CONFIG_SH_RTS7751R2D) += mach-r2d
  122. machdir-$(CONFIG_SH_HIGHLANDER) += mach-highlander
  123. machdir-$(CONFIG_SH_MIGOR) += mach-migor
  124. machdir-$(CONFIG_SH_AP325RXA) += mach-ap325rxa
  125. machdir-$(CONFIG_SH_KFR2R09) += mach-kfr2r09
  126. machdir-$(CONFIG_SH_ECOVEC) += mach-ecovec24
  127. machdir-$(CONFIG_SH_SDK7780) += mach-sdk7780
  128. machdir-$(CONFIG_SH_SDK7786) += mach-sdk7786
  129. machdir-$(CONFIG_SH_X3PROTO) += mach-x3proto
  130. machdir-$(CONFIG_SH_SH7763RDP) += mach-sh7763rdp
  131. machdir-$(CONFIG_SH_SH4202_MICRODEV) += mach-microdev
  132. machdir-$(CONFIG_SH_LANDISK) += mach-landisk
  133. machdir-$(CONFIG_SH_LBOX_RE2) += mach-lboxre2
  134. machdir-$(CONFIG_SH_CAYMAN) += mach-cayman
  135. machdir-$(CONFIG_SH_RSK) += mach-rsk
  136. ifneq ($(machdir-y),)
  137. core-y += $(addprefix arch/sh/boards/, \
  138. $(filter-out ., $(patsubst %,%/,$(machdir-y))))
  139. endif
  140. # Common machine type headers. Not part of the arch/sh/boards/ hierarchy.
  141. machdir-y += mach-common
  142. # Companion chips
  143. core-$(CONFIG_HD6446X_SERIES) += arch/sh/cchips/hd6446x/
  144. #
  145. # CPU header paths
  146. #
  147. # These are ordered by optimization level. A CPU family that is a subset
  148. # of another (ie, SH-2A / SH-2), is picked up first, with increasing
  149. # levels of genericness if nothing more suitable is situated in the
  150. # hierarchy.
  151. #
  152. # As an example, in order of preference, SH-2A > SH-2 > common definitions.
  153. #
  154. cpuincdir-$(CONFIG_CPU_SH2A) += cpu-sh2a
  155. cpuincdir-$(CONFIG_CPU_SH2) += cpu-sh2
  156. cpuincdir-$(CONFIG_CPU_SH3) += cpu-sh3
  157. cpuincdir-$(CONFIG_CPU_SH4A) += cpu-sh4a
  158. cpuincdir-$(CONFIG_CPU_SH4) += cpu-sh4
  159. cpuincdir-$(CONFIG_CPU_SH5) += cpu-sh5
  160. cpuincdir-y += cpu-common # Must be last
  161. drivers-y += arch/sh/drivers/
  162. drivers-$(CONFIG_OPROFILE) += arch/sh/oprofile/
  163. boot := arch/sh/boot
  164. cflags-y += $(foreach d, $(cpuincdir-y), -Iarch/sh/include/$(d)) \
  165. $(foreach d, $(machdir-y), -Iarch/sh/include/$(d))
  166. KBUILD_CFLAGS += -pipe $(cflags-y)
  167. KBUILD_CPPFLAGS += $(cflags-y)
  168. KBUILD_AFLAGS += $(cflags-y)
  169. ifeq ($(CONFIG_MCOUNT),y)
  170. KBUILD_CFLAGS += -pg
  171. endif
  172. ifeq ($(CONFIG_DWARF_UNWINDER),y)
  173. KBUILD_CFLAGS += -fasynchronous-unwind-tables
  174. endif
  175. libs-$(CONFIG_SUPERH32) := arch/sh/lib/ $(libs-y)
  176. libs-$(CONFIG_SUPERH64) := arch/sh/lib64/ $(libs-y)
  177. BOOT_TARGETS = uImage uImage.bz2 uImage.gz uImage.lzma uImage.xz uImage.lzo \
  178. uImage.srec uImage.bin zImage vmlinux.bin vmlinux.srec \
  179. romImage
  180. PHONY += $(BOOT_TARGETS)
  181. all: $(KBUILD_IMAGE)
  182. $(BOOT_TARGETS): vmlinux
  183. $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
  184. compressed: zImage
  185. archprepare:
  186. $(Q)$(MAKE) $(build)=arch/sh/tools include/generated/machtypes.h
  187. archclean:
  188. $(Q)$(MAKE) $(clean)=$(boot)
  189. $(Q)$(MAKE) $(clean)=arch/sh/kernel/vsyscall
  190. define archhelp
  191. @echo ' zImage - Compressed kernel image'
  192. @echo ' romImage - Compressed ROM image, if supported'
  193. @echo ' vmlinux.srec - Create an ELF S-record'
  194. @echo ' vmlinux.bin - Create an uncompressed binary image'
  195. @echo '* uImage - Alias to bootable U-Boot image'
  196. @echo ' uImage.srec - Create an S-record for U-Boot'
  197. @echo ' uImage.bin - Kernel-only image for U-Boot (bin)'
  198. @echo '* uImage.gz - Kernel-only image for U-Boot (gzip)'
  199. @echo ' uImage.bz2 - Kernel-only image for U-Boot (bzip2)'
  200. @echo ' uImage.lzma - Kernel-only image for U-Boot (lzma)'
  201. @echo ' uImage.xz - Kernel-only image for U-Boot (xz)'
  202. @echo ' uImage.lzo - Kernel-only image for U-Boot (lzo)'
  203. endef