added NE2000 (Ralf Baechle)
[qemu] / Makefile.target
1 include config.mak
2
3 TARGET_BASE_ARCH:=$(TARGET_ARCH)
4 ifeq ($(TARGET_ARCH), x86_64)
5 TARGET_BASE_ARCH:=i386
6 endif
7 ifeq ($(TARGET_ARCH), sparc64)
8 TARGET_BASE_ARCH:=sparc
9 endif
10 TARGET_PATH=$(SRC_PATH)/target-$(TARGET_BASE_ARCH)
11 VPATH=$(SRC_PATH):$(TARGET_PATH):$(SRC_PATH)/hw:$(SRC_PATH)/audio
12 DEFINES=-I. -I$(TARGET_PATH) -I$(SRC_PATH)
13 ifdef CONFIG_USER_ONLY
14 VPATH+=:$(SRC_PATH)/linux-user
15 DEFINES+=-I$(SRC_PATH)/linux-user -I$(SRC_PATH)/linux-user/$(TARGET_ARCH)
16 endif
17 CFLAGS=-Wall -O2 -g -fno-strict-aliasing
18 #CFLAGS+=-Werror
19 LDFLAGS=-g
20 LIBS=
21 HELPER_CFLAGS=$(CFLAGS)
22 DYNGEN=../dyngen$(EXESUF)
23 # user emulator name
24 ifeq ($(TARGET_ARCH),arm)
25   ifeq ($(TARGET_WORDS_BIGENDIAN),yes)
26     QEMU_USER=qemu-armeb
27   else
28     QEMU_USER=qemu-arm
29   endif
30 else
31   QEMU_USER=qemu-$(TARGET_ARCH)
32 endif
33 # system emulator name
34 ifdef CONFIG_SOFTMMU
35 ifeq ($(TARGET_ARCH), i386)
36 QEMU_SYSTEM=qemu$(EXESUF)
37 else
38 QEMU_SYSTEM=qemu-system-$(TARGET_ARCH)$(EXESUF)
39 endif
40 else
41 QEMU_SYSTEM=qemu-fast
42 endif
43
44 ifdef CONFIG_USER_ONLY
45 PROGS=$(QEMU_USER)
46 else
47 ifeq ($(TARGET_ARCH), i386)
48
49 ifeq ($(ARCH), i386)
50 PROGS+=$(QEMU_SYSTEM)
51 ifndef CONFIG_SOFTMMU
52 CONFIG_STATIC=y
53 endif
54 else
55 # the system emulator using soft mmu is portable
56 ifdef CONFIG_SOFTMMU
57 PROGS+=$(QEMU_SYSTEM)
58 endif
59 endif # ARCH != i386
60
61 endif # TARGET_ARCH = i386
62
63 ifeq ($(TARGET_ARCH), x86_64)
64 ifdef CONFIG_SOFTMMU
65 PROGS+=$(QEMU_SYSTEM)
66 endif
67 endif # TARGET_ARCH = x86_64
68
69 ifeq ($(TARGET_ARCH), ppc)
70
71 ifeq ($(ARCH), ppc)
72 PROGS+=$(QEMU_SYSTEM)
73 endif
74
75 endif # TARGET_ARCH = ppc
76
77 ifeq ($(TARGET_ARCH), mips)
78
79 ifeq ($(ARCH), i386)
80 ifdef CONFIG_SOFTMMU
81 PROGS+=$(QEMU_SYSTEM)
82 endif
83 endif # ARCH = i386
84
85 ifeq ($(ARCH), x86_64)
86 ifdef CONFIG_SOFTMMU
87 PROGS+=$(QEMU_SYSTEM)
88 endif
89 endif # ARCH = x86_64
90
91 endif # TARGET_ARCH = mips
92
93 ifeq ($(TARGET_ARCH), sparc)
94
95 ifeq ($(ARCH), ppc)
96 PROGS+=$(QEMU_SYSTEM)
97 endif
98
99 ifeq ($(ARCH), i386)
100 ifdef CONFIG_SOFTMMU
101 PROGS+=$(QEMU_SYSTEM)
102 endif
103 endif # ARCH = i386
104
105 ifeq ($(ARCH), x86_64)
106 ifdef CONFIG_SOFTMMU
107 PROGS+=$(QEMU_SYSTEM)
108 endif
109 endif # ARCH = x86_64
110
111 endif # TARGET_ARCH = sparc
112
113 ifeq ($(TARGET_ARCH), sparc64)
114 ifdef CONFIG_SOFTMMU
115 PROGS+=$(QEMU_SYSTEM)
116 endif
117 endif # TARGET_ARCH = sparc64
118
119 endif # !CONFIG_USER_ONLY
120
121 ifdef CONFIG_STATIC
122 LDFLAGS+=-static
123 endif
124
125 ifeq ($(ARCH),i386)
126 CFLAGS+=-fomit-frame-pointer
127 OP_CFLAGS=$(CFLAGS) -mpreferred-stack-boundary=2
128 ifeq ($(HAVE_GCC3_OPTIONS),yes)
129 OP_CFLAGS+= -falign-functions=0 -fno-gcse
130 else
131 OP_CFLAGS+= -malign-functions=0
132 endif
133
134 ifdef TARGET_GPROF
135 USE_I386_LD=y
136 endif
137 ifdef CONFIG_STATIC
138 USE_I386_LD=y
139 endif
140 ifdef USE_I386_LD
141 LDFLAGS+=-Wl,-T,$(SRC_PATH)/i386.ld
142 else
143 # WARNING: this LDFLAGS is _very_ tricky : qemu is an ELF shared object
144 # that the kernel ELF loader considers as an executable. I think this
145 # is the simplest way to make it self virtualizable!
146 LDFLAGS+=-Wl,-shared
147 endif
148 endif
149
150 ifeq ($(ARCH),x86_64)
151 OP_CFLAGS=$(CFLAGS) -falign-functions=0
152 LDFLAGS+=-Wl,-T,$(SRC_PATH)/x86_64.ld
153 endif
154
155 ifeq ($(ARCH),ppc)
156 CFLAGS+= -D__powerpc__
157 OP_CFLAGS=$(CFLAGS)
158 LDFLAGS+=-Wl,-T,$(SRC_PATH)/ppc.ld
159 endif
160
161 ifeq ($(ARCH),s390)
162 OP_CFLAGS=$(CFLAGS)
163 LDFLAGS+=-Wl,-T,$(SRC_PATH)/s390.ld
164 endif
165
166 ifeq ($(ARCH),sparc)
167 CFLAGS+=-m32 -ffixed-g1 -ffixed-g2 -ffixed-g3 -ffixed-g6
168 LDFLAGS+=-m32
169 OP_CFLAGS=$(CFLAGS) -fno-delayed-branch -ffixed-i0
170 HELPER_CFLAGS=$(CFLAGS) -ffixed-i0 -mflat
171 # -static is used to avoid g1/g3 usage by the dynamic linker
172 LDFLAGS+=-Wl,-T,$(SRC_PATH)/sparc.ld -static
173 endif
174
175 ifeq ($(ARCH),sparc64)
176 CFLAGS+=-m64 -ffixed-g1 -ffixed-g2 -ffixed-g3 -ffixed-g6
177 LDFLAGS+=-m64
178 OP_CFLAGS=$(CFLAGS) -fno-delayed-branch -ffixed-i0
179 endif
180
181 ifeq ($(ARCH),alpha)
182 # -msmall-data is not used because we want two-instruction relocations
183 # for the constant constructions
184 OP_CFLAGS=-Wall -O2 -g
185 # Ensure there's only a single GP
186 CFLAGS += -msmall-data
187 LDFLAGS+=-Wl,-T,$(SRC_PATH)/alpha.ld
188 endif
189
190 ifeq ($(ARCH),ia64)
191 CFLAGS += -mno-sdata
192 OP_CFLAGS=$(CFLAGS)
193 LDFLAGS+=-Wl,-G0 -Wl,-T,$(SRC_PATH)/ia64.ld
194 endif
195
196 ifeq ($(ARCH),arm)
197 OP_CFLAGS=$(CFLAGS) -mno-sched-prolog -fno-omit-frame-pointer
198 LDFLAGS+=-Wl,-T,$(SRC_PATH)/arm.ld
199 endif
200
201 ifeq ($(ARCH),m68k)
202 OP_CFLAGS=$(CFLAGS) -fomit-frame-pointer
203 LDFLAGS+=-Wl,-T,m68k.ld
204 endif
205
206 ifeq ($(HAVE_GCC3_OPTIONS),yes)
207 # very important to generate a return at the end of every operation
208 OP_CFLAGS+=-fno-reorder-blocks -fno-optimize-sibling-calls
209 endif
210
211 ifeq ($(CONFIG_DARWIN),yes)
212 OP_CFLAGS+= -mdynamic-no-pic
213 LIBS+=-lmx
214 endif
215
216 #########################################################
217
218 DEFINES+=-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
219 LIBS+=-lm
220 ifndef CONFIG_USER_ONLY
221 LIBS+=-lz
222 endif
223 ifdef CONFIG_WIN32
224 LIBS+=-lwinmm -lws2_32 -liphlpapi
225 endif
226
227 # profiling code
228 ifdef TARGET_GPROF
229 LDFLAGS+=-p
230 main.o: CFLAGS+=-p
231 endif
232
233 OBJS= elfload.o main.o syscall.o mmap.o signal.o path.o osdep.o thunk.o 
234 ifeq ($(TARGET_ARCH), i386)
235 OBJS+= vm86.o
236 endif
237 ifeq ($(TARGET_ARCH), arm)
238 OBJS+=nwfpe/fpa11.o nwfpe/fpa11_cpdo.o \
239 nwfpe/fpa11_cpdt.o nwfpe/fpa11_cprt.o nwfpe/fpopcode.o nwfpe/single_cpdo.o \
240  nwfpe/double_cpdo.o nwfpe/extended_cpdo.o arm-semi.o
241 endif
242 SRCS:= $(OBJS:.o=.c)
243 OBJS+= libqemu.a
244
245 # cpu emulator library
246 LIBOBJS=exec.o kqemu.o translate-op.o translate-all.o cpu-exec.o\
247         translate.o op.o 
248 ifdef CONFIG_SOFTFLOAT
249 LIBOBJS+=fpu/softfloat.o
250 else
251 LIBOBJS+=fpu/softfloat-native.o
252 endif
253 DEFINES+=-I$(SRC_PATH)/fpu
254
255 ifeq ($(TARGET_ARCH), i386)
256 LIBOBJS+=helper.o helper2.o
257 ifeq ($(ARCH), i386)
258 LIBOBJS+=translate-copy.o
259 endif
260 endif
261
262 ifeq ($(TARGET_ARCH), x86_64)
263 LIBOBJS+=helper.o helper2.o
264 endif
265
266 ifeq ($(TARGET_ARCH), ppc)
267 LIBOBJS+= op_helper.o helper.o
268 endif
269
270 ifeq ($(TARGET_ARCH), mips)
271 LIBOBJS+= op_helper.o helper.o
272 endif
273
274 ifeq ($(TARGET_BASE_ARCH), sparc)
275 LIBOBJS+= op_helper.o helper.o
276 endif
277
278 ifeq ($(TARGET_BASE_ARCH), arm)
279 LIBOBJS+= op_helper.o
280 endif
281
282 # NOTE: the disassembler code is only needed for debugging
283 LIBOBJS+=disas.o 
284 ifeq ($(findstring i386, $(TARGET_ARCH) $(ARCH)),i386)
285 USE_I386_DIS=y
286 endif
287 ifeq ($(findstring x86_64, $(TARGET_ARCH) $(ARCH)),x86_64)
288 USE_I386_DIS=y
289 endif
290 ifdef USE_I386_DIS
291 LIBOBJS+=i386-dis.o
292 endif
293 ifeq ($(findstring alpha, $(TARGET_ARCH) $(ARCH)),alpha)
294 LIBOBJS+=alpha-dis.o
295 endif
296 ifeq ($(findstring ppc, $(TARGET_ARCH) $(ARCH)),ppc)
297 LIBOBJS+=ppc-dis.o
298 endif
299 ifeq ($(findstring mips, $(TARGET_ARCH) $(ARCH)),mips)
300 LIBOBJS+=mips-dis.o
301 endif
302 ifeq ($(findstring sparc, $(TARGET_BASE_ARCH) $(ARCH)),sparc)
303 LIBOBJS+=sparc-dis.o
304 endif
305 ifeq ($(findstring arm, $(TARGET_ARCH) $(ARCH)),arm)
306 LIBOBJS+=arm-dis.o
307 endif
308
309 ifeq ($(ARCH),ia64)
310 OBJS += ia64-syscall.o
311 endif
312 ifdef CONFIG_GDBSTUB
313 OBJS+=gdbstub.o
314 endif
315
316 all: $(PROGS)
317
318 $(QEMU_USER): $(OBJS)
319         $(CC) $(LDFLAGS) -o $@ $^  $(LIBS)
320 ifeq ($(ARCH),alpha)
321 # Mark as 32 bit binary, i. e. it will be mapped into the low 31 bit of
322 # the address space (31 bit so sign extending doesn't matter)
323         echo -ne '\001\000\000\000' | dd of=qemu bs=1 seek=48 count=4 conv=notrunc
324 endif
325
326 # must use static linking to avoid leaving stuff in virtual address space
327 VL_OBJS=vl.o osdep.o block.o readline.o monitor.o pci.o console.o
328 VL_OBJS+=block-cow.o block-qcow.o aes.o block-vmdk.o block-cloop.o block-dmg.o block-bochs.o block-vpc.o block-vvfat.o
329
330 SOUND_HW = sb16.o
331 AUDIODRV = audio.o noaudio.o wavaudio.o
332 ifdef CONFIG_SDL
333 AUDIODRV += sdlaudio.o
334 endif
335 ifdef CONFIG_OSS
336 AUDIODRV += ossaudio.o
337 endif
338
339 pc.o: DEFINES := -DUSE_SB16 $(DEFINES)
340
341 ifdef CONFIG_ADLIB
342 SOUND_HW += fmopl.o adlib.o
343 endif
344
345 ifdef CONFIG_FMOD
346 AUDIODRV += fmodaudio.o
347 audio.o fmodaudio.o: DEFINES := -I$(CONFIG_FMOD_INC) $(DEFINES)
348 LIBS += $(CONFIG_FMOD_LIB)
349 endif
350
351 ifeq ($(TARGET_BASE_ARCH), i386)
352 # Hardware support
353 VL_OBJS+= ide.o ne2000.o pckbd.o vga.o $(SOUND_HW) dma.o $(AUDIODRV)
354 VL_OBJS+= fdc.o mc146818rtc.o serial.o i8259.o i8254.o pc.o
355 VL_OBJS+= cirrus_vga.o mixeng.o apic.o parallel.o
356 endif
357 ifeq ($(TARGET_ARCH), ppc)
358 VL_OBJS+= ppc.o ide.o ne2000.o pckbd.o vga.o $(SOUND_HW) dma.o $(AUDIODRV)
359 VL_OBJS+= mc146818rtc.o serial.o i8259.o i8254.o fdc.o m48t59.o
360 VL_OBJS+= ppc_prep.o ppc_chrp.o cuda.o adb.o openpic.o heathrow_pic.o mixeng.o
361 endif
362 ifeq ($(TARGET_ARCH), mips)
363 VL_OBJS+= mips.o mips_r4k.o dma.o vga.o serial.o ne2000.o #ide.o pckbd.o
364 VL_OBJS+= #i8259.o i8254.o fdc.o m48t59.o
365 endif
366 ifeq ($(TARGET_BASE_ARCH), sparc)
367 ifeq ($(TARGET_ARCH), sparc64)
368 VL_OBJS+= sun4u.o m48t08.o magic-load.o slavio_serial.o
369 else
370 VL_OBJS+= sun4m.o tcx.o lance.o iommu.o m48t08.o magic-load.o slavio_intctl.o slavio_timer.o slavio_serial.o slavio_misc.o fdc.o esp.o
371 endif
372 endif
373 ifdef CONFIG_GDBSTUB
374 VL_OBJS+=gdbstub.o 
375 endif
376 ifdef CONFIG_SDL
377 VL_OBJS+=sdl.o
378 endif
379 ifdef CONFIG_COCOA
380 VL_OBJS+=cocoa.o
381 COCOA_LIBS=-F/System/Library/Frameworks -framework Cocoa
382 endif
383 ifdef CONFIG_SLIRP
384 DEFINES+=-I$(SRC_PATH)/slirp
385 SLIRP_OBJS=cksum.o if.o ip_icmp.o ip_input.o ip_output.o \
386 slirp.o mbuf.o misc.o sbuf.o socket.o tcp_input.o tcp_output.o \
387 tcp_subr.o tcp_timer.o udp.o bootp.o debug.o tftp.o
388 VL_OBJS+=$(addprefix slirp/, $(SLIRP_OBJS))
389 endif
390
391 VL_LDFLAGS=
392 # specific flags are needed for non soft mmu emulator
393 ifdef CONFIG_STATIC
394 VL_LDFLAGS+=-static
395 endif
396 ifndef CONFIG_SOFTMMU
397 VL_LDFLAGS+=-Wl,-T,$(SRC_PATH)/i386-vl.ld 
398 endif
399 ifndef CONFIG_DARWIN
400 ifndef CONFIG_WIN32
401 VL_LIBS=-lutil
402 endif
403 endif
404 ifdef TARGET_GPROF
405 vl.o: CFLAGS+=-p
406 VL_LDFLAGS+=-p
407 endif
408
409 ifeq ($(ARCH),ia64)
410 VL_LDFLAGS+=-Wl,-G0 -Wl,-T,$(SRC_PATH)/ia64.ld
411 endif
412
413 $(QEMU_SYSTEM): $(VL_OBJS) libqemu.a
414         $(CC) $(VL_LDFLAGS) -o $@ $^ $(LIBS) $(SDL_LIBS) $(COCOA_LIBS) $(VL_LIBS)
415
416 cocoa.o: cocoa.m
417         $(CC) $(CFLAGS) $(DEFINES) -c -o $@ $<
418
419 sdl.o: sdl.c keymaps.c sdl_keysym.h
420         $(CC) $(CFLAGS) $(DEFINES) $(SDL_CFLAGS) -c -o $@ $<
421
422 sdlaudio.o: sdlaudio.c
423         $(CC) $(CFLAGS) $(DEFINES) $(SDL_CFLAGS) -c -o $@ $<
424
425 depend: $(SRCS)
426         $(CC) -MM $(CFLAGS) $(DEFINES) $^ 1>.depend
427
428 # libqemu 
429
430 libqemu.a: $(LIBOBJS)
431         rm -f $@
432         $(AR) rcs $@ $(LIBOBJS)
433
434 translate.o: translate.c gen-op.h opc.h cpu.h
435
436 translate-all.o: translate-all.c opc.h cpu.h
437
438 translate-op.o: translate-all.c op.h opc.h cpu.h
439
440 op.h: op.o $(DYNGEN)
441         $(DYNGEN) -o $@ $<
442
443 opc.h: op.o $(DYNGEN)
444         $(DYNGEN) -c -o $@ $<
445
446 gen-op.h: op.o $(DYNGEN)
447         $(DYNGEN) -g -o $@ $<
448
449 op.o: op.c
450         $(CC) $(OP_CFLAGS) $(DEFINES) -c -o $@ $<
451
452 helper.o: helper.c
453         $(CC) $(HELPER_CFLAGS) $(DEFINES) -c -o $@ $<
454
455 ifeq ($(TARGET_BASE_ARCH), i386)
456 op.o: op.c opreg_template.h ops_template.h ops_template_mem.h ops_mem.h ops_sse.h
457 endif
458
459 ifeq ($(TARGET_ARCH), arm)
460 op.o: op.c op_template.h
461 endif
462
463 ifeq ($(TARGET_BASE_ARCH), sparc)
464 op.o: op.c op_template.h op_mem.h fop_template.h fbranch_template.h
465 magic_load.o: elf_op.h
466 endif
467
468 ifeq ($(TARGET_ARCH), ppc)
469 op.o: op.c op_template.h op_mem.h
470 op_helper.o: op_helper_mem.h
471 endif
472
473 ifeq ($(TARGET_ARCH), mips)
474 op.o: op.c op_template.c op_mem.c
475 op_helper.o: op_helper_mem.c
476 endif
477
478 mixeng.o: mixeng.c mixeng.h mixeng_template.h
479
480 %.o: %.c
481         $(CC) $(CFLAGS) $(DEFINES) -c -o $@ $<
482
483 %.o: %.S
484         $(CC) $(DEFINES) -c -o $@ $<
485
486 clean:
487         rm -f *.o  *.a *~ $(PROGS) gen-op.h opc.h op.h nwfpe/*.o slirp/*.o fpu/*.o
488
489 install: all 
490 ifneq ($(PROGS),)
491         install -m 755 -s $(PROGS) "$(bindir)"
492 endif
493
494 ifneq ($(wildcard .depend),)
495 include .depend
496 endif