Back to home page

LXR

 
 

    


0001 #
0002 # arch/sh/Makefile
0003 #
0004 # Copyright (C) 1999  Kaz Kojima
0005 # Copyright (C) 2002 - 2008  Paul Mundt
0006 # Copyright (C) 2002  M. R. Brown
0007 #
0008 # This file is subject to the terms and conditions of the GNU General Public
0009 # License.  See the file "COPYING" in the main directory of this archive
0010 # for more details.
0011 #
0012 ifneq ($(SUBARCH),$(ARCH))
0013   ifeq ($(CROSS_COMPILE),)
0014     CROSS_COMPILE := $(call cc-cross-prefix, $(UTS_MACHINE)-linux-  $(UTS_MACHINE)-linux-gnu-  $(UTS_MACHINE)-unknown-linux-gnu-)
0015   endif
0016 endif
0017 
0018 isa-y                                   := any
0019 isa-$(CONFIG_SH_DSP)                    := sh
0020 isa-$(CONFIG_CPU_SH2)                   := sh2
0021 isa-$(CONFIG_CPU_SH2A)                  := sh2a
0022 isa-$(CONFIG_CPU_SH3)                   := sh3
0023 isa-$(CONFIG_CPU_SH4)                   := sh4
0024 isa-$(CONFIG_CPU_SH4A)                  := sh4a
0025 isa-$(CONFIG_CPU_SH4AL_DSP)             := sh4al
0026 isa-$(CONFIG_CPU_SH5)                   := shmedia
0027 
0028 ifeq ($(CONFIG_SUPERH32),y)
0029 isa-$(CONFIG_SH_DSP)                    := $(isa-y)-dsp
0030 isa-y                                   := $(isa-y)-up
0031 endif
0032 
0033 cflags-$(CONFIG_CPU_SH2)                := $(call cc-option,-m2,)
0034 cflags-$(CONFIG_CPU_J2)                 += $(call cc-option,-mj2,)
0035 cflags-$(CONFIG_CPU_SH2A)               += $(call cc-option,-m2a,) \
0036                                            $(call cc-option,-m2a-nofpu,) \
0037                                            $(call cc-option,-m4-nofpu,)
0038 cflags-$(CONFIG_CPU_SH3)                := $(call cc-option,-m3,)
0039 cflags-$(CONFIG_CPU_SH4)                := $(call cc-option,-m4,) \
0040         $(call cc-option,-mno-implicit-fp,-m4-nofpu)
0041 cflags-$(CONFIG_CPU_SH4A)               += $(call cc-option,-m4a,) \
0042                                            $(call cc-option,-m4a-nofpu,)
0043 cflags-$(CONFIG_CPU_SH4AL_DSP)          += $(call cc-option,-m4al,)
0044 cflags-$(CONFIG_CPU_SH5)                := $(call cc-option,-m5-32media-nofpu,)
0045 
0046 ifeq ($(cflags-y),)
0047 #
0048 # In the case where we are stuck with a compiler that has been uselessly
0049 # restricted to a particular ISA, a favourite default of newer GCCs when
0050 # extensive multilib targets are not provided, ensure we get the best fit
0051 # regarding FP generation. This is intentionally stupid (albeit many
0052 # orders of magnitude less than GCC's default behaviour), as anything
0053 # with a large number of multilib targets better have been built
0054 # correctly for the target in mind.
0055 #
0056 cflags-y        += $(shell $(CC) $(KBUILD_CFLAGS) -print-multi-lib | \
0057                      grep nofpu | sed q | sed -e 's/^/-/;s/;.*$$//')
0058 # At this point, anything goes.
0059 isaflags-y      := $(call as-option,-Wa$(comma)-isa=any,)
0060 else
0061 #
0062 # -Wa,-isa= tuning implies -Wa,-dsp for the versions of binutils that
0063 # support it, while -Wa,-dsp by itself limits the range of usable opcodes
0064 # on certain CPU subtypes. Try the ISA variant first, and if that fails,
0065 # fall back on -Wa,-dsp for the old binutils versions. Even without DSP
0066 # opcodes, we always want the best ISA tuning the version of binutils
0067 # will provide.
0068 #
0069 isaflags-y      := $(call as-option,-Wa$(comma)-isa=$(isa-y),)
0070 
0071 isaflags-$(CONFIG_SH_DSP)               := \
0072         $(call as-option,-Wa$(comma)-isa=$(isa-y),-Wa$(comma)-dsp)
0073 endif
0074 
0075 cflags-$(CONFIG_CPU_BIG_ENDIAN)         += -mb
0076 cflags-$(CONFIG_CPU_LITTLE_ENDIAN)      += -ml
0077 
0078 cflags-y        += $(call cc-option,-mno-fdpic)
0079 cflags-y        += $(isaflags-y) -ffreestanding
0080 
0081 OBJCOPYFLAGS    := -O binary -R .note -R .note.gnu.build-id -R .comment \
0082                    -R .stab -R .stabstr -S
0083 
0084 # Give the various platforms the opportunity to set default image types
0085 defaultimage-$(CONFIG_SUPERH32)                 := zImage
0086 defaultimage-$(CONFIG_SH_SH7785LCR)             := uImage
0087 defaultimage-$(CONFIG_SH_RSK)                   := uImage
0088 defaultimage-$(CONFIG_SH_URQUELL)               := uImage
0089 defaultimage-$(CONFIG_SH_MIGOR)                 := uImage
0090 defaultimage-$(CONFIG_SH_AP325RXA)              := uImage
0091 defaultimage-$(CONFIG_SH_SH7757LCR)             := uImage
0092 defaultimage-$(CONFIG_SH_7724_SOLUTION_ENGINE)  := uImage
0093 defaultimage-$(CONFIG_SH_7206_SOLUTION_ENGINE)  := vmlinux
0094 defaultimage-$(CONFIG_SH_7619_SOLUTION_ENGINE)  := vmlinux
0095 
0096 # Set some sensible Kbuild defaults
0097 KBUILD_IMAGE            := $(defaultimage-y)
0098 
0099 #
0100 # Choosing incompatible machines durings configuration will result in
0101 # error messages during linking.
0102 #
0103 ifdef CONFIG_SUPERH32
0104 UTS_MACHINE             := sh
0105 BITS                    := 32
0106 LDFLAGS_vmlinux         += -e _stext
0107 KBUILD_DEFCONFIG        := shx3_defconfig
0108 else
0109 UTS_MACHINE             := sh64
0110 BITS                    := 64
0111 LDFLAGS_vmlinux         += --defsym phys_stext=_stext-$(CONFIG_PAGE_OFFSET) \
0112                            --defsym phys_stext_shmedia=phys_stext+1 \
0113                            -e phys_stext_shmedia
0114 KBUILD_DEFCONFIG        := cayman_defconfig
0115 endif
0116 
0117 ifdef CONFIG_CPU_LITTLE_ENDIAN
0118 ld-bfd                  := elf32-$(UTS_MACHINE)-linux
0119 LDFLAGS_vmlinux         += --defsym jiffies=jiffies_64 --oformat $(ld-bfd)
0120 LDFLAGS                 += -EL
0121 else
0122 ld-bfd                  := elf32-$(UTS_MACHINE)big-linux
0123 LDFLAGS_vmlinux         += --defsym jiffies=jiffies_64+4 --oformat $(ld-bfd)
0124 LDFLAGS                 += -EB
0125 endif
0126 
0127 export ld-bfd BITS
0128 
0129 head-y  := arch/sh/kernel/head_$(BITS).o
0130 
0131 core-y                          += arch/sh/kernel/ arch/sh/mm/ arch/sh/boards/
0132 core-$(CONFIG_SH_FPU_EMU)       += arch/sh/math-emu/
0133 
0134 core-$(CONFIG_USE_BUILTIN_DTB)  += arch/sh/boot/dts/
0135 
0136 # Mach groups
0137 machdir-$(CONFIG_SOLUTION_ENGINE)               += mach-se
0138 machdir-$(CONFIG_SH_HP6XX)                      += mach-hp6xx
0139 machdir-$(CONFIG_SH_DREAMCAST)                  += mach-dreamcast
0140 machdir-$(CONFIG_SH_SH03)                       += mach-sh03
0141 machdir-$(CONFIG_SH_RTS7751R2D)                 += mach-r2d
0142 machdir-$(CONFIG_SH_HIGHLANDER)                 += mach-highlander
0143 machdir-$(CONFIG_SH_MIGOR)                      += mach-migor
0144 machdir-$(CONFIG_SH_AP325RXA)                   += mach-ap325rxa
0145 machdir-$(CONFIG_SH_KFR2R09)                    += mach-kfr2r09
0146 machdir-$(CONFIG_SH_ECOVEC)                     += mach-ecovec24
0147 machdir-$(CONFIG_SH_SDK7780)                    += mach-sdk7780
0148 machdir-$(CONFIG_SH_SDK7786)                    += mach-sdk7786
0149 machdir-$(CONFIG_SH_X3PROTO)                    += mach-x3proto
0150 machdir-$(CONFIG_SH_SH7763RDP)                  += mach-sh7763rdp
0151 machdir-$(CONFIG_SH_SH4202_MICRODEV)            += mach-microdev
0152 machdir-$(CONFIG_SH_LANDISK)                    += mach-landisk
0153 machdir-$(CONFIG_SH_LBOX_RE2)                   += mach-lboxre2
0154 machdir-$(CONFIG_SH_CAYMAN)                     += mach-cayman
0155 machdir-$(CONFIG_SH_RSK)                        += mach-rsk
0156 
0157 ifneq ($(machdir-y),)
0158 core-y  += $(addprefix arch/sh/boards/, \
0159              $(filter-out ., $(patsubst %,%/,$(machdir-y))))
0160 endif
0161 
0162 # Common machine type headers. Not part of the arch/sh/boards/ hierarchy.
0163 machdir-y       += mach-common
0164 
0165 # Companion chips
0166 core-$(CONFIG_HD6446X_SERIES)   += arch/sh/cchips/hd6446x/
0167 
0168 #
0169 # CPU header paths
0170 #
0171 # These are ordered by optimization level. A CPU family that is a subset
0172 # of another (ie, SH-2A / SH-2), is picked up first, with increasing
0173 # levels of genericness if nothing more suitable is situated in the
0174 # hierarchy.
0175 #
0176 # As an example, in order of preference, SH-2A > SH-2 > common definitions.
0177 #
0178 cpuincdir-$(CONFIG_CPU_SH2A)    += cpu-sh2a
0179 cpuincdir-$(CONFIG_CPU_SH2)     += cpu-sh2
0180 cpuincdir-$(CONFIG_CPU_SH3)     += cpu-sh3
0181 cpuincdir-$(CONFIG_CPU_SH4A)    += cpu-sh4a
0182 cpuincdir-$(CONFIG_CPU_SH4)     += cpu-sh4
0183 cpuincdir-$(CONFIG_CPU_SH5)     += cpu-sh5
0184 cpuincdir-y                     += cpu-common   # Must be last
0185 
0186 drivers-y                       += arch/sh/drivers/
0187 drivers-$(CONFIG_OPROFILE)      += arch/sh/oprofile/
0188 
0189 boot := arch/sh/boot
0190 
0191 cflags-y        += $(foreach d, $(cpuincdir-y), -Iarch/sh/include/$(d)) \
0192                    $(foreach d, $(machdir-y), -Iarch/sh/include/$(d))
0193 
0194 KBUILD_CFLAGS           += -pipe $(cflags-y)
0195 KBUILD_CPPFLAGS         += $(cflags-y)
0196 KBUILD_AFLAGS           += $(cflags-y)
0197 
0198 ifeq ($(CONFIG_MCOUNT),y)
0199   KBUILD_CFLAGS += -pg
0200 endif
0201 
0202 ifeq ($(CONFIG_DWARF_UNWINDER),y)
0203   KBUILD_CFLAGS += -fasynchronous-unwind-tables
0204 endif
0205 
0206 libs-$(CONFIG_SUPERH32)         := arch/sh/lib/ $(libs-y)
0207 libs-$(CONFIG_SUPERH64)         := arch/sh/lib64/ $(libs-y)
0208 
0209 BOOT_TARGETS = uImage uImage.bz2 uImage.gz uImage.lzma uImage.xz uImage.lzo \
0210                uImage.srec uImage.bin zImage vmlinux.bin vmlinux.srec \
0211                romImage
0212 PHONY += $(BOOT_TARGETS)
0213 
0214 all: $(KBUILD_IMAGE)
0215 
0216 $(BOOT_TARGETS): vmlinux
0217         $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
0218 
0219 compressed: zImage
0220 
0221 archprepare:
0222         $(Q)$(MAKE) $(build)=arch/sh/tools include/generated/machtypes.h
0223 
0224 archclean:
0225         $(Q)$(MAKE) $(clean)=$(boot)
0226         $(Q)$(MAKE) $(clean)=arch/sh/kernel/vsyscall
0227 
0228 define archhelp
0229         @echo '  zImage                    - Compressed kernel image'
0230         @echo '  romImage                  - Compressed ROM image, if supported'
0231         @echo '  vmlinux.srec              - Create an ELF S-record'
0232         @echo '  vmlinux.bin               - Create an uncompressed binary image'
0233         @echo '* uImage                    - Alias to bootable U-Boot image'
0234         @echo '  uImage.srec               - Create an S-record for U-Boot'
0235         @echo '  uImage.bin                - Kernel-only image for U-Boot (bin)'
0236         @echo '* uImage.gz                 - Kernel-only image for U-Boot (gzip)'
0237         @echo '  uImage.bz2                - Kernel-only image for U-Boot (bzip2)'
0238         @echo '  uImage.lzma               - Kernel-only image for U-Boot (lzma)'
0239         @echo '  uImage.xz                 - Kernel-only image for U-Boot (xz)'
0240         @echo '  uImage.lzo                - Kernel-only image for U-Boot (lzo)'
0241 endef