18c2ecf20Sopenharmony_ci# 28c2ecf20Sopenharmony_ci# arch/sh/Makefile 38c2ecf20Sopenharmony_ci# 48c2ecf20Sopenharmony_ci# Copyright (C) 1999 Kaz Kojima 58c2ecf20Sopenharmony_ci# Copyright (C) 2002 - 2008 Paul Mundt 68c2ecf20Sopenharmony_ci# Copyright (C) 2002 M. R. Brown 78c2ecf20Sopenharmony_ci# 88c2ecf20Sopenharmony_ci# This file is subject to the terms and conditions of the GNU General Public 98c2ecf20Sopenharmony_ci# License. See the file "COPYING" in the main directory of this archive 108c2ecf20Sopenharmony_ci# for more details. 118c2ecf20Sopenharmony_ci# 128c2ecf20Sopenharmony_ciifneq ($(SUBARCH),$(ARCH)) 138c2ecf20Sopenharmony_ci ifeq ($(CROSS_COMPILE),) 148c2ecf20Sopenharmony_ci CROSS_COMPILE := $(call cc-cross-prefix, sh-linux- sh-linux-gnu- sh-unknown-linux-gnu-) 158c2ecf20Sopenharmony_ci endif 168c2ecf20Sopenharmony_ciendif 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ciKBUILD_DEFCONFIG := shx3_defconfig 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ciisa-y := any 218c2ecf20Sopenharmony_ciisa-$(CONFIG_SH_DSP) := sh 228c2ecf20Sopenharmony_ciisa-$(CONFIG_CPU_SH2) := sh2 238c2ecf20Sopenharmony_ciisa-$(CONFIG_CPU_SH2A) := sh2a 248c2ecf20Sopenharmony_ciisa-$(CONFIG_CPU_SH3) := sh3 258c2ecf20Sopenharmony_ciisa-$(CONFIG_CPU_SH4) := sh4 268c2ecf20Sopenharmony_ciisa-$(CONFIG_CPU_SH4A) := sh4a 278c2ecf20Sopenharmony_ciisa-$(CONFIG_CPU_SH4AL_DSP) := sh4al 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_ciisa-$(CONFIG_SH_DSP) := $(isa-y)-dsp 308c2ecf20Sopenharmony_ciisa-y := $(isa-y)-up 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_cicflags-$(CONFIG_CPU_SH2) := $(call cc-option,-m2,) 338c2ecf20Sopenharmony_cicflags-$(CONFIG_CPU_J2) += $(call cc-option,-mj2,) 348c2ecf20Sopenharmony_cicflags-$(CONFIG_CPU_SH2A) += $(call cc-option,-m2a,) \ 358c2ecf20Sopenharmony_ci $(call cc-option,-m2a-nofpu,) \ 368c2ecf20Sopenharmony_ci $(call cc-option,-m4-nofpu,) 378c2ecf20Sopenharmony_cicflags-$(CONFIG_CPU_SH3) := $(call cc-option,-m3,) 388c2ecf20Sopenharmony_cicflags-$(CONFIG_CPU_SH4) := $(call cc-option,-m4,) \ 398c2ecf20Sopenharmony_ci $(call cc-option,-mno-implicit-fp,-m4-nofpu) 408c2ecf20Sopenharmony_cicflags-$(CONFIG_CPU_SH4A) += $(call cc-option,-m4a,) \ 418c2ecf20Sopenharmony_ci $(call cc-option,-m4a-nofpu,) 428c2ecf20Sopenharmony_cicflags-$(CONFIG_CPU_SH4AL_DSP) += $(call cc-option,-m4al,) 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ciifeq ($(cflags-y),) 458c2ecf20Sopenharmony_ci# 468c2ecf20Sopenharmony_ci# In the case where we are stuck with a compiler that has been uselessly 478c2ecf20Sopenharmony_ci# restricted to a particular ISA, a favourite default of newer GCCs when 488c2ecf20Sopenharmony_ci# extensive multilib targets are not provided, ensure we get the best fit 498c2ecf20Sopenharmony_ci# regarding FP generation. This is intentionally stupid (albeit many 508c2ecf20Sopenharmony_ci# orders of magnitude less than GCC's default behaviour), as anything 518c2ecf20Sopenharmony_ci# with a large number of multilib targets better have been built 528c2ecf20Sopenharmony_ci# correctly for the target in mind. 538c2ecf20Sopenharmony_ci# 548c2ecf20Sopenharmony_cicflags-y += $(shell $(CC) $(KBUILD_CFLAGS) -print-multi-lib | \ 558c2ecf20Sopenharmony_ci grep nofpu | sed q | sed -e 's/^/-/;s/;.*$$//') 568c2ecf20Sopenharmony_ci# At this point, anything goes. 578c2ecf20Sopenharmony_ciisaflags-y := $(call as-option,-Wa$(comma)-isa=any,) 588c2ecf20Sopenharmony_cielse 598c2ecf20Sopenharmony_ci# 608c2ecf20Sopenharmony_ci# -Wa,-isa= tuning implies -Wa,-dsp for the versions of binutils that 618c2ecf20Sopenharmony_ci# support it, while -Wa,-dsp by itself limits the range of usable opcodes 628c2ecf20Sopenharmony_ci# on certain CPU subtypes. Try the ISA variant first, and if that fails, 638c2ecf20Sopenharmony_ci# fall back on -Wa,-dsp for the old binutils versions. Even without DSP 648c2ecf20Sopenharmony_ci# opcodes, we always want the best ISA tuning the version of binutils 658c2ecf20Sopenharmony_ci# will provide. 668c2ecf20Sopenharmony_ci# 678c2ecf20Sopenharmony_ciisaflags-y := $(call as-option,-Wa$(comma)-isa=$(isa-y),) 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_ciisaflags-$(CONFIG_SH_DSP) := \ 708c2ecf20Sopenharmony_ci $(call as-option,-Wa$(comma)-isa=$(isa-y),-Wa$(comma)-dsp) 718c2ecf20Sopenharmony_ciendif 728c2ecf20Sopenharmony_ci 738c2ecf20Sopenharmony_cicflags-$(CONFIG_CPU_BIG_ENDIAN) += -mb 748c2ecf20Sopenharmony_cicflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -ml 758c2ecf20Sopenharmony_ci 768c2ecf20Sopenharmony_cicflags-y += $(call cc-option,-mno-fdpic) 778c2ecf20Sopenharmony_cicflags-y += $(isaflags-y) -ffreestanding 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_ciOBJCOPYFLAGS := -O binary -R .note -R .note.gnu.build-id -R .comment \ 808c2ecf20Sopenharmony_ci -R .stab -R .stabstr -S 818c2ecf20Sopenharmony_ci 828c2ecf20Sopenharmony_ci# Give the various platforms the opportunity to set default image types 838c2ecf20Sopenharmony_cidefaultimage-y := zImage 848c2ecf20Sopenharmony_cidefaultimage-$(CONFIG_SH_SH7785LCR) := uImage 858c2ecf20Sopenharmony_cidefaultimage-$(CONFIG_SH_RSK) := uImage 868c2ecf20Sopenharmony_cidefaultimage-$(CONFIG_SH_URQUELL) := uImage 878c2ecf20Sopenharmony_cidefaultimage-$(CONFIG_SH_MIGOR) := uImage 888c2ecf20Sopenharmony_cidefaultimage-$(CONFIG_SH_AP325RXA) := uImage 898c2ecf20Sopenharmony_cidefaultimage-$(CONFIG_SH_SH7757LCR) := uImage 908c2ecf20Sopenharmony_cidefaultimage-$(CONFIG_SH_7724_SOLUTION_ENGINE) := uImage 918c2ecf20Sopenharmony_cidefaultimage-$(CONFIG_SH_7206_SOLUTION_ENGINE) := vmlinux 928c2ecf20Sopenharmony_cidefaultimage-$(CONFIG_SH_7619_SOLUTION_ENGINE) := vmlinux 938c2ecf20Sopenharmony_ci 948c2ecf20Sopenharmony_ci# Set some sensible Kbuild defaults 958c2ecf20Sopenharmony_ciboot := arch/sh/boot 968c2ecf20Sopenharmony_ciKBUILD_IMAGE := $(boot)/$(defaultimage-y) 978c2ecf20Sopenharmony_ci 988c2ecf20Sopenharmony_ci# 998c2ecf20Sopenharmony_ci# Choosing incompatible machines durings configuration will result in 1008c2ecf20Sopenharmony_ci# error messages during linking. 1018c2ecf20Sopenharmony_ci# 1028c2ecf20Sopenharmony_ciUTS_MACHINE := sh 1038c2ecf20Sopenharmony_ciLDFLAGS_vmlinux += -e _stext 1048c2ecf20Sopenharmony_ci 1058c2ecf20Sopenharmony_ciifdef CONFIG_CPU_LITTLE_ENDIAN 1068c2ecf20Sopenharmony_cild-bfd := elf32-sh-linux 1078c2ecf20Sopenharmony_ciLDFLAGS_vmlinux += --defsym jiffies=jiffies_64 --oformat $(ld-bfd) 1088c2ecf20Sopenharmony_ciKBUILD_LDFLAGS += -EL 1098c2ecf20Sopenharmony_cielse 1108c2ecf20Sopenharmony_cild-bfd := elf32-shbig-linux 1118c2ecf20Sopenharmony_ciLDFLAGS_vmlinux += --defsym jiffies=jiffies_64+4 --oformat $(ld-bfd) 1128c2ecf20Sopenharmony_ciKBUILD_LDFLAGS += -EB 1138c2ecf20Sopenharmony_ciendif 1148c2ecf20Sopenharmony_ci 1158c2ecf20Sopenharmony_ciexport ld-bfd 1168c2ecf20Sopenharmony_ci 1178c2ecf20Sopenharmony_cihead-y := arch/sh/kernel/head_32.o 1188c2ecf20Sopenharmony_ci 1198c2ecf20Sopenharmony_cicore-y += arch/sh/kernel/ arch/sh/mm/ arch/sh/boards/ 1208c2ecf20Sopenharmony_cicore-$(CONFIG_SH_FPU_EMU) += arch/sh/math-emu/ 1218c2ecf20Sopenharmony_ci 1228c2ecf20Sopenharmony_cicore-$(CONFIG_USE_BUILTIN_DTB) += arch/sh/boot/dts/ 1238c2ecf20Sopenharmony_ci 1248c2ecf20Sopenharmony_ci# Mach groups 1258c2ecf20Sopenharmony_cimachdir-$(CONFIG_SOLUTION_ENGINE) += mach-se 1268c2ecf20Sopenharmony_cimachdir-$(CONFIG_SH_HP6XX) += mach-hp6xx 1278c2ecf20Sopenharmony_cimachdir-$(CONFIG_SH_DREAMCAST) += mach-dreamcast 1288c2ecf20Sopenharmony_cimachdir-$(CONFIG_SH_SH03) += mach-sh03 1298c2ecf20Sopenharmony_cimachdir-$(CONFIG_SH_RTS7751R2D) += mach-r2d 1308c2ecf20Sopenharmony_cimachdir-$(CONFIG_SH_HIGHLANDER) += mach-highlander 1318c2ecf20Sopenharmony_cimachdir-$(CONFIG_SH_MIGOR) += mach-migor 1328c2ecf20Sopenharmony_cimachdir-$(CONFIG_SH_AP325RXA) += mach-ap325rxa 1338c2ecf20Sopenharmony_cimachdir-$(CONFIG_SH_KFR2R09) += mach-kfr2r09 1348c2ecf20Sopenharmony_cimachdir-$(CONFIG_SH_ECOVEC) += mach-ecovec24 1358c2ecf20Sopenharmony_cimachdir-$(CONFIG_SH_SDK7780) += mach-sdk7780 1368c2ecf20Sopenharmony_cimachdir-$(CONFIG_SH_SDK7786) += mach-sdk7786 1378c2ecf20Sopenharmony_cimachdir-$(CONFIG_SH_X3PROTO) += mach-x3proto 1388c2ecf20Sopenharmony_cimachdir-$(CONFIG_SH_SH7763RDP) += mach-sh7763rdp 1398c2ecf20Sopenharmony_cimachdir-$(CONFIG_SH_SH4202_MICRODEV) += mach-microdev 1408c2ecf20Sopenharmony_cimachdir-$(CONFIG_SH_LANDISK) += mach-landisk 1418c2ecf20Sopenharmony_cimachdir-$(CONFIG_SH_LBOX_RE2) += mach-lboxre2 1428c2ecf20Sopenharmony_cimachdir-$(CONFIG_SH_RSK) += mach-rsk 1438c2ecf20Sopenharmony_ci 1448c2ecf20Sopenharmony_ciifneq ($(machdir-y),) 1458c2ecf20Sopenharmony_cicore-y += $(addprefix arch/sh/boards/, \ 1468c2ecf20Sopenharmony_ci $(filter-out ., $(patsubst %,%/,$(machdir-y)))) 1478c2ecf20Sopenharmony_ciendif 1488c2ecf20Sopenharmony_ci 1498c2ecf20Sopenharmony_ci# Common machine type headers. Not part of the arch/sh/boards/ hierarchy. 1508c2ecf20Sopenharmony_cimachdir-y += mach-common 1518c2ecf20Sopenharmony_ci 1528c2ecf20Sopenharmony_ci# Companion chips 1538c2ecf20Sopenharmony_cicore-$(CONFIG_HD6446X_SERIES) += arch/sh/cchips/hd6446x/ 1548c2ecf20Sopenharmony_ci 1558c2ecf20Sopenharmony_ci# 1568c2ecf20Sopenharmony_ci# CPU header paths 1578c2ecf20Sopenharmony_ci# 1588c2ecf20Sopenharmony_ci# These are ordered by optimization level. A CPU family that is a subset 1598c2ecf20Sopenharmony_ci# of another (ie, SH-2A / SH-2), is picked up first, with increasing 1608c2ecf20Sopenharmony_ci# levels of genericness if nothing more suitable is situated in the 1618c2ecf20Sopenharmony_ci# hierarchy. 1628c2ecf20Sopenharmony_ci# 1638c2ecf20Sopenharmony_ci# As an example, in order of preference, SH-2A > SH-2 > common definitions. 1648c2ecf20Sopenharmony_ci# 1658c2ecf20Sopenharmony_cicpuincdir-$(CONFIG_CPU_SH2A) += cpu-sh2a 1668c2ecf20Sopenharmony_cicpuincdir-$(CONFIG_CPU_SH2) += cpu-sh2 1678c2ecf20Sopenharmony_cicpuincdir-$(CONFIG_CPU_SH3) += cpu-sh3 1688c2ecf20Sopenharmony_cicpuincdir-$(CONFIG_CPU_SH4A) += cpu-sh4a 1698c2ecf20Sopenharmony_cicpuincdir-$(CONFIG_CPU_SH4) += cpu-sh4 1708c2ecf20Sopenharmony_cicpuincdir-y += cpu-common # Must be last 1718c2ecf20Sopenharmony_ci 1728c2ecf20Sopenharmony_cidrivers-y += arch/sh/drivers/ 1738c2ecf20Sopenharmony_cidrivers-$(CONFIG_OPROFILE) += arch/sh/oprofile/ 1748c2ecf20Sopenharmony_ci 1758c2ecf20Sopenharmony_cicflags-y += $(foreach d, $(cpuincdir-y), -I $(srctree)/arch/sh/include/$(d)) \ 1768c2ecf20Sopenharmony_ci $(foreach d, $(machdir-y), -I $(srctree)/arch/sh/include/$(d)) 1778c2ecf20Sopenharmony_ci 1788c2ecf20Sopenharmony_ciKBUILD_CFLAGS += -pipe $(cflags-y) 1798c2ecf20Sopenharmony_ciKBUILD_CPPFLAGS += $(cflags-y) 1808c2ecf20Sopenharmony_ciKBUILD_AFLAGS += $(cflags-y) 1818c2ecf20Sopenharmony_ci 1828c2ecf20Sopenharmony_ciifeq ($(CONFIG_MCOUNT),y) 1838c2ecf20Sopenharmony_ci KBUILD_CFLAGS += -pg 1848c2ecf20Sopenharmony_ciendif 1858c2ecf20Sopenharmony_ci 1868c2ecf20Sopenharmony_ciifeq ($(CONFIG_DWARF_UNWINDER),y) 1878c2ecf20Sopenharmony_ci KBUILD_CFLAGS += -fasynchronous-unwind-tables 1888c2ecf20Sopenharmony_ciendif 1898c2ecf20Sopenharmony_ci 1908c2ecf20Sopenharmony_cilibs-y := arch/sh/lib/ $(libs-y) 1918c2ecf20Sopenharmony_ci 1928c2ecf20Sopenharmony_ciBOOT_TARGETS = uImage uImage.bz2 uImage.gz uImage.lzma uImage.xz uImage.lzo \ 1938c2ecf20Sopenharmony_ci uImage.srec uImage.bin zImage vmlinux.bin vmlinux.srec \ 1948c2ecf20Sopenharmony_ci romImage 1958c2ecf20Sopenharmony_ciPHONY += $(BOOT_TARGETS) 1968c2ecf20Sopenharmony_ci 1978c2ecf20Sopenharmony_ciall: $(notdir $(KBUILD_IMAGE)) 1988c2ecf20Sopenharmony_ci 1998c2ecf20Sopenharmony_ci$(BOOT_TARGETS): vmlinux 2008c2ecf20Sopenharmony_ci $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@ 2018c2ecf20Sopenharmony_ci 2028c2ecf20Sopenharmony_cicompressed: zImage 2038c2ecf20Sopenharmony_ci 2048c2ecf20Sopenharmony_ciarchprepare: 2058c2ecf20Sopenharmony_ci $(Q)$(MAKE) $(build)=arch/sh/tools include/generated/machtypes.h 2068c2ecf20Sopenharmony_ci 2078c2ecf20Sopenharmony_ciarchclean: 2088c2ecf20Sopenharmony_ci $(Q)$(MAKE) $(clean)=$(boot) 2098c2ecf20Sopenharmony_ci $(Q)$(MAKE) $(clean)=arch/sh/kernel/vsyscall 2108c2ecf20Sopenharmony_ci 2118c2ecf20Sopenharmony_ciarchheaders: 2128c2ecf20Sopenharmony_ci $(Q)$(MAKE) $(build)=arch/sh/kernel/syscalls all 2138c2ecf20Sopenharmony_ci 2148c2ecf20Sopenharmony_cidefine archhelp 2158c2ecf20Sopenharmony_ci @echo ' zImage - Compressed kernel image' 2168c2ecf20Sopenharmony_ci @echo ' romImage - Compressed ROM image, if supported' 2178c2ecf20Sopenharmony_ci @echo ' vmlinux.srec - Create an ELF S-record' 2188c2ecf20Sopenharmony_ci @echo ' vmlinux.bin - Create an uncompressed binary image' 2198c2ecf20Sopenharmony_ci @echo '* uImage - Alias to bootable U-Boot image' 2208c2ecf20Sopenharmony_ci @echo ' uImage.srec - Create an S-record for U-Boot' 2218c2ecf20Sopenharmony_ci @echo ' uImage.bin - Kernel-only image for U-Boot (bin)' 2228c2ecf20Sopenharmony_ci @echo '* uImage.gz - Kernel-only image for U-Boot (gzip)' 2238c2ecf20Sopenharmony_ci @echo ' uImage.bz2 - Kernel-only image for U-Boot (bzip2)' 2248c2ecf20Sopenharmony_ci @echo ' uImage.lzma - Kernel-only image for U-Boot (lzma)' 2258c2ecf20Sopenharmony_ci @echo ' uImage.xz - Kernel-only image for U-Boot (xz)' 2268c2ecf20Sopenharmony_ci @echo ' uImage.lzo - Kernel-only image for U-Boot (lzo)' 2278c2ecf20Sopenharmony_ciendef 228