Makefile 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  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. ifdef cross_compiling
  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. # Mach groups
  103. machdir-$(CONFIG_SOLUTION_ENGINE) += mach-se
  104. machdir-$(CONFIG_SH_DREAMCAST) += mach-dreamcast
  105. machdir-$(CONFIG_SH_SH03) += mach-sh03
  106. machdir-$(CONFIG_SH_MIGOR) += mach-migor
  107. machdir-$(CONFIG_SH_KFR2R09) += mach-kfr2r09
  108. machdir-$(CONFIG_SH_ECOVEC) += mach-ecovec24
  109. machdir-$(CONFIG_SH_SDK7786) += mach-sdk7786
  110. machdir-$(CONFIG_SH_X3PROTO) += mach-x3proto
  111. machdir-$(CONFIG_SH_LANDISK) += mach-landisk
  112. machdir-y += mach-common
  113. #
  114. # CPU header paths
  115. #
  116. # These are ordered by optimization level. A CPU family that is a subset
  117. # of another (ie, SH-2A / SH-2), is picked up first, with increasing
  118. # levels of genericness if nothing more suitable is situated in the
  119. # hierarchy.
  120. #
  121. # As an example, in order of preference, SH-2A > SH-2 > common definitions.
  122. #
  123. cpuincdir-$(CONFIG_CPU_SH2A) += cpu-sh2a
  124. cpuincdir-$(CONFIG_CPU_SH2) += cpu-sh2
  125. cpuincdir-$(CONFIG_CPU_SH3) += cpu-sh3
  126. cpuincdir-$(CONFIG_CPU_SH4A) += cpu-sh4a
  127. cpuincdir-$(CONFIG_CPU_SH4) += cpu-sh4
  128. cpuincdir-y += cpu-common # Must be last
  129. drivers-y += arch/sh/drivers/
  130. KBUILD_CPPFLAGS += $(addprefix -I $(srctree)/arch/sh/include/, $(cpuincdir-y) $(machdir-y))
  131. KBUILD_CFLAGS += -pipe $(cflags-y)
  132. KBUILD_AFLAGS += $(cflags-y)
  133. ifeq ($(CONFIG_MCOUNT),y)
  134. KBUILD_CFLAGS += -pg
  135. endif
  136. ifeq ($(CONFIG_DWARF_UNWINDER),y)
  137. KBUILD_CFLAGS += -fasynchronous-unwind-tables
  138. endif
  139. libs-y := arch/sh/lib/ $(libs-y)
  140. BOOT_TARGETS = uImage uImage.bz2 uImage.gz uImage.lzma uImage.xz uImage.lzo \
  141. uImage.srec uImage.bin zImage vmlinux.bin vmlinux.srec \
  142. romImage
  143. PHONY += $(BOOT_TARGETS)
  144. all: $(notdir $(KBUILD_IMAGE))
  145. $(BOOT_TARGETS): vmlinux
  146. $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
  147. compressed: zImage
  148. archprepare:
  149. $(Q)$(MAKE) $(build)=arch/sh/tools include/generated/machtypes.h
  150. archheaders:
  151. $(Q)$(MAKE) $(build)=arch/sh/kernel/syscalls all
  152. define archhelp
  153. @echo ' zImage - Compressed kernel image'
  154. @echo ' romImage - Compressed ROM image, if supported'
  155. @echo ' vmlinux.srec - Create an ELF S-record'
  156. @echo ' vmlinux.bin - Create an uncompressed binary image'
  157. @echo '* uImage - Alias to bootable U-Boot image'
  158. @echo ' uImage.srec - Create an S-record for U-Boot'
  159. @echo ' uImage.bin - Kernel-only image for U-Boot (bin)'
  160. @echo '* uImage.gz - Kernel-only image for U-Boot (gzip)'
  161. @echo ' uImage.bz2 - Kernel-only image for U-Boot (bzip2)'
  162. @echo ' uImage.lzma - Kernel-only image for U-Boot (lzma)'
  163. @echo ' uImage.xz - Kernel-only image for U-Boot (xz)'
  164. @echo ' uImage.lzo - Kernel-only image for U-Boot (lzo)'
  165. endef