3 TARGET_BASE_ARCH:=$(TARGET_ARCH)
4 ifeq ($(TARGET_ARCH), x86_64)
7 ifeq ($(TARGET_ARCH), ppc64)
10 ifeq ($(TARGET_ARCH), sparc64)
11 TARGET_BASE_ARCH:=sparc
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)
20 CFLAGS=-Wall -O2 -g -fno-strict-aliasing
24 HELPER_CFLAGS=$(CFLAGS)
25 DYNGEN=../dyngen$(EXESUF)
27 TARGET_ARCH2=$(TARGET_ARCH)
28 ifeq ($(TARGET_ARCH),arm)
29 ifeq ($(TARGET_WORDS_BIGENDIAN),yes)
33 ifeq ($(TARGET_ARCH),sh4)
34 ifeq ($(TARGET_WORDS_BIGENDIAN),yes)
38 ifeq ($(TARGET_ARCH),mips)
39 ifneq ($(TARGET_WORDS_BIGENDIAN),yes)
43 QEMU_USER=qemu-$(TARGET_ARCH2)
44 # system emulator name
46 ifeq ($(TARGET_ARCH), i386)
47 QEMU_SYSTEM=qemu$(EXESUF)
49 QEMU_SYSTEM=qemu-system-$(TARGET_ARCH2)$(EXESUF)
55 ifdef CONFIG_USER_ONLY
62 endif # !CONFIG_USER_ONLY
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
74 OP_CFLAGS+= -malign-functions=0
84 LDFLAGS+=-Wl,-T,$(SRC_PATH)/i386.ld
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!
94 OP_CFLAGS=$(CFLAGS) -falign-functions=0
95 LDFLAGS+=-Wl,-T,$(SRC_PATH)/x86_64.ld
99 CFLAGS+= -D__powerpc__
101 LDFLAGS+=-Wl,-T,$(SRC_PATH)/ppc.ld
106 LDFLAGS+=-Wl,-T,$(SRC_PATH)/s390.ld
110 ifeq ($(CONFIG_SOLARIS),yes)
111 CFLAGS+=-mcpu=ultrasparc -m32 -ffixed-g2 -ffixed-g3
113 OP_CFLAGS=$(CFLAGS) -fno-delayed-branch -fno-omit-frame-pointer -ffixed-i0
115 CFLAGS+=-mcpu=ultrasparc -m32 -ffixed-g1 -ffixed-g2 -ffixed-g3 -ffixed-g6
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
124 ifeq ($(ARCH),sparc64)
125 CFLAGS+=-mcpu=ultrasparc -m64 -ffixed-g1 -ffixed-g4 -ffixed-g5 -ffixed-g7
127 LDFLAGS+=-Wl,-T,$(SRC_PATH)/sparc64.ld
128 OP_CFLAGS=$(CFLAGS) -fno-delayed-branch -ffixed-i0
132 # -msmall-data is not used because we want two-instruction relocations
133 # for the constant constructions
134 OP_CFLAGS=-Wall -O2 -g
135 # Ensure there's only a single GP
136 CFLAGS += -msmall-data
137 LDFLAGS+=-Wl,-T,$(SRC_PATH)/alpha.ld
143 LDFLAGS+=-Wl,-G0 -Wl,-T,$(SRC_PATH)/ia64.ld
147 OP_CFLAGS=$(CFLAGS) -mno-sched-prolog -fno-omit-frame-pointer
148 LDFLAGS+=-Wl,-T,$(SRC_PATH)/arm.ld
152 OP_CFLAGS=$(CFLAGS) -fomit-frame-pointer
153 LDFLAGS+=-Wl,-T,m68k.ld
156 ifeq ($(HAVE_GCC3_OPTIONS),yes)
157 # very important to generate a return at the end of every operation
158 OP_CFLAGS+=-fno-reorder-blocks -fno-optimize-sibling-calls
161 ifeq ($(CONFIG_DARWIN),yes)
162 OP_CFLAGS+= -mdynamic-no-pic
166 #########################################################
168 DEFINES+=-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
170 ifndef CONFIG_USER_ONLY
174 LIBS+=-lwinmm -lws2_32 -liphlpapi
177 LIBS+=-lsocket -lnsl -lresolv
186 OBJS= main.o syscall.o mmap.o signal.o path.o osdep.o thunk.o \
187 elfload.o linuxload.o
188 ifdef TARGET_HAS_BFLT
192 ifeq ($(TARGET_ARCH), i386)
195 ifeq ($(TARGET_ARCH), arm)
196 OBJS+=nwfpe/fpa11.o nwfpe/fpa11_cpdo.o \
197 nwfpe/fpa11_cpdt.o nwfpe/fpa11_cprt.o nwfpe/fpopcode.o nwfpe/single_cpdo.o \
198 nwfpe/double_cpdo.o nwfpe/extended_cpdo.o arm-semi.o
203 # cpu emulator library
204 LIBOBJS=exec.o kqemu.o qemu-kvm.o translate-op.o translate-all.o cpu-exec.o\
206 ifdef CONFIG_SOFTFLOAT
207 LIBOBJS+=fpu/softfloat.o
209 LIBOBJS+=fpu/softfloat-native.o
211 DEFINES+=-I$(SRC_PATH)/fpu
213 ifeq ($(TARGET_ARCH), i386)
214 LIBOBJS+=helper.o helper2.o
216 LIBOBJS+=translate-copy.o
220 ifeq ($(TARGET_ARCH), x86_64)
221 LIBOBJS+=helper.o helper2.o
224 ifeq ($(TARGET_BASE_ARCH), ppc)
225 LIBOBJS+= op_helper.o helper.o
228 ifeq ($(TARGET_ARCH), mips)
229 LIBOBJS+= op_helper.o helper.o
232 ifeq ($(TARGET_BASE_ARCH), sparc)
233 LIBOBJS+= op_helper.o helper.o
236 ifeq ($(TARGET_BASE_ARCH), arm)
237 LIBOBJS+= op_helper.o helper.o
240 ifeq ($(TARGET_BASE_ARCH), sh4)
241 LIBOBJS+= op_helper.o helper.o
244 # NOTE: the disassembler code is only needed for debugging
246 ifeq ($(findstring i386, $(TARGET_ARCH) $(ARCH)),i386)
249 ifeq ($(findstring x86_64, $(TARGET_ARCH) $(ARCH)),x86_64)
255 ifeq ($(findstring alpha, $(TARGET_ARCH) $(ARCH)),alpha)
258 ifeq ($(findstring ppc, $(TARGET_BASE_ARCH) $(ARCH)),ppc)
261 ifeq ($(findstring mips, $(TARGET_ARCH) $(ARCH)),mips)
264 ifeq ($(findstring sparc, $(TARGET_BASE_ARCH) $(ARCH)),sparc)
267 ifeq ($(findstring arm, $(TARGET_ARCH) $(ARCH)),arm)
270 ifeq ($(findstring m68k, $(TARGET_ARCH) $(ARCH)),m68k)
273 ifeq ($(findstring sh4, $(TARGET_ARCH) $(ARCH)),sh4)
283 $(QEMU_USER): $(OBJS)
284 $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
286 # Mark as 32 bit binary, i. e. it will be mapped into the low 31 bit of
287 # the address space (31 bit so sign extending doesn't matter)
288 echo -ne '\001\000\000\000' | dd of=qemu bs=1 seek=48 count=4 conv=notrunc
291 # must use static linking to avoid leaving stuff in virtual address space
292 VL_OBJS=vl.o osdep.o block.o readline.o monitor.o pci.o console.o loader.o
293 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
298 SOUND_HW = sb16.o es1370.o
299 AUDIODRV = audio.o noaudio.o wavaudio.o
301 AUDIODRV += sdlaudio.o
304 AUDIODRV += ossaudio.o
306 ifdef CONFIG_COREAUDIO
307 AUDIODRV += coreaudio.o
310 AUDIODRV += alsaaudio.o
314 AUDIODRV += dsoundaudio.o
315 LIBS += -lole32 -ldxguid
318 AUDIODRV += fmodaudio.o
319 audio.o fmodaudio.o: DEFINES := -I$(CONFIG_FMOD_INC) $(DEFINES)
320 LIBS += $(CONFIG_FMOD_LIB)
323 SOUND_HW += fmopl.o adlib.o
325 AUDIODRV+= wavcapture.o
327 DEFINES += -I $(CONFIG_KVM_INC) -I $(CONFIG_KVM_KERNEL_INC)
328 LIBS += -L $(CONFIG_KVM_LIB) -lkvm
332 VL_OBJS+= scsi-disk.o cdrom.o lsi53c895a.o
335 VL_OBJS+= usb.o usb-hub.o usb-linux.o usb-hid.o usb-ohci.o usb-msd.o
338 VL_OBJS+= ne2000.o rtl8139.o pcnet.o
340 ifeq ($(TARGET_BASE_ARCH), i386)
342 VL_OBJS+= ide.o pckbd.o ps2.o vga.o $(SOUND_HW) dma.o $(AUDIODRV)
343 VL_OBJS+= fdc.o mc146818rtc.o serial.o i8259.o i8254.o pcspk.o pc.o
344 VL_OBJS+= cirrus_vga.o mixeng.o apic.o parallel.o acpi.o piix_pci.o
346 DEFINES += -DHAS_AUDIO
348 ifeq ($(TARGET_BASE_ARCH), ppc)
349 VL_OBJS+= ppc.o ide.o pckbd.o ps2.o vga.o $(SOUND_HW) dma.o $(AUDIODRV)
350 VL_OBJS+= mc146818rtc.o serial.o i8259.o i8254.o fdc.o m48t59.o
351 VL_OBJS+= ppc_prep.o ppc_chrp.o cuda.o adb.o openpic.o heathrow_pic.o mixeng.o
352 VL_OBJS+= grackle_pci.o prep_pci.o unin_pci.o
353 DEFINES += -DHAS_AUDIO
355 ifeq ($(TARGET_ARCH), mips)
356 VL_OBJS+= mips_r4k.o dma.o vga.o serial.o i8254.o i8259.o
357 #VL_OBJS+= #ide.o pckbd.o fdc.o m48t59.o
359 ifeq ($(TARGET_BASE_ARCH), sparc)
360 ifeq ($(TARGET_ARCH), sparc64)
361 VL_OBJS+= sun4u.o ide.o pckbd.o ps2.o vga.o apb_pci.o
362 VL_OBJS+= fdc.o mc146818rtc.o serial.o m48t59.o
363 VL_OBJS+= cirrus_vga.o parallel.o
365 VL_OBJS+= sun4m.o tcx.o lance.o iommu.o m48t59.o slavio_intctl.o
366 VL_OBJS+= slavio_timer.o slavio_serial.o slavio_misc.o fdc.o esp.o
369 ifeq ($(TARGET_BASE_ARCH), arm)
370 VL_OBJS+= integratorcp.o versatilepb.o ps2.o smc91c111.o arm_pic.o arm_timer.o
371 VL_OBJS+= arm_boot.o pl011.o pl050.o pl080.o pl110.o pl190.o
372 VL_OBJS+= versatile_pci.o
374 ifeq ($(TARGET_BASE_ARCH), sh4)
375 VL_OBJS+= shix.o sh7750.o sh7750_regnames.o tc58128.o
386 COCOA_LIBS=-F/System/Library/Frameworks -framework Cocoa -framework IOKit
387 ifdef CONFIG_COREAUDIO
388 COCOA_LIBS+=-framework CoreAudio
392 DEFINES+=-I$(SRC_PATH)/slirp
393 SLIRP_OBJS=cksum.o if.o ip_icmp.o ip_input.o ip_output.o \
394 slirp.o mbuf.o misc.o sbuf.o socket.o tcp_input.o tcp_output.o \
395 tcp_subr.o tcp_timer.o udp.o bootp.o debug.o tftp.o
396 VL_OBJS+=$(addprefix slirp/, $(SLIRP_OBJS))
400 # specific flags are needed for non soft mmu emulator
404 ifndef CONFIG_SOFTMMU
405 VL_LDFLAGS+=-Wl,-T,$(SRC_PATH)/i386-vl.ld
409 ifndef CONFIG_SOLARIS
410 VL_LIBS=-lutil -lrt -luuid
420 VL_LDFLAGS+=-Wl,-G0 -Wl,-T,$(SRC_PATH)/ia64.ld
423 ifeq ($(ARCH),sparc64)
425 VL_LDFLAGS+=-Wl,-T,$(SRC_PATH)/sparc64.ld
429 SDL_LIBS := $(filter-out -mwindows, $(SDL_LIBS)) -mconsole
432 $(QEMU_SYSTEM): $(VL_OBJS) libqemu.a
433 $(CC) $(VL_LDFLAGS) -o $@ $^ $(LIBS) $(SDL_LIBS) $(COCOA_LIBS) $(VL_LIBS)
436 $(CC) $(CFLAGS) $(DEFINES) -c -o $@ $<
438 sdl.o: sdl.c keymaps.c sdl_keysym.h
439 $(CC) $(CFLAGS) $(DEFINES) $(SDL_CFLAGS) -c -o $@ $<
441 vnc.o: vnc.c keymaps.c sdl_keysym.h vnchextile.h
442 $(CC) $(CFLAGS) $(DEFINES) -c -o $@ $<
444 sdlaudio.o: sdlaudio.c
445 $(CC) $(CFLAGS) $(DEFINES) $(SDL_CFLAGS) -c -o $@ $<
448 $(CC) -MM $(CFLAGS) $(DEFINES) $^ 1>.depend
450 vldepend: $(VL_OBJS:.o=.c)
451 $(CC) -MM $(CFLAGS) $(DEFINES) $^ 1>.depend
455 libqemu.a: $(LIBOBJS)
457 $(AR) rcs $@ $(LIBOBJS)
459 translate.o: translate.c gen-op.h opc.h cpu.h
461 translate-all.o: translate-all.c opc.h cpu.h
463 translate-op.o: translate-all.c op.h opc.h cpu.h
468 opc.h: op.o $(DYNGEN)
469 $(DYNGEN) -c -o $@ $<
471 gen-op.h: op.o $(DYNGEN)
472 $(DYNGEN) -g -o $@ $<
475 $(CC) $(OP_CFLAGS) $(DEFINES) -c -o $@ $<
478 $(CC) $(HELPER_CFLAGS) $(DEFINES) -c -o $@ $<
480 ifeq ($(TARGET_BASE_ARCH), i386)
481 op.o: op.c opreg_template.h ops_template.h ops_template_mem.h ops_mem.h ops_sse.h
484 ifeq ($(TARGET_ARCH), arm)
485 op.o: op.c op_template.h
486 pl110.o: pl110_template.h
489 ifeq ($(TARGET_BASE_ARCH), sparc)
490 op.o: op.c op_template.h op_mem.h fop_template.h fbranch_template.h
491 magic_load.o: elf_op.h
494 ifeq ($(TARGET_BASE_ARCH), ppc)
495 op.o: op.c op_template.h op_mem.h
496 op_helper.o: op_helper_mem.h
497 translate.o: translate.c translate_init.c
500 ifeq ($(TARGET_ARCH), mips)
501 op.o: op.c op_template.c op_mem.c
502 op_helper.o: op_helper_mem.c
505 loader.o: loader.c elf_ops.h
507 acpi.o: acpi.c acpi-dsdt.hex
509 ifdef BUILD_ACPI_TABLES
510 $(SRC_PATH)/hw/acpi-dsdt.hex: acpi-dsdt.dsl
514 ifeq ($(TARGET_ARCH), sh4)
515 op.o: op.c op_mem.c cpu.h
516 op_helper.o: op_helper.c exec.h cpu.h
517 helper.o: helper.c exec.h cpu.h
518 sh7750.o: sh7750.c sh7750_regs.h sh7750_regnames.h cpu.h
519 shix.o: shix.c sh7750_regs.h sh7750_regnames.h
520 sh7750_regnames.o: sh7750_regnames.c sh7750_regnames.h sh7750_regs.h
524 $(OBJS) $(LIBOBJS) $(VL_OBJS): config.h ../config-host.h
527 $(CC) $(CFLAGS) $(DEFINES) -c -o $@ $<
530 $(CC) $(DEFINES) -c -o $@ $<
533 rm -f *.o *.a *~ $(PROGS) gen-op.h opc.h op.h nwfpe/*.o slirp/*.o fpu/*.o
537 $(INSTALL) -m 755 $(PROGS) "$(DESTDIR)$(bindir)"
540 ifneq ($(wildcard .depend),)
545 audio.o sdlaudio.o dsoundaudio.o ossaudio.o wavaudio.o noaudio.o \
546 fmodaudio.o alsaaudio.o mixeng.o sb16.o es1370.o gus.o adlib.o: \
547 CFLAGS := $(CFLAGS) -Wall -Werror -W -Wsign-compare