sparc merge (Blue Swirl)
[qemu] / Makefile.target
1 include config.mak
2
3 TARGET_PATH=$(SRC_PATH)/target-$(TARGET_ARCH)
4 VPATH=$(SRC_PATH):$(TARGET_PATH):$(SRC_PATH)/hw
5 DEFINES=-I. -I$(TARGET_PATH) -I$(SRC_PATH)
6 ifdef CONFIG_USER_ONLY
7 VPATH+=:$(SRC_PATH)/linux-user
8 DEFINES+=-I$(SRC_PATH)/linux-user -I$(SRC_PATH)/linux-user/$(TARGET_ARCH)
9 endif
10 CFLAGS=-Wall -O2 -g -fno-strict-aliasing
11 LDFLAGS=-g
12 LIBS=
13 HELPER_CFLAGS=$(CFLAGS)
14 DYNGEN=../dyngen$(EXESUF)
15 # user emulator name
16 QEMU_USER=qemu-$(TARGET_ARCH)
17 # system emulator name
18 ifdef CONFIG_SOFTMMU
19 ifeq ($(TARGET_ARCH), i386)
20 QEMU_SYSTEM=qemu$(EXESUF)
21 else
22 QEMU_SYSTEM=qemu-system-$(TARGET_ARCH)$(EXESUF)
23 endif
24 else
25 QEMU_SYSTEM=qemu-fast
26 endif
27
28 ifdef CONFIG_USER_ONLY
29 PROGS=$(QEMU_USER)
30 else
31 ifeq ($(TARGET_ARCH), i386)
32
33 ifeq ($(ARCH), i386)
34 PROGS+=$(QEMU_SYSTEM)
35 ifndef CONFIG_SOFTMMU
36 CONFIG_STATIC=y
37 endif
38 else
39 # the system emulator using soft mmu is portable
40 ifdef CONFIG_SOFTMMU
41 PROGS+=$(QEMU_SYSTEM)
42 endif
43 endif # ARCH != i386
44
45 endif # TARGET_ARCH = i386
46
47 ifeq ($(TARGET_ARCH), ppc)
48
49 ifeq ($(ARCH), ppc)
50 PROGS+=$(QEMU_SYSTEM)
51 endif
52
53 ifeq ($(ARCH), i386)
54 ifdef CONFIG_SOFTMMU
55 PROGS+=$(QEMU_SYSTEM)
56 endif
57 endif # ARCH = i386
58
59 ifeq ($(ARCH), amd64)
60 ifdef CONFIG_SOFTMMU
61 PROGS+=$(QEMU_SYSTEM)
62 endif
63 endif # ARCH = amd64
64
65 endif # TARGET_ARCH = ppc
66
67 ifeq ($(TARGET_ARCH), sparc)
68
69 ifeq ($(ARCH), ppc)
70 PROGS+=$(QEMU_SYSTEM)
71 endif
72
73 ifeq ($(ARCH), i386)
74 ifdef CONFIG_SOFTMMU
75 PROGS+=$(QEMU_SYSTEM)
76 endif
77 endif # ARCH = i386
78
79 ifeq ($(ARCH), amd64)
80 ifdef CONFIG_SOFTMMU
81 PROGS+=$(QEMU_SYSTEM)
82 endif
83 endif # ARCH = amd64
84
85 endif # TARGET_ARCH = sparc
86 endif # !CONFIG_USER_ONLY
87
88 ifdef CONFIG_STATIC
89 LDFLAGS+=-static
90 endif
91
92 ifeq ($(ARCH),i386)
93 CFLAGS+=-fomit-frame-pointer
94 OP_CFLAGS=$(CFLAGS) -mpreferred-stack-boundary=2
95 ifeq ($(HAVE_GCC3_OPTIONS),yes)
96 OP_CFLAGS+= -falign-functions=0 -fno-gcse
97 else
98 OP_CFLAGS+= -malign-functions=0
99 endif
100
101 ifdef TARGET_GPROF
102 USE_I386_LD=y
103 endif
104 ifdef CONFIG_STATIC
105 USE_I386_LD=y
106 endif
107 ifdef USE_I386_LD
108 LDFLAGS+=-Wl,-T,$(SRC_PATH)/i386.ld
109 else
110 # WARNING: this LDFLAGS is _very_ tricky : qemu is an ELF shared object
111 # that the kernel ELF loader considers as an executable. I think this
112 # is the simplest way to make it self virtualizable!
113 LDFLAGS+=-Wl,-shared
114 endif
115 endif
116
117 ifeq ($(ARCH),amd64)
118 OP_CFLAGS=$(CFLAGS) -falign-functions=0
119 LDFLAGS+=-Wl,-T,$(SRC_PATH)/amd64.ld
120 endif
121
122 ifeq ($(ARCH),ppc)
123 CFLAGS+= -D__powerpc__
124 OP_CFLAGS=$(CFLAGS)
125 LDFLAGS+=-Wl,-T,$(SRC_PATH)/ppc.ld
126 endif
127
128 ifeq ($(ARCH),s390)
129 OP_CFLAGS=$(CFLAGS)
130 LDFLAGS+=-Wl,-T,$(SRC_PATH)/s390.ld
131 endif
132
133 ifeq ($(ARCH),sparc)
134 CFLAGS+=-m32 -ffixed-g1 -ffixed-g2 -ffixed-g3 -ffixed-g6
135 LDFLAGS+=-m32
136 OP_CFLAGS=$(CFLAGS) -fno-delayed-branch -ffixed-i0
137 HELPER_CFLAGS=$(CFLAGS) -ffixed-i0 -mflat
138 # -static is used to avoid g1/g3 usage by the dynamic linker
139 LDFLAGS+=-Wl,-T,$(SRC_PATH)/sparc.ld -static
140 endif
141
142 ifeq ($(ARCH),sparc64)
143 CFLAGS+=-m64 -ffixed-g1 -ffixed-g2 -ffixed-g3 -ffixed-g6
144 LDFLAGS+=-m64
145 OP_CFLAGS=$(CFLAGS) -fno-delayed-branch -ffixed-i0
146 endif
147
148 ifeq ($(ARCH),alpha)
149 # -msmall-data is not used because we want two-instruction relocations
150 # for the constant constructions
151 OP_CFLAGS=-Wall -O2 -g
152 # Ensure there's only a single GP
153 CFLAGS += -msmall-data
154 LDFLAGS+=-Wl,-T,$(SRC_PATH)/alpha.ld
155 endif
156
157 ifeq ($(ARCH),ia64)
158 OP_CFLAGS=$(CFLAGS)
159 endif
160
161 ifeq ($(ARCH),arm)
162 OP_CFLAGS=$(CFLAGS) -mno-sched-prolog
163 LDFLAGS+=-Wl,-T,$(SRC_PATH)/arm.ld
164 endif
165
166 ifeq ($(ARCH),m68k)
167 OP_CFLAGS=$(CFLAGS) -fomit-frame-pointer
168 LDFLAGS+=-Wl,-T,m68k.ld
169 endif
170
171 ifeq ($(HAVE_GCC3_OPTIONS),yes)
172 # very important to generate a return at the end of every operation
173 OP_CFLAGS+=-fno-reorder-blocks -fno-optimize-sibling-calls
174 endif
175
176 ifeq ($(CONFIG_DARWIN),yes)
177 OP_CFLAGS+= -mdynamic-no-pic
178 endif
179
180 #########################################################
181
182 DEFINES+=-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
183 LIBS+=-lm
184 ifndef CONFIG_USER_ONLY
185 LIBS+=-lz
186 endif
187 ifdef CONFIG_WIN32
188 LIBS+=-lwinmm -lws2_32 -liphlpapi
189 endif
190
191 # profiling code
192 ifdef TARGET_GPROF
193 LDFLAGS+=-p
194 main.o: CFLAGS+=-p
195 endif
196
197 OBJS= elfload.o main.o syscall.o mmap.o signal.o path.o osdep.o thunk.o 
198 ifeq ($(TARGET_ARCH), i386)
199 OBJS+= vm86.o
200 endif
201 ifeq ($(TARGET_ARCH), arm)
202 OBJS+=nwfpe/softfloat.o nwfpe/fpa11.o nwfpe/fpa11_cpdo.o \
203 nwfpe/fpa11_cpdt.o nwfpe/fpa11_cprt.o nwfpe/fpopcode.o nwfpe/single_cpdo.o \
204  nwfpe/double_cpdo.o nwfpe/extended_cpdo.o
205 endif
206 SRCS:= $(OBJS:.o=.c)
207 OBJS+= libqemu.a
208
209 # cpu emulator library
210 LIBOBJS=exec.o translate-all.o cpu-exec.o\
211         translate.o op.o
212
213 ifeq ($(TARGET_ARCH), i386)
214 LIBOBJS+=helper.o helper2.o
215 ifeq ($(ARCH), i386)
216 LIBOBJS+=translate-copy.o
217 endif
218 endif
219
220 ifeq ($(TARGET_ARCH), ppc)
221 LIBOBJS+= op_helper.o helper.o
222 endif
223
224 ifeq ($(TARGET_ARCH), sparc)
225 LIBOBJS+= op_helper.o helper.o
226 endif
227
228 # NOTE: the disassembler code is only needed for debugging
229 LIBOBJS+=disas.o 
230 ifeq ($(findstring i386, $(TARGET_ARCH) $(ARCH)),i386)
231 USE_I386_DIS=y
232 endif
233 ifeq ($(findstring amd64, $(TARGET_ARCH) $(ARCH)),amd64)
234 USE_I386_DIS=y
235 endif
236 ifdef USE_I386_DIS
237 LIBOBJS+=i386-dis.o
238 endif
239 ifeq ($(findstring alpha, $(TARGET_ARCH) $(ARCH)),alpha)
240 LIBOBJS+=alpha-dis.o
241 endif
242 ifeq ($(findstring ppc, $(TARGET_ARCH) $(ARCH)),ppc)
243 LIBOBJS+=ppc-dis.o
244 endif
245 ifeq ($(findstring sparc, $(TARGET_ARCH) $(ARCH)),sparc)
246 LIBOBJS+=sparc-dis.o
247 endif
248 ifeq ($(findstring arm, $(TARGET_ARCH) $(ARCH)),arm)
249 LIBOBJS+=arm-dis.o
250 endif
251
252 ifeq ($(ARCH),ia64)
253 OBJS += ia64-syscall.o
254 endif
255
256 all: $(PROGS)
257
258 $(QEMU_USER): $(OBJS)
259         $(CC) $(LDFLAGS) -o $@ $^  $(LIBS)
260 ifeq ($(ARCH),alpha)
261 # Mark as 32 bit binary, i. e. it will be mapped into the low 31 bit of
262 # the address space (31 bit so sign extending doesn't matter)
263         echo -ne '\001\000\000\000' | dd of=qemu bs=1 seek=48 count=4 conv=notrunc
264 endif
265
266 # must use static linking to avoid leaving stuff in virtual address space
267 VL_OBJS=vl.o osdep.o block.o readline.o monitor.o pci.o console.o 
268 VL_OBJS+=block-cow.o block-qcow.o aes.o block-vmdk.o block-cloop.o
269
270 ifeq ($(TARGET_ARCH), i386)
271 # Hardware support
272 VL_OBJS+= ide.o ne2000.o pckbd.o vga.o sb16.o dma.o oss.o
273 VL_OBJS+= fdc.o mc146818rtc.o serial.o i8259.o i8254.o pc.o 
274 VL_OBJS+= cirrus_vga.o
275 endif
276 ifeq ($(TARGET_ARCH), ppc)
277 VL_OBJS+= ppc.o ide.o ne2000.o pckbd.o vga.o sb16.o dma.o oss.o
278 VL_OBJS+= mc146818rtc.o serial.o i8259.o i8254.o fdc.o m48t59.o
279 VL_OBJS+= ppc_prep.o ppc_chrp.o cuda.o adb.o openpic.o
280 endif
281 ifeq ($(TARGET_ARCH), sparc)
282 VL_OBJS+= sun4m.o tcx.o lance.o iommu.o sched.o m48t08.o magic-load.o timer.o
283 endif
284 ifdef CONFIG_GDBSTUB
285 VL_OBJS+=gdbstub.o 
286 endif
287 ifdef CONFIG_SDL
288 VL_OBJS+=sdl.o
289 endif
290 ifdef CONFIG_SLIRP
291 DEFINES+=-I$(SRC_PATH)/slirp
292 SLIRP_OBJS=cksum.o if.o ip_icmp.o ip_input.o ip_output.o \
293 slirp.o mbuf.o misc.o sbuf.o socket.o tcp_input.o tcp_output.o \
294 tcp_subr.o tcp_timer.o udp.o bootp.o debug.o tftp.o
295 VL_OBJS+=$(addprefix slirp/, $(SLIRP_OBJS))
296 endif
297
298 VL_LDFLAGS=
299 # specific flags are needed for non soft mmu emulator
300 ifdef CONFIG_STATIC
301 VL_LDFLAGS+=-static
302 endif
303 ifndef CONFIG_SOFTMMU
304 VL_LDFLAGS+=-Wl,-T,$(SRC_PATH)/i386-vl.ld 
305 endif
306 ifndef CONFIG_DARWIN
307 ifndef CONFIG_WIN32
308 VL_LIBS=-lutil
309 endif
310 endif
311
312 $(QEMU_SYSTEM): $(VL_OBJS) libqemu.a
313         $(CC) $(VL_LDFLAGS) -o $@ $^ $(LIBS) $(SDL_LIBS) $(VL_LIBS)
314
315 sdl.o: sdl.c
316         $(CC) $(CFLAGS) $(DEFINES) $(SDL_CFLAGS) -c -o $@ $<
317
318 depend: $(SRCS)
319         $(CC) -MM $(CFLAGS) $(DEFINES) $^ 1>.depend
320
321 # libqemu 
322
323 libqemu.a: $(LIBOBJS)
324         rm -f $@
325         $(AR) rcs $@ $(LIBOBJS)
326
327 translate.o: translate.c gen-op.h opc.h cpu.h
328
329 translate-all.o: translate-all.c op.h opc.h cpu.h
330
331 op.h: op.o $(DYNGEN)
332         $(DYNGEN) -o $@ $<
333
334 opc.h: op.o $(DYNGEN)
335         $(DYNGEN) -c -o $@ $<
336
337 gen-op.h: op.o $(DYNGEN)
338         $(DYNGEN) -g -o $@ $<
339
340 op.o: op.c
341         $(CC) $(OP_CFLAGS) $(DEFINES) -c -o $@ $<
342
343 helper.o: helper.c
344         $(CC) $(HELPER_CFLAGS) $(DEFINES) -c -o $@ $<
345
346 ifeq ($(TARGET_ARCH), i386)
347 op.o: op.c opreg_template.h ops_template.h ops_template_mem.h ops_mem.h
348 endif
349
350 ifeq ($(TARGET_ARCH), arm)
351 op.o: op.c op_template.h
352 endif
353
354 ifeq ($(TARGET_ARCH), sparc)
355 op.o: op.c op_template.h op_mem.h
356 endif
357
358 ifeq ($(TARGET_ARCH), ppc)
359 op.o: op.c op_template.h op_mem.h
360 op_helper.o: op_helper_mem.h
361 endif
362
363 %.o: %.c
364         $(CC) $(CFLAGS) $(DEFINES) -c -o $@ $<
365
366 %.o: %.S
367         $(CC) $(DEFINES) -c -o $@ $<
368
369 clean:
370         rm -f *.o  *.a *~ $(PROGS) gen-op.h opc.h op.h nwfpe/*.o slirp/*.o
371
372 install: all 
373 ifneq ($(PROGS),)
374         install -m 755 -s $(PROGS) "$(bindir)"
375 endif
376
377 ifneq ($(wildcard .depend),)
378 include .depend
379 endif