diff options
Diffstat (limited to 'arch/mips/Makefile')
-rw-r--r-- | arch/mips/Makefile | 231 |
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 | ||
15 | as-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 | |||
19 | cflags-y := | 15 | cflags-y := |
20 | 16 | ||
21 | # | 17 | # |
@@ -38,12 +34,10 @@ else | |||
38 | endif | 34 | endif |
39 | 35 | ||
40 | ifdef CONFIG_32BIT | 36 | ifdef CONFIG_32BIT |
41 | gcc-abi = 32 | ||
42 | tool-prefix = $(32bit-tool-prefix) | 37 | tool-prefix = $(32bit-tool-prefix) |
43 | UTS_MACHINE := mips | 38 | UTS_MACHINE := mips |
44 | endif | 39 | endif |
45 | ifdef CONFIG_64BIT | 40 | ifdef CONFIG_64BIT |
46 | gcc-abi = 64 | ||
47 | tool-prefix = $(64bit-tool-prefix) | 41 | tool-prefix = $(64bit-tool-prefix) |
48 | UTS_MACHINE := mips64 | 42 | UTS_MACHINE := mips64 |
49 | endif | 43 | endif |
@@ -52,37 +46,27 @@ ifdef CONFIG_CROSSCOMPILE | |||
52 | CROSS_COMPILE := $(tool-prefix) | 46 | CROSS_COMPILE := $(tool-prefix) |
53 | endif | 47 | endif |
54 | 48 | ||
55 | CHECKFLAGS-y += -D__linux__ -D__mips__ \ | 49 | ifdef CONFIG_32BIT |
56 | -D_MIPS_SZINT=32 \ | 50 | ld-emul = $(32bit-emul) |
57 | -D_ABIO32=1 \ | 51 | vmlinux-32 = vmlinux |
58 | -D_ABIN32=2 \ | 52 | vmlinux-64 = vmlinux.64 |
59 | -D_ABI64=3 | 53 | |
60 | CHECKFLAGS-$(CONFIG_32BIT) += -D_MIPS_SIM=_ABIO32 \ | 54 | cflags-y += -mabi=32 |
61 | -D_MIPS_SZLONG=32 \ | 55 | endif |
62 | -D_MIPS_SZPTR=32 \ | ||
63 | -D__PTRDIFF_TYPE__=int | ||
64 | CHECKFLAGS-$(CONFIG_64BIT) += -m64 -D_MIPS_SIM=_ABI64 \ | ||
65 | -D_MIPS_SZLONG=64 \ | ||
66 | -D_MIPS_SZPTR=64 \ | ||
67 | -D__PTRDIFF_TYPE__="long int" | ||
68 | CHECKFLAGS-$(CONFIG_CPU_BIG_ENDIAN) += -D__MIPSEB__ | ||
69 | CHECKFLAGS-$(CONFIG_CPU_LITTLE_ENDIAN) += -D__MIPSEL__ | ||
70 | |||
71 | CHECKFLAGS = $(CHECKFLAGS-y) | ||
72 | 56 | ||
73 | ifdef CONFIG_BUILD_ELF64 | 57 | ifdef CONFIG_64BIT |
74 | gas-abi = 64 | ||
75 | ld-emul = $(64bit-emul) | 58 | ld-emul = $(64bit-emul) |
76 | vmlinux-32 = vmlinux.32 | 59 | vmlinux-32 = vmlinux.32 |
77 | vmlinux-64 = vmlinux | 60 | vmlinux-64 = vmlinux |
78 | else | ||
79 | gas-abi = 32 | ||
80 | ld-emul = $(32bit-emul) | ||
81 | vmlinux-32 = vmlinux | ||
82 | vmlinux-64 = vmlinux.64 | ||
83 | 61 | ||
84 | cflags-$(CONFIG_64BIT) += $(call cc-option,-mno-explicit-relocs) | 62 | cflags-y += -mabi=64 |
63 | ifdef CONFIG_BUILD_ELF64 | ||
64 | cflags-y += $(call cc-option,-mno-explicit-relocs) | ||
65 | else | ||
66 | cflags-y += $(call cc-option,-msym32) | ||
85 | endif | 67 | endif |
68 | endif | ||
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 | # |
108 | cflags-$(CONFIG_CPU_BIG_ENDIAN) += $(shell $(CC) -dumpmachine |grep -q 'mips.*el-.*' && echo -EB) | 92 | cflags-$(CONFIG_CPU_BIG_ENDIAN) += $(shell $(CC) -dumpmachine |grep -q 'mips.*el-.*' && echo -EB -D__MIPSEB__) |
109 | cflags-$(CONFIG_CPU_LITTLE_ENDIAN) += $(shell $(CC) -dumpmachine |grep -q 'mips.*el-.*' || echo -EL) | 93 | cflags-$(CONFIG_CPU_LITTLE_ENDIAN) += $(shell $(CC) -dumpmachine |grep -q 'mips.*el-.*' || echo -EL -D__MIPSEL__) |
110 | 94 | ||
111 | cflags-$(CONFIG_SB1XXX_CORELIS) += $(call cc-option,-mno-sched-prolog) \ | 95 | cflags-$(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 | # | ||
126 | set_gccflags = $(shell \ | ||
127 | while :; 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; \ | ||
141 | done; \ | ||
142 | gcc_abi=-mabi=$(gcc-abi); gcc_cpu=$$cpu; \ | ||
143 | if $(CC) $$gcc_abi -S -o /dev/null -xc /dev/null > /dev/null 2>&1; then \ | ||
144 | gcc_isa=$$isa; \ | ||
145 | else \ | ||
146 | gcc_abi=; gcc_isa=-$(5); \ | ||
147 | fi; \ | ||
148 | gas_abi=-Wa,-$(gcc-abi); gas_cpu=$$cpu; gas_isa=-Wa,$$isa; \ | ||
149 | while :; 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; \ | ||
157 | done; \ | ||
158 | if test "$(gcc-abi)" != "$(gas-abi)"; then \ | ||
159 | gas_abi="-Wa,-$(gas-abi) -Wa,-mgp$(gcc-abi)"; \ | ||
160 | fi; \ | ||
161 | if 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=; \ | ||
165 | fi; \ | ||
166 | echo $$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 | # |
171 | cflags-$(CONFIG_CPU_R3000) += \ | 101 | cflags-$(CONFIG_CPU_R3000) += -march=r3000 |
172 | $(call set_gccflags,r3000,mips1,r3000,mips1,mips1) | 102 | cflags-$(CONFIG_CPU_TX39XX) += -march=r3900 |
173 | CHECKFLAGS-$(CONFIG_CPU_R3000) += -D_MIPS_ISA=_MIPS_ISA_MIPS1 | 103 | cflags-$(CONFIG_CPU_R6000) += -march=r6000 -Wa,--trap |
174 | 104 | cflags-$(CONFIG_CPU_R4300) += -march=r4300 -Wa,--trap | |
175 | cflags-$(CONFIG_CPU_TX39XX) += \ | 105 | cflags-$(CONFIG_CPU_VR41XX) += -march=r4100 -Wa,--trap |
176 | $(call set_gccflags,r3900,mips1,r3000,mips1,mips1) | 106 | cflags-$(CONFIG_CPU_R4X00) += -march=r4600 -Wa,--trap |
177 | CHECKFLAGS-$(CONFIG_CPU_TX39XX) += -D_MIPS_ISA=_MIPS_ISA_MIPS1 | 107 | cflags-$(CONFIG_CPU_TX49XX) += -march=r4600 -Wa,--trap |
178 | 108 | cflags-$(CONFIG_CPU_MIPS32_R1) += $(call cc-option,-march=mips32,-mips2 -mtune=r4600) \ | |
179 | cflags-$(CONFIG_CPU_R6000) += \ | 109 | -Wa,-mips32 -Wa,--trap |
180 | $(call set_gccflags,r6000,mips2,r6000,mips2,mips2) \ | 110 | cflags-$(CONFIG_CPU_MIPS32_R2) += $(call cc-option,-march=mips32r2,-mips2 -mtune=r4600) \ |
181 | -Wa,--trap | 111 | -Wa,-mips32r2 -Wa,--trap |
182 | CHECKFLAGS-$(CONFIG_CPU_R6000) += -D_MIPS_ISA=_MIPS_ISA_MIPS2 | 112 | cflags-$(CONFIG_CPU_MIPS64_R1) += $(call cc-option,-march=mips64,-mips2 -mtune=r4600) \ |
183 | 113 | -Wa,-mips64 -Wa,--trap | |
184 | cflags-$(CONFIG_CPU_R4300) += \ | 114 | cflags-$(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 | 116 | cflags-$(CONFIG_CPU_R5000) += -march=r5000 -Wa,--trap |
187 | CHECKFLAGS-$(CONFIG_CPU_R4300) += -D_MIPS_ISA=_MIPS_ISA_MIPS3 | 117 | cflags-$(CONFIG_CPU_R5432) += $(call cc-options,-march=r5400,-march=r5000) \ |
188 | |||
189 | cflags-$(CONFIG_CPU_VR41XX) += \ | ||
190 | $(call set_gccflags,r4100,mips3,r4600,mips3,mips2) \ | ||
191 | -Wa,--trap | ||
192 | CHECKFLAGS-$(CONFIG_CPU_VR41XX) += -D_MIPS_ISA=_MIPS_ISA_MIPS3 | ||
193 | |||
194 | cflags-$(CONFIG_CPU_R4X00) += \ | ||
195 | $(call set_gccflags,r4600,mips3,r4600,mips3,mips2) \ | ||
196 | -Wa,--trap | ||
197 | CHECKFLAGS-$(CONFIG_CPU_R4X00) += -D_MIPS_ISA=_MIPS_ISA_MIPS3 | ||
198 | |||
199 | cflags-$(CONFIG_CPU_TX49XX) += \ | ||
200 | $(call set_gccflags,r4600,mips3,r4600,mips3,mips2) \ | ||
201 | -Wa,--trap | 118 | -Wa,--trap |
202 | CHECKFLAGS-$(CONFIG_CPU_TX49XX) += -D_MIPS_ISA=_MIPS_ISA_MIPS3 | 119 | cflags-$(CONFIG_CPU_NEVADA) += $(call cc-options,-march=rm5200,-march=r5000) \ |
203 | |||
204 | cflags-$(CONFIG_CPU_MIPS32_R1) += \ | ||
205 | $(call set_gccflags,mips32,mips32,r4600,mips3,mips2) \ | ||
206 | -Wa,--trap | ||
207 | CHECKFLAGS-$(CONFIG_CPU_MIPS32_R1) += -D_MIPS_ISA=_MIPS_ISA_MIPS32 | ||
208 | |||
209 | cflags-$(CONFIG_CPU_MIPS32_R2) += \ | ||
210 | $(call set_gccflags,mips32r2,mips32r2,r4600,mips3,mips2) \ | ||
211 | -Wa,--trap | 120 | -Wa,--trap |
212 | CHECKFLAGS-$(CONFIG_CPU_MIPS32_R2) += -D_MIPS_ISA=_MIPS_ISA_MIPS32 | 121 | cflags-$(CONFIG_CPU_RM7000) += $(call cc-option,-march=rm7000,-march=r5000) \ |
213 | |||
214 | cflags-$(CONFIG_CPU_MIPS64_R1) += \ | ||
215 | $(call set_gccflags,mips64,mips64,r4600,mips3,mips2) \ | ||
216 | -Wa,--trap | 122 | -Wa,--trap |
217 | CHECKFLAGS-$(CONFIG_CPU_MIPS64_R1) += -D_MIPS_ISA=_MIPS_ISA_MIPS64 | 123 | cflags-$(CONFIG_CPU_RM9000) += $(call cc-option,-march=rm9000,-march=r5000) \ |
218 | |||
219 | cflags-$(CONFIG_CPU_MIPS64_R2) += \ | ||
220 | $(call set_gccflags,mips64r2,mips64r2,r4600,mips3,mips2) \ | ||
221 | -Wa,--trap | 124 | -Wa,--trap |
222 | CHECKFLAGS-$(CONFIG_CPU_MIPS64_R2) += -D_MIPS_ISA=_MIPS_ISA_MIPS64 | 125 | cflags-$(CONFIG_CPU_SB1) += $(call cc-option,-march=sb1,-march=r5000) \ |
223 | |||
224 | cflags-$(CONFIG_CPU_R5000) += \ | ||
225 | $(call set_gccflags,r5000,mips4,r5000,mips4,mips2) \ | ||
226 | -Wa,--trap | 126 | -Wa,--trap |
227 | CHECKFLAGS-$(CONFIG_CPU_R5000) += -D_MIPS_ISA=_MIPS_ISA_MIPS4 | 127 | cflags-$(CONFIG_CPU_R8000) += -march=r8000 -Wa,--trap |
228 | 128 | cflags-$(CONFIG_CPU_R10000) += $(call cc-option,-march=r10000,-march=r8000) \ | |
229 | cflags-$(CONFIG_CPU_R5432) += \ | ||
230 | $(call set_gccflags,r5400,mips4,r5000,mips4,mips2) \ | ||
231 | -Wa,--trap | 129 | -Wa,--trap |
232 | CHECKFLAGS-$(CONFIG_CPU_R5432) += -D_MIPS_ISA=_MIPS_ISA_MIPS4 | ||
233 | |||
234 | cflags-$(CONFIG_CPU_NEVADA) += \ | ||
235 | $(call set_gccflags,rm5200,mips4,r5000,mips4,mips2) \ | ||
236 | -Wa,--trap | ||
237 | CHECKFLAGS-$(CONFIG_CPU_NEVADA) += -D_MIPS_ISA=_MIPS_ISA_MIPS4 | ||
238 | |||
239 | cflags-$(CONFIG_CPU_RM7000) += \ | ||
240 | $(call set_gccflags,rm7000,mips4,r5000,mips4,mips2) \ | ||
241 | -Wa,--trap | ||
242 | CHECKFLAGS-$(CONFIG_CPU_RM7000) += -D_MIPS_ISA=_MIPS_ISA_MIPS4 | ||
243 | |||
244 | cflags-$(CONFIG_CPU_RM9000) += \ | ||
245 | $(call set_gccflags,rm9000,mips4,r5000,mips4,mips2) \ | ||
246 | -Wa,--trap | ||
247 | CHECKFLAGS-$(CONFIG_CPU_RM9000) += -D_MIPS_ISA=_MIPS_ISA_MIPS4 | ||
248 | |||
249 | |||
250 | cflags-$(CONFIG_CPU_SB1) += \ | ||
251 | $(call set_gccflags,sb1,mips64,r5000,mips4,mips2) \ | ||
252 | -Wa,--trap | ||
253 | CHECKFLAGS-$(CONFIG_CPU_SB1) += -D_MIPS_ISA=_MIPS_ISA_MIPS64 | ||
254 | |||
255 | cflags-$(CONFIG_CPU_R8000) += \ | ||
256 | $(call set_gccflags,r8000,mips4,r8000,mips4,mips2) \ | ||
257 | -Wa,--trap | ||
258 | CHECKFLAGS-$(CONFIG_CPU_R8000) += -D_MIPS_ISA=_MIPS_ISA_MIPS4 | ||
259 | |||
260 | cflags-$(CONFIG_CPU_R10000) += \ | ||
261 | $(call set_gccflags,r10000,mips4,r8000,mips4,mips2) \ | ||
262 | -Wa,--trap | ||
263 | CHECKFLAGS-$(CONFIG_CPU_R10000) += -D_MIPS_ISA=_MIPS_ISA_MIPS4 | ||
264 | 130 | ||
265 | ifdef CONFIG_CPU_SB1 | 131 | ifdef CONFIG_CPU_SB1 |
266 | ifdef CONFIG_SB1_PASS_1_WORKAROUNDS | 132 | ifdef CONFIG_SB1_PASS_1_WORKAROUNDS |
@@ -630,7 +496,6 @@ endif | |||
630 | ifdef CONFIG_SGI_IP27 | 496 | ifdef CONFIG_SGI_IP27 |
631 | core-$(CONFIG_SGI_IP27) += arch/mips/sgi-ip27/ | 497 | core-$(CONFIG_SGI_IP27) += arch/mips/sgi-ip27/ |
632 | cflags-$(CONFIG_SGI_IP27) += -Iinclude/asm-mips/mach-ip27 | 498 | cflags-$(CONFIG_SGI_IP27) += -Iinclude/asm-mips/mach-ip27 |
633 | ifdef CONFIG_BUILD_ELF64 | ||
634 | ifdef CONFIG_MAPPED_KERNEL | 499 | ifdef CONFIG_MAPPED_KERNEL |
635 | load-$(CONFIG_SGI_IP27) += 0xc00000004001c000 | 500 | load-$(CONFIG_SGI_IP27) += 0xc00000004001c000 |
636 | OBJCOPYFLAGS := --change-addresses=0x3fffffff80000000 | 501 | OBJCOPYFLAGS := --change-addresses=0x3fffffff80000000 |
@@ -639,16 +504,6 @@ else | |||
639 | load-$(CONFIG_SGI_IP27) += 0xa80000000001c000 | 504 | load-$(CONFIG_SGI_IP27) += 0xa80000000001c000 |
640 | OBJCOPYFLAGS := --change-addresses=0x57ffffff80000000 | 505 | OBJCOPYFLAGS := --change-addresses=0x57ffffff80000000 |
641 | endif | 506 | endif |
642 | else | ||
643 | ifdef CONFIG_MAPPED_KERNEL | ||
644 | load-$(CONFIG_SGI_IP27) += 0xffffffffc001c000 | ||
645 | OBJCOPYFLAGS := --change-addresses=0xc000000080000000 | ||
646 | dataoffset-$(CONFIG_SGI_IP27) += 0x01000000 | ||
647 | else | ||
648 | load-$(CONFIG_SGI_IP27) += 0xffffffff8001c000 | ||
649 | OBJCOPYFLAGS := --change-addresses=0xa800000080000000 | ||
650 | endif | ||
651 | endif | ||
652 | endif | 507 | endif |
653 | 508 | ||
654 | # | 509 | # |
@@ -757,6 +612,12 @@ CFLAGS += $(cflags-y) | |||
757 | 612 | ||
758 | LDFLAGS += -m $(ld-emul) | 613 | LDFLAGS += -m $(ld-emul) |
759 | 614 | ||
615 | ifdef CONFIG_MIPS | ||
616 | CHECKFLAGS += $(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/$$/"/') | ||
619 | endif | ||
620 | |||
760 | OBJCOPYFLAGS += --remove-section=.reginfo | 621 | OBJCOPYFLAGS += --remove-section=.reginfo |
761 | 622 | ||
762 | # | 623 | # |