Makefile 7.6 KB

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