xref: /openbmc/linux/arch/mips/Makefile (revision e4acfbc1)
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
16e245767aSPaul Burton	$(Q)$(MAKE) $(build)=arch/mips/tools elf-entry
17e4acfbc1SPaul Burtonifeq ($(CONFIG_CPU_LOONGSON3_WORKAROUNDS),y)
18e4acfbc1SPaul Burton	$(Q)$(MAKE) $(build)=arch/mips/tools loongson3-llsc-check
19e4acfbc1SPaul Burtonendif
20aadeec4dSMatt Redfearn	$(Q)$(MAKE) $(build)=arch/mips/boot/tools relocs
21aadeec4dSMatt Redfearn
2204d8405eSMatt RedfearnKBUILD_DEFCONFIG := 32r2el_defconfig
23637dfa0fSCedric HombourgerKBUILD_DTBS      := dtbs
24de0c1698SAdrian Bunk
251da177e4SLinus Torvalds#
261da177e4SLinus Torvalds# Select the object file format to substitute into the linker script.
271da177e4SLinus Torvalds#
281da177e4SLinus Torvaldsifdef CONFIG_CPU_LITTLE_ENDIAN
2917f690beSRalf Baechle32bit-tool-archpref	= mipsel
3017f690beSRalf Baechle64bit-tool-archpref	= mips64el
311da177e4SLinus Torvalds32bit-bfd		= elf32-tradlittlemips
321da177e4SLinus Torvalds64bit-bfd		= elf64-tradlittlemips
331da177e4SLinus Torvalds32bit-emul		= elf32ltsmip
341da177e4SLinus Torvalds64bit-emul		= elf64ltsmip
351da177e4SLinus Torvaldselse
3617f690beSRalf Baechle32bit-tool-archpref	= mips
3717f690beSRalf Baechle64bit-tool-archpref	= mips64
381da177e4SLinus Torvalds32bit-bfd		= elf32-tradbigmips
391da177e4SLinus Torvalds64bit-bfd		= elf64-tradbigmips
401da177e4SLinus Torvalds32bit-emul		= elf32btsmip
411da177e4SLinus Torvalds64bit-emul		= elf64btsmip
421da177e4SLinus Torvaldsendif
431da177e4SLinus Torvalds
44875d43e7SRalf Baechleifdef CONFIG_32BIT
4517f690beSRalf Baechletool-archpref		= $(32bit-tool-archpref)
461da177e4SLinus TorvaldsUTS_MACHINE		:= mips
471da177e4SLinus Torvaldsendif
48875d43e7SRalf Baechleifdef CONFIG_64BIT
4917f690beSRalf Baechletool-archpref		= $(64bit-tool-archpref)
501da177e4SLinus TorvaldsUTS_MACHINE		:= mips64
511da177e4SLinus Torvaldsendif
521da177e4SLinus Torvalds
5317f690beSRalf Baechleifneq ($(SUBARCH),$(ARCH))
5417f690beSRalf Baechle  ifeq ($(CROSS_COMPILE),)
553247989eSMaciej W. Rozycki    CROSS_COMPILE := $(call cc-cross-prefix, $(tool-archpref)-linux-  $(tool-archpref)-linux-gnu-  $(tool-archpref)-unknown-linux-gnu-)
5617f690beSRalf Baechle  endif
571da177e4SLinus Torvaldsendif
581da177e4SLinus Torvalds
597326c4e5SWu Zhangjinifdef CONFIG_FUNCTION_GRAPH_TRACER
607326c4e5SWu Zhangjin  ifndef KBUILD_MCOUNT_RA_ADDRESS
617326c4e5SWu Zhangjin    ifeq ($(call cc-option-yn,-mmcount-ra-address), y)
627326c4e5SWu Zhangjin      cflags-y += -mmcount-ra-address -DKBUILD_MCOUNT_RA_ADDRESS
637326c4e5SWu Zhangjin    endif
647326c4e5SWu Zhangjin  endif
657326c4e5SWu Zhangjinendif
661a4ba061SRalf Baechlecflags-y += $(call cc-option, -mno-check-zero-division)
6705e41404SRalf Baechle
688145095cSRalf Baechleifdef CONFIG_32BIT
691da177e4SLinus Torvaldsld-emul			= $(32bit-emul)
701da177e4SLinus Torvaldsvmlinux-32		= vmlinux
711da177e4SLinus Torvaldsvmlinux-64		= vmlinux.64
7259b3e8e9SRalf Baechle
7359b3e8e9SRalf Baechlecflags-y		+= -mabi=32
748145095cSRalf Baechleendif
751da177e4SLinus Torvalds
768145095cSRalf Baechleifdef CONFIG_64BIT
778145095cSRalf Baechleld-emul			= $(64bit-emul)
788145095cSRalf Baechlevmlinux-32		= vmlinux.32
798145095cSRalf Baechlevmlinux-64		= vmlinux
808145095cSRalf Baechle
8159b3e8e9SRalf Baechlecflags-y		+= -mabi=64
8259b3e8e9SRalf Baechleendif
8359b3e8e9SRalf Baechle
848496b401SRalf Baechleall-$(CONFIG_BOOT_ELF32)	:= $(vmlinux-32)
858496b401SRalf Baechleall-$(CONFIG_BOOT_ELF64)	:= $(vmlinux-64)
861b93b3c3SWu Zhangjinall-$(CONFIG_SYS_SUPPORTS_ZBOOT)+= vmlinuz
871da177e4SLinus Torvalds
881da177e4SLinus Torvalds#
891da177e4SLinus Torvalds# GCC uses -G 0 -mabicalls -fpic as default.  We don't want PIC in the kernel
901da177e4SLinus Torvalds# code since it only slows down the whole thing.  At some point we might make
911da177e4SLinus Torvalds# use of global pointer optimizations but their use of $28 conflicts with
921da177e4SLinus Torvalds# the current pointer optimization.
931da177e4SLinus Torvalds#
941da177e4SLinus Torvalds# The DECStation requires an ECOFF kernel for remote booting, other MIPS
951da177e4SLinus Torvalds# machines may also.  Since BFD is incredibly buggy with respect to
961da177e4SLinus Torvalds# crossformat linking we rely on the elf2ecoff tool for format conversion.
971da177e4SLinus Torvalds#
981da177e4SLinus Torvaldscflags-y			+= -G 0 -mno-abicalls -fno-pic -pipe
996218cf44SRalf Baechlecflags-y			+= -msoft-float
1009f83d839SThiemo SeuferLDFLAGS_vmlinux			+= -G 0 -static -n -nostdlib
1016588169dSSam RavnborgKBUILD_AFLAGS_MODULE		+= -mlong-calls
1026588169dSSam RavnborgKBUILD_CFLAGS_MODULE		+= -mlong-calls
1031da177e4SLinus Torvalds
104e818fac5SMatt Redfearnifeq ($(CONFIG_RELOCATABLE),y)
105e818fac5SMatt RedfearnLDFLAGS_vmlinux			+= --emit-relocs
106e818fac5SMatt Redfearnendif
107e818fac5SMatt Redfearn
108842dfc11SManuel Lauss#
109842dfc11SManuel Lauss# pass -msoft-float to GAS if it supports it.  However on newer binutils
110842dfc11SManuel Lauss# (specifically newer than 2.24.51.20140728) we then also need to explicitly
111842dfc11SManuel Lauss# set ".set hardfloat" in all files which manipulate floating point registers.
112842dfc11SManuel Lauss#
113842dfc11SManuel Laussifneq ($(call as-option,-Wa$(comma)-msoft-float,),)
114842dfc11SManuel Lauss	cflags-y		+= -DGAS_HAS_SET_HARDFLOAT -Wa,-msoft-float
115842dfc11SManuel Laussendif
116842dfc11SManuel Lauss
11772fbfb26SRalf Baechlecflags-y += -ffreestanding
11872fbfb26SRalf Baechle
119f425a6dcSThiemo Seufer#
120f425a6dcSThiemo Seufer# We explicitly add the endianness specifier if needed, this allows
121f425a6dcSThiemo Seufer# to compile kernels with a toolchain for the other endianness. We
122f425a6dcSThiemo Seufer# carefully avoid to add it redundantly because gcc 3.3/3.4 complains
123f425a6dcSThiemo Seufer# when fed the toolchain default!
124f425a6dcSThiemo Seufer#
125f9405412SRalf Baechle# Certain gcc versions up to gcc 4.1.1 (probably 4.2-subversion as of
12659c51591SMichael Opdenacker# 2006-10-10 don't properly change the predefined symbols if -EB / -EL
127f9405412SRalf Baechle# are used, so we kludge that here.  A bug has been filed at
128f9405412SRalf Baechle# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29413.
129f9405412SRalf Baechle#
130c6d6f4c5SPaul Burton# clang doesn't suffer from these issues and our checks against -dumpmachine
131c6d6f4c5SPaul Burton# don't work so well when cross compiling, since without providing --target
132c6d6f4c5SPaul Burton# clang's output will be based upon the build machine. So for clang we simply
133c6d6f4c5SPaul Burton# unconditionally specify -EB or -EL as appropriate.
134c6d6f4c5SPaul Burton#
135076f421dSMasahiro Yamadaifdef CONFIG_CC_IS_CLANG
136c6d6f4c5SPaul Burtoncflags-$(CONFIG_CPU_BIG_ENDIAN)		+= -EB
137c6d6f4c5SPaul Burtoncflags-$(CONFIG_CPU_LITTLE_ENDIAN)	+= -EL
138c6d6f4c5SPaul Burtonelse
139f9405412SRalf Baechleundef-all += -UMIPSEB -U_MIPSEB -U__MIPSEB -U__MIPSEB__
140f9405412SRalf Baechleundef-all += -UMIPSEL -U_MIPSEL -U__MIPSEL -U__MIPSEL__
141f9405412SRalf Baechlepredef-be += -DMIPSEB -D_MIPSEB -D__MIPSEB -D__MIPSEB__
142f9405412SRalf Baechlepredef-le += -DMIPSEL -D_MIPSEL -D__MIPSEL -D__MIPSEL__
143f9405412SRalf Baechlecflags-$(CONFIG_CPU_BIG_ENDIAN)		+= $(shell $(CC) -dumpmachine |grep -q 'mips.*el-.*' && echo -EB $(undef-all) $(predef-be))
144f9405412SRalf Baechlecflags-$(CONFIG_CPU_LITTLE_ENDIAN)	+= $(shell $(CC) -dumpmachine |grep -q 'mips.*el-.*' || echo -EL $(undef-all) $(predef-le))
145c6d6f4c5SPaul Burtonendif
146f425a6dcSThiemo Seufer
1479007c9a2SRalf Baechlecflags-$(CONFIG_SB1XXX_CORELIS)	+= $(call cc-option,-mno-sched-prolog) \
1489007c9a2SRalf Baechle				   -fno-omit-frame-pointer
149573deec0SJoshua Kinard
150573deec0SJoshua Kinard# Some distribution-specific toolchains might pass the -fstack-check
151573deec0SJoshua Kinard# option during the build, which adds a simple stack-probe at the beginning
152573deec0SJoshua Kinard# of every function.  This stack probe is to ensure that there is enough
153573deec0SJoshua Kinard# stack space, else a SEGV is generated.  This is not desirable for MIPS
154573deec0SJoshua Kinard# as kernel stacks are small, placed in unmapped virtual memory, and do not
155573deec0SJoshua Kinard# grow when overflowed.  Especially on SGI IP27 platforms, this check will
156573deec0SJoshua Kinard# lead to a NULL pointer dereference in _raw_spin_lock_irq.
157573deec0SJoshua Kinard#
158573deec0SJoshua Kinard# In disassembly, this stack probe appears at the top of a function as:
159573deec0SJoshua Kinard#    sd		zero,<offset>(sp)
160573deec0SJoshua Kinard# Where <offset> is a negative value.
161573deec0SJoshua Kinard#
162573deec0SJoshua Kinardcflags-y += -fno-stack-check
163573deec0SJoshua Kinard
1641da177e4SLinus Torvalds#
1651da177e4SLinus Torvalds# CPU-dependent compiler/assembler options for optimization.
1661da177e4SLinus Torvalds#
16759b3e8e9SRalf Baechlecflags-$(CONFIG_CPU_R3000)	+= -march=r3000
16859b3e8e9SRalf Baechlecflags-$(CONFIG_CPU_TX39XX)	+= -march=r3900
16959b3e8e9SRalf Baechlecflags-$(CONFIG_CPU_VR41XX)	+= -march=r4100 -Wa,--trap
17059b3e8e9SRalf Baechlecflags-$(CONFIG_CPU_R4X00)	+= -march=r4600 -Wa,--trap
17159b3e8e9SRalf Baechlecflags-$(CONFIG_CPU_TX49XX)	+= -march=r4600 -Wa,--trap
172344ebf09SPaul Burtoncflags-$(CONFIG_CPU_MIPS32_R1)	+= -march=mips32 -Wa,--trap
173344ebf09SPaul Burtoncflags-$(CONFIG_CPU_MIPS32_R2)	+= -march=mips32r2 -Wa,--trap
17421855a6eSMiodrag Diniccflags-$(CONFIG_CPU_MIPS32_R6)	+= -march=mips32r6 -Wa,--trap -modd-spreg
175344ebf09SPaul Burtoncflags-$(CONFIG_CPU_MIPS64_R1)	+= -march=mips64 -Wa,--trap
176344ebf09SPaul Burtoncflags-$(CONFIG_CPU_MIPS64_R2)	+= -march=mips64r2 -Wa,--trap
1777fd08ca5SLeonid Yegoshincflags-$(CONFIG_CPU_MIPS64_R6)	+= -march=mips64r6 -Wa,--trap
17859b3e8e9SRalf Baechlecflags-$(CONFIG_CPU_R5000)	+= -march=r5000 -Wa,--trap
179542c1020SShinya Kuribayashicflags-$(CONFIG_CPU_R5500)	+= $(call cc-option,-march=r5500,-march=r5000) \
180542c1020SShinya Kuribayashi			-Wa,--trap
181c9e321e0SRalf Baechlecflags-$(CONFIG_CPU_NEVADA)	+= $(call cc-option,-march=rm5200,-march=r5000) \
1821da177e4SLinus Torvalds			-Wa,--trap
18359b3e8e9SRalf Baechlecflags-$(CONFIG_CPU_RM7000)	+= $(call cc-option,-march=rm7000,-march=r5000) \
1841da177e4SLinus Torvalds			-Wa,--trap
185b625cd4aSMaciej W. Rozyckicflags-$(CONFIG_CPU_SB1)	+= $(call cc-option,-march=sb1,-march=r5000) \
1861da177e4SLinus Torvalds			-Wa,--trap
187b625cd4aSMaciej W. Rozyckicflags-$(CONFIG_CPU_SB1)	+= $(call cc-option,-mno-mdmx)
188b625cd4aSMaciej W. Rozyckicflags-$(CONFIG_CPU_SB1)	+= $(call cc-option,-mno-mips3d)
18959b3e8e9SRalf Baechlecflags-$(CONFIG_CPU_R10000)	+= $(call cc-option,-march=r10000,-march=r8000) \
1901da177e4SLinus Torvalds			-Wa,--trap
1917e69deb8SDavid Daneycflags-$(CONFIG_CPU_CAVIUM_OCTEON) += $(call cc-option,-march=octeon) -Wa,--trap
1927e69deb8SDavid Daneyifeq (,$(findstring march=octeon, $(cflags-$(CONFIG_CPU_CAVIUM_OCTEON))))
1937e69deb8SDavid Daneycflags-$(CONFIG_CPU_CAVIUM_OCTEON) += -Wa,-march=octeon
1947e69deb8SDavid Daneyendif
195c9941158SDavid Daneycflags-$(CONFIG_CAVIUM_CN63XXP1) += -Wa,-mfix-cn63xxp1
1961c7c4451SKevin Cernekeecflags-$(CONFIG_CPU_BMIPS)	+= -march=mips32 -Wa,-mips32 -Wa,--trap
1971da177e4SLinus Torvalds
19820d60d99SMaciej W. Rozyckicflags-$(CONFIG_CPU_R4000_WORKAROUNDS)	+= $(call cc-option,-mfix-r4000,)
19920d60d99SMaciej W. Rozyckicflags-$(CONFIG_CPU_R4400_WORKAROUNDS)	+= $(call cc-option,-mfix-r4400,)
20020d60d99SMaciej W. Rozyckicflags-$(CONFIG_CPU_DADDI_WORKAROUNDS)	+= $(call cc-option,-mno-daddi,)
20120d60d99SMaciej W. Rozycki
20232098ec7SMarkos Chandras# For smartmips configurations, there are hundreds of warnings due to ISA overrides
20332098ec7SMarkos Chandras# in assembly and header files. smartmips is only supported for MIPS32r1 onwards
20432098ec7SMarkos Chandras# and there is no support for 64-bit. Various '.set mips2' or '.set mips3' or
20532098ec7SMarkos Chandras# similar directives in the kernel will spam the build logs with the following warnings:
20632098ec7SMarkos Chandras# Warning: the `smartmips' extension requires MIPS32 revision 1 or greater
20732098ec7SMarkos Chandras# or
20832098ec7SMarkos Chandras# Warning: the 64-bit MIPS architecture does not support the `smartmips' extension
20932098ec7SMarkos Chandras# Pass -Wa,--no-warn to disable all assembler warnings until the kernel code has
21032098ec7SMarkos Chandras# been fixed properly.
2115306a545SMarkos Chandrasmips-cflags				:= $(cflags-y)
2125306a545SMarkos Chandrasifeq ($(CONFIG_CPU_HAS_SMARTMIPS),y)
2135306a545SMarkos Chandrassmartmips-ase				:= $(call cc-option-yn,$(mips-cflags) -msmartmips)
2145306a545SMarkos Chandrascflags-$(smartmips-ase)			+= -msmartmips -Wa,--no-warn
2155306a545SMarkos Chandrasendif
2165306a545SMarkos Chandrasifeq ($(CONFIG_CPU_MICROMIPS),y)
2175306a545SMarkos Chandrasmicromips-ase				:= $(call cc-option-yn,$(mips-cflags) -mmicromips)
2185306a545SMarkos Chandrascflags-$(micromips-ase)			+= -mmicromips
2195306a545SMarkos Chandrasendif
22032098ec7SMarkos Chandrasifeq ($(CONFIG_CPU_HAS_MSA),y)
2215306a545SMarkos Chandrastoolchain-msa				:= $(call cc-option-yn,$(mips-cflags) -mhard-float -mfp64 -Wa$(comma)-mmsa)
22232098ec7SMarkos Chandrascflags-$(toolchain-msa)			+= -DTOOLCHAIN_SUPPORTS_MSA
22332098ec7SMarkos Chandrasendif
224bad50d79SJames Hogantoolchain-virt				:= $(call cc-option-yn,$(mips-cflags) -mvirt)
225bad50d79SJames Hogancflags-$(toolchain-virt)		+= -DTOOLCHAIN_SUPPORTS_VIRT
2268e4789d2SJames Hogan# For -mmicromips, use -Wa,-fatal-warnings to catch unsupported -mxpa which
2278e4789d2SJames Hogan# only warns
2288e4789d2SJames Hoganxpa-cflags-y				:= $(mips-cflags)
2298e4789d2SJames Hoganxpa-cflags-$(micromips-ase)		+= -mmicromips -Wa$(comma)-fatal-warnings
2308e4789d2SJames Hogantoolchain-xpa				:= $(call cc-option-yn,$(xpa-cflags-y) -mxpa)
2318e4789d2SJames Hogancflags-$(toolchain-xpa)			+= -DTOOLCHAIN_SUPPORTS_XPA
2324a5dc51eSMarcin Nowakowskitoolchain-crc				:= $(call cc-option-yn,$(mips-cflags) -Wa$(comma)-mcrc)
2334a5dc51eSMarcin Nowakowskicflags-$(toolchain-crc)			+= -DTOOLCHAIN_SUPPORTS_CRC
234edbb4233SPaul Burtontoolchain-dsp				:= $(call cc-option-yn,$(mips-cflags) -Wa$(comma)-mdsp)
235edbb4233SPaul Burtoncflags-$(toolchain-dsp)			+= -DTOOLCHAIN_SUPPORTS_DSP
23653511389SPaul Burtontoolchain-ginv				:= $(call cc-option-yn,$(mips-cflags) -Wa$(comma)-mginv)
23753511389SPaul Burtoncflags-$(toolchain-ginv)		+= -DTOOLCHAIN_SUPPORTS_GINV
23832098ec7SMarkos Chandras
2391da177e4SLinus Torvalds#
2401da177e4SLinus Torvalds# Firmware support
2411da177e4SLinus Torvalds#
2420e2794b0SRalf Baechlelibs-$(CONFIG_FW_ARC)		+= arch/mips/fw/arc/
2430e2794b0SRalf Baechlelibs-$(CONFIG_FW_CFE)		+= arch/mips/fw/cfe/
2440e2794b0SRalf Baechlelibs-$(CONFIG_FW_SNIPROM)	+= arch/mips/fw/sni/
245231a35d3SThomas Bogendoerferlibs-y				+= arch/mips/fw/lib/
2461da177e4SLinus Torvalds
2471da177e4SLinus Torvalds#
248ebc89718SRalf Baechle# Kernel compression
249ebc89718SRalf Baechle#
250809769a8SDaniel Sabogalifdef CONFIG_SYS_SUPPORTS_ZBOOT
251ebc89718SRalf BaechleCOMPRESSION_FNAME		= vmlinuz
252ebc89718SRalf Baechleelse
253ebc89718SRalf BaechleCOMPRESSION_FNAME		= vmlinux
254ebc89718SRalf Baechleendif
255ebc89718SRalf Baechle
256ebc89718SRalf Baechle#
2571da177e4SLinus Torvalds# Board-dependent options and extra files
2581da177e4SLinus Torvalds#
259a436bb7bSMasahiro Yamadainclude arch/mips/Kbuild.platforms
2607ca5dc14SFlorian Fainelli
261abe77f90SRalf Baechleifdef CONFIG_PHYSICAL_START
262abe77f90SRalf Baechleload-y					= $(CONFIG_PHYSICAL_START)
263abe77f90SRalf Baechleendif
2645fc9484fSPaul Burton
265e245767aSPaul Burtonentry-y				= $(shell $(objtree)/arch/mips/tools/elf-entry vmlinux)
266384740dcSRalf Baechlecflags-y			+= -I$(srctree)/arch/mips/include/asm/mach-generic
2671da177e4SLinus Torvaldsdrivers-$(CONFIG_PCI)		+= arch/mips/pci/
2681da177e4SLinus Torvalds
269adff90a9SFranck Bui-Huu#
270adff90a9SFranck Bui-Huu# Automatically detect the build format. By default we choose
271adff90a9SFranck Bui-Huu# the elf format according to the load address.
272adff90a9SFranck Bui-Huu# We can always force a build with a 64-bits symbol format by
273054c51b4SFranck Bui-Huu# passing 'KBUILD_SYM32=no' option to the make's command line.
274adff90a9SFranck Bui-Huu#
275adff90a9SFranck Bui-Huuifdef CONFIG_64BIT
276054c51b4SFranck Bui-Huu  ifndef KBUILD_SYM32
277adff90a9SFranck Bui-Huu    ifeq ($(shell expr $(load-y) \< 0xffffffff80000000), 0)
278054c51b4SFranck Bui-Huu      KBUILD_SYM32 = y
279adff90a9SFranck Bui-Huu    endif
280adff90a9SFranck Bui-Huu  endif
281adff90a9SFranck Bui-Huu
28220d60d99SMaciej W. Rozycki  ifeq ($(KBUILD_SYM32)$(call cc-option-yn,-msym32), yy)
283054c51b4SFranck Bui-Huu    cflags-y += -msym32 -DKBUILD_64BIT_SYM32
28420d60d99SMaciej W. Rozycki  else
28520d60d99SMaciej W. Rozycki    ifeq ($(CONFIG_CPU_DADDI_WORKAROUNDS), y)
28620d60d99SMaciej W. Rozycki      $(error CONFIG_CPU_DADDI_WORKAROUNDS unsupported without -msym32)
287adff90a9SFranck Bui-Huu    endif
288adff90a9SFranck Bui-Huu  endif
289e58d95abSFranck Bui-Huuendif
290adff90a9SFranck Bui-Huu
291222d394dSSam RavnborgKBUILD_AFLAGS	+= $(cflags-y)
29251b563fcSSam RavnborgKBUILD_CFLAGS	+= $(cflags-y)
293f7fc237eSMichal MarekKBUILD_CPPFLAGS += -DVMLINUX_LOAD_ADDRESS=$(load-y)
294f7fc237eSMichal MarekKBUILD_CPPFLAGS += -DDATAOFFSET=$(if $(dataoffset-y),$(dataoffset-y),0)
2951da177e4SLinus Torvalds
2963185557dSJames Hoganbootvars-y	= VMLINUX_LOAD_ADDRESS=$(load-y) \
297cf2a5e0bSPaul Burton		  VMLINUX_ENTRY_ADDRESS=$(entry-y) \
298436c6a44SPaul Burton		  PLATFORM="$(platform-y)" \
299436c6a44SPaul Burton		  ITS_INPUTS="$(its-y)"
300eed0eabdSPaul Burtonifdef CONFIG_32BIT
301eed0eabdSPaul Burtonbootvars-y	+= ADDR_BITS=32
302eed0eabdSPaul Burtonendif
303eed0eabdSPaul Burtonifdef CONFIG_64BIT
304eed0eabdSPaul Burtonbootvars-y	+= ADDR_BITS=64
305eed0eabdSPaul Burtonendif
3063185557dSJames Hogan
307866b6a89SCorey Minyard# This is required to get dwarf unwinding tables into .debug_frame
308866b6a89SCorey Minyard# instead of .eh_frame so we don't discard them.
309866b6a89SCorey MinyardKBUILD_CFLAGS += -fno-asynchronous-unwind-tables
310866b6a89SCorey Minyard
311d503ac53SMasahiro YamadaKBUILD_LDFLAGS		+= -m $(ld-emul)
3121da177e4SLinus Torvalds
31359b3e8e9SRalf Baechleifdef CONFIG_MIPS
314a0f97e06SSam RavnborgCHECKFLAGS += $(shell $(CC) $(KBUILD_CFLAGS) -dM -E -x c /dev/null | \
31548c35b2dSAlexey Dobriyan	egrep -vw '__GNUC_(|MINOR_|PATCHLEVEL_)_' | \
31673d8f99cSAaro Koskinen	sed -e "s/^\#define /-D'/" -e "s/ /'='/" -e "s/$$/'/" -e 's/\$$/&&/g')
31759b3e8e9SRalf Baechleendif
31859b3e8e9SRalf Baechle
3191da177e4SLinus TorvaldsOBJCOPYFLAGS		+= --remove-section=.reginfo
3201da177e4SLinus Torvalds
321957b369cSThomas Gleixnerhead-y := arch/mips/kernel/head.o
3221da177e4SLinus Torvalds
3231da177e4SLinus Torvaldslibs-y			+= arch/mips/lib/
32442b10815SPaul Burtonlibs-$(CONFIG_MIPS_FP_SUPPORT) += arch/mips/math-emu/
3251da177e4SLinus Torvalds
3269aeb404bSSam Ravnborg# See arch/mips/Kbuild for content of core part of the kernel
3279aeb404bSSam Ravnborgcore-y += arch/mips/
3281da177e4SLinus Torvalds
3294a5dc51eSMarcin Nowakowskidrivers-$(CONFIG_MIPS_CRC_SUPPORT) += arch/mips/crypto/
3301da177e4SLinus Torvaldsdrivers-$(CONFIG_OPROFILE)	+= arch/mips/oprofile/
3311da177e4SLinus Torvalds
332363c55caSWu Zhangjin# suspend and hibernation support
333363c55caSWu Zhangjindrivers-$(CONFIG_PM)	+= arch/mips/power/
334363c55caSWu Zhangjin
33538d2d649SJames Hogan# boot image targets (arch/mips/boot/)
33638d2d649SJames Hoganboot-y			:= vmlinux.bin
33738d2d649SJames Hoganboot-y			+= vmlinux.ecoff
33838d2d649SJames Hoganboot-y			+= vmlinux.srec
3394defe455SJames Hoganifeq ($(shell expr $(load-y) \< 0xffffffff80000000 2> /dev/null), 0)
3404defe455SJames Hoganboot-y			+= uImage
3419d6b80faSMarkos Chandrasboot-y			+= uImage.bin
3429d6b80faSMarkos Chandrasboot-y			+= uImage.bz2
3434defe455SJames Hoganboot-y			+= uImage.gz
3449d6b80faSMarkos Chandrasboot-y			+= uImage.lzma
3459d6b80faSMarkos Chandrasboot-y			+= uImage.lzo
3464defe455SJames Hoganendif
347cf2a5e0bSPaul Burtonboot-y			+= vmlinux.itb
348cf2a5e0bSPaul Burtonboot-y			+= vmlinux.gz.itb
349cf2a5e0bSPaul Burtonboot-y			+= vmlinux.bz2.itb
350cf2a5e0bSPaul Burtonboot-y			+= vmlinux.lzma.itb
351cf2a5e0bSPaul Burtonboot-y			+= vmlinux.lzo.itb
35238d2d649SJames Hogan
35338d2d649SJames Hogan# compressed boot image targets (arch/mips/boot/compressed/)
35438d2d649SJames Hoganbootz-y			:= vmlinuz
35538d2d649SJames Hoganbootz-y			+= vmlinuz.bin
35638d2d649SJames Hoganbootz-y			+= vmlinuz.ecoff
35738d2d649SJames Hoganbootz-y			+= vmlinuz.srec
358ccebb88aSMaarten ter Huurneifeq ($(shell expr $(zload-y) \< 0xffffffff80000000 2> /dev/null), 0)
359ccebb88aSMaarten ter Huurnebootz-y			+= uzImage.bin
360ccebb88aSMaarten ter Huurneendif
36138d2d649SJames Hogan
3621f21d2bdSBrian Murphyifdef CONFIG_LASAT
3631f21d2bdSBrian Murphyrom.bin rom.sw: vmlinux
3643185557dSJames Hogan	$(Q)$(MAKE) $(build)=arch/mips/lasat/image \
3653185557dSJames Hogan		$(bootvars-y) $@
3661f21d2bdSBrian Murphyendif
3671f21d2bdSBrian Murphy
3681da177e4SLinus Torvalds#
3691da177e4SLinus Torvalds# Some machines like the Indy need 32-bit ELF binaries for booting purposes.
3701da177e4SLinus Torvalds# Other need ECOFF, so we build a 32-bit ELF binary for them which we then
3711da177e4SLinus Torvalds# convert to ECOFF using elf2ecoff.
3721da177e4SLinus Torvalds#
373007fbbeaSWu Zhangjinquiet_cmd_32 = OBJCOPY $@
374007fbbeaSWu Zhangjin	cmd_32 = $(OBJCOPY) -O $(32bit-bfd) $(OBJCOPYFLAGS) $< $@
3751da177e4SLinus Torvaldsvmlinux.32: vmlinux
376007fbbeaSWu Zhangjin	$(call cmd,32)
3771da177e4SLinus Torvalds
3781da177e4SLinus Torvalds#
3791da177e4SLinus Torvalds# The 64-bit ELF tools are pretty broken so at this time we generate 64-bit
3801da177e4SLinus Torvalds# ELF files from 32-bit files by conversion.
3811da177e4SLinus Torvalds#
382007fbbeaSWu Zhangjinquiet_cmd_64 = OBJCOPY $@
383007fbbeaSWu Zhangjin	cmd_64 = $(OBJCOPY) -O $(64bit-bfd) $(OBJCOPYFLAGS) $< $@
3841da177e4SLinus Torvaldsvmlinux.64: vmlinux
385007fbbeaSWu Zhangjin	$(call cmd,64)
3861da177e4SLinus Torvalds
387637dfa0fSCedric Hombourgerall:	$(all-y) $(KBUILD_DTBS)
3881da177e4SLinus Torvalds
38935eaa1e9SSam Ravnborg# boot
39038d2d649SJames Hogan$(boot-y): $(vmlinux-32) FORCE
3913185557dSJames Hogan	$(Q)$(MAKE) $(build)=arch/mips/boot VMLINUX=$(vmlinux-32) \
3923185557dSJames Hogan		$(bootvars-y) arch/mips/boot/$@
3931da177e4SLinus Torvalds
39426fca83aSFlorian Fainelliifdef CONFIG_SYS_SUPPORTS_ZBOOT
39535eaa1e9SSam Ravnborg# boot/compressed
39638d2d649SJames Hogan$(bootz-y): $(vmlinux-32) FORCE
39735eaa1e9SSam Ravnborg	$(Q)$(MAKE) $(build)=arch/mips/boot/compressed \
3983185557dSJames Hogan		$(bootvars-y) 32bit-bfd=$(32bit-bfd) $@
39926fca83aSFlorian Fainellielse
40026fca83aSFlorian Fainellivmlinuz: FORCE
40126fca83aSFlorian Fainelli	@echo '   CONFIG_SYS_SUPPORTS_ZBOOT is not enabled'
40226fca83aSFlorian Fainelli	/bin/false
40326fca83aSFlorian Fainelliendif
40435eaa1e9SSam Ravnborg
40535eaa1e9SSam Ravnborg
406d745866eSSam RavnborgCLEAN_FILES += vmlinux.32 vmlinux.64
4071da177e4SLinus Torvalds
4087fafb068SAndrew Bresticker# device-trees
40937c8a5faSRob Herringcore-y += arch/mips/boot/dts/
410c8d333dfSAndrew Bresticker
411e48ce6b8SAtsushi Nemotoarchprepare:
412e48ce6b8SAtsushi Nemotoifdef CONFIG_MIPS32_N32
4138c9b23ffSArnd Bergmann	@$(kecho) '  Checking missing-syscalls for N32'
41444656fa0SDavid Daney	$(Q)$(MAKE) $(build)=. missing-syscalls missing_syscalls_flags="-mabi=n32"
415e48ce6b8SAtsushi Nemotoendif
416e48ce6b8SAtsushi Nemotoifdef CONFIG_MIPS32_O32
4178c9b23ffSArnd Bergmann	@$(kecho) '  Checking missing-syscalls for O32'
41844656fa0SDavid Daney	$(Q)$(MAKE) $(build)=. missing-syscalls missing_syscalls_flags="-mabi=32"
419e48ce6b8SAtsushi Nemotoendif
420e48ce6b8SAtsushi Nemoto
42159968d3bSRalf Baechleinstall:
42259968d3bSRalf Baechle	$(Q)install -D -m 755 vmlinux $(INSTALL_PATH)/vmlinux-$(KERNELRELEASE)
423d9beeecaSRalf Baechleifdef CONFIG_SYS_SUPPORTS_ZBOOT
4241b93b3c3SWu Zhangjin	$(Q)install -D -m 755 vmlinuz $(INSTALL_PATH)/vmlinuz-$(KERNELRELEASE)
425d9beeecaSRalf Baechleendif
42659968d3bSRalf Baechle	$(Q)install -D -m 644 .config $(INSTALL_PATH)/config-$(KERNELRELEASE)
42759968d3bSRalf Baechle	$(Q)install -D -m 644 System.map $(INSTALL_PATH)/System.map-$(KERNELRELEASE)
42859968d3bSRalf Baechle
4291da177e4SLinus Torvaldsarchclean:
430d745866eSSam Ravnborg	$(Q)$(MAKE) $(clean)=arch/mips/boot
431d745866eSSam Ravnborg	$(Q)$(MAKE) $(clean)=arch/mips/boot/compressed
432aadeec4dSMatt Redfearn	$(Q)$(MAKE) $(clean)=arch/mips/boot/tools
433d745866eSSam Ravnborg	$(Q)$(MAKE) $(clean)=arch/mips/lasat
4341da177e4SLinus Torvalds
43599bf73ebSFiroz Khanarchheaders:
43699bf73ebSFiroz Khan	$(Q)$(MAKE) $(build)=arch/mips/kernel/syscalls all
43799bf73ebSFiroz Khan
438e7865765SRalf Baechledefine archhelp
43959968d3bSRalf Baechle	echo '  install              - install kernel into $(INSTALL_PATH)'
440e7865765SRalf Baechle	echo '  vmlinux.ecoff        - ECOFF boot image'
441e7865765SRalf Baechle	echo '  vmlinux.bin          - Raw binary boot image'
442e7865765SRalf Baechle	echo '  vmlinux.srec         - SREC boot image'
44378931652SJoshua Kinard	echo '  vmlinux.32           - 64-bit boot image wrapped in 32bits (IP22/IP32)'
4441b93b3c3SWu Zhangjin	echo '  vmlinuz              - Compressed boot(zboot) image'
4451b93b3c3SWu Zhangjin	echo '  vmlinuz.ecoff        - ECOFF zboot image'
4461b93b3c3SWu Zhangjin	echo '  vmlinuz.bin          - Raw binary zboot image'
4471b93b3c3SWu Zhangjin	echo '  vmlinuz.srec         - SREC zboot image'
4484defe455SJames Hogan	echo '  uImage               - U-Boot image'
4499d6b80faSMarkos Chandras	echo '  uImage.bin           - U-Boot image (uncompressed)'
4509d6b80faSMarkos Chandras	echo '  uImage.bz2           - U-Boot image (bz2)'
4514defe455SJames Hogan	echo '  uImage.gz            - U-Boot image (gzip)'
4529d6b80faSMarkos Chandras	echo '  uImage.lzma          - U-Boot image (lzma)'
4539d6b80faSMarkos Chandras	echo '  uImage.lzo           - U-Boot image (lzo)'
454ccebb88aSMaarten ter Huurne	echo '  uzImage.bin          - U-Boot image (self-extracting)'
455e7865765SRalf Baechle	echo
45625985edcSLucas De Marchi	echo '  These will be default as appropriate for a configured platform.'
457eed0eabdSPaul Burton	echo
458eed0eabdSPaul Burton	echo '  If you are targeting a system supported by generic kernels you may'
459eed0eabdSPaul Burton	echo '  configure the kernel for a given architecture target like so:'
460eed0eabdSPaul Burton	echo
461eed0eabdSPaul Burton	echo '  {micro32,32,64}{r1,r2,r6}{el,}_defconfig <BOARDS="list of boards">'
462eed0eabdSPaul Burton	echo
463cccd0b9aSJames Hogan	echo '  Where BOARDS is some subset of the following:'
464cccd0b9aSJames Hogan	for board in $(sort $(BOARDS)); do echo "    $${board}"; done
465cccd0b9aSJames Hogan	echo
466cccd0b9aSJames Hogan	echo '  Specifically the following generic default configurations are'
467cccd0b9aSJames Hogan	echo '  supported:'
468cccd0b9aSJames Hogan	echo
469cccd0b9aSJames Hogan	$(foreach cfg,$(generic_defconfigs),
470cccd0b9aSJames Hogan	  printf "  %-24s - Build generic kernel for $(call describe_generic_defconfig,$(cfg))\n" $(cfg);)
471cccd0b9aSJames Hogan	echo
472cccd0b9aSJames Hogan	echo '  The following legacy default configurations have been converted to'
473cccd0b9aSJames Hogan	echo '  generic and can still be used:'
474cccd0b9aSJames Hogan	echo
475cccd0b9aSJames Hogan	$(foreach cfg,$(sort $(legacy_defconfigs)),
476cccd0b9aSJames Hogan	  printf "  %-24s - Build $($(cfg)-y)\n" $(cfg);)
477cccd0b9aSJames Hogan	echo
478eed0eabdSPaul Burton	echo '  Otherwise, the following default configurations are available:'
479e7865765SRalf Baechleendef
480eed0eabdSPaul Burton
481eed0eabdSPaul Burtongeneric_config_dir = $(srctree)/arch/$(ARCH)/configs/generic
482eed0eabdSPaul Burtongeneric_defconfigs :=
483eed0eabdSPaul Burton
484eed0eabdSPaul Burton#
485eed0eabdSPaul Burton# If the user generates a generic kernel configuration without specifying a
486eed0eabdSPaul Burton# list of boards to include the config fragments for, default to including all
487eed0eabdSPaul Burton# available board config fragments.
488eed0eabdSPaul Burton#
489eed0eabdSPaul Burtonifeq ($(BOARDS),)
490eed0eabdSPaul BurtonBOARDS = $(patsubst board-%.config,%,$(notdir $(wildcard $(generic_config_dir)/board-*.config)))
491eed0eabdSPaul Burtonendif
492eed0eabdSPaul Burton
493eed0eabdSPaul Burton#
494eed0eabdSPaul Burton# Generic kernel configurations which merge generic_defconfig with the
495eed0eabdSPaul Burton# appropriate config fragments from arch/mips/configs/generic/, resulting in
496eed0eabdSPaul Burton# the ability to easily configure the kernel for a given architecture,
497eed0eabdSPaul Burton# endianness & set of boards without duplicating the needed configuration in
498eed0eabdSPaul Burton# hundreds of defconfig files.
499eed0eabdSPaul Burton#
500eed0eabdSPaul Burtondefine gen_generic_defconfigs
501eed0eabdSPaul Burton$(foreach bits,$(1),$(foreach rev,$(2),$(foreach endian,$(3),
502eed0eabdSPaul Burtontarget := $(bits)$(rev)$(filter el,$(endian))_defconfig
503eed0eabdSPaul Burtongeneric_defconfigs += $$(target)
504eed0eabdSPaul Burton$$(target): $(generic_config_dir)/$(bits)$(rev).config
505eed0eabdSPaul Burton$$(target): $(generic_config_dir)/$(endian).config
506eed0eabdSPaul Burton)))
507eed0eabdSPaul Burtonendef
508eed0eabdSPaul Burton
509eed0eabdSPaul Burton$(eval $(call gen_generic_defconfigs,32 64,r1 r2 r6,eb el))
510eed0eabdSPaul Burton$(eval $(call gen_generic_defconfigs,micro32,r2,eb el))
511eed0eabdSPaul Burton
512cccd0b9aSJames Hogandefine describe_generic_defconfig
513cccd0b9aSJames Hogan$(subst 32r,MIPS32 r,$(subst 64r,MIPS64 r,$(subst el, little endian,$(patsubst %_defconfig,%,$(1)))))
514cccd0b9aSJames Hoganendef
515cccd0b9aSJames Hogan
516eed0eabdSPaul Burton.PHONY: $(generic_defconfigs)
517eed0eabdSPaul Burton$(generic_defconfigs):
518eed0eabdSPaul Burton	$(Q)$(CONFIG_SHELL) $(srctree)/scripts/kconfig/merge_config.sh \
51927e0d4b0SPaul Burton		-m -O $(objtree) $(srctree)/arch/$(ARCH)/configs/generic_defconfig $^ | \
52027e0d4b0SPaul Burton		grep -Ev '^#'
52127e0d4b0SPaul Burton	$(Q)cp $(KCONFIG_CONFIG) $(objtree)/.config.$@
52227e0d4b0SPaul Burton	$(Q)$(MAKE) -f $(srctree)/Makefile olddefconfig \
52327e0d4b0SPaul Burton		KCONFIG_CONFIG=$(objtree)/.config.$@ >/dev/null
52427e0d4b0SPaul Burton	$(Q)$(CONFIG_SHELL) $(srctree)/arch/$(ARCH)/tools/generic-board-config.sh \
52527e0d4b0SPaul Burton		$(srctree) $(objtree) $(objtree)/.config.$@ $(KCONFIG_CONFIG) \
52627e0d4b0SPaul Burton		"$(origin BOARDS)" $(BOARDS)
527337b775bSMarcin Nowakowski	$(Q)$(MAKE) -f $(srctree)/Makefile olddefconfig
528eed0eabdSPaul Burton
529eed0eabdSPaul Burton#
530eed0eabdSPaul Burton# Prevent generic merge_config rules attempting to merge single fragments
531eed0eabdSPaul Burton#
532eed0eabdSPaul Burton$(generic_config_dir)/%.config: ;
5333f5f0a44SPaul Burton
5343f5f0a44SPaul Burton#
535a4c2f797SPaul Burton# Prevent direct use of generic_defconfig, which is intended to be used as the
536a4c2f797SPaul Burton# basis of the various ISA-specific targets generated above.
537a4c2f797SPaul Burton#
538a4c2f797SPaul Burton.PHONY: generic_defconfig
539a4c2f797SPaul Burtongeneric_defconfig:
540a4c2f797SPaul Burton	$(Q)echo "generic_defconfig is not intended for direct use, but should instead be"
541a4c2f797SPaul Burton	$(Q)echo "used via an ISA-specific target from the following list:"
542a4c2f797SPaul Burton	$(Q)echo
543a4c2f797SPaul Burton	$(Q)for cfg in $(generic_defconfigs); do echo "  $${cfg}"; done
544a4c2f797SPaul Burton	$(Q)echo
545a4c2f797SPaul Burton	$(Q)false
546a4c2f797SPaul Burton
547a4c2f797SPaul Burton#
5483f5f0a44SPaul Burton# Legacy defconfig compatibility - these targets used to be real defconfigs but
5493f5f0a44SPaul Burton# now that the boards have been converted to use the generic kernel they are
5503f5f0a44SPaul Burton# wrappers around the generic rules above.
5513f5f0a44SPaul Burton#
5526bce3deaSAlexandre Bellonilegacy_defconfigs		+= ocelot_defconfig
5536bce3deaSAlexandre Belloniocelot_defconfig-y		:= 32r2el_defconfig BOARDS=ocelot
5546bce3deaSAlexandre Belloni
555318df806SJames Hoganlegacy_defconfigs		+= sead3_defconfig
556318df806SJames Hogansead3_defconfig-y		:= 32r2el_defconfig BOARDS=sead-3
5573f5f0a44SPaul Burton
558318df806SJames Hoganlegacy_defconfigs		+= sead3micro_defconfig
559318df806SJames Hogansead3micro_defconfig-y		:= micro32r2el_defconfig BOARDS=sead-3
5600861aa12SZubair Lutfullah Kakakhel
561318df806SJames Hoganlegacy_defconfigs		+= xilfpga_defconfig
562318df806SJames Hoganxilfpga_defconfig-y		:= 32r2el_defconfig BOARDS=xilfpga
563318df806SJames Hogan
564318df806SJames Hogan.PHONY: $(legacy_defconfigs)
565318df806SJames Hogan$(legacy_defconfigs):
566318df806SJames Hogan	$(Q)$(MAKE) -f $(srctree)/Makefile $($@-y)
567