aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'arch/mips/Makefile')
-rw-r--r--arch/mips/Makefile236
1 files changed, 49 insertions, 187 deletions
diff --git a/arch/mips/Makefile b/arch/mips/Makefile
index fe9da16f3a40..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,161 +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) += -mno-sched-prolog -fno-omit-frame-pointer 95cflags-$(CONFIG_SB1XXX_CORELIS) += $(call cc-option,-mno-sched-prolog) \
112 96 -fno-omit-frame-pointer
113#
114# Use: $(call set_gccflags,<cpu0>,<isa0>,<cpu1>,<isa1>,<isa2>)
115#
116# <cpu0>,<isa0> -- preferred CPU and ISA designations (may require
117# recent tools)
118# <cpu1>,<isa1> -- fallback CPU and ISA designations (have to work
119# with up to the oldest supported tools)
120# <isa2> -- an ISA designation used as an ABI selector for
121# gcc versions that do not support "-mabi=32"
122# (depending on the CPU type, either "mips1" or
123# "mips2")
124#
125set_gccflags = $(shell \
126while :; do \
127 cpu=$(1); isa=-$(2); \
128 for gcc_opt in -march= -mcpu=; do \
129 $(CC) $$gcc_opt$$cpu $$isa -S -o /dev/null \
130 -xc /dev/null > /dev/null 2>&1 && \
131 break 2; \
132 done; \
133 cpu=$(3); isa=-$(4); \
134 for gcc_opt in -march= -mcpu=; do \
135 $(CC) $$gcc_opt$$cpu $$isa -S -o /dev/null \
136 -xc /dev/null > /dev/null 2>&1 && \
137 break 2; \
138 done; \
139 break; \
140done; \
141gcc_abi=-mabi=$(gcc-abi); gcc_cpu=$$cpu; \
142if $(CC) $$gcc_abi -S -o /dev/null -xc /dev/null > /dev/null 2>&1; then \
143 gcc_isa=$$isa; \
144else \
145 gcc_abi=; gcc_isa=-$(5); \
146fi; \
147gas_abi=-Wa,-$(gcc-abi); gas_cpu=$$cpu; gas_isa=-Wa,$$isa; \
148while :; do \
149 for gas_opt in -Wa,-march= -Wa,-mcpu=; do \
150 $(CC) $$gas_abi $$gas_opt$$cpu $$gas_isa -Wa,-Z -c \
151 -o /dev/null -xassembler /dev/null > /dev/null 2>&1 && \
152 break 2; \
153 done; \
154 gas_abi=; gas_opt=; gas_cpu=; gas_isa=; \
155 break; \
156done; \
157if test "$(gcc-abi)" != "$(gas-abi)"; then \
158 gas_abi="-Wa,-$(gas-abi) -Wa,-mgp$(gcc-abi)"; \
159fi; \
160if test "$$gcc_opt" = -march= && test -n "$$gcc_abi"; then \
161 $(CC) $$gcc_abi $$gcc_opt$$gcc_cpu -S -o /dev/null \
162 -xc /dev/null > /dev/null 2>&1 && \
163 gcc_isa=; \
164fi; \
165echo $$gcc_abi $$gcc_opt$$gcc_cpu $$gcc_isa $$gas_abi $$gas_opt$$gas_cpu $$gas_isa)
166 97
167# 98#
168# CPU-dependent compiler/assembler options for optimization. 99# CPU-dependent compiler/assembler options for optimization.
169# 100#
170cflags-$(CONFIG_CPU_R3000) += \ 101cflags-$(CONFIG_CPU_R3000) += -march=r3000
171 $(call set_gccflags,r3000,mips1,r3000,mips1,mips1) 102cflags-$(CONFIG_CPU_TX39XX) += -march=r3900
172CHECKFLAGS-$(CONFIG_CPU_R3000) += -D_MIPS_ISA=_MIPS_ISA_MIPS1 103cflags-$(CONFIG_CPU_R6000) += -march=r6000 -Wa,--trap
173 104cflags-$(CONFIG_CPU_R4300) += -march=r4300 -Wa,--trap
174cflags-$(CONFIG_CPU_TX39XX) += \ 105cflags-$(CONFIG_CPU_VR41XX) += -march=r4100 -Wa,--trap
175 $(call set_gccflags,r3900,mips1,r3000,mips1,mips1) 106cflags-$(CONFIG_CPU_R4X00) += -march=r4600 -Wa,--trap
176CHECKFLAGS-$(CONFIG_CPU_TX39XX) += -D_MIPS_ISA=_MIPS_ISA_MIPS1 107cflags-$(CONFIG_CPU_TX49XX) += -march=r4600 -Wa,--trap
177 108cflags-$(CONFIG_CPU_MIPS32_R1) += $(call cc-option,-march=mips32,-mips2 -mtune=r4600) \
178cflags-$(CONFIG_CPU_R6000) += \ 109 -Wa,-mips32 -Wa,--trap
179 $(call set_gccflags,r6000,mips2,r6000,mips2,mips2) \ 110cflags-$(CONFIG_CPU_MIPS32_R2) += $(call cc-option,-march=mips32r2,-mips2 -mtune=r4600) \
180 -Wa,--trap 111 -Wa,-mips32r2 -Wa,--trap
181CHECKFLAGS-$(CONFIG_CPU_R6000) += -D_MIPS_ISA=_MIPS_ISA_MIPS2 112cflags-$(CONFIG_CPU_MIPS64_R1) += $(call cc-option,-march=mips64,-mips2 -mtune=r4600) \
182 113 -Wa,-mips64 -Wa,--trap
183cflags-$(CONFIG_CPU_R4300) += \ 114cflags-$(CONFIG_CPU_MIPS64_R2) += $(call cc-option,-march=mips64r2,-mips2 -mtune=r4600 ) \
184 $(call set_gccflags,r4300,mips3,r4300,mips3,mips2) \ 115 -Wa,-mips64r2 -Wa,--trap
116cflags-$(CONFIG_CPU_R5000) += -march=r5000 -Wa,--trap
117cflags-$(CONFIG_CPU_R5432) += $(call cc-options,-march=r5400,-march=r5000) \
185 -Wa,--trap 118 -Wa,--trap
186CHECKFLAGS-$(CONFIG_CPU_R4300) += -D_MIPS_ISA=_MIPS_ISA_MIPS3 119cflags-$(CONFIG_CPU_NEVADA) += $(call cc-options,-march=rm5200,-march=r5000) \
187
188cflags-$(CONFIG_CPU_VR41XX) += \
189 $(call set_gccflags,r4100,mips3,r4600,mips3,mips2) \
190 -Wa,--trap 120 -Wa,--trap
191CHECKFLAGS-$(CONFIG_CPU_VR41XX) += -D_MIPS_ISA=_MIPS_ISA_MIPS3 121cflags-$(CONFIG_CPU_RM7000) += $(call cc-option,-march=rm7000,-march=r5000) \
192
193cflags-$(CONFIG_CPU_R4X00) += \
194 $(call set_gccflags,r4600,mips3,r4600,mips3,mips2) \
195 -Wa,--trap 122 -Wa,--trap
196CHECKFLAGS-$(CONFIG_CPU_R4X00) += -D_MIPS_ISA=_MIPS_ISA_MIPS3 123cflags-$(CONFIG_CPU_RM9000) += $(call cc-option,-march=rm9000,-march=r5000) \
197
198cflags-$(CONFIG_CPU_TX49XX) += \
199 $(call set_gccflags,r4600,mips3,r4600,mips3,mips2) \
200 -Wa,--trap 124 -Wa,--trap
201CHECKFLAGS-$(CONFIG_CPU_TX49XX) += -D_MIPS_ISA=_MIPS_ISA_MIPS3 125cflags-$(CONFIG_CPU_SB1) += $(call cc-option,-march=sb1,-march=r5000) \
202
203cflags-$(CONFIG_CPU_MIPS32_R1) += \
204 $(call set_gccflags,mips32,mips32,r4600,mips3,mips2) \
205 -Wa,--trap 126 -Wa,--trap
206CHECKFLAGS-$(CONFIG_CPU_MIPS32_R1) += -D_MIPS_ISA=_MIPS_ISA_MIPS32 127cflags-$(CONFIG_CPU_R8000) += -march=r8000 -Wa,--trap
207 128cflags-$(CONFIG_CPU_R10000) += $(call cc-option,-march=r10000,-march=r8000) \
208cflags-$(CONFIG_CPU_MIPS32_R2) += \
209 $(call set_gccflags,mips32r2,mips32r2,r4600,mips3,mips2) \
210 -Wa,--trap
211CHECKFLAGS-$(CONFIG_CPU_MIPS32_R2) += -D_MIPS_ISA=_MIPS_ISA_MIPS32
212
213cflags-$(CONFIG_CPU_MIPS64_R1) += \
214 $(call set_gccflags,mips64,mips64,r4600,mips3,mips2) \
215 -Wa,--trap 129 -Wa,--trap
216CHECKFLAGS-$(CONFIG_CPU_MIPS64_R1) += -D_MIPS_ISA=_MIPS_ISA_MIPS64
217
218cflags-$(CONFIG_CPU_MIPS64_R2) += \
219 $(call set_gccflags,mips64r2,mips64r2,r4600,mips3,mips2) \
220 -Wa,--trap
221CHECKFLAGS-$(CONFIG_CPU_MIPS64_R2) += -D_MIPS_ISA=_MIPS_ISA_MIPS64
222
223cflags-$(CONFIG_CPU_R5000) += \
224 $(call set_gccflags,r5000,mips4,r5000,mips4,mips2) \
225 -Wa,--trap
226CHECKFLAGS-$(CONFIG_CPU_R5000) += -D_MIPS_ISA=_MIPS_ISA_MIPS4
227
228cflags-$(CONFIG_CPU_R5432) += \
229 $(call set_gccflags,r5400,mips4,r5000,mips4,mips2) \
230 -Wa,--trap
231CHECKFLAGS-$(CONFIG_CPU_R5432) += -D_MIPS_ISA=_MIPS_ISA_MIPS4
232
233cflags-$(CONFIG_CPU_NEVADA) += \
234 $(call set_gccflags,rm5200,mips4,r5000,mips4,mips2) \
235 -Wa,--trap
236CHECKFLAGS-$(CONFIG_CPU_NEVADA) += -D_MIPS_ISA=_MIPS_ISA_MIPS4
237
238cflags-$(CONFIG_CPU_RM7000) += \
239 $(call set_gccflags,rm7000,mips4,r5000,mips4,mips2) \
240 -Wa,--trap
241CHECKFLAGS-$(CONFIG_CPU_RM7000) += -D_MIPS_ISA=_MIPS_ISA_MIPS4
242
243cflags-$(CONFIG_CPU_RM9000) += \
244 $(call set_gccflags,rm9000,mips4,r5000,mips4,mips2) \
245 -Wa,--trap
246CHECKFLAGS-$(CONFIG_CPU_RM9000) += -D_MIPS_ISA=_MIPS_ISA_MIPS4
247
248
249cflags-$(CONFIG_CPU_SB1) += \
250 $(call set_gccflags,sb1,mips64,r5000,mips4,mips2) \
251 -Wa,--trap
252CHECKFLAGS-$(CONFIG_CPU_SB1) += -D_MIPS_ISA=_MIPS_ISA_MIPS64
253
254cflags-$(CONFIG_CPU_R8000) += \
255 $(call set_gccflags,r8000,mips4,r8000,mips4,mips2) \
256 -Wa,--trap
257CHECKFLAGS-$(CONFIG_CPU_R8000) += -D_MIPS_ISA=_MIPS_ISA_MIPS4
258
259cflags-$(CONFIG_CPU_R10000) += \
260 $(call set_gccflags,r10000,mips4,r8000,mips4,mips2) \
261 -Wa,--trap
262CHECKFLAGS-$(CONFIG_CPU_R10000) += -D_MIPS_ISA=_MIPS_ISA_MIPS4
263 130
264ifdef CONFIG_CPU_SB1 131ifdef CONFIG_CPU_SB1
265ifdef CONFIG_SB1_PASS_1_WORKAROUNDS 132ifdef CONFIG_SB1_PASS_1_WORKAROUNDS
@@ -629,7 +496,6 @@ endif
629ifdef CONFIG_SGI_IP27 496ifdef CONFIG_SGI_IP27
630core-$(CONFIG_SGI_IP27) += arch/mips/sgi-ip27/ 497core-$(CONFIG_SGI_IP27) += arch/mips/sgi-ip27/
631cflags-$(CONFIG_SGI_IP27) += -Iinclude/asm-mips/mach-ip27 498cflags-$(CONFIG_SGI_IP27) += -Iinclude/asm-mips/mach-ip27
632ifdef CONFIG_BUILD_ELF64
633ifdef CONFIG_MAPPED_KERNEL 499ifdef CONFIG_MAPPED_KERNEL
634load-$(CONFIG_SGI_IP27) += 0xc00000004001c000 500load-$(CONFIG_SGI_IP27) += 0xc00000004001c000
635OBJCOPYFLAGS := --change-addresses=0x3fffffff80000000 501OBJCOPYFLAGS := --change-addresses=0x3fffffff80000000
@@ -638,16 +504,6 @@ else
638load-$(CONFIG_SGI_IP27) += 0xa80000000001c000 504load-$(CONFIG_SGI_IP27) += 0xa80000000001c000
639OBJCOPYFLAGS := --change-addresses=0x57ffffff80000000 505OBJCOPYFLAGS := --change-addresses=0x57ffffff80000000
640endif 506endif
641else
642ifdef CONFIG_MAPPED_KERNEL
643load-$(CONFIG_SGI_IP27) += 0xffffffffc001c000
644OBJCOPYFLAGS := --change-addresses=0xc000000080000000
645dataoffset-$(CONFIG_SGI_IP27) += 0x01000000
646else
647load-$(CONFIG_SGI_IP27) += 0xffffffff8001c000
648OBJCOPYFLAGS := --change-addresses=0xa800000080000000
649endif
650endif
651endif 507endif
652 508
653# 509#
@@ -756,6 +612,12 @@ CFLAGS += $(cflags-y)
756 612
757LDFLAGS += -m $(ld-emul) 613LDFLAGS += -m $(ld-emul)
758 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
759OBJCOPYFLAGS += --remove-section=.reginfo 621OBJCOPYFLAGS += --remove-section=.reginfo
760 622
761# 623#