Makefile 8.1 KB

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