Makefile 7.6 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. cflags-$(CONFIG_MORE_COMPILE_OPTIONS) += \
  67. $(shell echo $(CONFIG_COMPILE_OPTIONS) | sed -e 's/"//g')
  68. OBJCOPYFLAGS := -O binary -R .note -R .note.gnu.build-id -R .comment \
  69. -R .stab -R .stabstr -S
  70. # Give the various platforms the opportunity to set default image types
  71. defaultimage-$(CONFIG_SUPERH32) := zImage
  72. defaultimage-$(CONFIG_SH_SH7785LCR) := uImage
  73. defaultimage-$(CONFIG_SH_RSK) := uImage
  74. defaultimage-$(CONFIG_SH_URQUELL) := uImage
  75. defaultimage-$(CONFIG_SH_7206_SOLUTION_ENGINE) := vmlinux
  76. defaultimage-$(CONFIG_SH_7619_SOLUTION_ENGINE) := vmlinux
  77. # Set some sensible Kbuild defaults
  78. KBUILD_DEFCONFIG := shx3_defconfig
  79. KBUILD_IMAGE := $(defaultimage-y)
  80. #
  81. # Choosing incompatible machines durings configuration will result in
  82. # error messages during linking.
  83. #
  84. ifdef CONFIG_SUPERH32
  85. UTS_MACHINE := sh
  86. LDFLAGS_vmlinux += -e _stext
  87. else
  88. UTS_MACHINE := sh64
  89. LDFLAGS_vmlinux += --defsym phys_stext=_stext-$(CONFIG_PAGE_OFFSET) \
  90. --defsym phys_stext_shmedia=phys_stext+1 \
  91. -e phys_stext_shmedia
  92. endif
  93. ifdef CONFIG_CPU_LITTLE_ENDIAN
  94. LDFLAGS_vmlinux += --defsym 'jiffies=jiffies_64'
  95. LDFLAGS += -EL
  96. else
  97. LDFLAGS_vmlinux += --defsym 'jiffies=jiffies_64+4'
  98. LDFLAGS += -EB
  99. endif
  100. head-y := arch/sh/kernel/init_task.o
  101. head-$(CONFIG_SUPERH32) += arch/sh/kernel/head_32.o
  102. head-$(CONFIG_SUPERH64) += arch/sh/kernel/head_64.o
  103. core-y += arch/sh/kernel/ arch/sh/mm/ arch/sh/boards/
  104. core-$(CONFIG_SH_FPU_EMU) += arch/sh/math-emu/
  105. # Mach groups
  106. machdir-$(CONFIG_SOLUTION_ENGINE) += mach-se
  107. machdir-$(CONFIG_SH_HP6XX) += mach-hp6xx
  108. machdir-$(CONFIG_SH_DREAMCAST) += mach-dreamcast
  109. machdir-$(CONFIG_SH_SH03) += mach-sh03
  110. machdir-$(CONFIG_SH_SECUREEDGE5410) += mach-snapgear
  111. machdir-$(CONFIG_SH_RTS7751R2D) += mach-r2d
  112. machdir-$(CONFIG_SH_7751_SYSTEMH) += mach-systemh
  113. machdir-$(CONFIG_SH_EDOSK7705) += mach-edosk7705
  114. machdir-$(CONFIG_SH_HIGHLANDER) += mach-highlander
  115. machdir-$(CONFIG_SH_MIGOR) += mach-migor
  116. machdir-$(CONFIG_SH_SDK7780) += mach-sdk7780
  117. machdir-$(CONFIG_SH_X3PROTO) += mach-x3proto
  118. machdir-$(CONFIG_SH_SH7763RDP) += mach-sh7763rdp
  119. machdir-$(CONFIG_SH_SH4202_MICRODEV) += mach-microdev
  120. machdir-$(CONFIG_SH_LANDISK) += mach-landisk
  121. machdir-$(CONFIG_SH_TITAN) += mach-titan
  122. machdir-$(CONFIG_SH_LBOX_RE2) += mach-lboxre2
  123. machdir-$(CONFIG_SH_CAYMAN) += mach-cayman
  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_SH4) += cpu-sh4
  147. cpuincdir-$(CONFIG_CPU_SH5) += cpu-sh5
  148. cpuincdir-y += cpu-common # Must be last
  149. drivers-y += arch/sh/drivers/
  150. drivers-$(CONFIG_OPROFILE) += arch/sh/oprofile/
  151. boot := arch/sh/boot
  152. cflags-y += $(foreach d, $(cpuincdir-y), -Iarch/sh/include/$(d)) \
  153. $(foreach d, $(machdir-y), -Iarch/sh/include/$(d))
  154. KBUILD_CFLAGS += -pipe $(cflags-y)
  155. KBUILD_CPPFLAGS += $(cflags-y)
  156. KBUILD_AFLAGS += $(cflags-y)
  157. libs-$(CONFIG_SUPERH32) := arch/sh/lib/ $(libs-y)
  158. libs-$(CONFIG_SUPERH64) := arch/sh/lib64/ $(libs-y)
  159. PHONY += maketools FORCE
  160. maketools: include/linux/version.h FORCE
  161. $(Q)$(MAKE) $(build)=arch/sh/tools include/asm-sh/machtypes.h
  162. all: $(KBUILD_IMAGE)
  163. zImage uImage uImage.srec vmlinux.srec: vmlinux
  164. $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
  165. compressed: zImage
  166. archprepare: maketools arch/sh/lib64/syscalltab.h
  167. archclean:
  168. $(Q)$(MAKE) $(clean)=$(boot)
  169. define archhelp
  170. @echo '* zImage - Compressed kernel image'
  171. @echo ' vmlinux.srec - Create an ELF S-record'
  172. @echo ' uImage - Create a bootable image for U-Boot'
  173. @echo ' uImage.srec - Create an S-record for U-Boot'
  174. endef
  175. define filechk_gen-syscalltab
  176. (set -e; \
  177. echo "/*"; \
  178. echo " * DO NOT MODIFY."; \
  179. echo " *"; \
  180. echo " * This file was generated by arch/sh/Makefile"; \
  181. echo " * Any changes will be reverted at build time."; \
  182. echo " */"; \
  183. echo ""; \
  184. echo "#ifndef __SYSCALLTAB_H"; \
  185. echo "#define __SYSCALLTAB_H"; \
  186. echo ""; \
  187. echo "#include <linux/kernel.h>"; \
  188. echo ""; \
  189. echo "struct syscall_info {"; \
  190. echo " const char *name;"; \
  191. echo "} syscall_info_table[] = {"; \
  192. sed -e '/^.*\.long /!d;s// { "/;s/\(\([^/]*\)\/\)\{1\}.*/\2/; \
  193. s/[ \t]*$$//g;s/$$/" },/;s/\("\)sys_/\1/g'; \
  194. echo "};"; \
  195. echo ""; \
  196. echo "#define NUM_SYSCALL_INFO_ENTRIES ARRAY_SIZE(syscall_info_table)";\
  197. echo ""; \
  198. echo "#endif /* __SYSCALLTAB_H */" )
  199. endef
  200. arch/sh/lib64/syscalltab.h: arch/sh/kernel/syscalls_64.S
  201. $(call filechk,gen-syscalltab)
  202. CLEAN_FILES += arch/sh/lib64/syscalltab.h \
  203. include/asm-sh/machtypes.h