xref: /openbmc/linux/arch/mips/Makefile (revision 818f38c5)
11da177e4SLinus Torvalds#
21da177e4SLinus Torvalds# This file is subject to the terms and conditions of the GNU General Public
31da177e4SLinus Torvalds# License.  See the file "COPYING" in the main directory of this archive
41da177e4SLinus Torvalds# for more details.
51da177e4SLinus Torvalds#
61da177e4SLinus Torvalds# Copyright (C) 1994, 95, 96, 2003 by Ralf Baechle
71da177e4SLinus Torvalds# DECStation modifications by Paul M. Antoine, 1996
81da177e4SLinus Torvalds# Copyright (C) 2002, 2003, 2004  Maciej W. Rozycki
91da177e4SLinus Torvalds#
101da177e4SLinus Torvalds# This file is included by the global makefile so that you can add your own
111da177e4SLinus Torvalds# architecture-specific flags and dependencies. Remember to do have actions
121da177e4SLinus Torvalds# for "archclean" cleaning up for this architecture.
131da177e4SLinus Torvalds#
141da177e4SLinus Torvalds
15aadeec4dSMatt Redfearnarchscripts: scripts_basic
16aadeec4dSMatt Redfearn	$(Q)$(MAKE) $(build)=arch/mips/boot/tools relocs
17aadeec4dSMatt Redfearn
18de0c1698SAdrian BunkKBUILD_DEFCONFIG := ip22_defconfig
19de0c1698SAdrian Bunk
201da177e4SLinus Torvalds#
211da177e4SLinus Torvalds# Select the object file format to substitute into the linker script.
221da177e4SLinus Torvalds#
231da177e4SLinus Torvaldsifdef CONFIG_CPU_LITTLE_ENDIAN
2417f690beSRalf Baechle32bit-tool-archpref	= mipsel
2517f690beSRalf Baechle64bit-tool-archpref	= mips64el
261da177e4SLinus Torvalds32bit-bfd		= elf32-tradlittlemips
271da177e4SLinus Torvalds64bit-bfd		= elf64-tradlittlemips
281da177e4SLinus Torvalds32bit-emul		= elf32ltsmip
291da177e4SLinus Torvalds64bit-emul		= elf64ltsmip
301da177e4SLinus Torvaldselse
3117f690beSRalf Baechle32bit-tool-archpref	= mips
3217f690beSRalf Baechle64bit-tool-archpref	= mips64
331da177e4SLinus Torvalds32bit-bfd		= elf32-tradbigmips
341da177e4SLinus Torvalds64bit-bfd		= elf64-tradbigmips
351da177e4SLinus Torvalds32bit-emul		= elf32btsmip
361da177e4SLinus Torvalds64bit-emul		= elf64btsmip
371da177e4SLinus Torvaldsendif
381da177e4SLinus Torvalds
39875d43e7SRalf Baechleifdef CONFIG_32BIT
4017f690beSRalf Baechletool-archpref		= $(32bit-tool-archpref)
411da177e4SLinus TorvaldsUTS_MACHINE		:= mips
421da177e4SLinus Torvaldsendif
43875d43e7SRalf Baechleifdef CONFIG_64BIT
4417f690beSRalf Baechletool-archpref		= $(64bit-tool-archpref)
451da177e4SLinus TorvaldsUTS_MACHINE		:= mips64
461da177e4SLinus Torvaldsendif
471da177e4SLinus Torvalds
4817f690beSRalf Baechleifneq ($(SUBARCH),$(ARCH))
4917f690beSRalf Baechle  ifeq ($(CROSS_COMPILE),)
503247989eSMaciej W. Rozycki    CROSS_COMPILE := $(call cc-cross-prefix, $(tool-archpref)-linux-  $(tool-archpref)-linux-gnu-  $(tool-archpref)-unknown-linux-gnu-)
5117f690beSRalf Baechle  endif
521da177e4SLinus Torvaldsendif
531da177e4SLinus Torvalds
547326c4e5SWu Zhangjinifdef CONFIG_FUNCTION_GRAPH_TRACER
557326c4e5SWu Zhangjin  ifndef KBUILD_MCOUNT_RA_ADDRESS
567326c4e5SWu Zhangjin    ifeq ($(call cc-option-yn,-mmcount-ra-address), y)
577326c4e5SWu Zhangjin      cflags-y += -mmcount-ra-address -DKBUILD_MCOUNT_RA_ADDRESS
587326c4e5SWu Zhangjin    endif
597326c4e5SWu Zhangjin  endif
607326c4e5SWu Zhangjinendif
611a4ba061SRalf Baechlecflags-y += $(call cc-option, -mno-check-zero-division)
6205e41404SRalf Baechle
638145095cSRalf Baechleifdef CONFIG_32BIT
641da177e4SLinus Torvaldsld-emul			= $(32bit-emul)
651da177e4SLinus Torvaldsvmlinux-32		= vmlinux
661da177e4SLinus Torvaldsvmlinux-64		= vmlinux.64
6759b3e8e9SRalf Baechle
6859b3e8e9SRalf Baechlecflags-y		+= -mabi=32
698145095cSRalf Baechleendif
701da177e4SLinus Torvalds
718145095cSRalf Baechleifdef CONFIG_64BIT
728145095cSRalf Baechleld-emul			= $(64bit-emul)
738145095cSRalf Baechlevmlinux-32		= vmlinux.32
748145095cSRalf Baechlevmlinux-64		= vmlinux
758145095cSRalf Baechle
7659b3e8e9SRalf Baechlecflags-y		+= -mabi=64
7759b3e8e9SRalf Baechleendif
7859b3e8e9SRalf Baechle
798496b401SRalf Baechleall-$(CONFIG_BOOT_ELF32)	:= $(vmlinux-32)
808496b401SRalf Baechleall-$(CONFIG_BOOT_ELF64)	:= $(vmlinux-64)
811b93b3c3SWu Zhangjinall-$(CONFIG_SYS_SUPPORTS_ZBOOT)+= vmlinuz
821da177e4SLinus Torvalds
831da177e4SLinus Torvalds#
841da177e4SLinus Torvalds# GCC uses -G 0 -mabicalls -fpic as default.  We don't want PIC in the kernel
851da177e4SLinus Torvalds# code since it only slows down the whole thing.  At some point we might make
861da177e4SLinus Torvalds# use of global pointer optimizations but their use of $28 conflicts with
871da177e4SLinus Torvalds# the current pointer optimization.
881da177e4SLinus Torvalds#
891da177e4SLinus Torvalds# The DECStation requires an ECOFF kernel for remote booting, other MIPS
901da177e4SLinus Torvalds# machines may also.  Since BFD is incredibly buggy with respect to
911da177e4SLinus Torvalds# crossformat linking we rely on the elf2ecoff tool for format conversion.
921da177e4SLinus Torvalds#
931da177e4SLinus Torvaldscflags-y			+= -G 0 -mno-abicalls -fno-pic -pipe
946218cf44SRalf Baechlecflags-y			+= -msoft-float
959f83d839SThiemo SeuferLDFLAGS_vmlinux			+= -G 0 -static -n -nostdlib
966588169dSSam RavnborgKBUILD_AFLAGS_MODULE		+= -mlong-calls
976588169dSSam RavnborgKBUILD_CFLAGS_MODULE		+= -mlong-calls
981da177e4SLinus Torvalds
99e818fac5SMatt Redfearnifeq ($(CONFIG_RELOCATABLE),y)
100e818fac5SMatt RedfearnLDFLAGS_vmlinux			+= --emit-relocs
101e818fac5SMatt Redfearnendif
102e818fac5SMatt Redfearn
103842dfc11SManuel Lauss#
104842dfc11SManuel Lauss# pass -msoft-float to GAS if it supports it.  However on newer binutils
105842dfc11SManuel Lauss# (specifically newer than 2.24.51.20140728) we then also need to explicitly
106842dfc11SManuel Lauss# set ".set hardfloat" in all files which manipulate floating point registers.
107842dfc11SManuel Lauss#
108842dfc11SManuel Laussifneq ($(call as-option,-Wa$(comma)-msoft-float,),)
109842dfc11SManuel Lauss	cflags-y		+= -DGAS_HAS_SET_HARDFLOAT -Wa,-msoft-float
110842dfc11SManuel Laussendif
111842dfc11SManuel Lauss
11272fbfb26SRalf Baechlecflags-y += -ffreestanding
11372fbfb26SRalf Baechle
114f425a6dcSThiemo Seufer#
115f425a6dcSThiemo Seufer# We explicitly add the endianness specifier if needed, this allows
116f425a6dcSThiemo Seufer# to compile kernels with a toolchain for the other endianness. We
117f425a6dcSThiemo Seufer# carefully avoid to add it redundantly because gcc 3.3/3.4 complains
118f425a6dcSThiemo Seufer# when fed the toolchain default!
119f425a6dcSThiemo Seufer#
120f9405412SRalf Baechle# Certain gcc versions up to gcc 4.1.1 (probably 4.2-subversion as of
12159c51591SMichael Opdenacker# 2006-10-10 don't properly change the predefined symbols if -EB / -EL
122f9405412SRalf Baechle# are used, so we kludge that here.  A bug has been filed at
123f9405412SRalf Baechle# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29413.
124f9405412SRalf Baechle#
125f9405412SRalf Baechleundef-all += -UMIPSEB -U_MIPSEB -U__MIPSEB -U__MIPSEB__
126f9405412SRalf Baechleundef-all += -UMIPSEL -U_MIPSEL -U__MIPSEL -U__MIPSEL__
127f9405412SRalf Baechlepredef-be += -DMIPSEB -D_MIPSEB -D__MIPSEB -D__MIPSEB__
128f9405412SRalf Baechlepredef-le += -DMIPSEL -D_MIPSEL -D__MIPSEL -D__MIPSEL__
129f9405412SRalf Baechlecflags-$(CONFIG_CPU_BIG_ENDIAN)		+= $(shell $(CC) -dumpmachine |grep -q 'mips.*el-.*' && echo -EB $(undef-all) $(predef-be))
130f9405412SRalf Baechlecflags-$(CONFIG_CPU_LITTLE_ENDIAN)	+= $(shell $(CC) -dumpmachine |grep -q 'mips.*el-.*' || echo -EL $(undef-all) $(predef-le))
131f425a6dcSThiemo Seufer
1329007c9a2SRalf Baechlecflags-$(CONFIG_SB1XXX_CORELIS)	+= $(call cc-option,-mno-sched-prolog) \
1339007c9a2SRalf Baechle				   -fno-omit-frame-pointer
1341da177e4SLinus Torvalds#
1351da177e4SLinus Torvalds# CPU-dependent compiler/assembler options for optimization.
1361da177e4SLinus Torvalds#
13759b3e8e9SRalf Baechlecflags-$(CONFIG_CPU_R3000)	+= -march=r3000
13859b3e8e9SRalf Baechlecflags-$(CONFIG_CPU_TX39XX)	+= -march=r3900
13959b3e8e9SRalf Baechlecflags-$(CONFIG_CPU_R6000)	+= -march=r6000 -Wa,--trap
14059b3e8e9SRalf Baechlecflags-$(CONFIG_CPU_R4300)	+= -march=r4300 -Wa,--trap
14159b3e8e9SRalf Baechlecflags-$(CONFIG_CPU_VR41XX)	+= -march=r4100 -Wa,--trap
14259b3e8e9SRalf Baechlecflags-$(CONFIG_CPU_R4X00)	+= -march=r4600 -Wa,--trap
14359b3e8e9SRalf Baechlecflags-$(CONFIG_CPU_TX49XX)	+= -march=r4600 -Wa,--trap
1449200c0b2SRalf Baechlecflags-$(CONFIG_CPU_MIPS32_R1)	+= $(call cc-option,-march=mips32,-mips32 -U_MIPS_ISA -D_MIPS_ISA=_MIPS_ISA_MIPS32) \
14559b3e8e9SRalf Baechle			-Wa,-mips32 -Wa,--trap
1469200c0b2SRalf Baechlecflags-$(CONFIG_CPU_MIPS32_R2)	+= $(call cc-option,-march=mips32r2,-mips32r2 -U_MIPS_ISA -D_MIPS_ISA=_MIPS_ISA_MIPS32) \
14759b3e8e9SRalf Baechle			-Wa,-mips32r2 -Wa,--trap
1487fd08ca5SLeonid Yegoshincflags-$(CONFIG_CPU_MIPS32_R6)	+= -march=mips32r6 -Wa,--trap
1499200c0b2SRalf Baechlecflags-$(CONFIG_CPU_MIPS64_R1)	+= $(call cc-option,-march=mips64,-mips64 -U_MIPS_ISA -D_MIPS_ISA=_MIPS_ISA_MIPS64) \
15059b3e8e9SRalf Baechle			-Wa,-mips64 -Wa,--trap
1519200c0b2SRalf Baechlecflags-$(CONFIG_CPU_MIPS64_R2)	+= $(call cc-option,-march=mips64r2,-mips64r2 -U_MIPS_ISA -D_MIPS_ISA=_MIPS_ISA_MIPS64) \
15259b3e8e9SRalf Baechle			-Wa,-mips64r2 -Wa,--trap
1537fd08ca5SLeonid Yegoshincflags-$(CONFIG_CPU_MIPS64_R6)	+= -march=mips64r6 -Wa,--trap
15459b3e8e9SRalf Baechlecflags-$(CONFIG_CPU_R5000)	+= -march=r5000 -Wa,--trap
155c9e321e0SRalf Baechlecflags-$(CONFIG_CPU_R5432)	+= $(call cc-option,-march=r5400,-march=r5000) \
1561da177e4SLinus Torvalds			-Wa,--trap
157542c1020SShinya Kuribayashicflags-$(CONFIG_CPU_R5500)	+= $(call cc-option,-march=r5500,-march=r5000) \
158542c1020SShinya Kuribayashi			-Wa,--trap
159c9e321e0SRalf Baechlecflags-$(CONFIG_CPU_NEVADA)	+= $(call cc-option,-march=rm5200,-march=r5000) \
1601da177e4SLinus Torvalds			-Wa,--trap
16159b3e8e9SRalf Baechlecflags-$(CONFIG_CPU_RM7000)	+= $(call cc-option,-march=rm7000,-march=r5000) \
1621da177e4SLinus Torvalds			-Wa,--trap
163b625cd4aSMaciej W. Rozyckicflags-$(CONFIG_CPU_SB1)	+= $(call cc-option,-march=sb1,-march=r5000) \
1641da177e4SLinus Torvalds			-Wa,--trap
165b625cd4aSMaciej W. Rozyckicflags-$(CONFIG_CPU_SB1)	+= $(call cc-option,-mno-mdmx)
166b625cd4aSMaciej W. Rozyckicflags-$(CONFIG_CPU_SB1)	+= $(call cc-option,-mno-mips3d)
16759b3e8e9SRalf Baechlecflags-$(CONFIG_CPU_R8000)	+= -march=r8000 -Wa,--trap
16859b3e8e9SRalf Baechlecflags-$(CONFIG_CPU_R10000)	+= $(call cc-option,-march=r10000,-march=r8000) \
1691da177e4SLinus Torvalds			-Wa,--trap
1707e69deb8SDavid Daneycflags-$(CONFIG_CPU_CAVIUM_OCTEON) += $(call cc-option,-march=octeon) -Wa,--trap
1717e69deb8SDavid Daneyifeq (,$(findstring march=octeon, $(cflags-$(CONFIG_CPU_CAVIUM_OCTEON))))
1727e69deb8SDavid Daneycflags-$(CONFIG_CPU_CAVIUM_OCTEON) += -Wa,-march=octeon
1737e69deb8SDavid Daneyendif
174c9941158SDavid Daneycflags-$(CONFIG_CAVIUM_CN63XXP1) += -Wa,-mfix-cn63xxp1
1751c7c4451SKevin Cernekeecflags-$(CONFIG_CPU_BMIPS)	+= -march=mips32 -Wa,-mips32 -Wa,--trap
1761da177e4SLinus Torvalds
17720d60d99SMaciej W. Rozyckicflags-$(CONFIG_CPU_R4000_WORKAROUNDS)	+= $(call cc-option,-mfix-r4000,)
17820d60d99SMaciej W. Rozyckicflags-$(CONFIG_CPU_R4400_WORKAROUNDS)	+= $(call cc-option,-mfix-r4400,)
17920d60d99SMaciej W. Rozyckicflags-$(CONFIG_CPU_DADDI_WORKAROUNDS)	+= $(call cc-option,-mno-daddi,)
18020d60d99SMaciej W. Rozycki
18132098ec7SMarkos Chandras# For smartmips configurations, there are hundreds of warnings due to ISA overrides
18232098ec7SMarkos Chandras# in assembly and header files. smartmips is only supported for MIPS32r1 onwards
18332098ec7SMarkos Chandras# and there is no support for 64-bit. Various '.set mips2' or '.set mips3' or
18432098ec7SMarkos Chandras# similar directives in the kernel will spam the build logs with the following warnings:
18532098ec7SMarkos Chandras# Warning: the `smartmips' extension requires MIPS32 revision 1 or greater
18632098ec7SMarkos Chandras# or
18732098ec7SMarkos Chandras# Warning: the 64-bit MIPS architecture does not support the `smartmips' extension
18832098ec7SMarkos Chandras# Pass -Wa,--no-warn to disable all assembler warnings until the kernel code has
18932098ec7SMarkos Chandras# been fixed properly.
1905306a545SMarkos Chandrasmips-cflags				:= $(cflags-y)
1915306a545SMarkos Chandrasifeq ($(CONFIG_CPU_HAS_SMARTMIPS),y)
1925306a545SMarkos Chandrassmartmips-ase				:= $(call cc-option-yn,$(mips-cflags) -msmartmips)
1935306a545SMarkos Chandrascflags-$(smartmips-ase)			+= -msmartmips -Wa,--no-warn
1945306a545SMarkos Chandrasendif
1955306a545SMarkos Chandrasifeq ($(CONFIG_CPU_MICROMIPS),y)
1965306a545SMarkos Chandrasmicromips-ase				:= $(call cc-option-yn,$(mips-cflags) -mmicromips)
1975306a545SMarkos Chandrascflags-$(micromips-ase)			+= -mmicromips
1985306a545SMarkos Chandrasendif
19932098ec7SMarkos Chandrasifeq ($(CONFIG_CPU_HAS_MSA),y)
2005306a545SMarkos Chandrastoolchain-msa				:= $(call cc-option-yn,$(mips-cflags) -mhard-float -mfp64 -Wa$(comma)-mmsa)
20132098ec7SMarkos Chandrascflags-$(toolchain-msa)			+= -DTOOLCHAIN_SUPPORTS_MSA
20232098ec7SMarkos Chandrasendif
203bad50d79SJames Hogantoolchain-virt				:= $(call cc-option-yn,$(mips-cflags) -mvirt)
204bad50d79SJames Hogancflags-$(toolchain-virt)		+= -DTOOLCHAIN_SUPPORTS_VIRT
20532098ec7SMarkos Chandras
2061da177e4SLinus Torvalds#
2071da177e4SLinus Torvalds# Firmware support
2081da177e4SLinus Torvalds#
2090e2794b0SRalf Baechlelibs-$(CONFIG_FW_ARC)		+= arch/mips/fw/arc/
2100e2794b0SRalf Baechlelibs-$(CONFIG_FW_CFE)		+= arch/mips/fw/cfe/
2110e2794b0SRalf Baechlelibs-$(CONFIG_FW_SNIPROM)	+= arch/mips/fw/sni/
212231a35d3SThomas Bogendoerferlibs-y				+= arch/mips/fw/lib/
2131da177e4SLinus Torvalds
2141da177e4SLinus Torvalds#
215ebc89718SRalf Baechle# Kernel compression
216ebc89718SRalf Baechle#
217ebc89718SRalf Baechleifdef SYS_SUPPORTS_ZBOOT
218ebc89718SRalf BaechleCOMPRESSION_FNAME		= vmlinuz
219ebc89718SRalf Baechleelse
220ebc89718SRalf BaechleCOMPRESSION_FNAME		= vmlinux
221ebc89718SRalf Baechleendif
222ebc89718SRalf Baechle
223ebc89718SRalf Baechle#
2241da177e4SLinus Torvalds# Board-dependent options and extra files
2251da177e4SLinus Torvalds#
226a436bb7bSMasahiro Yamadainclude arch/mips/Kbuild.platforms
2277ca5dc14SFlorian Fainelli
228abe77f90SRalf Baechleifdef CONFIG_PHYSICAL_START
229abe77f90SRalf Baechleload-y					= $(CONFIG_PHYSICAL_START)
230abe77f90SRalf Baechleendif
2313185557dSJames Hoganentry-y				= 0x$(shell $(NM) vmlinux 2>/dev/null \
2323185557dSJames Hogan					| grep "\bkernel_entry\b" | cut -f1 -d \ )
233abe77f90SRalf Baechle
234384740dcSRalf Baechlecflags-y			+= -I$(srctree)/arch/mips/include/asm/mach-generic
2351da177e4SLinus Torvaldsdrivers-$(CONFIG_PCI)		+= arch/mips/pci/
2361da177e4SLinus Torvalds
237adff90a9SFranck Bui-Huu#
238adff90a9SFranck Bui-Huu# Automatically detect the build format. By default we choose
239adff90a9SFranck Bui-Huu# the elf format according to the load address.
240adff90a9SFranck Bui-Huu# We can always force a build with a 64-bits symbol format by
241054c51b4SFranck Bui-Huu# passing 'KBUILD_SYM32=no' option to the make's command line.
242adff90a9SFranck Bui-Huu#
243adff90a9SFranck Bui-Huuifdef CONFIG_64BIT
244054c51b4SFranck Bui-Huu  ifndef KBUILD_SYM32
245adff90a9SFranck Bui-Huu    ifeq ($(shell expr $(load-y) \< 0xffffffff80000000), 0)
246054c51b4SFranck Bui-Huu      KBUILD_SYM32 = y
247adff90a9SFranck Bui-Huu    endif
248adff90a9SFranck Bui-Huu  endif
249adff90a9SFranck Bui-Huu
25020d60d99SMaciej W. Rozycki  ifeq ($(KBUILD_SYM32)$(call cc-option-yn,-msym32), yy)
251054c51b4SFranck Bui-Huu    cflags-y += -msym32 -DKBUILD_64BIT_SYM32
25220d60d99SMaciej W. Rozycki  else
25320d60d99SMaciej W. Rozycki    ifeq ($(CONFIG_CPU_DADDI_WORKAROUNDS), y)
25420d60d99SMaciej W. Rozycki      $(error CONFIG_CPU_DADDI_WORKAROUNDS unsupported without -msym32)
255adff90a9SFranck Bui-Huu    endif
256adff90a9SFranck Bui-Huu  endif
257e58d95abSFranck Bui-Huuendif
258adff90a9SFranck Bui-Huu
259222d394dSSam RavnborgKBUILD_AFLAGS	+= $(cflags-y)
26051b563fcSSam RavnborgKBUILD_CFLAGS	+= $(cflags-y)
261f7fc237eSMichal MarekKBUILD_CPPFLAGS += -DVMLINUX_LOAD_ADDRESS=$(load-y)
262f7fc237eSMichal MarekKBUILD_CPPFLAGS += -DDATAOFFSET=$(if $(dataoffset-y),$(dataoffset-y),0)
2631da177e4SLinus Torvalds
2643185557dSJames Hoganbootvars-y	= VMLINUX_LOAD_ADDRESS=$(load-y) \
265cf2a5e0bSPaul Burton		  VMLINUX_ENTRY_ADDRESS=$(entry-y) \
266818f38c5SMatt Redfearn		  PLATFORM="$(platform-y)"
267eed0eabdSPaul Burtonifdef CONFIG_32BIT
268eed0eabdSPaul Burtonbootvars-y	+= ADDR_BITS=32
269eed0eabdSPaul Burtonendif
270eed0eabdSPaul Burtonifdef CONFIG_64BIT
271eed0eabdSPaul Burtonbootvars-y	+= ADDR_BITS=64
272eed0eabdSPaul Burtonendif
2733185557dSJames Hogan
2741da177e4SLinus TorvaldsLDFLAGS			+= -m $(ld-emul)
2751da177e4SLinus Torvalds
27659b3e8e9SRalf Baechleifdef CONFIG_MIPS
277a0f97e06SSam RavnborgCHECKFLAGS += $(shell $(CC) $(KBUILD_CFLAGS) -dM -E -x c /dev/null | \
27848c35b2dSAlexey Dobriyan	egrep -vw '__GNUC_(|MINOR_|PATCHLEVEL_)_' | \
27973d8f99cSAaro Koskinen	sed -e "s/^\#define /-D'/" -e "s/ /'='/" -e "s/$$/'/" -e 's/\$$/&&/g')
2802a2c3e45SAtsushi Nemotoifdef CONFIG_64BIT
2812a2c3e45SAtsushi NemotoCHECKFLAGS		+= -m64
2822a2c3e45SAtsushi Nemotoendif
28359b3e8e9SRalf Baechleendif
28459b3e8e9SRalf Baechle
2851da177e4SLinus TorvaldsOBJCOPYFLAGS		+= --remove-section=.reginfo
2861da177e4SLinus Torvalds
287957b369cSThomas Gleixnerhead-y := arch/mips/kernel/head.o
2881da177e4SLinus Torvalds
2891da177e4SLinus Torvaldslibs-y			+= arch/mips/lib/
290593d33feSRalf Baechlelibs-y			+= arch/mips/math-emu/
2911da177e4SLinus Torvalds
2929aeb404bSSam Ravnborg# See arch/mips/Kbuild for content of core part of the kernel
2939aeb404bSSam Ravnborgcore-y += arch/mips/
2941da177e4SLinus Torvalds
2951da177e4SLinus Torvaldsdrivers-$(CONFIG_OPROFILE)	+= arch/mips/oprofile/
2961da177e4SLinus Torvalds
297363c55caSWu Zhangjin# suspend and hibernation support
298363c55caSWu Zhangjindrivers-$(CONFIG_PM)	+= arch/mips/power/
299363c55caSWu Zhangjin
30038d2d649SJames Hogan# boot image targets (arch/mips/boot/)
30138d2d649SJames Hoganboot-y			:= vmlinux.bin
30238d2d649SJames Hoganboot-y			+= vmlinux.ecoff
30338d2d649SJames Hoganboot-y			+= vmlinux.srec
3044defe455SJames Hoganifeq ($(shell expr $(load-y) \< 0xffffffff80000000 2> /dev/null), 0)
3054defe455SJames Hoganboot-y			+= uImage
3069d6b80faSMarkos Chandrasboot-y			+= uImage.bin
3079d6b80faSMarkos Chandrasboot-y			+= uImage.bz2
3084defe455SJames Hoganboot-y			+= uImage.gz
3099d6b80faSMarkos Chandrasboot-y			+= uImage.lzma
3109d6b80faSMarkos Chandrasboot-y			+= uImage.lzo
3114defe455SJames Hoganendif
312cf2a5e0bSPaul Burtonboot-y			+= vmlinux.itb
313cf2a5e0bSPaul Burtonboot-y			+= vmlinux.gz.itb
314cf2a5e0bSPaul Burtonboot-y			+= vmlinux.bz2.itb
315cf2a5e0bSPaul Burtonboot-y			+= vmlinux.lzma.itb
316cf2a5e0bSPaul Burtonboot-y			+= vmlinux.lzo.itb
31738d2d649SJames Hogan
31838d2d649SJames Hogan# compressed boot image targets (arch/mips/boot/compressed/)
31938d2d649SJames Hoganbootz-y			:= vmlinuz
32038d2d649SJames Hoganbootz-y			+= vmlinuz.bin
32138d2d649SJames Hoganbootz-y			+= vmlinuz.ecoff
32238d2d649SJames Hoganbootz-y			+= vmlinuz.srec
32338d2d649SJames Hogan
3241f21d2bdSBrian Murphyifdef CONFIG_LASAT
3251f21d2bdSBrian Murphyrom.bin rom.sw: vmlinux
3263185557dSJames Hogan	$(Q)$(MAKE) $(build)=arch/mips/lasat/image \
3273185557dSJames Hogan		$(bootvars-y) $@
3281f21d2bdSBrian Murphyendif
3291f21d2bdSBrian Murphy
330e818fac5SMatt RedfearnCMD_RELOCS = arch/mips/boot/tools/relocs
331e818fac5SMatt Redfearnquiet_cmd_relocs = RELOCS  $<
332e818fac5SMatt Redfearn      cmd_relocs = $(CMD_RELOCS) $<
333e818fac5SMatt Redfearn
3341da177e4SLinus Torvalds#
3351da177e4SLinus Torvalds# Some machines like the Indy need 32-bit ELF binaries for booting purposes.
3361da177e4SLinus Torvalds# Other need ECOFF, so we build a 32-bit ELF binary for them which we then
3371da177e4SLinus Torvalds# convert to ECOFF using elf2ecoff.
3381da177e4SLinus Torvalds#
339007fbbeaSWu Zhangjinquiet_cmd_32 = OBJCOPY $@
340007fbbeaSWu Zhangjin	cmd_32 = $(OBJCOPY) -O $(32bit-bfd) $(OBJCOPYFLAGS) $< $@
3411da177e4SLinus Torvaldsvmlinux.32: vmlinux
342e818fac5SMatt Redfearnifeq ($(CONFIG_RELOCATABLE)$(CONFIG_64BIT),yy)
343e818fac5SMatt Redfearn# Currently, objcopy fails to handle the relocations in the elf64
344e818fac5SMatt Redfearn# So the relocs tool must be run here to remove them first
345e818fac5SMatt Redfearn	$(call cmd,relocs)
346e818fac5SMatt Redfearnendif
347007fbbeaSWu Zhangjin	$(call cmd,32)
3481da177e4SLinus Torvalds
3491da177e4SLinus Torvalds#
3501da177e4SLinus Torvalds# The 64-bit ELF tools are pretty broken so at this time we generate 64-bit
3511da177e4SLinus Torvalds# ELF files from 32-bit files by conversion.
3521da177e4SLinus Torvalds#
353007fbbeaSWu Zhangjinquiet_cmd_64 = OBJCOPY $@
354007fbbeaSWu Zhangjin	cmd_64 = $(OBJCOPY) -O $(64bit-bfd) $(OBJCOPYFLAGS) $< $@
3551da177e4SLinus Torvaldsvmlinux.64: vmlinux
356007fbbeaSWu Zhangjin	$(call cmd,64)
3571da177e4SLinus Torvalds
3588496b401SRalf Baechleall:	$(all-y)
3591da177e4SLinus Torvalds
36035eaa1e9SSam Ravnborg# boot
36138d2d649SJames Hogan$(boot-y): $(vmlinux-32) FORCE
362e818fac5SMatt Redfearnifeq ($(CONFIG_RELOCATABLE)$(CONFIG_32BIT),yy)
363e818fac5SMatt Redfearn	$(call cmd,relocs)
364e818fac5SMatt Redfearnendif
3653185557dSJames Hogan	$(Q)$(MAKE) $(build)=arch/mips/boot VMLINUX=$(vmlinux-32) \
3663185557dSJames Hogan		$(bootvars-y) arch/mips/boot/$@
3671da177e4SLinus Torvalds
36826fca83aSFlorian Fainelliifdef CONFIG_SYS_SUPPORTS_ZBOOT
36935eaa1e9SSam Ravnborg# boot/compressed
37038d2d649SJames Hogan$(bootz-y): $(vmlinux-32) FORCE
37135eaa1e9SSam Ravnborg	$(Q)$(MAKE) $(build)=arch/mips/boot/compressed \
3723185557dSJames Hogan		$(bootvars-y) 32bit-bfd=$(32bit-bfd) $@
37326fca83aSFlorian Fainellielse
37426fca83aSFlorian Fainellivmlinuz: FORCE
37526fca83aSFlorian Fainelli	@echo '   CONFIG_SYS_SUPPORTS_ZBOOT is not enabled'
37626fca83aSFlorian Fainelli	/bin/false
37726fca83aSFlorian Fainelliendif
37835eaa1e9SSam Ravnborg
37935eaa1e9SSam Ravnborg
380d745866eSSam RavnborgCLEAN_FILES += vmlinux.32 vmlinux.64
3811da177e4SLinus Torvalds
3827fafb068SAndrew Bresticker# device-trees
3837fafb068SAndrew Brestickercore-$(CONFIG_BUILTIN_DTB) += arch/mips/boot/dts/
3847fafb068SAndrew Bresticker
3857fafb068SAndrew Bresticker%.dtb %.dtb.S %.dtb.o: | scripts
3867fafb068SAndrew Bresticker	$(Q)$(MAKE) $(build)=arch/mips/boot/dts arch/mips/boot/dts/$@
3877fafb068SAndrew Bresticker
388c8d333dfSAndrew BrestickerPHONY += dtbs
389c8d333dfSAndrew Brestickerdtbs: scripts
3908c0b9ee8SAndrew Bresticker	$(Q)$(MAKE) $(build)=arch/mips/boot/dts
391c8d333dfSAndrew Bresticker
392eb2236eaSAndrew BrestickerPHONY += dtbs_install
393eb2236eaSAndrew Brestickerdtbs_install:
394eb2236eaSAndrew Bresticker	$(Q)$(MAKE) $(dtbinst)=arch/mips/boot/dts
395e48ce6b8SAtsushi Nemoto
396e48ce6b8SAtsushi Nemotoarchprepare:
39744656fa0SDavid Daneyifdef CONFIG_MIPS32_N32
398e48ce6b8SAtsushi Nemoto	@echo '  Checking missing-syscalls for N32'
399e48ce6b8SAtsushi Nemoto	$(Q)$(MAKE) $(build)=. missing-syscalls missing_syscalls_flags="-mabi=n32"
40059968d3bSRalf Baechleendif
40159968d3bSRalf Baechleifdef CONFIG_MIPS32_O32
402d9beeecaSRalf Baechle	@echo '  Checking missing-syscalls for O32'
4031b93b3c3SWu Zhangjin	$(Q)$(MAKE) $(build)=. missing-syscalls missing_syscalls_flags="-mabi=32"
404d9beeecaSRalf Baechleendif
40559968d3bSRalf Baechle
40659968d3bSRalf Baechleinstall:
40759968d3bSRalf Baechle	$(Q)install -D -m 755 vmlinux $(INSTALL_PATH)/vmlinux-$(KERNELRELEASE)
4081da177e4SLinus Torvaldsifdef CONFIG_SYS_SUPPORTS_ZBOOT
409d745866eSSam Ravnborg	$(Q)install -D -m 755 vmlinuz $(INSTALL_PATH)/vmlinuz-$(KERNELRELEASE)
410d745866eSSam Ravnborgendif
411d745866eSSam Ravnborg	$(Q)install -D -m 644 .config $(INSTALL_PATH)/config-$(KERNELRELEASE)
4121da177e4SLinus Torvalds	$(Q)install -D -m 644 System.map $(INSTALL_PATH)/System.map-$(KERNELRELEASE)
413e7865765SRalf Baechle
41459968d3bSRalf Baechlearchclean:
415e7865765SRalf Baechle	$(Q)$(MAKE) $(clean)=arch/mips/boot
416e7865765SRalf Baechle	$(Q)$(MAKE) $(clean)=arch/mips/boot/compressed
417aadeec4dSMatt Redfearn	$(Q)$(MAKE) $(clean)=arch/mips/boot/tools
418e7865765SRalf Baechle	$(Q)$(MAKE) $(clean)=arch/mips/lasat
419e7865765SRalf Baechle
420e7865765SRalf Baechledefine archhelp
421e7865765SRalf Baechle	echo '  install              - install kernel into $(INSTALL_PATH)'
422e7865765SRalf Baechle	echo '  vmlinux.ecoff        - ECOFF boot image'
423048eb582SSam Ravnborg	echo '  vmlinux.bin          - Raw binary boot image'
4241da177e4SLinus Torvalds	echo '  vmlinux.srec         - SREC boot image'
42578931652SJoshua Kinard	echo '  vmlinux.32           - 64-bit boot image wrapped in 32bits (IP22/IP32)'
4261b93b3c3SWu Zhangjin	echo '  vmlinuz              - Compressed boot(zboot) image'
4271b93b3c3SWu Zhangjin	echo '  vmlinuz.ecoff        - ECOFF zboot image'
4281b93b3c3SWu Zhangjin	echo '  vmlinuz.bin          - Raw binary zboot image'
4291b93b3c3SWu Zhangjin	echo '  vmlinuz.srec         - SREC zboot image'
4304defe455SJames Hogan	echo '  uImage               - U-Boot image'
4319d6b80faSMarkos Chandras	echo '  uImage.bin           - U-Boot image (uncompressed)'
4329d6b80faSMarkos Chandras	echo '  uImage.bz2           - U-Boot image (bz2)'
4334defe455SJames Hogan	echo '  uImage.gz            - U-Boot image (gzip)'
4349d6b80faSMarkos Chandras	echo '  uImage.lzma          - U-Boot image (lzma)'
4359d6b80faSMarkos Chandras	echo '  uImage.lzo           - U-Boot image (lzo)'
436c8d333dfSAndrew Bresticker	echo '  dtbs                 - Device-tree blobs for enabled boards'
437eb2236eaSAndrew Bresticker	echo '  dtbs_install         - Install dtbs to $(INSTALL_DTBS_PATH)'
4381da177e4SLinus Torvalds	echo
43925985edcSLucas De Marchi	echo '  These will be default as appropriate for a configured platform.'
440eed0eabdSPaul Burton	echo
441eed0eabdSPaul Burton	echo '  If you are targeting a system supported by generic kernels you may'
442eed0eabdSPaul Burton	echo '  configure the kernel for a given architecture target like so:'
443eed0eabdSPaul Burton	echo
444eed0eabdSPaul Burton	echo '  {micro32,32,64}{r1,r2,r6}{el,}_defconfig <BOARDS="list of boards">'
445eed0eabdSPaul Burton	echo
446eed0eabdSPaul Burton	echo '  Otherwise, the following default configurations are available:'
4471da177e4SLinus Torvaldsendef
448eed0eabdSPaul Burton
449eed0eabdSPaul Burtongeneric_config_dir = $(srctree)/arch/$(ARCH)/configs/generic
450eed0eabdSPaul Burtongeneric_defconfigs :=
451eed0eabdSPaul Burton
452eed0eabdSPaul Burton#
453eed0eabdSPaul Burton# If the user generates a generic kernel configuration without specifying a
454eed0eabdSPaul Burton# list of boards to include the config fragments for, default to including all
455eed0eabdSPaul Burton# available board config fragments.
456eed0eabdSPaul Burton#
457eed0eabdSPaul Burtonifeq ($(BOARDS),)
458eed0eabdSPaul BurtonBOARDS = $(patsubst board-%.config,%,$(notdir $(wildcard $(generic_config_dir)/board-*.config)))
459eed0eabdSPaul Burtonendif
460eed0eabdSPaul Burton
461eed0eabdSPaul Burton#
462eed0eabdSPaul Burton# Generic kernel configurations which merge generic_defconfig with the
463eed0eabdSPaul Burton# appropriate config fragments from arch/mips/configs/generic/, resulting in
464eed0eabdSPaul Burton# the ability to easily configure the kernel for a given architecture,
465eed0eabdSPaul Burton# endianness & set of boards without duplicating the needed configuration in
466eed0eabdSPaul Burton# hundreds of defconfig files.
467eed0eabdSPaul Burton#
468eed0eabdSPaul Burtondefine gen_generic_defconfigs
469eed0eabdSPaul Burton$(foreach bits,$(1),$(foreach rev,$(2),$(foreach endian,$(3),
470eed0eabdSPaul Burtontarget := $(bits)$(rev)$(filter el,$(endian))_defconfig
471eed0eabdSPaul Burtongeneric_defconfigs += $$(target)
472eed0eabdSPaul Burton$$(target): $(generic_config_dir)/$(bits)$(rev).config
473eed0eabdSPaul Burton$$(target): $(generic_config_dir)/$(endian).config
474eed0eabdSPaul Burton)))
475eed0eabdSPaul Burtonendef
476eed0eabdSPaul Burton
477eed0eabdSPaul Burton$(eval $(call gen_generic_defconfigs,32 64,r1 r2 r6,eb el))
478eed0eabdSPaul Burton$(eval $(call gen_generic_defconfigs,micro32,r2,eb el))
479eed0eabdSPaul Burton
480eed0eabdSPaul Burton.PHONY: $(generic_defconfigs)
481eed0eabdSPaul Burton$(generic_defconfigs):
482eed0eabdSPaul Burton	$(Q)$(CONFIG_SHELL) $(srctree)/scripts/kconfig/merge_config.sh \
483eed0eabdSPaul Burton		-m -O $(objtree) $(srctree)/arch/$(ARCH)/configs/generic_defconfig $^ \
484eed0eabdSPaul Burton		$(foreach board,$(BOARDS),$(generic_config_dir)/board-$(board).config)
485eed0eabdSPaul Burton	$(Q)$(MAKE) olddefconfig
486eed0eabdSPaul Burton
487eed0eabdSPaul Burton#
488eed0eabdSPaul Burton# Prevent generic merge_config rules attempting to merge single fragments
489eed0eabdSPaul Burton#
490eed0eabdSPaul Burton$(generic_config_dir)/%.config: ;
4913f5f0a44SPaul Burton
4923f5f0a44SPaul Burton#
4933f5f0a44SPaul Burton# Legacy defconfig compatibility - these targets used to be real defconfigs but
4943f5f0a44SPaul Burton# now that the boards have been converted to use the generic kernel they are
4953f5f0a44SPaul Burton# wrappers around the generic rules above.
4963f5f0a44SPaul Burton#
4973f5f0a44SPaul Burton.PHONY: sead3_defconfig
4983f5f0a44SPaul Burtonsead3_defconfig:
4993f5f0a44SPaul Burton	$(Q)$(MAKE) 32r2el_defconfig BOARDS=sead-3
5003f5f0a44SPaul Burton
5013f5f0a44SPaul Burton.PHONY: sead3micro_defconfig
5023f5f0a44SPaul Burtonsead3micro_defconfig:
5033f5f0a44SPaul Burton	$(Q)$(MAKE) micro32r2el_defconfig BOARDS=sead-3
504