162306a36Sopenharmony_ci# 262306a36Sopenharmony_ci# arch/sh/Makefile 362306a36Sopenharmony_ci# 462306a36Sopenharmony_ci# Copyright (C) 1999 Kaz Kojima 562306a36Sopenharmony_ci# Copyright (C) 2002 - 2008 Paul Mundt 662306a36Sopenharmony_ci# Copyright (C) 2002 M. R. Brown 762306a36Sopenharmony_ci# 862306a36Sopenharmony_ci# This file is subject to the terms and conditions of the GNU General Public 962306a36Sopenharmony_ci# License. See the file "COPYING" in the main directory of this archive 1062306a36Sopenharmony_ci# for more details. 1162306a36Sopenharmony_ci# 1262306a36Sopenharmony_ciifdef cross_compiling 1362306a36Sopenharmony_ci ifeq ($(CROSS_COMPILE),) 1462306a36Sopenharmony_ci CROSS_COMPILE := $(call cc-cross-prefix, sh-linux- sh-linux-gnu- sh-unknown-linux-gnu-) 1562306a36Sopenharmony_ci endif 1662306a36Sopenharmony_ciendif 1762306a36Sopenharmony_ci 1862306a36Sopenharmony_ciKBUILD_DEFCONFIG := shx3_defconfig 1962306a36Sopenharmony_ci 2062306a36Sopenharmony_ciisa-y := any 2162306a36Sopenharmony_ciisa-$(CONFIG_SH_DSP) := sh 2262306a36Sopenharmony_ciisa-$(CONFIG_CPU_SH2) := sh2 2362306a36Sopenharmony_ciisa-$(CONFIG_CPU_SH2A) := sh2a 2462306a36Sopenharmony_ciisa-$(CONFIG_CPU_SH3) := sh3 2562306a36Sopenharmony_ciisa-$(CONFIG_CPU_SH4) := sh4 2662306a36Sopenharmony_ciisa-$(CONFIG_CPU_SH4A) := sh4a 2762306a36Sopenharmony_ciisa-$(CONFIG_CPU_SH4AL_DSP) := sh4al 2862306a36Sopenharmony_ci 2962306a36Sopenharmony_ciisa-$(CONFIG_SH_DSP) := $(isa-y)-dsp 3062306a36Sopenharmony_ciisa-y := $(isa-y)-up 3162306a36Sopenharmony_ci 3262306a36Sopenharmony_cicflags-$(CONFIG_CPU_SH2) := $(call cc-option,-m2,) 3362306a36Sopenharmony_cicflags-$(CONFIG_CPU_J2) += $(call cc-option,-mj2,) 3462306a36Sopenharmony_cicflags-$(CONFIG_CPU_SH2A) += $(call cc-option,-m2a,) \ 3562306a36Sopenharmony_ci $(call cc-option,-m2a-nofpu,) \ 3662306a36Sopenharmony_ci $(call cc-option,-m4-nofpu,) 3762306a36Sopenharmony_cicflags-$(CONFIG_CPU_SH3) := $(call cc-option,-m3,) 3862306a36Sopenharmony_cicflags-$(CONFIG_CPU_SH4) := $(call cc-option,-m4,) \ 3962306a36Sopenharmony_ci $(call cc-option,-mno-implicit-fp,-m4-nofpu) 4062306a36Sopenharmony_cicflags-$(CONFIG_CPU_SH4A) += $(call cc-option,-m4a,) \ 4162306a36Sopenharmony_ci $(call cc-option,-m4a-nofpu,) 4262306a36Sopenharmony_cicflags-$(CONFIG_CPU_SH4AL_DSP) += $(call cc-option,-m4al,) 4362306a36Sopenharmony_ci 4462306a36Sopenharmony_ciifeq ($(cflags-y),) 4562306a36Sopenharmony_ci# 4662306a36Sopenharmony_ci# In the case where we are stuck with a compiler that has been uselessly 4762306a36Sopenharmony_ci# restricted to a particular ISA, a favourite default of newer GCCs when 4862306a36Sopenharmony_ci# extensive multilib targets are not provided, ensure we get the best fit 4962306a36Sopenharmony_ci# regarding FP generation. This is intentionally stupid (albeit many 5062306a36Sopenharmony_ci# orders of magnitude less than GCC's default behaviour), as anything 5162306a36Sopenharmony_ci# with a large number of multilib targets better have been built 5262306a36Sopenharmony_ci# correctly for the target in mind. 5362306a36Sopenharmony_ci# 5462306a36Sopenharmony_cicflags-y += $(shell $(CC) $(KBUILD_CFLAGS) -print-multi-lib | \ 5562306a36Sopenharmony_ci grep nofpu | sed q | sed -e 's/^/-/;s/;.*$$//') 5662306a36Sopenharmony_ci# At this point, anything goes. 5762306a36Sopenharmony_ciisaflags-y := $(call as-option,-Wa$(comma)-isa=any,) 5862306a36Sopenharmony_cielse 5962306a36Sopenharmony_ci# 6062306a36Sopenharmony_ci# -Wa,-isa= tuning implies -Wa,-dsp for the versions of binutils that 6162306a36Sopenharmony_ci# support it, while -Wa,-dsp by itself limits the range of usable opcodes 6262306a36Sopenharmony_ci# on certain CPU subtypes. Try the ISA variant first, and if that fails, 6362306a36Sopenharmony_ci# fall back on -Wa,-dsp for the old binutils versions. Even without DSP 6462306a36Sopenharmony_ci# opcodes, we always want the best ISA tuning the version of binutils 6562306a36Sopenharmony_ci# will provide. 6662306a36Sopenharmony_ci# 6762306a36Sopenharmony_ciisaflags-y := $(call as-option,-Wa$(comma)-isa=$(isa-y),) 6862306a36Sopenharmony_ci 6962306a36Sopenharmony_ciisaflags-$(CONFIG_SH_DSP) := \ 7062306a36Sopenharmony_ci $(call as-option,-Wa$(comma)-isa=$(isa-y),-Wa$(comma)-dsp) 7162306a36Sopenharmony_ciendif 7262306a36Sopenharmony_ci 7362306a36Sopenharmony_cicflags-$(CONFIG_CPU_BIG_ENDIAN) += -mb 7462306a36Sopenharmony_cicflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -ml 7562306a36Sopenharmony_ci 7662306a36Sopenharmony_cicflags-y += $(call cc-option,-mno-fdpic) 7762306a36Sopenharmony_cicflags-y += $(isaflags-y) -ffreestanding 7862306a36Sopenharmony_ci 7962306a36Sopenharmony_ciOBJCOPYFLAGS := -O binary -R .note -R .note.gnu.build-id -R .comment \ 8062306a36Sopenharmony_ci -R .stab -R .stabstr -S 8162306a36Sopenharmony_ci 8262306a36Sopenharmony_ci# Give the various platforms the opportunity to set default image types 8362306a36Sopenharmony_cidefaultimage-y := zImage 8462306a36Sopenharmony_cidefaultimage-$(CONFIG_SH_SH7785LCR) := uImage 8562306a36Sopenharmony_cidefaultimage-$(CONFIG_SH_RSK) := uImage 8662306a36Sopenharmony_cidefaultimage-$(CONFIG_SH_URQUELL) := uImage 8762306a36Sopenharmony_cidefaultimage-$(CONFIG_SH_MIGOR) := uImage 8862306a36Sopenharmony_cidefaultimage-$(CONFIG_SH_AP325RXA) := uImage 8962306a36Sopenharmony_cidefaultimage-$(CONFIG_SH_SH7757LCR) := uImage 9062306a36Sopenharmony_cidefaultimage-$(CONFIG_SH_7724_SOLUTION_ENGINE) := uImage 9162306a36Sopenharmony_cidefaultimage-$(CONFIG_SH_7206_SOLUTION_ENGINE) := vmlinux 9262306a36Sopenharmony_cidefaultimage-$(CONFIG_SH_7619_SOLUTION_ENGINE) := vmlinux 9362306a36Sopenharmony_ci 9462306a36Sopenharmony_ci# Set some sensible Kbuild defaults 9562306a36Sopenharmony_ciboot := arch/sh/boot 9662306a36Sopenharmony_ciKBUILD_IMAGE := $(boot)/$(defaultimage-y) 9762306a36Sopenharmony_ci 9862306a36Sopenharmony_ci# 9962306a36Sopenharmony_ci# Choosing incompatible machines durings configuration will result in 10062306a36Sopenharmony_ci# error messages during linking. 10162306a36Sopenharmony_ci# 10262306a36Sopenharmony_ciUTS_MACHINE := sh 10362306a36Sopenharmony_ciLDFLAGS_vmlinux += -e _stext 10462306a36Sopenharmony_ci 10562306a36Sopenharmony_ciifdef CONFIG_CPU_LITTLE_ENDIAN 10662306a36Sopenharmony_cild-bfd := elf32-sh-linux 10762306a36Sopenharmony_ciLDFLAGS_vmlinux += --defsym jiffies=jiffies_64 --oformat $(ld-bfd) 10862306a36Sopenharmony_ciKBUILD_LDFLAGS += -EL 10962306a36Sopenharmony_cielse 11062306a36Sopenharmony_cild-bfd := elf32-shbig-linux 11162306a36Sopenharmony_ciLDFLAGS_vmlinux += --defsym jiffies=jiffies_64+4 --oformat $(ld-bfd) 11262306a36Sopenharmony_ciKBUILD_LDFLAGS += -EB 11362306a36Sopenharmony_ciendif 11462306a36Sopenharmony_ci 11562306a36Sopenharmony_ciexport ld-bfd 11662306a36Sopenharmony_ci 11762306a36Sopenharmony_ci# Mach groups 11862306a36Sopenharmony_cimachdir-$(CONFIG_SOLUTION_ENGINE) += mach-se 11962306a36Sopenharmony_cimachdir-$(CONFIG_SH_DREAMCAST) += mach-dreamcast 12062306a36Sopenharmony_cimachdir-$(CONFIG_SH_SH03) += mach-sh03 12162306a36Sopenharmony_cimachdir-$(CONFIG_SH_MIGOR) += mach-migor 12262306a36Sopenharmony_cimachdir-$(CONFIG_SH_KFR2R09) += mach-kfr2r09 12362306a36Sopenharmony_cimachdir-$(CONFIG_SH_ECOVEC) += mach-ecovec24 12462306a36Sopenharmony_cimachdir-$(CONFIG_SH_SDK7786) += mach-sdk7786 12562306a36Sopenharmony_cimachdir-$(CONFIG_SH_X3PROTO) += mach-x3proto 12662306a36Sopenharmony_cimachdir-$(CONFIG_SH_LANDISK) += mach-landisk 12762306a36Sopenharmony_cimachdir-y += mach-common 12862306a36Sopenharmony_ci 12962306a36Sopenharmony_ci# 13062306a36Sopenharmony_ci# CPU header paths 13162306a36Sopenharmony_ci# 13262306a36Sopenharmony_ci# These are ordered by optimization level. A CPU family that is a subset 13362306a36Sopenharmony_ci# of another (ie, SH-2A / SH-2), is picked up first, with increasing 13462306a36Sopenharmony_ci# levels of genericness if nothing more suitable is situated in the 13562306a36Sopenharmony_ci# hierarchy. 13662306a36Sopenharmony_ci# 13762306a36Sopenharmony_ci# As an example, in order of preference, SH-2A > SH-2 > common definitions. 13862306a36Sopenharmony_ci# 13962306a36Sopenharmony_cicpuincdir-$(CONFIG_CPU_SH2A) += cpu-sh2a 14062306a36Sopenharmony_cicpuincdir-$(CONFIG_CPU_SH2) += cpu-sh2 14162306a36Sopenharmony_cicpuincdir-$(CONFIG_CPU_SH3) += cpu-sh3 14262306a36Sopenharmony_cicpuincdir-$(CONFIG_CPU_SH4A) += cpu-sh4a 14362306a36Sopenharmony_cicpuincdir-$(CONFIG_CPU_SH4) += cpu-sh4 14462306a36Sopenharmony_cicpuincdir-y += cpu-common # Must be last 14562306a36Sopenharmony_ci 14662306a36Sopenharmony_cidrivers-y += arch/sh/drivers/ 14762306a36Sopenharmony_ci 14862306a36Sopenharmony_ciKBUILD_CPPFLAGS += $(addprefix -I $(srctree)/arch/sh/include/, $(cpuincdir-y) $(machdir-y)) 14962306a36Sopenharmony_ciKBUILD_CFLAGS += -pipe $(cflags-y) 15062306a36Sopenharmony_ciKBUILD_AFLAGS += $(cflags-y) 15162306a36Sopenharmony_ci 15262306a36Sopenharmony_ciifeq ($(CONFIG_MCOUNT),y) 15362306a36Sopenharmony_ci KBUILD_CFLAGS += -pg 15462306a36Sopenharmony_ciendif 15562306a36Sopenharmony_ci 15662306a36Sopenharmony_ciifeq ($(CONFIG_DWARF_UNWINDER),y) 15762306a36Sopenharmony_ci KBUILD_CFLAGS += -fasynchronous-unwind-tables 15862306a36Sopenharmony_ciendif 15962306a36Sopenharmony_ci 16062306a36Sopenharmony_cilibs-y := arch/sh/lib/ $(libs-y) 16162306a36Sopenharmony_ci 16262306a36Sopenharmony_ciBOOT_TARGETS = uImage uImage.bz2 uImage.gz uImage.lzma uImage.xz uImage.lzo \ 16362306a36Sopenharmony_ci uImage.srec uImage.bin zImage vmlinux.bin vmlinux.srec \ 16462306a36Sopenharmony_ci romImage 16562306a36Sopenharmony_ciPHONY += $(BOOT_TARGETS) 16662306a36Sopenharmony_ci 16762306a36Sopenharmony_ciall: $(notdir $(KBUILD_IMAGE)) 16862306a36Sopenharmony_ci 16962306a36Sopenharmony_ci$(BOOT_TARGETS): vmlinux 17062306a36Sopenharmony_ci $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@ 17162306a36Sopenharmony_ci 17262306a36Sopenharmony_cicompressed: zImage 17362306a36Sopenharmony_ci 17462306a36Sopenharmony_ciarchprepare: 17562306a36Sopenharmony_ci $(Q)$(MAKE) $(build)=arch/sh/tools include/generated/machtypes.h 17662306a36Sopenharmony_ci 17762306a36Sopenharmony_ciarchheaders: 17862306a36Sopenharmony_ci $(Q)$(MAKE) $(build)=arch/sh/kernel/syscalls all 17962306a36Sopenharmony_ci 18062306a36Sopenharmony_cidefine archhelp 18162306a36Sopenharmony_ci @echo ' zImage - Compressed kernel image' 18262306a36Sopenharmony_ci @echo ' romImage - Compressed ROM image, if supported' 18362306a36Sopenharmony_ci @echo ' vmlinux.srec - Create an ELF S-record' 18462306a36Sopenharmony_ci @echo ' vmlinux.bin - Create an uncompressed binary image' 18562306a36Sopenharmony_ci @echo '* uImage - Alias to bootable U-Boot image' 18662306a36Sopenharmony_ci @echo ' uImage.srec - Create an S-record for U-Boot' 18762306a36Sopenharmony_ci @echo ' uImage.bin - Kernel-only image for U-Boot (bin)' 18862306a36Sopenharmony_ci @echo '* uImage.gz - Kernel-only image for U-Boot (gzip)' 18962306a36Sopenharmony_ci @echo ' uImage.bz2 - Kernel-only image for U-Boot (bzip2)' 19062306a36Sopenharmony_ci @echo ' uImage.lzma - Kernel-only image for U-Boot (lzma)' 19162306a36Sopenharmony_ci @echo ' uImage.xz - Kernel-only image for U-Boot (xz)' 19262306a36Sopenharmony_ci @echo ' uImage.lzo - Kernel-only image for U-Boot (lzo)' 19362306a36Sopenharmony_ciendef 194