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