aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'arch/mips/Makefile')
-rw-r--r--arch/mips/Makefile231
1 files changed, 46 insertions, 185 deletions
diff --git a/arch/mips/Makefile b/arch/mips/Makefile
index 3d8dac681c63..9a69e0f0ab76 100644
--- a/arch/mips/Makefile
+++ b/arch/mips/Makefile
@@ -12,10 +12,6 @@
12# for "archclean" cleaning up for this architecture. 12# for "archclean" cleaning up for this architecture.
13# 13#
14 14
15as-option = $(shell if $(CC) $(CFLAGS) $(1) -Wa,-Z -c -o /dev/null \
16 -xassembler /dev/null > /dev/null 2>&1; then echo "$(1)"; \
17 else echo "$(2)"; fi ;)
18
19cflags-y := 15cflags-y :=
20 16
21# 17#
@@ -38,12 +34,10 @@ else
38endif 34endif
39 35
40ifdef CONFIG_32BIT 36ifdef CONFIG_32BIT
41gcc-abi = 32
42tool-prefix = $(32bit-tool-prefix) 37tool-prefix = $(32bit-tool-prefix)
43UTS_MACHINE := mips 38UTS_MACHINE := mips
44endif 39endif
45ifdef CONFIG_64BIT 40ifdef CONFIG_64BIT
46gcc-abi = 64
47tool-prefix = $(64bit-tool-prefix) 41tool-prefix = $(64bit-tool-prefix)
48UTS_MACHINE := mips64 42UTS_MACHINE := mips64
49endif 43endif
@@ -52,37 +46,27 @@ ifdef CONFIG_CROSSCOMPILE
52CROSS_COMPILE := $(tool-prefix) 46CROSS_COMPILE := $(tool-prefix)
53endif 47endif
54 48
55CHECKFLAGS-y += -D__linux__ -D__mips__ \ 49ifdef CONFIG_32BIT
56 -D_MIPS_SZINT=32 \ 50ld-emul = $(32bit-emul)
57 -D_ABIO32=1 \ 51vmlinux-32 = vmlinux
58 -D_ABIN32=2 \ 52vmlinux-64 = vmlinux.64
59 -D_ABI64=3 53
60CHECKFLAGS-$(CONFIG_32BIT) += -D_MIPS_SIM=_ABIO32 \ 54cflags-y += -mabi=32
61 -D_MIPS_SZLONG=32 \ 55endif
62 -D_MIPS_SZPTR=32 \
63 -D__PTRDIFF_TYPE__=int
64CHECKFLAGS-$(CONFIG_64BIT) += -m64 -D_MIPS_SIM=_ABI64 \
65 -D_MIPS_SZLONG=64 \
66 -D_MIPS_SZPTR=64 \
67 -D__PTRDIFF_TYPE__="long int"
68CHECKFLAGS-$(CONFIG_CPU_BIG_ENDIAN) += -D__MIPSEB__
69CHECKFLAGS-$(CONFIG_CPU_LITTLE_ENDIAN) += -D__MIPSEL__
70
71CHECKFLAGS = $(CHECKFLAGS-y)
72 56
73ifdef CONFIG_BUILD_ELF64 57ifdef CONFIG_64BIT
74gas-abi = 64
75ld-emul = $(64bit-emul) 58ld-emul = $(64bit-emul)
76vmlinux-32 = vmlinux.32 59vmlinux-32 = vmlinux.32
77vmlinux-64 = vmlinux 60vmlinux-64 = vmlinux
78else
79gas-abi = 32
80ld-emul = $(32bit-emul)
81vmlinux-32 = vmlinux
82vmlinux-64 = vmlinux.64
83 61
84cflags-$(CONFIG_64BIT) += $(call cc-option,-mno-explicit-relocs) 62cflags-y += -mabi=64
63ifdef CONFIG_BUILD_ELF64
64cflags-y += $(call cc-option,-mno-explicit-relocs)
65else
66cflags-y += $(call cc-option,-msym32)
85endif 67endif
68endif
69
86 70
87# 71#
88# GCC uses -G 0 -mabicalls -fpic as default. We don't want PIC in the kernel 72# GCC uses -G 0 -mabicalls -fpic as default. We don't want PIC in the kernel
@@ -105,162 +89,44 @@ MODFLAGS += -mlong-calls
105# carefully avoid to add it redundantly because gcc 3.3/3.4 complains 89# carefully avoid to add it redundantly because gcc 3.3/3.4 complains
106# when fed the toolchain default! 90# when fed the toolchain default!
107# 91#
108cflags-$(CONFIG_CPU_BIG_ENDIAN) += $(shell $(CC) -dumpmachine |grep -q 'mips.*el-.*' && echo -EB) 92cflags-$(CONFIG_CPU_BIG_ENDIAN) += $(shell $(CC) -dumpmachine |grep -q 'mips.*el-.*' && echo -EB -D__MIPSEB__)
109cflags-$(CONFIG_CPU_LITTLE_ENDIAN) += $(shell $(CC) -dumpmachine |grep -q 'mips.*el-.*' || echo -EL) 93cflags-$(CONFIG_CPU_LITTLE_ENDIAN) += $(shell $(CC) -dumpmachine |grep -q 'mips.*el-.*' || echo -EL -D__MIPSEL__)
110 94
111cflags-$(CONFIG_SB1XXX_CORELIS) += $(call cc-option,-mno-sched-prolog) \ 95cflags-$(CONFIG_SB1XXX_CORELIS) += $(call cc-option,-mno-sched-prolog) \
112 -fno-omit-frame-pointer 96 -fno-omit-frame-pointer
113 97
114# 98#
115# Use: $(call set_gccflags,<cpu0>,<isa0>,<cpu1>,<isa1>,<isa2>)
116#
117# <cpu0>,<isa0> -- preferred CPU and ISA designations (may require
118# recent tools)
119# <cpu1>,<isa1> -- fallback CPU and ISA designations (have to work
120# with up to the oldest supported tools)
121# <isa2> -- an ISA designation used as an ABI selector for
122# gcc versions that do not support "-mabi=32"
123# (depending on the CPU type, either "mips1" or
124# "mips2")
125#
126set_gccflags = $(shell \
127while :; do \
128 cpu=$(1); isa=-$(2); \
129 for gcc_opt in -march= -mcpu=; do \
130 $(CC) $$gcc_opt$$cpu $$isa -S -o /dev/null \
131 -xc /dev/null > /dev/null 2>&1 && \
132 break 2; \
133 done; \
134 cpu=$(3); isa=-$(4); \
135 for gcc_opt in -march= -mcpu=; do \
136 $(CC) $$gcc_opt$$cpu $$isa -S -o /dev/null \
137 -xc /dev/null > /dev/null 2>&1 && \
138 break 2; \
139 done; \
140 break; \
141done; \
142gcc_abi=-mabi=$(gcc-abi); gcc_cpu=$$cpu; \
143if $(CC) $$gcc_abi -S -o /dev/null -xc /dev/null > /dev/null 2>&1; then \
144 gcc_isa=$$isa; \
145else \
146 gcc_abi=; gcc_isa=-$(5); \
147fi; \
148gas_abi=-Wa,-$(gcc-abi); gas_cpu=$$cpu; gas_isa=-Wa,$$isa; \
149while :; do \
150 for gas_opt in -Wa,-march= -Wa,-mcpu=; do \
151 $(CC) $$gas_abi $$gas_opt$$cpu $$gas_isa -Wa,-Z -c \
152 -o /dev/null -xassembler /dev/null > /dev/null 2>&1 && \
153 break 2; \
154 done; \
155 gas_abi=; gas_opt=; gas_cpu=; gas_isa=; \
156 break; \
157done; \
158if test "$(gcc-abi)" != "$(gas-abi)"; then \
159 gas_abi="-Wa,-$(gas-abi) -Wa,-mgp$(gcc-abi)"; \
160fi; \
161if test "$$gcc_opt" = -march= && test -n "$$gcc_abi"; then \
162 $(CC) $$gcc_abi $$gcc_opt$$gcc_cpu -S -o /dev/null \
163 -xc /dev/null > /dev/null 2>&1 && \
164 gcc_isa=; \
165fi; \
166echo $$gcc_abi $$gcc_opt$$gcc_cpu $$gcc_isa $$gas_abi $$gas_opt$$gas_cpu $$gas_isa)
167
168#
169# CPU-dependent compiler/assembler options for optimization. 99# CPU-dependent compiler/assembler options for optimization.
170# 100#
171cflags-$(CONFIG_CPU_R3000) += \ 101cflags-$(CONFIG_CPU_R3000) += -march=r3000
172 $(call set_gccflags,r3000,mips1,r3000,mips1,mips1) 102cflags-$(CONFIG_CPU_TX39XX) += -march=r3900
173CHECKFLAGS-$(CONFIG_CPU_R3000) += -D_MIPS_ISA=_MIPS_ISA_MIPS1 103cflags-$(CONFIG_CPU_R6000) += -march=r6000 -Wa,--trap
174 104cflags-$(CONFIG_CPU_R4300) += -march=r4300 -Wa,--trap
175cflags-$(CONFIG_CPU_TX39XX) += \ 105cflags-$(CONFIG_CPU_VR41XX) += -march=r4100 -Wa,--trap
176 $(call set_gccflags,r3900,mips1,r3000,mips1,mips1) 106cflags-$(CONFIG_CPU_R4X00) += -march=r4600 -Wa,--trap
177CHECKFLAGS-$(CONFIG_CPU_TX39XX) += -D_MIPS_ISA=_MIPS_ISA_MIPS1 107cflags-$(CONFIG_CPU_TX49XX) += -march=r4600 -Wa,--trap
178 108cflags-$(CONFIG_CPU_MIPS32_R1) += $(call cc-option,-march=mips32,-mips2 -mtune=r4600) \
179cflags-$(CONFIG_CPU_R6000) += \ 109 -Wa,-mips32 -Wa,--trap
180 $(call set_gccflags,r6000,mips2,r6000,mips2,mips2) \ 110cflags-$(CONFIG_CPU_MIPS32_R2) += $(call cc-option,-march=mips32r2,-mips2 -mtune=r4600) \
181 -Wa,--trap 111 -Wa,-mips32r2 -Wa,--trap
182CHECKFLAGS-$(CONFIG_CPU_R6000) += -D_MIPS_ISA=_MIPS_ISA_MIPS2 112cflags-$(CONFIG_CPU_MIPS64_R1) += $(call cc-option,-march=mips64,-mips2 -mtune=r4600) \
183 113 -Wa,-mips64 -Wa,--trap
184cflags-$(CONFIG_CPU_R4300) += \ 114cflags-$(CONFIG_CPU_MIPS64_R2) += $(call cc-option,-march=mips64r2,-mips2 -mtune=r4600 ) \
185 $(call set_gccflags,r4300,mips3,r4300,mips3,mips2) \ 115 -Wa,-mips64r2 -Wa,--trap
186 -Wa,--trap 116cflags-$(CONFIG_CPU_R5000) += -march=r5000 -Wa,--trap
187CHECKFLAGS-$(CONFIG_CPU_R4300) += -D_MIPS_ISA=_MIPS_ISA_MIPS3 117cflags-$(CONFIG_CPU_R5432) += $(call cc-options,-march=r5400,-march=r5000) \
188
189cflags-$(CONFIG_CPU_VR41XX) += \
190 $(call set_gccflags,r4100,mips3,r4600,mips3,mips2) \
191 -Wa,--trap
192CHECKFLAGS-$(CONFIG_CPU_VR41XX) += -D_MIPS_ISA=_MIPS_ISA_MIPS3
193
194cflags-$(CONFIG_CPU_R4X00) += \
195 $(call set_gccflags,r4600,mips3,r4600,mips3,mips2) \
196 -Wa,--trap
197CHECKFLAGS-$(CONFIG_CPU_R4X00) += -D_MIPS_ISA=_MIPS_ISA_MIPS3
198
199cflags-$(CONFIG_CPU_TX49XX) += \
200 $(call set_gccflags,r4600,mips3,r4600,mips3,mips2) \
201 -Wa,--trap 118 -Wa,--trap
202CHECKFLAGS-$(CONFIG_CPU_TX49XX) += -D_MIPS_ISA=_MIPS_ISA_MIPS3 119cflags-$(CONFIG_CPU_NEVADA) += $(call cc-options,-march=rm5200,-march=r5000) \
203
204cflags-$(CONFIG_CPU_MIPS32_R1) += \
205 $(call set_gccflags,mips32,mips32,r4600,mips3,mips2) \
206 -Wa,--trap
207CHECKFLAGS-$(CONFIG_CPU_MIPS32_R1) += -D_MIPS_ISA=_MIPS_ISA_MIPS32
208
209cflags-$(CONFIG_CPU_MIPS32_R2) += \
210 $(call set_gccflags,mips32r2,mips32r2,r4600,mips3,mips2) \
211 -Wa,--trap 120 -Wa,--trap
212CHECKFLAGS-$(CONFIG_CPU_MIPS32_R2) += -D_MIPS_ISA=_MIPS_ISA_MIPS32 121cflags-$(CONFIG_CPU_RM7000) += $(call cc-option,-march=rm7000,-march=r5000) \
213
214cflags-$(CONFIG_CPU_MIPS64_R1) += \
215 $(call set_gccflags,mips64,mips64,r4600,mips3,mips2) \
216 -Wa,--trap 122 -Wa,--trap
217CHECKFLAGS-$(CONFIG_CPU_MIPS64_R1) += -D_MIPS_ISA=_MIPS_ISA_MIPS64 123cflags-$(CONFIG_CPU_RM9000) += $(call cc-option,-march=rm9000,-march=r5000) \
218
219cflags-$(CONFIG_CPU_MIPS64_R2) += \
220 $(call set_gccflags,mips64r2,mips64r2,r4600,mips3,mips2) \
221 -Wa,--trap 124 -Wa,--trap
222CHECKFLAGS-$(CONFIG_CPU_MIPS64_R2) += -D_MIPS_ISA=_MIPS_ISA_MIPS64 125cflags-$(CONFIG_CPU_SB1) += $(call cc-option,-march=sb1,-march=r5000) \
223
224cflags-$(CONFIG_CPU_R5000) += \
225 $(call set_gccflags,r5000,mips4,r5000,mips4,mips2) \
226 -Wa,--trap 126 -Wa,--trap
227CHECKFLAGS-$(CONFIG_CPU_R5000) += -D_MIPS_ISA=_MIPS_ISA_MIPS4 127cflags-$(CONFIG_CPU_R8000) += -march=r8000 -Wa,--trap
228 128cflags-$(CONFIG_CPU_R10000) += $(call cc-option,-march=r10000,-march=r8000) \
229cflags-$(CONFIG_CPU_R5432) += \
230 $(call set_gccflags,r5400,mips4,r5000,mips4,mips2) \
231 -Wa,--trap 129 -Wa,--trap
232CHECKFLAGS-$(CONFIG_CPU_R5432) += -D_MIPS_ISA=_MIPS_ISA_MIPS4
233
234cflags-$(CONFIG_CPU_NEVADA) += \
235 $(call set_gccflags,rm5200,mips4,r5000,mips4,mips2) \
236 -Wa,--trap
237CHECKFLAGS-$(CONFIG_CPU_NEVADA) += -D_MIPS_ISA=_MIPS_ISA_MIPS4
238
239cflags-$(CONFIG_CPU_RM7000) += \
240 $(call set_gccflags,rm7000,mips4,r5000,mips4,mips2) \
241 -Wa,--trap
242CHECKFLAGS-$(CONFIG_CPU_RM7000) += -D_MIPS_ISA=_MIPS_ISA_MIPS4
243
244cflags-$(CONFIG_CPU_RM9000) += \
245 $(call set_gccflags,rm9000,mips4,r5000,mips4,mips2) \
246 -Wa,--trap
247CHECKFLAGS-$(CONFIG_CPU_RM9000) += -D_MIPS_ISA=_MIPS_ISA_MIPS4
248
249
250cflags-$(CONFIG_CPU_SB1) += \
251 $(call set_gccflags,sb1,mips64,r5000,mips4,mips2) \
252 -Wa,--trap
253CHECKFLAGS-$(CONFIG_CPU_SB1) += -D_MIPS_ISA=_MIPS_ISA_MIPS64
254
255cflags-$(CONFIG_CPU_R8000) += \
256 $(call set_gccflags,r8000,mips4,r8000,mips4,mips2) \
257 -Wa,--trap
258CHECKFLAGS-$(CONFIG_CPU_R8000) += -D_MIPS_ISA=_MIPS_ISA_MIPS4
259
260cflags-$(CONFIG_CPU_R10000) += \
261 $(call set_gccflags,r10000,mips4,r8000,mips4,mips2) \
262 -Wa,--trap
263CHECKFLAGS-$(CONFIG_CPU_R10000) += -D_MIPS_ISA=_MIPS_ISA_MIPS4
264 130
265ifdef CONFIG_CPU_SB1 131ifdef CONFIG_CPU_SB1
266ifdef CONFIG_SB1_PASS_1_WORKAROUNDS 132ifdef CONFIG_SB1_PASS_1_WORKAROUNDS
@@ -630,7 +496,6 @@ endif
630ifdef CONFIG_SGI_IP27 496ifdef CONFIG_SGI_IP27
631core-$(CONFIG_SGI_IP27) += arch/mips/sgi-ip27/ 497core-$(CONFIG_SGI_IP27) += arch/mips/sgi-ip27/
632cflags-$(CONFIG_SGI_IP27) += -Iinclude/asm-mips/mach-ip27 498cflags-$(CONFIG_SGI_IP27) += -Iinclude/asm-mips/mach-ip27
633ifdef CONFIG_BUILD_ELF64
634ifdef CONFIG_MAPPED_KERNEL 499ifdef CONFIG_MAPPED_KERNEL
635load-$(CONFIG_SGI_IP27) += 0xc00000004001c000 500load-$(CONFIG_SGI_IP27) += 0xc00000004001c000
636OBJCOPYFLAGS := --change-addresses=0x3fffffff80000000 501OBJCOPYFLAGS := --change-addresses=0x3fffffff80000000
@@ -639,16 +504,6 @@ else
639load-$(CONFIG_SGI_IP27) += 0xa80000000001c000 504load-$(CONFIG_SGI_IP27) += 0xa80000000001c000
640OBJCOPYFLAGS := --change-addresses=0x57ffffff80000000 505OBJCOPYFLAGS := --change-addresses=0x57ffffff80000000
641endif 506endif
642else
643ifdef CONFIG_MAPPED_KERNEL
644load-$(CONFIG_SGI_IP27) += 0xffffffffc001c000
645OBJCOPYFLAGS := --change-addresses=0xc000000080000000
646dataoffset-$(CONFIG_SGI_IP27) += 0x01000000
647else
648load-$(CONFIG_SGI_IP27) += 0xffffffff8001c000
649OBJCOPYFLAGS := --change-addresses=0xa800000080000000
650endif
651endif
652endif 507endif
653 508
654# 509#
@@ -757,6 +612,12 @@ CFLAGS += $(cflags-y)
757 612
758LDFLAGS += -m $(ld-emul) 613LDFLAGS += -m $(ld-emul)
759 614
615ifdef CONFIG_MIPS
616CHECKFLAGS += $(shell $(CC) $(CFLAGS) -dM -E -xc /dev/null | \
617 egrep -vw '__GNUC_(MAJOR|MINOR|PATCHLEVEL)__' | \
618 sed -e 's/^\#define /-D/' -e 's/ /="/' -e 's/$$/"/')
619endif
620
760OBJCOPYFLAGS += --remove-section=.reginfo 621OBJCOPYFLAGS += --remove-section=.reginfo
761 622
762# 623#