Makefile 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  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. isa-$(CONFIG_SH_DSP) := $(isa-y)-dsp
  22. cflags-$(CONFIG_CPU_SH2) := $(call cc-option,-m2,)
  23. cflags-$(CONFIG_CPU_SH2A) += $(call cc-option,-m2a,) \
  24. $(call cc-option,-m2a-nofpu,)
  25. cflags-$(CONFIG_CPU_SH3) := $(call cc-option,-m3,)
  26. cflags-$(CONFIG_CPU_SH4) := $(call cc-option,-m4,) \
  27. $(call cc-option,-mno-implicit-fp,-m4-nofpu)
  28. cflags-$(CONFIG_CPU_SH4A) += $(call cc-option,-m4a,) \
  29. $(call cc-option,-m4a-nofpu,)
  30. cflags-$(CONFIG_CPU_SH5) := $(call cc-option,-m5-32media-nofpu,)
  31. ifeq ($(cflags-y),)
  32. #
  33. # In the case where we are stuck with a compiler that has been uselessly
  34. # restricted to a particular ISA, a favourite default of newer GCCs when
  35. # extensive multilib targets are not provided, ensure we get the best fit
  36. # regarding FP generation. This is necessary to avoid references to FP
  37. # variants in libgcc where integer variants exist, which otherwise result
  38. # in link errors. This is intentionally stupid (albeit many orders of
  39. # magnitude less than GCC's default behaviour), as anything with a large
  40. # number of multilib targets better have been built correctly for
  41. # the target in mind.
  42. #
  43. cflags-y += $(shell $(CC) $(KBUILD_CFLAGS) -print-multi-lib | \
  44. grep nofpu | sed q | sed -e 's/^/-/;s/;.*$$//')
  45. endif
  46. cflags-$(CONFIG_CPU_BIG_ENDIAN) += -mb
  47. cflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -ml
  48. cflags-y += $(call cc-option,-mno-fdpic)
  49. #
  50. # -Wa,-isa= tuning implies -Wa,-dsp for the versions of binutils that
  51. # support it, while -Wa,-dsp by itself limits the range of usable opcodes
  52. # on certain CPU subtypes. Try the ISA variant first, and if that fails,
  53. # fall back on -Wa,-dsp for the old binutils versions. Even without DSP
  54. # opcodes, we always want the best ISA tuning the version of binutils
  55. # will provide.
  56. #
  57. isaflags-y := $(call as-option,-Wa$(comma)-isa=$(isa-y),)
  58. isaflags-$(CONFIG_SH_DSP) := \
  59. $(call as-option,-Wa$(comma)-isa=$(isa-y),-Wa$(comma)-dsp)
  60. cflags-y += $(isaflags-y) -ffreestanding
  61. cflags-$(CONFIG_MORE_COMPILE_OPTIONS) += \
  62. $(shell echo $(CONFIG_COMPILE_OPTIONS) | sed -e 's/"//g')
  63. OBJCOPYFLAGS := -O binary -R .note -R .note.gnu.build-id -R .comment \
  64. -R .stab -R .stabstr -S
  65. # Give the various platforms the opportunity to set default image types
  66. defaultimage-$(CONFIG_SUPERH32) := zImage
  67. defaultimage-$(CONFIG_SH_SH7785LCR) := uImage
  68. # Set some sensible Kbuild defaults
  69. KBUILD_DEFCONFIG := shx3_defconfig
  70. KBUILD_IMAGE := $(defaultimage-y)
  71. #
  72. # Choosing incompatible machines durings configuration will result in
  73. # error messages during linking.
  74. #
  75. ifdef CONFIG_SUPERH32
  76. UTS_MACHINE := sh
  77. LDFLAGS_vmlinux += -e _stext
  78. else
  79. UTS_MACHINE := sh64
  80. LDFLAGS_vmlinux += --defsym phys_stext=_stext-$(CONFIG_PAGE_OFFSET) \
  81. --defsym phys_stext_shmedia=phys_stext+1 \
  82. -e phys_stext_shmedia
  83. endif
  84. ifdef CONFIG_CPU_LITTLE_ENDIAN
  85. LDFLAGS_vmlinux += --defsym 'jiffies=jiffies_64'
  86. LDFLAGS += -EL
  87. else
  88. LDFLAGS_vmlinux += --defsym 'jiffies=jiffies_64+4'
  89. LDFLAGS += -EB
  90. endif
  91. head-y := arch/sh/kernel/init_task.o
  92. head-$(CONFIG_SUPERH32) += arch/sh/kernel/head_32.o
  93. head-$(CONFIG_SUPERH64) += arch/sh/kernel/head_64.o
  94. core-y += arch/sh/kernel/ arch/sh/mm/ arch/sh/boards/
  95. core-$(CONFIG_SH_FPU_EMU) += arch/sh/math-emu/
  96. # Mach groups
  97. machdir-$(CONFIG_SOLUTION_ENGINE) += mach-se
  98. machdir-$(CONFIG_SH_HP6XX) += mach-hp6xx
  99. machdir-$(CONFIG_SH_DREAMCAST) += mach-dreamcast
  100. machdir-$(CONFIG_SH_SH03) += mach-sh03
  101. machdir-$(CONFIG_SH_SECUREEDGE5410) += mach-snapgear
  102. machdir-$(CONFIG_SH_RTS7751R2D) += mach-r2d
  103. machdir-$(CONFIG_SH_7751_SYSTEMH) += mach-systemh
  104. machdir-$(CONFIG_SH_EDOSK7705) += mach-edosk7705
  105. machdir-$(CONFIG_SH_HIGHLANDER) += mach-highlander
  106. machdir-$(CONFIG_SH_MIGOR) += mach-migor
  107. machdir-$(CONFIG_SH_SDK7780) += mach-sdk7780
  108. machdir-$(CONFIG_SH_X3PROTO) += mach-x3proto
  109. machdir-$(CONFIG_SH_SH7763RDP) += mach-sh7763rdp
  110. machdir-$(CONFIG_SH_SH4202_MICRODEV) += mach-microdev
  111. machdir-$(CONFIG_SH_LANDISK) += mach-landisk
  112. machdir-$(CONFIG_SH_TITAN) += mach-titan
  113. machdir-$(CONFIG_SH_LBOX_RE2) += mach-lboxre2
  114. machdir-$(CONFIG_SH_CAYMAN) += mach-cayman
  115. ifneq ($(machdir-y),)
  116. core-y += $(addprefix arch/sh/boards/, \
  117. $(filter-out ., $(patsubst %,%/,$(machdir-y))))
  118. endif
  119. # Common machine type headers. Not part of the arch/sh/boards/ hierarchy.
  120. machdir-y += mach-common
  121. # Companion chips
  122. core-$(CONFIG_HD6446X_SERIES) += arch/sh/cchips/hd6446x/
  123. #
  124. # CPU header paths
  125. #
  126. # These are ordered by optimization level. A CPU family that is a subset
  127. # of another (ie, SH-2A / SH-2), is picked up first, with increasing
  128. # levels of genericness if nothing more suitable is situated in the
  129. # hierarchy.
  130. #
  131. # As an example, in order of preference, SH-2A > SH-2 > common definitions.
  132. #
  133. cpuincdir-$(CONFIG_CPU_SH2A) += cpu-sh2a
  134. cpuincdir-$(CONFIG_CPU_SH2) += cpu-sh2
  135. cpuincdir-$(CONFIG_CPU_SH3) += cpu-sh3
  136. cpuincdir-$(CONFIG_CPU_SH4) += cpu-sh4
  137. cpuincdir-$(CONFIG_CPU_SH5) += cpu-sh5
  138. cpuincdir-y += cpu-common # Must be last
  139. drivers-y += arch/sh/drivers/
  140. drivers-$(CONFIG_OPROFILE) += arch/sh/oprofile/
  141. boot := arch/sh/boot
  142. cflags-y += $(foreach d, $(cpuincdir-y), -Iarch/sh/include/$(d)) \
  143. $(foreach d, $(machdir-y), -Iarch/sh/include/$(d))
  144. KBUILD_CFLAGS += -pipe $(cflags-y)
  145. KBUILD_CPPFLAGS += $(cflags-y)
  146. KBUILD_AFLAGS += $(cflags-y)
  147. LIBGCC := $(shell $(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name)
  148. libs-$(CONFIG_SUPERH32) := arch/sh/lib/ $(libs-y)
  149. libs-$(CONFIG_SUPERH64) := arch/sh/lib64/ $(libs-y)
  150. libs-y += $(LIBGCC)
  151. PHONY += maketools FORCE
  152. maketools: include/linux/version.h FORCE
  153. $(Q)$(MAKE) $(build)=arch/sh/tools include/asm-sh/machtypes.h
  154. all: $(KBUILD_IMAGE)
  155. zImage uImage uImage.srec vmlinux.srec: vmlinux
  156. $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
  157. compressed: zImage
  158. archprepare: maketools arch/sh/lib64/syscalltab.h
  159. archclean:
  160. $(Q)$(MAKE) $(clean)=$(boot)
  161. define archhelp
  162. @echo '* zImage - Compressed kernel image'
  163. @echo ' vmlinux.srec - Create an ELF S-record'
  164. @echo ' uImage - Create a bootable image for U-Boot'
  165. @echo ' uImage.srec - Create an S-record for U-Boot'
  166. endef
  167. define filechk_gen-syscalltab
  168. (set -e; \
  169. echo "/*"; \
  170. echo " * DO NOT MODIFY."; \
  171. echo " *"; \
  172. echo " * This file was generated by arch/sh/Makefile"; \
  173. echo " * Any changes will be reverted at build time."; \
  174. echo " */"; \
  175. echo ""; \
  176. echo "#ifndef __SYSCALLTAB_H"; \
  177. echo "#define __SYSCALLTAB_H"; \
  178. echo ""; \
  179. echo "#include <linux/kernel.h>"; \
  180. echo ""; \
  181. echo "struct syscall_info {"; \
  182. echo " const char *name;"; \
  183. echo "} syscall_info_table[] = {"; \
  184. sed -e '/^.*\.long /!d;s// { "/;s/\(\([^/]*\)\/\)\{1\}.*/\2/; \
  185. s/[ \t]*$$//g;s/$$/" },/;s/\("\)sys_/\1/g'; \
  186. echo "};"; \
  187. echo ""; \
  188. echo "#define NUM_SYSCALL_INFO_ENTRIES ARRAY_SIZE(syscall_info_table)";\
  189. echo ""; \
  190. echo "#endif /* __SYSCALLTAB_H */" )
  191. endef
  192. arch/sh/lib64/syscalltab.h: arch/sh/kernel/syscalls_64.S
  193. $(call filechk,gen-syscalltab)
  194. CLEAN_FILES += arch/sh/lib64/syscalltab.h \
  195. include/asm-sh/machtypes.h