setup enviroment for compilation
[linux-2.4.21-pre4.git] / arch / mips64 / Makefile
1 #
2 # This file is subject to the terms and conditions of the GNU General Public
3 # License.  See the file "COPYING" in the main directory of this archive
4 # for more details.
5 #
6 # Copyright (C) 2002  Maciej W. Rozycki
7 #
8 # This file is included by the global makefile so that you can add your own
9 # architecture-specific flags and dependencies. Remember to do have actions
10 # for "archclean" and "archdep" for cleaning up and making dependencies for
11 # this architecture
12 #
13
14 #
15 # Select the object file format to substitute into the linker script.
16 #
17 ifdef CONFIG_CPU_LITTLE_ENDIAN
18 tool-prefix     = mips64el-linux-
19 else
20 tool-prefix     = mips64-linux-
21 endif
22
23 ifdef CONFIG_CROSSCOMPILE
24 CROSS_COMPILE   = $(tool-prefix)
25 endif
26
27 #
28 # The ELF GCC uses -G 0 -mabicalls -fpic as default.  We don't need PIC
29 # code in the kernel since it only slows down the whole thing.  For the
30 # old GCC these options are just the defaults.  At some point we might
31 # make use of global pointer optimizations.
32 #
33 # The DECStation requires an ECOFF kernel for remote booting, other MIPS
34 # machines may also.  Since BFD is incredibly buggy with respect to
35 # crossformat linking we rely on the elf2ecoff tool for format conversion.
36 #
37 GCCFLAGS        := -I $(TOPDIR)/include/asm/gcc
38 GCCFLAGS        += -mabi=64 -G 0 -mno-abicalls -fno-pic -Wa,--trap -pipe
39 LINKFLAGS       += -G 0 -static # -N
40 MODFLAGS        += -mlong-calls
41
42 ifdef CONFIG_REMOTE_DEBUG
43 GCCFLAGS        += -g
44 endif
45
46 #
47 # CPU-dependent compiler/assembler options for optimization.
48 #
49 ifdef CONFIG_CPU_R4300
50 GCCFLAGS        += -mcpu=r4300 -mips3
51 endif
52 ifdef CONFIG_CPU_R4X00
53 GCCFLAGS        += -mcpu=r4600 -mips3
54 endif
55 ifdef CONFIG_CPU_R5000
56 GCCFLAGS        += -mcpu=r8000 -mips4
57 endif
58 ifdef CONFIG_CPU_NEVADA
59 GCCFLAGS        += -mcpu=r8000 -mips3 -mmad
60 endif
61 ifdef CONFIG_CPU_R8000
62 GCCFLAGS        += -mcpu=r8000 -mips4
63 endif
64 ifdef CONFIG_CPU_R10000
65 GCCFLAGS        += -mcpu=r8000 -mips4
66 endif
67 ifdef CONFIG_CPU_SB1
68 GCCFLAGS        += -mcpu=r8000 -mips4
69 endif
70 ifdef CONFIG_CPU_MIPS64
71 #CFLAGS         += -mips64      # Should be used then we get a MIPS64 compiler
72 CFLAGS          += -mcpu=r8000 -mips4
73 endif
74
75 #
76 # We unconditionally build the math emulator
77 #
78 CORE_FILES      += arch/mips/math-emu/fpu_emulator.o
79 SUBDIRS         += arch/mips/math-emu
80
81
82 #
83 # Board-dependent options and extra files
84 #
85
86 #
87 # MIPS Atlas board
88 #
89 ifdef CONFIG_MIPS_ATLAS
90 LIBS            += arch/mips/mips-boards/atlas/atlas.o \
91                    arch/mips/mips-boards/generic/mipsboards.o
92 SUBDIRS         += arch/mips/mips-boards/generic arch/mips/mips-boards/atlas
93 LOADADDR        := 0x80100000
94 endif
95
96 #
97 # MIPS Malta board
98 #
99 ifdef CONFIG_MIPS_MALTA
100 LIBS            += arch/mips/mips-boards/malta/malta.o \
101                    arch/mips/mips-boards/generic/mipsboards.o
102 SUBDIRS         += arch/mips/mips-boards/malta arch/mips/mips-boards/generic
103 LOADADDR        := 0x80100000
104 endif
105
106 #
107 # MIPS SEAD board
108 #
109 ifdef CONFIG_MIPS_SEAD
110 LIBS            += arch/mips/mips-boards/sead/sead.o \
111                    arch/mips/mips-boards/generic/mipsboards.o
112 SUBDIRS         += arch/mips/mips-boards/generic arch/mips/mips-boards/sead
113 LOADADDR        := 0x80100000
114 endif
115
116 #
117 # SGI IP22 (Indy/Indigo2)
118 #
119 ifdef CONFIG_SGI_IP22
120 CORE_FILES      += arch/mips/sgi-ip22/ip22-kern.o
121 LIBS            += arch/mips/arc/arclib.a
122 SUBDIRS         += arch/mips/sgi-ip22 arch/mips/arc
123 #
124 # Set LOADADDR to >= 0x88069000 if you want to leave space for symmon,
125 # 0x88004000 for production kernels.  Note that the value must be
126 # 16kb aligned or the handling of the current variable will break.
127 #
128 LOADADDR        := 0x88004000
129 endif
130
131 #
132 # SGI-IP27 (Origin200/2000)
133 #
134 ifdef CONFIG_SGI_IP27
135 CORE_FILES      += arch/mips/sgi-ip27/ip27.o
136 LIBS            += arch/mips/arc/arclib.a
137 SUBDIRS         += arch/mips/sgi-ip27 arch/mips/arc
138 #
139 # Set LOADADDR to >= 0xc000000000300000 if you want to leave space for
140 # symmon, 0xc00000000001c000 for production kernels.  Note that the value
141 # must be 16kb aligned or the handling of the current variable will break.
142 #
143 #LOADADDR       := 0xa80000000001c000
144 ifdef CONFIG_MAPPED_KERNEL
145 LOADADDR        := 0xc001c000
146 else
147 LOADADDR        := 0x8001c000
148 endif
149 endif
150
151 #
152 # SGI-IP32 (O2)
153 #
154 ifdef CONFIG_SGI_IP32
155 CORE_FILES      += arch/mips/sgi-ip32/ip32-kern.a
156 LIBS            += arch/mips/arc/arclib.a
157 SUBDIRS         += arch/mips/sgi-ip32 arch/mips/arc
158 #
159 # Set LOADADDR to >= 0x????????? if you want to leave space for symmon,
160 # 0x80002000 for production kernels.  Note that the value must be
161 # 16kb aligned or the handling of the current variable will break.
162 #
163 LOADADDR        := 0x80002000
164 endif
165
166 #
167 # Sibyte SB1250 SOC
168 #
169 ifdef CONFIG_SIBYTE_SB1250
170 # This is a LIB so that it links at the end, and initcalls are later
171 # the sequence; but it is built as an object so that modules don't get
172 # removed (as happens, even if they have __initcall/module_init)
173 LIBS            += arch/mips/sibyte/sb1250/sb1250.o
174 SUBDIRS         += arch/mips/sibyte/sb1250
175 endif
176
177 #
178 # Sibyte SWARM board
179 #
180 ifdef CONFIG_SIBYTE_SWARM
181 LIBS            += arch/mips/sibyte/swarm/sbswarm.a
182 SUBDIRS         += arch/mips/sibyte/swarm
183 LOADADDR        := 0x80100000
184 endif
185
186 #
187 # Sibyte CFE firmware
188 #
189 ifdef CONFIG_SIBYTE_CFE
190 LIBS            += arch/mips/sibyte/cfe/cfe.a
191 SUBDIRS         += arch/mips/sibyte/cfe
192 endif
193
194 #
195 # SB1 Cache Error handler
196 #
197 ifdef CONFIG_SB1_CACHE_ERROR
198 LIBS            += arch/mips/sibyte/sb1/sb1kern.a
199 SUBDIRS         += arch/mips/sibyte/sb1
200 endif
201
202
203 #
204 # Some machines like the Indy need 32-bit ELF binaries for booting purposes.
205 # Other need ECOFF, so we build a 32-bit ELF binary for them which we then
206 # convert to ECOFF using elf2ecoff.
207 #
208 ifdef CONFIG_BOOT_ELF32
209 GCCFLAGS += -Wa,-32
210 LINKFLAGS += -T arch/mips64/ld.script.elf32
211 endif
212 #
213 # The 64-bit ELF tools are pretty broken so at this time we generate 64-bit
214 # ELF files from 32-bit files by conversion.
215 #
216 ifdef CONFIG_BOOT_ELF64
217 GCCFLAGS += -Wa,-32
218 LINKFLAGS += -T arch/mips64/ld.script.elf32
219 #AS += -64
220 #LD += -m elf64bmip
221 #LINKFLAGS += -T arch/mips64/ld.script.elf64
222 endif
223
224
225 AFLAGS          += $(GCCFLAGS)
226 CFLAGS          += $(GCCFLAGS)
227
228
229 LINKFLAGS += -Ttext $(LOADADDR)
230
231 HEAD := arch/mips64/kernel/head.o arch/mips64/kernel/init_task.o
232
233 SUBDIRS := $(addprefix arch/mips/, tools) $(SUBDIRS) $(addprefix arch/mips64/, kernel mm lib)
234 CORE_FILES := arch/mips64/kernel/kernel.o arch/mips64/mm/mm.o $(CORE_FILES)
235 LIBS := arch/mips64/lib/lib.a $(LIBS)
236
237 MAKEBOOT = $(MAKE) -C arch/$(ARCH)/boot
238
239 ifdef CONFIG_CPU_LITTLE_ENDIAN
240 64bit-bfd = elf64-littlemips
241 else
242 64bit-bfd = elf64-bigmips
243 endif
244
245 vmlinux: arch/mips64/ld.script.elf32
246 arch/mips64/ld.script.elf32: arch/mips64/ld.script.elf32.S
247         $(CPP) -C -P -I$(HPATH) -imacros $(HPATH)/asm-mips64/sn/mapped_kernel.h -Umips arch/mips64/ld.script.elf32.S > arch/mips64/ld.script.elf32
248
249 ifdef CONFIG_MAPPED_KERNEL
250 vmlinux.64: vmlinux
251         $(OBJCOPY) -O $(64bit-bfd) --change-addresses=0xbfffffff40000000 $< $@
252 else
253 vmlinux.64: vmlinux
254         $(OBJCOPY) -O $(64bit-bfd) --change-addresses=0xa7ffffff80000000 $< $@
255 endif
256
257 zImage: vmlinux
258         @$(MAKEBOOT) zImage
259
260 compressed: zImage
261
262 zdisk: vmlinux
263         @$(MAKEBOOT) zdisk
264
265 archclean:
266         @$(MAKEBOOT) clean
267         $(MAKE) -C arch/mips/tools clean
268         rm -f vmlinux.64 arch/$(ARCH)/ld.script.elf32
269
270 archmrproper:
271         @$(MAKEBOOT) mrproper
272         $(MAKE) -C arch/mips/tools mrproper
273
274 archdep:
275         if [ ! -f $(TOPDIR)/include/asm-$(ARCH)/offset.h ]; then \
276                 touch $(TOPDIR)/include/asm-$(ARCH)/offset.h; \
277         fi;
278         @$(MAKEBOOT) dep