11da177e4SLinus Torvalds# 2c2f1755bSPaul Mundt# arch/sh/Makefile 31da177e4SLinus Torvalds# 41da177e4SLinus Torvalds# Copyright (C) 1999 Kaz Kojima 5b2d86a3fSPaul Mundt# Copyright (C) 2002 - 2008 Paul Mundt 61da177e4SLinus Torvalds# Copyright (C) 2002 M. R. Brown 71da177e4SLinus Torvalds# 8c2f1755bSPaul Mundt# This file is subject to the terms and conditions of the GNU General Public 9c2f1755bSPaul Mundt# License. See the file "COPYING" in the main directory of this archive 10c2f1755bSPaul Mundt# for more details. 111da177e4SLinus Torvalds# 1223243c1aSMasahiro Yamadaifdef cross_compiling 13d14a5fdcSGeert Uytterhoeven ifeq ($(CROSS_COMPILE),) 1437744feeSArnd Bergmann CROSS_COMPILE := $(call cc-cross-prefix, sh-linux- sh-linux-gnu- sh-unknown-linux-gnu-) 15d14a5fdcSGeert Uytterhoeven endif 16d14a5fdcSGeert Uytterhoevenendif 17d14a5fdcSGeert Uytterhoeven 18859fd586SMasahiro YamadaKBUILD_DEFCONFIG := shx3_defconfig 19859fd586SMasahiro Yamada 20cad82448SPaul Mundtisa-y := any 21e5723e0eSPaul Mundtisa-$(CONFIG_SH_DSP) := sh 22cad82448SPaul Mundtisa-$(CONFIG_CPU_SH2) := sh2 23e5723e0eSPaul Mundtisa-$(CONFIG_CPU_SH2A) := sh2a 24cad82448SPaul Mundtisa-$(CONFIG_CPU_SH3) := sh3 25cad82448SPaul Mundtisa-$(CONFIG_CPU_SH4) := sh4 26cad82448SPaul Mundtisa-$(CONFIG_CPU_SH4A) := sh4a 27e5723e0eSPaul Mundtisa-$(CONFIG_CPU_SH4AL_DSP) := sh4al 28ddb72b02SPaul Mundt 29cad82448SPaul Mundtisa-$(CONFIG_SH_DSP) := $(isa-y)-dsp 30ddb72b02SPaul Mundtisa-y := $(isa-y)-up 31cad82448SPaul Mundt 326240d92fSPaul Mundtcflags-$(CONFIG_CPU_SH2) := $(call cc-option,-m2,) 33f208b87bSRich Felkercflags-$(CONFIG_CPU_J2) += $(call cc-option,-mj2,) 34aab1b16aSPaul Mundtcflags-$(CONFIG_CPU_SH2A) += $(call cc-option,-m2a,) \ 35b1923b55SGeert Uytterhoeven $(call cc-option,-m2a-nofpu,) \ 36b1923b55SGeert Uytterhoeven $(call cc-option,-m4-nofpu,) 376240d92fSPaul Mundtcflags-$(CONFIG_CPU_SH3) := $(call cc-option,-m3,) 386240d92fSPaul Mundtcflags-$(CONFIG_CPU_SH4) := $(call cc-option,-m4,) \ 391da177e4SLinus Torvalds $(call cc-option,-mno-implicit-fp,-m4-nofpu) 40aab1b16aSPaul Mundtcflags-$(CONFIG_CPU_SH4A) += $(call cc-option,-m4a,) \ 416240d92fSPaul Mundt $(call cc-option,-m4a-nofpu,) 428bcc5c1cSPaul Mundtcflags-$(CONFIG_CPU_SH4AL_DSP) += $(call cc-option,-m4al,) 4353644087SPaul Mundt 445dd61476SPaul Mundtifeq ($(cflags-y),) 455dd61476SPaul Mundt# 465dd61476SPaul Mundt# In the case where we are stuck with a compiler that has been uselessly 475dd61476SPaul Mundt# restricted to a particular ISA, a favourite default of newer GCCs when 485dd61476SPaul Mundt# extensive multilib targets are not provided, ensure we get the best fit 495dd61476SPaul Mundt# regarding FP generation. This is intentionally stupid (albeit many 505dd61476SPaul Mundt# orders of magnitude less than GCC's default behaviour), as anything 515dd61476SPaul Mundt# with a large number of multilib targets better have been built 525dd61476SPaul Mundt# correctly for the target in mind. 535dd61476SPaul Mundt# 545dd61476SPaul Mundtcflags-y += $(shell $(CC) $(KBUILD_CFLAGS) -print-multi-lib | \ 555dd61476SPaul Mundt grep nofpu | sed q | sed -e 's/^/-/;s/;.*$$//') 565dd61476SPaul Mundt# At this point, anything goes. 575dd61476SPaul Mundtisaflags-y := $(call as-option,-Wa$(comma)-isa=any,) 585dd61476SPaul Mundtelse 59da2f5f7bSPaul Mundt# 60da2f5f7bSPaul Mundt# -Wa,-isa= tuning implies -Wa,-dsp for the versions of binutils that 61da2f5f7bSPaul Mundt# support it, while -Wa,-dsp by itself limits the range of usable opcodes 62da2f5f7bSPaul Mundt# on certain CPU subtypes. Try the ISA variant first, and if that fails, 63da2f5f7bSPaul Mundt# fall back on -Wa,-dsp for the old binutils versions. Even without DSP 64da2f5f7bSPaul Mundt# opcodes, we always want the best ISA tuning the version of binutils 65da2f5f7bSPaul Mundt# will provide. 66da2f5f7bSPaul Mundt# 67da2f5f7bSPaul Mundtisaflags-y := $(call as-option,-Wa$(comma)-isa=$(isa-y),) 68da2f5f7bSPaul Mundt 69da2f5f7bSPaul Mundtisaflags-$(CONFIG_SH_DSP) := \ 70da2f5f7bSPaul Mundt $(call as-option,-Wa$(comma)-isa=$(isa-y),-Wa$(comma)-dsp) 715dd61476SPaul Mundtendif 72da2f5f7bSPaul Mundt 735dd61476SPaul Mundtcflags-$(CONFIG_CPU_BIG_ENDIAN) += -mb 745dd61476SPaul Mundtcflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -ml 755dd61476SPaul Mundt 765dd61476SPaul Mundtcflags-y += $(call cc-option,-mno-fdpic) 77da2f5f7bSPaul Mundtcflags-y += $(isaflags-y) -ffreestanding 781da177e4SLinus Torvalds 79c2f1755bSPaul MundtOBJCOPYFLAGS := -O binary -R .note -R .note.gnu.build-id -R .comment \ 80c2f1755bSPaul Mundt -R .stab -R .stabstr -S 811da177e4SLinus Torvalds 82c2f1755bSPaul Mundt# Give the various platforms the opportunity to set default image types 8337744feeSArnd Bergmanndefaultimage-y := zImage 841a306032SPaul Mundtdefaultimage-$(CONFIG_SH_SH7785LCR) := uImage 856f5cd2bdSPaul Mundtdefaultimage-$(CONFIG_SH_RSK) := uImage 86ae68df56SPaul Mundtdefaultimage-$(CONFIG_SH_URQUELL) := uImage 878144a7ddSPaul Mundtdefaultimage-$(CONFIG_SH_MIGOR) := uImage 888144a7ddSPaul Mundtdefaultimage-$(CONFIG_SH_AP325RXA) := uImage 89e857bfd4SNobuhiro Iwamatsudefaultimage-$(CONFIG_SH_SH7757LCR) := uImage 908144a7ddSPaul Mundtdefaultimage-$(CONFIG_SH_7724_SOLUTION_ENGINE) := uImage 91709420ddSPaul Mundtdefaultimage-$(CONFIG_SH_7206_SOLUTION_ENGINE) := vmlinux 92709420ddSPaul Mundtdefaultimage-$(CONFIG_SH_7619_SOLUTION_ENGINE) := vmlinux 93c2f1755bSPaul Mundt 94c2f1755bSPaul Mundt# Set some sensible Kbuild defaults 95e62c527eSMichal Marekboot := arch/sh/boot 96e62c527eSMichal MarekKBUILD_IMAGE := $(boot)/$(defaultimage-y) 971da177e4SLinus Torvalds 981da177e4SLinus Torvalds# 991da177e4SLinus Torvalds# Choosing incompatible machines durings configuration will result in 1001da177e4SLinus Torvalds# error messages during linking. 1011da177e4SLinus Torvalds# 10209558748SPaul MundtUTS_MACHINE := sh 1031da177e4SLinus TorvaldsLDFLAGS_vmlinux += -e _stext 1041da177e4SLinus Torvalds 1051da177e4SLinus Torvaldsifdef CONFIG_CPU_LITTLE_ENDIAN 10637744feeSArnd Bergmannld-bfd := elf32-sh-linux 1078e780be9SPaul MundtLDFLAGS_vmlinux += --defsym jiffies=jiffies_64 --oformat $(ld-bfd) 108d503ac53SMasahiro YamadaKBUILD_LDFLAGS += -EL 1091da177e4SLinus Torvaldselse 11037744feeSArnd Bergmannld-bfd := elf32-shbig-linux 1118e780be9SPaul MundtLDFLAGS_vmlinux += --defsym jiffies=jiffies_64+4 --oformat $(ld-bfd) 112d503ac53SMasahiro YamadaKBUILD_LDFLAGS += -EB 1131da177e4SLinus Torvaldsendif 1141da177e4SLinus Torvalds 11537744feeSArnd Bergmannexport ld-bfd 1167b022d07SPaul Mundt 117c8b5d9dcSPaul Mundt# Mach groups 118939a24a6SPaul Mundtmachdir-$(CONFIG_SOLUTION_ENGINE) += mach-se 119da2014a2SPaul Mundtmachdir-$(CONFIG_SH_DREAMCAST) += mach-dreamcast 120da2014a2SPaul Mundtmachdir-$(CONFIG_SH_SH03) += mach-sh03 121da2014a2SPaul Mundtmachdir-$(CONFIG_SH_MIGOR) += mach-migor 122e7d16514SMagnus Dammmachdir-$(CONFIG_SH_KFR2R09) += mach-kfr2r09 1234138b740SKuninori Morimotomachdir-$(CONFIG_SH_ECOVEC) += mach-ecovec24 12402bf6cc7SPaul Mundtmachdir-$(CONFIG_SH_SDK7786) += mach-sdk7786 125da2014a2SPaul Mundtmachdir-$(CONFIG_SH_X3PROTO) += mach-x3proto 126da2014a2SPaul Mundtmachdir-$(CONFIG_SH_LANDISK) += mach-landisk 1277639a454SPaul Mundtmachdir-y += mach-common 1287639a454SPaul Mundt 12993dc544cSPaul Mundt# 13093dc544cSPaul Mundt# CPU header paths 13193dc544cSPaul Mundt# 13293dc544cSPaul Mundt# These are ordered by optimization level. A CPU family that is a subset 13393dc544cSPaul Mundt# of another (ie, SH-2A / SH-2), is picked up first, with increasing 13493dc544cSPaul Mundt# levels of genericness if nothing more suitable is situated in the 13593dc544cSPaul Mundt# hierarchy. 13693dc544cSPaul Mundt# 13793dc544cSPaul Mundt# As an example, in order of preference, SH-2A > SH-2 > common definitions. 13893dc544cSPaul Mundt# 13993dc544cSPaul Mundtcpuincdir-$(CONFIG_CPU_SH2A) += cpu-sh2a 14093dc544cSPaul Mundtcpuincdir-$(CONFIG_CPU_SH2) += cpu-sh2 14193dc544cSPaul Mundtcpuincdir-$(CONFIG_CPU_SH3) += cpu-sh3 14261a6976bSPaul Mundtcpuincdir-$(CONFIG_CPU_SH4A) += cpu-sh4a 14393dc544cSPaul Mundtcpuincdir-$(CONFIG_CPU_SH4) += cpu-sh4 14493dc544cSPaul Mundtcpuincdir-y += cpu-common # Must be last 1451da177e4SLinus Torvalds 1461da177e4SLinus Torvaldsdrivers-y += arch/sh/drivers/ 1471da177e4SLinus Torvalds 148*4bd04b20SMasahiro YamadaKBUILD_CPPFLAGS += $(addprefix -I $(srctree)/arch/sh/include/, $(cpuincdir-y) $(machdir-y)) 149f15cbe6fSPaul MundtKBUILD_CFLAGS += -pipe $(cflags-y) 150f15cbe6fSPaul MundtKBUILD_AFLAGS += $(cflags-y) 1511da177e4SLinus Torvalds 152473d1cf4SPaul Mundtifeq ($(CONFIG_MCOUNT),y) 153473d1cf4SPaul Mundt KBUILD_CFLAGS += -pg 154473d1cf4SPaul Mundtendif 155473d1cf4SPaul Mundt 156bd353861SMatt Flemingifeq ($(CONFIG_DWARF_UNWINDER),y) 157bd353861SMatt Fleming KBUILD_CFLAGS += -fasynchronous-unwind-tables 158bd353861SMatt Flemingendif 159bd353861SMatt Fleming 16037744feeSArnd Bergmannlibs-y := arch/sh/lib/ $(libs-y) 16149de935cSAdrian Bunk 16250cfa79dSPaul MundtBOOT_TARGETS = uImage uImage.bz2 uImage.gz uImage.lzma uImage.xz uImage.lzo \ 163eca50f14SPaul Mundt uImage.srec uImage.bin zImage vmlinux.bin vmlinux.srec \ 164eca50f14SPaul Mundt romImage 1653252b11fSSam RavnborgPHONY += $(BOOT_TARGETS) 1661da177e4SLinus Torvalds 167e62c527eSMichal Marekall: $(notdir $(KBUILD_IMAGE)) 1681da177e4SLinus Torvalds 169ef9b542fSPaul Mundt$(BOOT_TARGETS): vmlinux 1701da177e4SLinus Torvalds $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@ 1711da177e4SLinus Torvalds 1721da177e4SLinus Torvaldscompressed: zImage 1731da177e4SLinus Torvalds 1743252b11fSSam Ravnborgarchprepare: 1753252b11fSSam Ravnborg $(Q)$(MAKE) $(build)=arch/sh/tools include/generated/machtypes.h 176d088f323SPaul Mundt 1772b3c5a99SFiroz Khanarchheaders: 1782b3c5a99SFiroz Khan $(Q)$(MAKE) $(build)=arch/sh/kernel/syscalls all 1792b3c5a99SFiroz Khan 1801da177e4SLinus Torvaldsdefine archhelp 181ef9b542fSPaul Mundt @echo ' zImage - Compressed kernel image' 182fdeb076fSPaul Mundt @echo ' romImage - Compressed ROM image, if supported' 183cf00e204SPaul Mundt @echo ' vmlinux.srec - Create an ELF S-record' 184eca50f14SPaul Mundt @echo ' vmlinux.bin - Create an uncompressed binary image' 185ef9b542fSPaul Mundt @echo '* uImage - Alias to bootable U-Boot image' 186cf00e204SPaul Mundt @echo ' uImage.srec - Create an S-record for U-Boot' 187a5c461bbSPaul Mundt @echo ' uImage.bin - Kernel-only image for U-Boot (bin)' 188ef9b542fSPaul Mundt @echo '* uImage.gz - Kernel-only image for U-Boot (gzip)' 189ef9b542fSPaul Mundt @echo ' uImage.bz2 - Kernel-only image for U-Boot (bzip2)' 190ef9b542fSPaul Mundt @echo ' uImage.lzma - Kernel-only image for U-Boot (lzma)' 19150cfa79dSPaul Mundt @echo ' uImage.xz - Kernel-only image for U-Boot (xz)' 192c7b16efbSPaul Mundt @echo ' uImage.lzo - Kernel-only image for U-Boot (lzo)' 1931da177e4SLinus Torvaldsendef 194