Makefile 7.5 KB

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