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 118212f898SMasahiro Yamada# architecture-specific flags and dependencies. 121da177e4SLinus Torvalds# 131da177e4SLinus Torvalds 14aadeec4dSMatt Redfearnarchscripts: scripts_basic 15e245767aSPaul Burton $(Q)$(MAKE) $(build)=arch/mips/tools elf-entry 16e4acfbc1SPaul Burtonifeq ($(CONFIG_CPU_LOONGSON3_WORKAROUNDS),y) 17e4acfbc1SPaul Burton $(Q)$(MAKE) $(build)=arch/mips/tools loongson3-llsc-check 18e4acfbc1SPaul Burtonendif 19aadeec4dSMatt Redfearn $(Q)$(MAKE) $(build)=arch/mips/boot/tools relocs 20aadeec4dSMatt Redfearn 2104d8405eSMatt RedfearnKBUILD_DEFCONFIG := 32r2el_defconfig 22637dfa0fSCedric HombourgerKBUILD_DTBS := dtbs 23de0c1698SAdrian Bunk 241da177e4SLinus Torvalds# 251da177e4SLinus Torvalds# Select the object file format to substitute into the linker script. 261da177e4SLinus Torvalds# 271da177e4SLinus Torvaldsifdef CONFIG_CPU_LITTLE_ENDIAN 2817f690beSRalf Baechle32bit-tool-archpref = mipsel 2917f690beSRalf Baechle64bit-tool-archpref = mips64el 301da177e4SLinus Torvalds32bit-bfd = elf32-tradlittlemips 311da177e4SLinus Torvalds64bit-bfd = elf64-tradlittlemips 321da177e4SLinus Torvalds32bit-emul = elf32ltsmip 331da177e4SLinus Torvalds64bit-emul = elf64ltsmip 341da177e4SLinus Torvaldselse 3517f690beSRalf Baechle32bit-tool-archpref = mips 3617f690beSRalf Baechle64bit-tool-archpref = mips64 371da177e4SLinus Torvalds32bit-bfd = elf32-tradbigmips 381da177e4SLinus Torvalds64bit-bfd = elf64-tradbigmips 391da177e4SLinus Torvalds32bit-emul = elf32btsmip 401da177e4SLinus Torvalds64bit-emul = elf64btsmip 411da177e4SLinus Torvaldsendif 421da177e4SLinus Torvalds 43875d43e7SRalf Baechleifdef CONFIG_32BIT 4417f690beSRalf Baechletool-archpref = $(32bit-tool-archpref) 451da177e4SLinus TorvaldsUTS_MACHINE := mips 461da177e4SLinus Torvaldsendif 47875d43e7SRalf Baechleifdef CONFIG_64BIT 4817f690beSRalf Baechletool-archpref = $(64bit-tool-archpref) 491da177e4SLinus TorvaldsUTS_MACHINE := mips64 501da177e4SLinus Torvaldsendif 511da177e4SLinus Torvalds 5223243c1aSMasahiro Yamadaifdef cross_compiling 5317f690beSRalf Baechle ifeq ($(CROSS_COMPILE),) 543247989eSMaciej W. Rozycki CROSS_COMPILE := $(call cc-cross-prefix, $(tool-archpref)-linux- $(tool-archpref)-linux-gnu- $(tool-archpref)-unknown-linux-gnu-) 5517f690beSRalf Baechle endif 561da177e4SLinus Torvaldsendif 571da177e4SLinus Torvalds 587326c4e5SWu Zhangjinifdef CONFIG_FUNCTION_GRAPH_TRACER 597326c4e5SWu Zhangjin ifndef KBUILD_MCOUNT_RA_ADDRESS 607326c4e5SWu Zhangjin ifeq ($(call cc-option-yn,-mmcount-ra-address), y) 617326c4e5SWu Zhangjin cflags-y += -mmcount-ra-address -DKBUILD_MCOUNT_RA_ADDRESS 627326c4e5SWu Zhangjin endif 637326c4e5SWu Zhangjin endif 647326c4e5SWu Zhangjinendif 651a4ba061SRalf Baechlecflags-y += $(call cc-option, -mno-check-zero-division) 6605e41404SRalf Baechle 678145095cSRalf Baechleifdef CONFIG_32BIT 681da177e4SLinus Torvaldsld-emul = $(32bit-emul) 691da177e4SLinus Torvaldsvmlinux-32 = vmlinux 701da177e4SLinus Torvaldsvmlinux-64 = vmlinux.64 7159b3e8e9SRalf Baechle 7259b3e8e9SRalf Baechlecflags-y += -mabi=32 738145095cSRalf Baechleendif 741da177e4SLinus Torvalds 758145095cSRalf Baechleifdef CONFIG_64BIT 768145095cSRalf Baechleld-emul = $(64bit-emul) 778145095cSRalf Baechlevmlinux-32 = vmlinux.32 788145095cSRalf Baechlevmlinux-64 = vmlinux 798145095cSRalf Baechle 8059b3e8e9SRalf Baechlecflags-y += -mabi=64 8159b3e8e9SRalf Baechleendif 8259b3e8e9SRalf Baechle 838496b401SRalf Baechleall-$(CONFIG_BOOT_ELF32) := $(vmlinux-32) 848496b401SRalf Baechleall-$(CONFIG_BOOT_ELF64) := $(vmlinux-64) 851b93b3c3SWu Zhangjinall-$(CONFIG_SYS_SUPPORTS_ZBOOT)+= vmlinuz 861da177e4SLinus Torvalds 871da177e4SLinus Torvalds# 881da177e4SLinus Torvalds# GCC uses -G 0 -mabicalls -fpic as default. We don't want PIC in the kernel 891da177e4SLinus Torvalds# code since it only slows down the whole thing. At some point we might make 901da177e4SLinus Torvalds# use of global pointer optimizations but their use of $28 conflicts with 911da177e4SLinus Torvalds# the current pointer optimization. 921da177e4SLinus Torvalds# 931da177e4SLinus Torvalds# The DECStation requires an ECOFF kernel for remote booting, other MIPS 941da177e4SLinus Torvalds# machines may also. Since BFD is incredibly buggy with respect to 951da177e4SLinus Torvalds# crossformat linking we rely on the elf2ecoff tool for format conversion. 961da177e4SLinus Torvalds# 971da177e4SLinus Torvaldscflags-y += -G 0 -mno-abicalls -fno-pic -pipe 9880a20d2fSNathan Chancellorcflags-y += -msoft-float -Wa,-msoft-float 999f83d839SThiemo SeuferLDFLAGS_vmlinux += -G 0 -static -n -nostdlib 1006588169dSSam RavnborgKBUILD_AFLAGS_MODULE += -mlong-calls 1016588169dSSam RavnborgKBUILD_CFLAGS_MODULE += -mlong-calls 1021da177e4SLinus Torvalds 103e818fac5SMatt Redfearnifeq ($(CONFIG_RELOCATABLE),y) 104e818fac5SMatt RedfearnLDFLAGS_vmlinux += --emit-relocs 105e818fac5SMatt Redfearnendif 106e818fac5SMatt Redfearn 10772fbfb26SRalf Baechlecflags-y += -ffreestanding 10872fbfb26SRalf Baechle 109c6d6f4c5SPaul Burtoncflags-$(CONFIG_CPU_BIG_ENDIAN) += -EB 110c6d6f4c5SPaul Burtoncflags-$(CONFIG_CPU_LITTLE_ENDIAN) += -EL 111f425a6dcSThiemo Seufer 1129007c9a2SRalf Baechlecflags-$(CONFIG_SB1XXX_CORELIS) += $(call cc-option,-mno-sched-prolog) \ 1139007c9a2SRalf Baechle -fno-omit-frame-pointer 114573deec0SJoshua Kinard 115573deec0SJoshua Kinard# Some distribution-specific toolchains might pass the -fstack-check 116573deec0SJoshua Kinard# option during the build, which adds a simple stack-probe at the beginning 117573deec0SJoshua Kinard# of every function. This stack probe is to ensure that there is enough 118573deec0SJoshua Kinard# stack space, else a SEGV is generated. This is not desirable for MIPS 119573deec0SJoshua Kinard# as kernel stacks are small, placed in unmapped virtual memory, and do not 120573deec0SJoshua Kinard# grow when overflowed. Especially on SGI IP27 platforms, this check will 121573deec0SJoshua Kinard# lead to a NULL pointer dereference in _raw_spin_lock_irq. 122573deec0SJoshua Kinard# 123573deec0SJoshua Kinard# In disassembly, this stack probe appears at the top of a function as: 124573deec0SJoshua Kinard# sd zero,<offset>(sp) 125573deec0SJoshua Kinard# Where <offset> is a negative value. 126573deec0SJoshua Kinard# 127573deec0SJoshua Kinardcflags-y += -fno-stack-check 128573deec0SJoshua Kinard 1295373ae67SAurelien Jarno# binutils from v2.35 when built with --enable-mips-fix-loongson3-llsc=yes, 1305373ae67SAurelien Jarno# supports an -mfix-loongson3-llsc flag which emits a sync prior to each ll 1315373ae67SAurelien Jarno# instruction to work around a CPU bug (see __SYNC_loongson3_war in asm/sync.h 1325373ae67SAurelien Jarno# for a description). 1335373ae67SAurelien Jarno# 1345373ae67SAurelien Jarno# We disable this in order to prevent the assembler meddling with the 1355373ae67SAurelien Jarno# instruction that labels refer to, ie. if we label an ll instruction: 1365373ae67SAurelien Jarno# 1375373ae67SAurelien Jarno# 1: ll v0, 0(a0) 1385373ae67SAurelien Jarno# 1395373ae67SAurelien Jarno# ...then with the assembler fix applied the label may actually point at a sync 1405373ae67SAurelien Jarno# instruction inserted by the assembler, and if we were using the label in an 1415373ae67SAurelien Jarno# exception table the table would no longer contain the address of the ll 1425373ae67SAurelien Jarno# instruction. 1435373ae67SAurelien Jarno# 1445373ae67SAurelien Jarno# Avoid this by explicitly disabling that assembler behaviour. 1455373ae67SAurelien Jarno# 146337ff6bbSNathan Chancellorcflags-y += $(call cc-option,-Wa$(comma)-mno-fix-loongson3-llsc,) 1475373ae67SAurelien Jarno 1481da177e4SLinus Torvalds# 1491da177e4SLinus Torvalds# CPU-dependent compiler/assembler options for optimization. 1501da177e4SLinus Torvalds# 151bfc0a330SJiaxun Yangcflags-$(CONFIG_CPU_R3000) += $(call cc-option,-march=r3000,-march=mips1) 152bfc0a330SJiaxun Yangcflags-$(CONFIG_CPU_R4300) += $(call cc-option,-march=r4300,-march=mips3) -Wa,--trap 153bfc0a330SJiaxun Yangcflags-$(CONFIG_CPU_R4X00) += $(call cc-option,-march=r4600,-march=mips3) -Wa,--trap 154bfc0a330SJiaxun Yangcflags-$(CONFIG_CPU_TX49XX) += $(call cc-option,-march=r4600,-march=mips3) -Wa,--trap 155344ebf09SPaul Burtoncflags-$(CONFIG_CPU_MIPS32_R1) += -march=mips32 -Wa,--trap 156344ebf09SPaul Burtoncflags-$(CONFIG_CPU_MIPS32_R2) += -march=mips32r2 -Wa,--trap 157ab7c01fdSSerge Semincflags-$(CONFIG_CPU_MIPS32_R5) += -march=mips32r5 -Wa,--trap -modd-spreg 15821855a6eSMiodrag Diniccflags-$(CONFIG_CPU_MIPS32_R6) += -march=mips32r6 -Wa,--trap -modd-spreg 159344ebf09SPaul Burtoncflags-$(CONFIG_CPU_MIPS64_R1) += -march=mips64 -Wa,--trap 160344ebf09SPaul Burtoncflags-$(CONFIG_CPU_MIPS64_R2) += -march=mips64r2 -Wa,--trap 161ab7c01fdSSerge Semincflags-$(CONFIG_CPU_MIPS64_R5) += -march=mips64r5 -Wa,--trap 1627fd08ca5SLeonid Yegoshincflags-$(CONFIG_CPU_MIPS64_R6) += -march=mips64r6 -Wa,--trap 163bfc0a330SJiaxun Yangcflags-$(CONFIG_CPU_P5600) += $(call cc-option,-march=p5600,-march=mips32r5) \ 164bfc0a330SJiaxun Yang -Wa,--trap -modd-spreg 165bfc0a330SJiaxun Yangcflags-$(CONFIG_CPU_R5000) += $(call cc-option,-march=r5000,-march=mips4) \ 166542c1020SShinya Kuribayashi -Wa,--trap 167bfc0a330SJiaxun Yangcflags-$(CONFIG_CPU_R5500) += $(call cc-option,-march=r5500,-march=mips4) \ 1681da177e4SLinus Torvalds -Wa,--trap 169bfc0a330SJiaxun Yangcflags-$(CONFIG_CPU_NEVADA) += $(call cc-option,-march=rm5200,-march=mips4) \ 1701da177e4SLinus Torvalds -Wa,--trap 171bfc0a330SJiaxun Yangcflags-$(CONFIG_CPU_RM7000) += $(call cc-option,-march=rm7000,-march=mips4) \ 172bfc0a330SJiaxun Yang -Wa,--trap 173*2326c8f2SJiaxun Yangcflags-$(CONFIG_CPU_SB1) += $(call cc-option,-march=sb1,-march=mips64) \ 1741da177e4SLinus Torvalds -Wa,--trap 175b625cd4aSMaciej W. Rozyckicflags-$(CONFIG_CPU_SB1) += $(call cc-option,-mno-mdmx) 176b625cd4aSMaciej W. Rozyckicflags-$(CONFIG_CPU_SB1) += $(call cc-option,-mno-mips3d) 177bfc0a330SJiaxun Yangcflags-$(CONFIG_CPU_R10000) += $(call cc-option,-march=r10000,-march=mips4) \ 1781da177e4SLinus Torvalds -Wa,--trap 1791d59822aSJiaxun Yangcflags-$(CONFIG_CPU_CAVIUM_OCTEON) += -march=octeon -Wa,--trap 180c9941158SDavid Daneycflags-$(CONFIG_CAVIUM_CN63XXP1) += -Wa,-mfix-cn63xxp1 181e7a30874SJiaxun Yangcflags-$(CONFIG_CPU_BMIPS) += -march=mips32 -Wa,--trap 1821da177e4SLinus Torvalds 183bfc0a330SJiaxun Yangcflags-$(CONFIG_CPU_LOONGSON2E) += \ 184bfc0a330SJiaxun Yang $(call cc-option,-march=loongson2e,-march=mips3) -Wa,--trap 185bfc0a330SJiaxun Yangcflags-$(CONFIG_CPU_LOONGSON2F) += \ 186bfc0a330SJiaxun Yang $(call cc-option,-march=loongson2f,-march=mips3) -Wa,--trap 187194a8352SJiaxun Yang# Some -march= flags enable MMI instructions, and GCC complains about that 188194a8352SJiaxun Yang# support being enabled alongside -msoft-float. Thus explicitly disable MMI. 189194a8352SJiaxun Yangcflags-$(CONFIG_CPU_LOONGSON2EF) += $(call cc-option,-mno-loongson-mmi) 1908a618697SJiaxun Yangcflags-$(CONFIG_CPU_LOONGSON64) += \ 1918a618697SJiaxun Yang $(call cc-option,-march=loongson3a,-march=mips64r2) -Wa,--trap 192194a8352SJiaxun Yangcflags-$(CONFIG_CPU_LOONGSON64) += $(call cc-option,-mno-loongson-mmi) 193194a8352SJiaxun Yang 19420d60d99SMaciej W. Rozyckicflags-$(CONFIG_CPU_R4000_WORKAROUNDS) += $(call cc-option,-mfix-r4000,) 19520d60d99SMaciej W. Rozyckicflags-$(CONFIG_CPU_R4400_WORKAROUNDS) += $(call cc-option,-mfix-r4400,) 19620d60d99SMaciej W. Rozyckicflags-$(CONFIG_CPU_DADDI_WORKAROUNDS) += $(call cc-option,-mno-daddi,) 197194a8352SJiaxun Yangifdef CONFIG_CPU_LOONGSON2F_WORKAROUNDS 198194a8352SJiaxun Yangcflags-$(CONFIG_CPU_NOP_WORKAROUNDS) += -Wa,-mfix-loongson2f-nop 199194a8352SJiaxun Yangcflags-$(CONFIG_CPU_JUMP_WORKAROUNDS) += -Wa,-mfix-loongson2f-jump 200194a8352SJiaxun Yangendif 201194a8352SJiaxun Yang 202194a8352SJiaxun Yang# 203194a8352SJiaxun Yang# Some versions of binutils, not currently mainline as of 2019/02/04, support 204194a8352SJiaxun Yang# an -mfix-loongson3-llsc flag which emits a sync prior to each ll instruction 205194a8352SJiaxun Yang# to work around a CPU bug (see __SYNC_loongson3_war in asm/sync.h for a 206194a8352SJiaxun Yang# description). 207194a8352SJiaxun Yang# 208194a8352SJiaxun Yang# We disable this in order to prevent the assembler meddling with the 209194a8352SJiaxun Yang# instruction that labels refer to, ie. if we label an ll instruction: 210194a8352SJiaxun Yang# 211194a8352SJiaxun Yang# 1: ll v0, 0(a0) 212194a8352SJiaxun Yang# 213194a8352SJiaxun Yang# ...then with the assembler fix applied the label may actually point at a sync 214194a8352SJiaxun Yang# instruction inserted by the assembler, and if we were using the label in an 215194a8352SJiaxun Yang# exception table the table would no longer contain the address of the ll 216194a8352SJiaxun Yang# instruction. 217194a8352SJiaxun Yang# 218194a8352SJiaxun Yang# Avoid this by explicitly disabling that assembler behaviour. If upstream 219194a8352SJiaxun Yang# binutils does not merge support for the flag then we can revisit & remove 220194a8352SJiaxun Yang# this later - for now it ensures vendor toolchains don't cause problems. 221194a8352SJiaxun Yang# 222194a8352SJiaxun Yangcflags-$(CONFIG_CPU_LOONGSON64) += $(call as-option,-Wa$(comma)-mno-fix-loongson3-llsc,) 22320d60d99SMaciej W. Rozycki 22432098ec7SMarkos Chandras# For smartmips configurations, there are hundreds of warnings due to ISA overrides 22532098ec7SMarkos Chandras# in assembly and header files. smartmips is only supported for MIPS32r1 onwards 22632098ec7SMarkos Chandras# and there is no support for 64-bit. Various '.set mips2' or '.set mips3' or 22732098ec7SMarkos Chandras# similar directives in the kernel will spam the build logs with the following warnings: 22832098ec7SMarkos Chandras# Warning: the `smartmips' extension requires MIPS32 revision 1 or greater 22932098ec7SMarkos Chandras# or 23032098ec7SMarkos Chandras# Warning: the 64-bit MIPS architecture does not support the `smartmips' extension 23132098ec7SMarkos Chandras# Pass -Wa,--no-warn to disable all assembler warnings until the kernel code has 23232098ec7SMarkos Chandras# been fixed properly. 2335306a545SMarkos Chandrasmips-cflags := $(cflags-y) 2345306a545SMarkos Chandrasifeq ($(CONFIG_CPU_HAS_SMARTMIPS),y) 2355306a545SMarkos Chandrassmartmips-ase := $(call cc-option-yn,$(mips-cflags) -msmartmips) 2365306a545SMarkos Chandrascflags-$(smartmips-ase) += -msmartmips -Wa,--no-warn 2375306a545SMarkos Chandrasendif 2385306a545SMarkos Chandrasifeq ($(CONFIG_CPU_MICROMIPS),y) 2395306a545SMarkos Chandrasmicromips-ase := $(call cc-option-yn,$(mips-cflags) -mmicromips) 2405306a545SMarkos Chandrascflags-$(micromips-ase) += -mmicromips 2415306a545SMarkos Chandrasendif 24232098ec7SMarkos Chandrasifeq ($(CONFIG_CPU_HAS_MSA),y) 2435306a545SMarkos Chandrastoolchain-msa := $(call cc-option-yn,$(mips-cflags) -mhard-float -mfp64 -Wa$(comma)-mmsa) 24432098ec7SMarkos Chandrascflags-$(toolchain-msa) += -DTOOLCHAIN_SUPPORTS_MSA 24532098ec7SMarkos Chandrasendif 246bad50d79SJames Hogantoolchain-virt := $(call cc-option-yn,$(mips-cflags) -mvirt) 247bad50d79SJames Hogancflags-$(toolchain-virt) += -DTOOLCHAIN_SUPPORTS_VIRT 2488e4789d2SJames Hogan# For -mmicromips, use -Wa,-fatal-warnings to catch unsupported -mxpa which 2498e4789d2SJames Hogan# only warns 2508e4789d2SJames Hoganxpa-cflags-y := $(mips-cflags) 2518e4789d2SJames Hoganxpa-cflags-$(micromips-ase) += -mmicromips -Wa$(comma)-fatal-warnings 2528e4789d2SJames Hogantoolchain-xpa := $(call cc-option-yn,$(xpa-cflags-y) -mxpa) 2538e4789d2SJames Hogancflags-$(toolchain-xpa) += -DTOOLCHAIN_SUPPORTS_XPA 2544a5dc51eSMarcin Nowakowskitoolchain-crc := $(call cc-option-yn,$(mips-cflags) -Wa$(comma)-mcrc) 2554a5dc51eSMarcin Nowakowskicflags-$(toolchain-crc) += -DTOOLCHAIN_SUPPORTS_CRC 256edbb4233SPaul Burtontoolchain-dsp := $(call cc-option-yn,$(mips-cflags) -Wa$(comma)-mdsp) 257edbb4233SPaul Burtoncflags-$(toolchain-dsp) += -DTOOLCHAIN_SUPPORTS_DSP 25853511389SPaul Burtontoolchain-ginv := $(call cc-option-yn,$(mips-cflags) -Wa$(comma)-mginv) 25953511389SPaul Burtoncflags-$(toolchain-ginv) += -DTOOLCHAIN_SUPPORTS_GINV 26032098ec7SMarkos Chandras 2611da177e4SLinus Torvalds# 2621da177e4SLinus Torvalds# Firmware support 2631da177e4SLinus Torvalds# 2640e2794b0SRalf Baechlelibs-$(CONFIG_FW_ARC) += arch/mips/fw/arc/ 2650e2794b0SRalf Baechlelibs-$(CONFIG_FW_CFE) += arch/mips/fw/cfe/ 2660e2794b0SRalf Baechlelibs-$(CONFIG_FW_SNIPROM) += arch/mips/fw/sni/ 267231a35d3SThomas Bogendoerferlibs-y += arch/mips/fw/lib/ 2681da177e4SLinus Torvalds 2691da177e4SLinus Torvalds# 270ebc89718SRalf Baechle# Kernel compression 271ebc89718SRalf Baechle# 272809769a8SDaniel Sabogalifdef CONFIG_SYS_SUPPORTS_ZBOOT 273ebc89718SRalf BaechleCOMPRESSION_FNAME = vmlinuz 274ebc89718SRalf Baechleelse 275ebc89718SRalf BaechleCOMPRESSION_FNAME = vmlinux 276ebc89718SRalf Baechleendif 277ebc89718SRalf Baechle 278ebc89718SRalf Baechle# 2791da177e4SLinus Torvalds# Board-dependent options and extra files 2801da177e4SLinus Torvalds# 281d8285639SMasahiro Yamadainclude $(srctree)/arch/mips/Kbuild.platforms 2827ca5dc14SFlorian Fainelli 283abe77f90SRalf Baechleifdef CONFIG_PHYSICAL_START 284abe77f90SRalf Baechleload-y = $(CONFIG_PHYSICAL_START) 285abe77f90SRalf Baechleendif 2865fc9484fSPaul Burton 287e245767aSPaul Burtonentry-y = $(shell $(objtree)/arch/mips/tools/elf-entry vmlinux) 288384740dcSRalf Baechlecflags-y += -I$(srctree)/arch/mips/include/asm/mach-generic 2891da177e4SLinus Torvaldsdrivers-$(CONFIG_PCI) += arch/mips/pci/ 2901da177e4SLinus Torvalds 291adff90a9SFranck Bui-Huu# 292adff90a9SFranck Bui-Huu# Automatically detect the build format. By default we choose 293adff90a9SFranck Bui-Huu# the elf format according to the load address. 294adff90a9SFranck Bui-Huu# We can always force a build with a 64-bits symbol format by 295054c51b4SFranck Bui-Huu# passing 'KBUILD_SYM32=no' option to the make's command line. 296adff90a9SFranck Bui-Huu# 297adff90a9SFranck Bui-Huuifdef CONFIG_64BIT 298054c51b4SFranck Bui-Huu ifndef KBUILD_SYM32 299adff90a9SFranck Bui-Huu ifeq ($(shell expr $(load-y) \< 0xffffffff80000000), 0) 30018ca63a2SJiaxun Yang KBUILD_SYM32 = $(call cc-option-yn, -msym32) 301adff90a9SFranck Bui-Huu endif 302adff90a9SFranck Bui-Huu endif 303adff90a9SFranck Bui-Huu 304a79a404eSMaciej W. Rozycki ifeq ($(KBUILD_SYM32), y) 305a79a404eSMaciej W. Rozycki cflags-$(KBUILD_SYM32) += -msym32 -DKBUILD_64BIT_SYM32 30620d60d99SMaciej W. Rozycki else 30720d60d99SMaciej W. Rozycki ifeq ($(CONFIG_CPU_DADDI_WORKAROUNDS), y) 30820d60d99SMaciej W. Rozycki $(error CONFIG_CPU_DADDI_WORKAROUNDS unsupported without -msym32) 309adff90a9SFranck Bui-Huu endif 310adff90a9SFranck Bui-Huu endif 311e58d95abSFranck Bui-Huuendif 312adff90a9SFranck Bui-Huu 313ff487d41SJiaxun Yang# When linking a 32-bit executable the LLVM linker cannot cope with a 314ff487d41SJiaxun Yang# 32-bit load address that has been sign-extended to 64 bits. Simply 315ff487d41SJiaxun Yang# remove the upper 32 bits then, as it is safe to do so with other 316ff487d41SJiaxun Yang# linkers. 317ff487d41SJiaxun Yangifdef CONFIG_64BIT 318ff487d41SJiaxun Yang load-ld = $(load-y) 319ff487d41SJiaxun Yangelse 320ff487d41SJiaxun Yang load-ld = $(subst 0xffffffff,0x,$(load-y)) 321ff487d41SJiaxun Yangendif 322ff487d41SJiaxun Yang 323222d394dSSam RavnborgKBUILD_AFLAGS += $(cflags-y) 32451b563fcSSam RavnborgKBUILD_CFLAGS += $(cflags-y) 325ff487d41SJiaxun YangKBUILD_CPPFLAGS += -DVMLINUX_LOAD_ADDRESS=$(load-y) -DLINKER_LOAD_ADDRESS=$(load-ld) 326f7fc237eSMichal MarekKBUILD_CPPFLAGS += -DDATAOFFSET=$(if $(dataoffset-y),$(dataoffset-y),0) 3271da177e4SLinus Torvalds 3283185557dSJames Hoganbootvars-y = VMLINUX_LOAD_ADDRESS=$(load-y) \ 329ff487d41SJiaxun Yang LINKER_LOAD_ADDRESS=$(load-ld) \ 330cf2a5e0bSPaul Burton VMLINUX_ENTRY_ADDRESS=$(entry-y) \ 331436c6a44SPaul Burton PLATFORM="$(platform-y)" \ 332436c6a44SPaul Burton ITS_INPUTS="$(its-y)" 333eed0eabdSPaul Burtonifdef CONFIG_32BIT 334eed0eabdSPaul Burtonbootvars-y += ADDR_BITS=32 335eed0eabdSPaul Burtonendif 336eed0eabdSPaul Burtonifdef CONFIG_64BIT 337eed0eabdSPaul Burtonbootvars-y += ADDR_BITS=64 338eed0eabdSPaul Burtonendif 3393185557dSJames Hogan 340866b6a89SCorey Minyard# This is required to get dwarf unwinding tables into .debug_frame 341866b6a89SCorey Minyard# instead of .eh_frame so we don't discard them. 342866b6a89SCorey MinyardKBUILD_CFLAGS += -fno-asynchronous-unwind-tables 343866b6a89SCorey Minyard 344d503ac53SMasahiro YamadaKBUILD_LDFLAGS += -m $(ld-emul) 3451da177e4SLinus Torvalds 3464fe4a637SMaciej W. Rozyckiifdef need-compiler 34708f6554fSNathan ChancellorCHECKFLAGS += $(shell $(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) -dM -E -x c /dev/null | \ 348d42f0c6aSTiezhu Yang grep -E -vw '__GNUC_(MINOR_|PATCHLEVEL_)?_' | \ 34973d8f99cSAaro Koskinen sed -e "s/^\#define /-D'/" -e "s/ /'='/" -e "s/$$/'/" -e 's/\$$/&&/g') 35059b3e8e9SRalf Baechleendif 35159b3e8e9SRalf Baechle 3521da177e4SLinus TorvaldsOBJCOPYFLAGS += --remove-section=.reginfo 3531da177e4SLinus Torvalds 3541da177e4SLinus Torvaldslibs-y += arch/mips/lib/ 35542b10815SPaul Burtonlibs-$(CONFIG_MIPS_FP_SUPPORT) += arch/mips/math-emu/ 3561da177e4SLinus Torvalds 3573a2f58f3SArd Biesheuveldrivers-y += arch/mips/crypto/ 3581da177e4SLinus Torvalds 359363c55caSWu Zhangjin# suspend and hibernation support 360363c55caSWu Zhangjindrivers-$(CONFIG_PM) += arch/mips/power/ 361363c55caSWu Zhangjin 36238d2d649SJames Hogan# boot image targets (arch/mips/boot/) 36338d2d649SJames Hoganboot-y := vmlinux.bin 36438d2d649SJames Hoganboot-y += vmlinux.ecoff 36538d2d649SJames Hoganboot-y += vmlinux.srec 3664defe455SJames Hoganboot-y += uImage 3679d6b80faSMarkos Chandrasboot-y += uImage.bin 3689d6b80faSMarkos Chandrasboot-y += uImage.bz2 3694defe455SJames Hoganboot-y += uImage.gz 3709d6b80faSMarkos Chandrasboot-y += uImage.lzma 3719d6b80faSMarkos Chandrasboot-y += uImage.lzo 372cf2a5e0bSPaul Burtonboot-y += vmlinux.itb 373cf2a5e0bSPaul Burtonboot-y += vmlinux.gz.itb 374cf2a5e0bSPaul Burtonboot-y += vmlinux.bz2.itb 375cf2a5e0bSPaul Burtonboot-y += vmlinux.lzma.itb 376cf2a5e0bSPaul Burtonboot-y += vmlinux.lzo.itb 37738d2d649SJames Hogan 37838d2d649SJames Hogan# compressed boot image targets (arch/mips/boot/compressed/) 37938d2d649SJames Hoganbootz-y := vmlinuz 38038d2d649SJames Hoganbootz-y += vmlinuz.bin 38138d2d649SJames Hoganbootz-y += vmlinuz.ecoff 38238d2d649SJames Hoganbootz-y += vmlinuz.srec 383ccebb88aSMaarten ter Huurnebootz-y += uzImage.bin 384a3fb6550SAlexander Lobakinbootz-y += vmlinuz.itb 38538d2d649SJames Hogan 3861da177e4SLinus Torvalds# 3871da177e4SLinus Torvalds# Some machines like the Indy need 32-bit ELF binaries for booting purposes. 3881da177e4SLinus Torvalds# Other need ECOFF, so we build a 32-bit ELF binary for them which we then 3891da177e4SLinus Torvalds# convert to ECOFF using elf2ecoff. 3901da177e4SLinus Torvalds# 391007fbbeaSWu Zhangjinquiet_cmd_32 = OBJCOPY $@ 392007fbbeaSWu Zhangjin cmd_32 = $(OBJCOPY) -O $(32bit-bfd) $(OBJCOPYFLAGS) $< $@ 3931da177e4SLinus Torvaldsvmlinux.32: vmlinux 394007fbbeaSWu Zhangjin $(call cmd,32) 3951da177e4SLinus Torvalds 3961da177e4SLinus Torvalds# 3971da177e4SLinus Torvalds# The 64-bit ELF tools are pretty broken so at this time we generate 64-bit 3981da177e4SLinus Torvalds# ELF files from 32-bit files by conversion. 3991da177e4SLinus Torvalds# 400007fbbeaSWu Zhangjinquiet_cmd_64 = OBJCOPY $@ 401007fbbeaSWu Zhangjin cmd_64 = $(OBJCOPY) -O $(64bit-bfd) $(OBJCOPYFLAGS) $< $@ 4021da177e4SLinus Torvaldsvmlinux.64: vmlinux 403007fbbeaSWu Zhangjin $(call cmd,64) 4041da177e4SLinus Torvalds 405637dfa0fSCedric Hombourgerall: $(all-y) $(KBUILD_DTBS) 4061da177e4SLinus Torvalds 40735eaa1e9SSam Ravnborg# boot 40838d2d649SJames Hogan$(boot-y): $(vmlinux-32) FORCE 4093185557dSJames Hogan $(Q)$(MAKE) $(build)=arch/mips/boot VMLINUX=$(vmlinux-32) \ 4103185557dSJames Hogan $(bootvars-y) arch/mips/boot/$@ 4111da177e4SLinus Torvalds 41226fca83aSFlorian Fainelliifdef CONFIG_SYS_SUPPORTS_ZBOOT 41335eaa1e9SSam Ravnborg# boot/compressed 41438d2d649SJames Hogan$(bootz-y): $(vmlinux-32) FORCE 41535eaa1e9SSam Ravnborg $(Q)$(MAKE) $(build)=arch/mips/boot/compressed \ 4169d63bcb8SAlexander Lobakin $(bootvars-y) 32bit-bfd=$(32bit-bfd) arch/mips/boot/$@ 41726fca83aSFlorian Fainellielse 41826fca83aSFlorian Fainellivmlinuz: FORCE 41926fca83aSFlorian Fainelli @echo ' CONFIG_SYS_SUPPORTS_ZBOOT is not enabled' 42026fca83aSFlorian Fainelli /bin/false 42126fca83aSFlorian Fainelliendif 42235eaa1e9SSam Ravnborg 42335eaa1e9SSam Ravnborg 424d745866eSSam RavnborgCLEAN_FILES += vmlinux.32 vmlinux.64 4251da177e4SLinus Torvalds 426e48ce6b8SAtsushi Nemotoarchprepare: 427e48ce6b8SAtsushi Nemotoifdef CONFIG_MIPS32_N32 4288c9b23ffSArnd Bergmann @$(kecho) ' Checking missing-syscalls for N32' 42944656fa0SDavid Daney $(Q)$(MAKE) $(build)=. missing-syscalls missing_syscalls_flags="-mabi=n32" 430e48ce6b8SAtsushi Nemotoendif 431e48ce6b8SAtsushi Nemotoifdef CONFIG_MIPS32_O32 4328c9b23ffSArnd Bergmann @$(kecho) ' Checking missing-syscalls for O32' 43344656fa0SDavid Daney $(Q)$(MAKE) $(build)=. missing-syscalls missing_syscalls_flags="-mabi=32" 434e48ce6b8SAtsushi Nemotoendif 435e48ce6b8SAtsushi Nemoto 43659968d3bSRalf Baechleinstall: 43759968d3bSRalf Baechle $(Q)install -D -m 755 vmlinux $(INSTALL_PATH)/vmlinux-$(KERNELRELEASE) 438d9beeecaSRalf Baechleifdef CONFIG_SYS_SUPPORTS_ZBOOT 4391b93b3c3SWu Zhangjin $(Q)install -D -m 755 vmlinuz $(INSTALL_PATH)/vmlinuz-$(KERNELRELEASE) 440d9beeecaSRalf Baechleendif 44159968d3bSRalf Baechle $(Q)install -D -m 644 .config $(INSTALL_PATH)/config-$(KERNELRELEASE) 44259968d3bSRalf Baechle $(Q)install -D -m 644 System.map $(INSTALL_PATH)/System.map-$(KERNELRELEASE) 44359968d3bSRalf Baechle 44499bf73ebSFiroz Khanarchheaders: 44599bf73ebSFiroz Khan $(Q)$(MAKE) $(build)=arch/mips/kernel/syscalls all 44699bf73ebSFiroz Khan 447e7865765SRalf Baechledefine archhelp 44859968d3bSRalf Baechle echo ' install - install kernel into $(INSTALL_PATH)' 449e7865765SRalf Baechle echo ' vmlinux.ecoff - ECOFF boot image' 450e7865765SRalf Baechle echo ' vmlinux.bin - Raw binary boot image' 451e7865765SRalf Baechle echo ' vmlinux.srec - SREC boot image' 45278931652SJoshua Kinard echo ' vmlinux.32 - 64-bit boot image wrapped in 32bits (IP22/IP32)' 4531b93b3c3SWu Zhangjin echo ' vmlinuz - Compressed boot(zboot) image' 4541b93b3c3SWu Zhangjin echo ' vmlinuz.ecoff - ECOFF zboot image' 4551b93b3c3SWu Zhangjin echo ' vmlinuz.bin - Raw binary zboot image' 4561b93b3c3SWu Zhangjin echo ' vmlinuz.srec - SREC zboot image' 4574defe455SJames Hogan echo ' uImage - U-Boot image' 4589d6b80faSMarkos Chandras echo ' uImage.bin - U-Boot image (uncompressed)' 4599d6b80faSMarkos Chandras echo ' uImage.bz2 - U-Boot image (bz2)' 4604defe455SJames Hogan echo ' uImage.gz - U-Boot image (gzip)' 4619d6b80faSMarkos Chandras echo ' uImage.lzma - U-Boot image (lzma)' 4629d6b80faSMarkos Chandras echo ' uImage.lzo - U-Boot image (lzo)' 463ccebb88aSMaarten ter Huurne echo ' uzImage.bin - U-Boot image (self-extracting)' 464e7865765SRalf Baechle echo 46525985edcSLucas De Marchi echo ' These will be default as appropriate for a configured platform.' 466eed0eabdSPaul Burton echo 467eed0eabdSPaul Burton echo ' If you are targeting a system supported by generic kernels you may' 468eed0eabdSPaul Burton echo ' configure the kernel for a given architecture target like so:' 469eed0eabdSPaul Burton echo 470eed0eabdSPaul Burton echo ' {micro32,32,64}{r1,r2,r6}{el,}_defconfig <BOARDS="list of boards">' 471eed0eabdSPaul Burton echo 472cccd0b9aSJames Hogan echo ' Where BOARDS is some subset of the following:' 473cccd0b9aSJames Hogan for board in $(sort $(BOARDS)); do echo " $${board}"; done 474cccd0b9aSJames Hogan echo 475cccd0b9aSJames Hogan echo ' Specifically the following generic default configurations are' 476cccd0b9aSJames Hogan echo ' supported:' 477cccd0b9aSJames Hogan echo 478cccd0b9aSJames Hogan $(foreach cfg,$(generic_defconfigs), 479cccd0b9aSJames Hogan printf " %-24s - Build generic kernel for $(call describe_generic_defconfig,$(cfg))\n" $(cfg);) 480cccd0b9aSJames Hogan echo 481cccd0b9aSJames Hogan echo ' The following legacy default configurations have been converted to' 482cccd0b9aSJames Hogan echo ' generic and can still be used:' 483cccd0b9aSJames Hogan echo 484cccd0b9aSJames Hogan $(foreach cfg,$(sort $(legacy_defconfigs)), 485cccd0b9aSJames Hogan printf " %-24s - Build $($(cfg)-y)\n" $(cfg);) 486cccd0b9aSJames Hogan echo 487eed0eabdSPaul Burton echo ' Otherwise, the following default configurations are available:' 488e7865765SRalf Baechleendef 489eed0eabdSPaul Burton 490eed0eabdSPaul Burtongeneric_config_dir = $(srctree)/arch/$(ARCH)/configs/generic 491eed0eabdSPaul Burtongeneric_defconfigs := 492eed0eabdSPaul Burton 493eed0eabdSPaul Burton# 494eed0eabdSPaul Burton# If the user generates a generic kernel configuration without specifying a 495eed0eabdSPaul Burton# list of boards to include the config fragments for, default to including all 496eed0eabdSPaul Burton# available board config fragments. 497eed0eabdSPaul Burton# 498eed0eabdSPaul Burtonifeq ($(BOARDS),) 499eed0eabdSPaul BurtonBOARDS = $(patsubst board-%.config,%,$(notdir $(wildcard $(generic_config_dir)/board-*.config))) 500eed0eabdSPaul Burtonendif 501eed0eabdSPaul Burton 502eed0eabdSPaul Burton# 503eed0eabdSPaul Burton# Generic kernel configurations which merge generic_defconfig with the 504eed0eabdSPaul Burton# appropriate config fragments from arch/mips/configs/generic/, resulting in 505eed0eabdSPaul Burton# the ability to easily configure the kernel for a given architecture, 506eed0eabdSPaul Burton# endianness & set of boards without duplicating the needed configuration in 507eed0eabdSPaul Burton# hundreds of defconfig files. 508eed0eabdSPaul Burton# 509eed0eabdSPaul Burtondefine gen_generic_defconfigs 510eed0eabdSPaul Burton$(foreach bits,$(1),$(foreach rev,$(2),$(foreach endian,$(3), 511eed0eabdSPaul Burtontarget := $(bits)$(rev)$(filter el,$(endian))_defconfig 512eed0eabdSPaul Burtongeneric_defconfigs += $$(target) 513eed0eabdSPaul Burton$$(target): $(generic_config_dir)/$(bits)$(rev).config 514eed0eabdSPaul Burton$$(target): $(generic_config_dir)/$(endian).config 515eed0eabdSPaul Burton))) 516eed0eabdSPaul Burtonendef 517eed0eabdSPaul Burton 518eed0eabdSPaul Burton$(eval $(call gen_generic_defconfigs,32 64,r1 r2 r6,eb el)) 519eed0eabdSPaul Burton$(eval $(call gen_generic_defconfigs,micro32,r2,eb el)) 520eed0eabdSPaul Burton 521cccd0b9aSJames Hogandefine describe_generic_defconfig 522cccd0b9aSJames Hogan$(subst 32r,MIPS32 r,$(subst 64r,MIPS64 r,$(subst el, little endian,$(patsubst %_defconfig,%,$(1))))) 523cccd0b9aSJames Hoganendef 524cccd0b9aSJames Hogan 525eed0eabdSPaul Burton.PHONY: $(generic_defconfigs) 526eed0eabdSPaul Burton$(generic_defconfigs): 527eed0eabdSPaul Burton $(Q)$(CONFIG_SHELL) $(srctree)/scripts/kconfig/merge_config.sh \ 52827e0d4b0SPaul Burton -m -O $(objtree) $(srctree)/arch/$(ARCH)/configs/generic_defconfig $^ | \ 52927e0d4b0SPaul Burton grep -Ev '^#' 53027e0d4b0SPaul Burton $(Q)cp $(KCONFIG_CONFIG) $(objtree)/.config.$@ 53127e0d4b0SPaul Burton $(Q)$(MAKE) -f $(srctree)/Makefile olddefconfig \ 53227e0d4b0SPaul Burton KCONFIG_CONFIG=$(objtree)/.config.$@ >/dev/null 53327e0d4b0SPaul Burton $(Q)$(CONFIG_SHELL) $(srctree)/arch/$(ARCH)/tools/generic-board-config.sh \ 53427e0d4b0SPaul Burton $(srctree) $(objtree) $(objtree)/.config.$@ $(KCONFIG_CONFIG) \ 53527e0d4b0SPaul Burton "$(origin BOARDS)" $(BOARDS) 536337b775bSMarcin Nowakowski $(Q)$(MAKE) -f $(srctree)/Makefile olddefconfig 537eed0eabdSPaul Burton 538eed0eabdSPaul Burton# 539eed0eabdSPaul Burton# Prevent generic merge_config rules attempting to merge single fragments 540eed0eabdSPaul Burton# 541eed0eabdSPaul Burton$(generic_config_dir)/%.config: ; 5423f5f0a44SPaul Burton 5433f5f0a44SPaul Burton# 544a4c2f797SPaul Burton# Prevent direct use of generic_defconfig, which is intended to be used as the 545a4c2f797SPaul Burton# basis of the various ISA-specific targets generated above. 546a4c2f797SPaul Burton# 547a4c2f797SPaul Burton.PHONY: generic_defconfig 548a4c2f797SPaul Burtongeneric_defconfig: 549a4c2f797SPaul Burton $(Q)echo "generic_defconfig is not intended for direct use, but should instead be" 550a4c2f797SPaul Burton $(Q)echo "used via an ISA-specific target from the following list:" 551a4c2f797SPaul Burton $(Q)echo 552a4c2f797SPaul Burton $(Q)for cfg in $(generic_defconfigs); do echo " $${cfg}"; done 553a4c2f797SPaul Burton $(Q)echo 554a4c2f797SPaul Burton $(Q)false 555a4c2f797SPaul Burton 556a4c2f797SPaul Burton# 5573f5f0a44SPaul Burton# Legacy defconfig compatibility - these targets used to be real defconfigs but 5583f5f0a44SPaul Burton# now that the boards have been converted to use the generic kernel they are 5593f5f0a44SPaul Burton# wrappers around the generic rules above. 5603f5f0a44SPaul Burton# 5616bce3deaSAlexandre Bellonilegacy_defconfigs += ocelot_defconfig 5626bce3deaSAlexandre Belloniocelot_defconfig-y := 32r2el_defconfig BOARDS=ocelot 5636bce3deaSAlexandre Belloni 564318df806SJames Hoganlegacy_defconfigs += sead3_defconfig 565318df806SJames Hogansead3_defconfig-y := 32r2el_defconfig BOARDS=sead-3 5663f5f0a44SPaul Burton 567318df806SJames Hoganlegacy_defconfigs += sead3micro_defconfig 568318df806SJames Hogansead3micro_defconfig-y := micro32r2el_defconfig BOARDS=sead-3 5690861aa12SZubair Lutfullah Kakakhel 570318df806SJames Hoganlegacy_defconfigs += xilfpga_defconfig 571318df806SJames Hoganxilfpga_defconfig-y := 32r2el_defconfig BOARDS=xilfpga 572318df806SJames Hogan 5733f66601eSJiaxun Yanglegacy_defconfigs += pistachio_defconfig 5743f66601eSJiaxun Yangpistachio_defconfig-y := 32r2el_defconfig BOARDS=marduk 5753f66601eSJiaxun Yang 576318df806SJames Hogan.PHONY: $(legacy_defconfigs) 577318df806SJames Hogan$(legacy_defconfigs): 578318df806SJames Hogan $(Q)$(MAKE) -f $(srctree)/Makefile $($@-y) 579