1*4882a593Smuzhiyun# 2*4882a593Smuzhiyun# arch/sh/Makefile 3*4882a593Smuzhiyun# 4*4882a593Smuzhiyun# Copyright (C) 1999 Kaz Kojima 5*4882a593Smuzhiyun# Copyright (C) 2002 - 2008 Paul Mundt 6*4882a593Smuzhiyun# Copyright (C) 2002 M. R. Brown 7*4882a593Smuzhiyun# 8*4882a593Smuzhiyun# This file is subject to the terms and conditions of the GNU General Public 9*4882a593Smuzhiyun# License. See the file "COPYING" in the main directory of this archive 10*4882a593Smuzhiyun# for more details. 11*4882a593Smuzhiyun# 12*4882a593Smuzhiyunifneq ($(SUBARCH),$(ARCH)) 13*4882a593Smuzhiyun ifeq ($(CROSS_COMPILE),) 14*4882a593Smuzhiyun CROSS_COMPILE := $(call cc-cross-prefix, sh-linux- sh-linux-gnu- sh-unknown-linux-gnu-) 15*4882a593Smuzhiyun endif 16*4882a593Smuzhiyunendif 17*4882a593Smuzhiyun 18*4882a593SmuzhiyunKBUILD_DEFCONFIG := shx3_defconfig 19*4882a593Smuzhiyun 20*4882a593Smuzhiyunisa-y := any 21*4882a593Smuzhiyunisa-$(CONFIG_SH_DSP) := sh 22*4882a593Smuzhiyunisa-$(CONFIG_CPU_SH2) := sh2 23*4882a593Smuzhiyunisa-$(CONFIG_CPU_SH2A) := sh2a 24*4882a593Smuzhiyunisa-$(CONFIG_CPU_SH3) := sh3 25*4882a593Smuzhiyunisa-$(CONFIG_CPU_SH4) := sh4 26*4882a593Smuzhiyunisa-$(CONFIG_CPU_SH4A) := sh4a 27*4882a593Smuzhiyunisa-$(CONFIG_CPU_SH4AL_DSP) := sh4al 28*4882a593Smuzhiyun 29*4882a593Smuzhiyunisa-$(CONFIG_SH_DSP) := $(isa-y)-dsp 30*4882a593Smuzhiyunisa-y := $(isa-y)-up 31*4882a593Smuzhiyun 32*4882a593Smuzhiyuncflags-$(CONFIG_CPU_SH2) := $(call cc-option,-m2,) 33*4882a593Smuzhiyuncflags-$(CONFIG_CPU_J2) += $(call cc-option,-mj2,) 34*4882a593Smuzhiyuncflags-$(CONFIG_CPU_SH2A) += $(call cc-option,-m2a,) \ 35*4882a593Smuzhiyun $(call cc-option,-m2a-nofpu,) \ 36*4882a593Smuzhiyun $(call cc-option,-m4-nofpu,) 37*4882a593Smuzhiyuncflags-$(CONFIG_CPU_SH3) := $(call cc-option,-m3,) 38*4882a593Smuzhiyuncflags-$(CONFIG_CPU_SH4) := $(call cc-option,-m4,) \ 39*4882a593Smuzhiyun $(call cc-option,-mno-implicit-fp,-m4-nofpu) 40*4882a593Smuzhiyuncflags-$(CONFIG_CPU_SH4A) += $(call cc-option,-m4a,) \ 41*4882a593Smuzhiyun $(call cc-option,-m4a-nofpu,) 42*4882a593Smuzhiyuncflags-$(CONFIG_CPU_SH4AL_DSP) += $(call cc-option,-m4al,) 43*4882a593Smuzhiyun 44*4882a593Smuzhiyunifeq ($(cflags-y),) 45*4882a593Smuzhiyun# 46*4882a593Smuzhiyun# In the case where we are stuck with a compiler that has been uselessly 47*4882a593Smuzhiyun# restricted to a particular ISA, a favourite default of newer GCCs when 48*4882a593Smuzhiyun# extensive multilib targets are not provided, ensure we get the best fit 49*4882a593Smuzhiyun# regarding FP generation. This is intentionally stupid (albeit many 50*4882a593Smuzhiyun# orders of magnitude less than GCC's default behaviour), as anything 51*4882a593Smuzhiyun# with a large number of multilib targets better have been built 52*4882a593Smuzhiyun# correctly for the target in mind. 53*4882a593Smuzhiyun# 54*4882a593Smuzhiyuncflags-y += $(shell $(CC) $(KBUILD_CFLAGS) -print-multi-lib | \ 55*4882a593Smuzhiyun grep nofpu | sed q | sed -e 's/^/-/;s/;.*$$//') 56*4882a593Smuzhiyun# At this point, anything goes. 57*4882a593Smuzhiyunisaflags-y := $(call as-option,-Wa$(comma)-isa=any,) 58*4882a593Smuzhiyunelse 59*4882a593Smuzhiyun# 60*4882a593Smuzhiyun# -Wa,-isa= tuning implies -Wa,-dsp for the versions of binutils that 61*4882a593Smuzhiyun# support it, while -Wa,-dsp by itself limits the range of usable opcodes 62*4882a593Smuzhiyun# on certain CPU subtypes. Try the ISA variant first, and if that fails, 63*4882a593Smuzhiyun# fall back on -Wa,-dsp for the old binutils versions. Even without DSP 64*4882a593Smuzhiyun# opcodes, we always want the best ISA tuning the version of binutils 65*4882a593Smuzhiyun# will provide. 66*4882a593Smuzhiyun# 67*4882a593Smuzhiyunisaflags-y := $(call as-option,-Wa$(comma)-isa=$(isa-y),) 68*4882a593Smuzhiyun 69*4882a593Smuzhiyunisaflags-$(CONFIG_SH_DSP) := \ 70*4882a593Smuzhiyun $(call as-option,-Wa$(comma)-isa=$(isa-y),-Wa$(comma)-dsp) 71*4882a593Smuzhiyunendif 72*4882a593Smuzhiyun 73*4882a593Smuzhiyuncflags-$(CONFIG_CPU_BIG_ENDIAN) += -mb 74*4882a593Smuzhiyuncflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -ml 75*4882a593Smuzhiyun 76*4882a593Smuzhiyuncflags-y += $(call cc-option,-mno-fdpic) 77*4882a593Smuzhiyuncflags-y += $(isaflags-y) -ffreestanding 78*4882a593Smuzhiyun 79*4882a593SmuzhiyunOBJCOPYFLAGS := -O binary -R .note -R .note.gnu.build-id -R .comment \ 80*4882a593Smuzhiyun -R .stab -R .stabstr -S 81*4882a593Smuzhiyun 82*4882a593Smuzhiyun# Give the various platforms the opportunity to set default image types 83*4882a593Smuzhiyundefaultimage-y := zImage 84*4882a593Smuzhiyundefaultimage-$(CONFIG_SH_SH7785LCR) := uImage 85*4882a593Smuzhiyundefaultimage-$(CONFIG_SH_RSK) := uImage 86*4882a593Smuzhiyundefaultimage-$(CONFIG_SH_URQUELL) := uImage 87*4882a593Smuzhiyundefaultimage-$(CONFIG_SH_MIGOR) := uImage 88*4882a593Smuzhiyundefaultimage-$(CONFIG_SH_AP325RXA) := uImage 89*4882a593Smuzhiyundefaultimage-$(CONFIG_SH_SH7757LCR) := uImage 90*4882a593Smuzhiyundefaultimage-$(CONFIG_SH_7724_SOLUTION_ENGINE) := uImage 91*4882a593Smuzhiyundefaultimage-$(CONFIG_SH_7206_SOLUTION_ENGINE) := vmlinux 92*4882a593Smuzhiyundefaultimage-$(CONFIG_SH_7619_SOLUTION_ENGINE) := vmlinux 93*4882a593Smuzhiyun 94*4882a593Smuzhiyun# Set some sensible Kbuild defaults 95*4882a593Smuzhiyunboot := arch/sh/boot 96*4882a593SmuzhiyunKBUILD_IMAGE := $(boot)/$(defaultimage-y) 97*4882a593Smuzhiyun 98*4882a593Smuzhiyun# 99*4882a593Smuzhiyun# Choosing incompatible machines durings configuration will result in 100*4882a593Smuzhiyun# error messages during linking. 101*4882a593Smuzhiyun# 102*4882a593SmuzhiyunUTS_MACHINE := sh 103*4882a593SmuzhiyunLDFLAGS_vmlinux += -e _stext 104*4882a593Smuzhiyun 105*4882a593Smuzhiyunifdef CONFIG_CPU_LITTLE_ENDIAN 106*4882a593Smuzhiyunld-bfd := elf32-sh-linux 107*4882a593SmuzhiyunLDFLAGS_vmlinux += --defsym jiffies=jiffies_64 --oformat $(ld-bfd) 108*4882a593SmuzhiyunKBUILD_LDFLAGS += -EL 109*4882a593Smuzhiyunelse 110*4882a593Smuzhiyunld-bfd := elf32-shbig-linux 111*4882a593SmuzhiyunLDFLAGS_vmlinux += --defsym jiffies=jiffies_64+4 --oformat $(ld-bfd) 112*4882a593SmuzhiyunKBUILD_LDFLAGS += -EB 113*4882a593Smuzhiyunendif 114*4882a593Smuzhiyun 115*4882a593Smuzhiyunexport ld-bfd 116*4882a593Smuzhiyun 117*4882a593Smuzhiyunhead-y := arch/sh/kernel/head_32.o 118*4882a593Smuzhiyun 119*4882a593Smuzhiyuncore-y += arch/sh/kernel/ arch/sh/mm/ arch/sh/boards/ 120*4882a593Smuzhiyuncore-$(CONFIG_SH_FPU_EMU) += arch/sh/math-emu/ 121*4882a593Smuzhiyun 122*4882a593Smuzhiyuncore-$(CONFIG_USE_BUILTIN_DTB) += arch/sh/boot/dts/ 123*4882a593Smuzhiyun 124*4882a593Smuzhiyun# Mach groups 125*4882a593Smuzhiyunmachdir-$(CONFIG_SOLUTION_ENGINE) += mach-se 126*4882a593Smuzhiyunmachdir-$(CONFIG_SH_HP6XX) += mach-hp6xx 127*4882a593Smuzhiyunmachdir-$(CONFIG_SH_DREAMCAST) += mach-dreamcast 128*4882a593Smuzhiyunmachdir-$(CONFIG_SH_SH03) += mach-sh03 129*4882a593Smuzhiyunmachdir-$(CONFIG_SH_RTS7751R2D) += mach-r2d 130*4882a593Smuzhiyunmachdir-$(CONFIG_SH_HIGHLANDER) += mach-highlander 131*4882a593Smuzhiyunmachdir-$(CONFIG_SH_MIGOR) += mach-migor 132*4882a593Smuzhiyunmachdir-$(CONFIG_SH_AP325RXA) += mach-ap325rxa 133*4882a593Smuzhiyunmachdir-$(CONFIG_SH_KFR2R09) += mach-kfr2r09 134*4882a593Smuzhiyunmachdir-$(CONFIG_SH_ECOVEC) += mach-ecovec24 135*4882a593Smuzhiyunmachdir-$(CONFIG_SH_SDK7780) += mach-sdk7780 136*4882a593Smuzhiyunmachdir-$(CONFIG_SH_SDK7786) += mach-sdk7786 137*4882a593Smuzhiyunmachdir-$(CONFIG_SH_X3PROTO) += mach-x3proto 138*4882a593Smuzhiyunmachdir-$(CONFIG_SH_SH7763RDP) += mach-sh7763rdp 139*4882a593Smuzhiyunmachdir-$(CONFIG_SH_SH4202_MICRODEV) += mach-microdev 140*4882a593Smuzhiyunmachdir-$(CONFIG_SH_LANDISK) += mach-landisk 141*4882a593Smuzhiyunmachdir-$(CONFIG_SH_LBOX_RE2) += mach-lboxre2 142*4882a593Smuzhiyunmachdir-$(CONFIG_SH_RSK) += mach-rsk 143*4882a593Smuzhiyun 144*4882a593Smuzhiyunifneq ($(machdir-y),) 145*4882a593Smuzhiyuncore-y += $(addprefix arch/sh/boards/, \ 146*4882a593Smuzhiyun $(filter-out ., $(patsubst %,%/,$(machdir-y)))) 147*4882a593Smuzhiyunendif 148*4882a593Smuzhiyun 149*4882a593Smuzhiyun# Common machine type headers. Not part of the arch/sh/boards/ hierarchy. 150*4882a593Smuzhiyunmachdir-y += mach-common 151*4882a593Smuzhiyun 152*4882a593Smuzhiyun# Companion chips 153*4882a593Smuzhiyuncore-$(CONFIG_HD6446X_SERIES) += arch/sh/cchips/hd6446x/ 154*4882a593Smuzhiyun 155*4882a593Smuzhiyun# 156*4882a593Smuzhiyun# CPU header paths 157*4882a593Smuzhiyun# 158*4882a593Smuzhiyun# These are ordered by optimization level. A CPU family that is a subset 159*4882a593Smuzhiyun# of another (ie, SH-2A / SH-2), is picked up first, with increasing 160*4882a593Smuzhiyun# levels of genericness if nothing more suitable is situated in the 161*4882a593Smuzhiyun# hierarchy. 162*4882a593Smuzhiyun# 163*4882a593Smuzhiyun# As an example, in order of preference, SH-2A > SH-2 > common definitions. 164*4882a593Smuzhiyun# 165*4882a593Smuzhiyuncpuincdir-$(CONFIG_CPU_SH2A) += cpu-sh2a 166*4882a593Smuzhiyuncpuincdir-$(CONFIG_CPU_SH2) += cpu-sh2 167*4882a593Smuzhiyuncpuincdir-$(CONFIG_CPU_SH3) += cpu-sh3 168*4882a593Smuzhiyuncpuincdir-$(CONFIG_CPU_SH4A) += cpu-sh4a 169*4882a593Smuzhiyuncpuincdir-$(CONFIG_CPU_SH4) += cpu-sh4 170*4882a593Smuzhiyuncpuincdir-y += cpu-common # Must be last 171*4882a593Smuzhiyun 172*4882a593Smuzhiyundrivers-y += arch/sh/drivers/ 173*4882a593Smuzhiyundrivers-$(CONFIG_OPROFILE) += arch/sh/oprofile/ 174*4882a593Smuzhiyun 175*4882a593Smuzhiyuncflags-y += $(foreach d, $(cpuincdir-y), -I $(srctree)/arch/sh/include/$(d)) \ 176*4882a593Smuzhiyun $(foreach d, $(machdir-y), -I $(srctree)/arch/sh/include/$(d)) 177*4882a593Smuzhiyun 178*4882a593SmuzhiyunKBUILD_CFLAGS += -pipe $(cflags-y) 179*4882a593SmuzhiyunKBUILD_CPPFLAGS += $(cflags-y) 180*4882a593SmuzhiyunKBUILD_AFLAGS += $(cflags-y) 181*4882a593Smuzhiyun 182*4882a593Smuzhiyunifeq ($(CONFIG_MCOUNT),y) 183*4882a593Smuzhiyun KBUILD_CFLAGS += -pg 184*4882a593Smuzhiyunendif 185*4882a593Smuzhiyun 186*4882a593Smuzhiyunifeq ($(CONFIG_DWARF_UNWINDER),y) 187*4882a593Smuzhiyun KBUILD_CFLAGS += -fasynchronous-unwind-tables 188*4882a593Smuzhiyunendif 189*4882a593Smuzhiyun 190*4882a593Smuzhiyunlibs-y := arch/sh/lib/ $(libs-y) 191*4882a593Smuzhiyun 192*4882a593SmuzhiyunBOOT_TARGETS = uImage uImage.bz2 uImage.gz uImage.lzma uImage.xz uImage.lzo \ 193*4882a593Smuzhiyun uImage.srec uImage.bin zImage vmlinux.bin vmlinux.srec \ 194*4882a593Smuzhiyun romImage 195*4882a593SmuzhiyunPHONY += $(BOOT_TARGETS) 196*4882a593Smuzhiyun 197*4882a593Smuzhiyunall: $(notdir $(KBUILD_IMAGE)) 198*4882a593Smuzhiyun 199*4882a593Smuzhiyun$(BOOT_TARGETS): vmlinux 200*4882a593Smuzhiyun $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@ 201*4882a593Smuzhiyun 202*4882a593Smuzhiyuncompressed: zImage 203*4882a593Smuzhiyun 204*4882a593Smuzhiyunarchprepare: 205*4882a593Smuzhiyun $(Q)$(MAKE) $(build)=arch/sh/tools include/generated/machtypes.h 206*4882a593Smuzhiyun 207*4882a593Smuzhiyunarchclean: 208*4882a593Smuzhiyun $(Q)$(MAKE) $(clean)=$(boot) 209*4882a593Smuzhiyun $(Q)$(MAKE) $(clean)=arch/sh/kernel/vsyscall 210*4882a593Smuzhiyun 211*4882a593Smuzhiyunarchheaders: 212*4882a593Smuzhiyun $(Q)$(MAKE) $(build)=arch/sh/kernel/syscalls all 213*4882a593Smuzhiyun 214*4882a593Smuzhiyundefine archhelp 215*4882a593Smuzhiyun @echo ' zImage - Compressed kernel image' 216*4882a593Smuzhiyun @echo ' romImage - Compressed ROM image, if supported' 217*4882a593Smuzhiyun @echo ' vmlinux.srec - Create an ELF S-record' 218*4882a593Smuzhiyun @echo ' vmlinux.bin - Create an uncompressed binary image' 219*4882a593Smuzhiyun @echo '* uImage - Alias to bootable U-Boot image' 220*4882a593Smuzhiyun @echo ' uImage.srec - Create an S-record for U-Boot' 221*4882a593Smuzhiyun @echo ' uImage.bin - Kernel-only image for U-Boot (bin)' 222*4882a593Smuzhiyun @echo '* uImage.gz - Kernel-only image for U-Boot (gzip)' 223*4882a593Smuzhiyun @echo ' uImage.bz2 - Kernel-only image for U-Boot (bzip2)' 224*4882a593Smuzhiyun @echo ' uImage.lzma - Kernel-only image for U-Boot (lzma)' 225*4882a593Smuzhiyun @echo ' uImage.xz - Kernel-only image for U-Boot (xz)' 226*4882a593Smuzhiyun @echo ' uImage.lzo - Kernel-only image for U-Boot (lzo)' 227*4882a593Smuzhiyunendef 228