6 LDFLAGS_BASE:=$(LDFLAGS)
7 TARGET_BASE_ARCH:=$(TARGET_ARCH)
8 ifeq ($(TARGET_ARCH), x86_64)
11 ifeq ($(TARGET_ARCH), ppc64)
14 ifeq ($(TARGET_ARCH), sparc64)
15 TARGET_BASE_ARCH:=sparc
17 TARGET_PATH=$(SRC_PATH)/target-$(TARGET_BASE_ARCH)
18 VPATH=$(SRC_PATH):$(TARGET_PATH):$(SRC_PATH)/hw:$(SRC_PATH)/audio
19 CPPFLAGS=-I. -I.. -I$(TARGET_PATH) -I$(SRC_PATH)
20 ifdef CONFIG_DARWIN_USER
21 VPATH+=:$(SRC_PATH)/darwin-user
22 CPPFLAGS+=-I$(SRC_PATH)/darwin-user -I$(SRC_PATH)/darwin-user/$(TARGET_ARCH)
24 ifdef CONFIG_LINUX_USER
25 VPATH+=:$(SRC_PATH)/linux-user
26 CPPFLAGS+=-I$(SRC_PATH)/linux-user -I$(SRC_PATH)/linux-user/$(TARGET_ARCH)
32 HELPER_CFLAGS=$(CFLAGS)
33 DYNGEN=../dyngen$(EXESUF)
35 TARGET_ARCH2=$(TARGET_ARCH)
36 ifeq ($(TARGET_ARCH),arm)
37 ifeq ($(TARGET_WORDS_BIGENDIAN),yes)
41 ifeq ($(TARGET_ARCH),sh4)
42 ifeq ($(TARGET_WORDS_BIGENDIAN),yes)
46 ifeq ($(TARGET_ARCH),mips)
47 ifneq ($(TARGET_WORDS_BIGENDIAN),yes)
51 QEMU_USER=qemu-$(TARGET_ARCH2)
52 # system emulator name
54 ifeq ($(TARGET_ARCH), i386)
55 QEMU_SYSTEM=qemu$(EXESUF)
57 QEMU_SYSTEM=qemu-system-$(TARGET_ARCH2)$(EXESUF)
63 ifdef CONFIG_USER_ONLY
70 endif # !CONFIG_USER_ONLY
76 # We require -O2 to avoid the stack setup prologue in EXIT_TB
77 OP_CFLAGS = -Wall -O2 -g -fno-strict-aliasing
80 HELPER_CFLAGS+=-fomit-frame-pointer
81 OP_CFLAGS+=-mpreferred-stack-boundary=2 -fomit-frame-pointer
82 ifeq ($(HAVE_GCC3_OPTIONS),yes)
83 OP_CFLAGS+= -falign-functions=0 -fno-gcse
85 OP_CFLAGS+= -malign-functions=0
94 BASE_LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
96 ifdef CONFIG_LINUX_USER
97 # WARNING: this LDFLAGS is _very_ tricky : qemu is an ELF shared object
98 # that the kernel ELF loader considers as an executable. I think this
99 # is the simplest way to make it self virtualizable!
100 BASE_LDFLAGS+=-Wl,-shared
105 ifeq ($(ARCH),x86_64)
106 BASE_LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
110 CPPFLAGS+= -D__powerpc__
111 ifdef CONFIG_LINUX_USER
112 BASE_LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
117 BASE_LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
121 ifeq ($(CONFIG_SOLARIS),yes)
122 BASE_CFLAGS+=-mcpu=ultrasparc -m32 -ffixed-g2 -ffixed-g3
124 OP_CFLAGS+=-fno-delayed-branch -fno-omit-frame-pointer -ffixed-i0
126 BASE_CFLAGS+=-mcpu=ultrasparc -m32 -ffixed-g1 -ffixed-g2 -ffixed-g3 -ffixed-g6
128 OP_CFLAGS+=-fno-delayed-branch -ffixed-i0
129 HELPER_CFLAGS=$(CFLAGS) -ffixed-i0 -mflat
130 # -static is used to avoid g1/g3 usage by the dynamic linker
131 BASE_LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld -static
135 ifeq ($(ARCH),sparc64)
136 BASE_CFLAGS+=-mcpu=ultrasparc -m64 -ffixed-g1 -ffixed-g4 -ffixed-g5 -ffixed-g7
138 BASE_LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
139 OP_CFLAGS+=-mcpu=ultrasparc -m64 -ffixed-g1 -ffixed-g4 -ffixed-g5 -ffixed-g7 -fno-delayed-branch -ffixed-i0
143 # -msmall-data is not used for OP_CFLAGS because we want two-instruction
144 # relocations for the constant constructions
145 # Ensure there's only a single GP
146 BASE_CFLAGS+=-msmall-data
147 BASE_LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
151 BASE_CFLAGS+=-mno-sdata
152 OP_CFLAGS+=-mno-sdata
153 BASE_LDFLAGS+=-Wl,-G0 -Wl,-T,$(SRC_PATH)/$(ARCH).ld
157 OP_CFLAGS+=-mno-sched-prolog -fno-omit-frame-pointer
158 BASE_LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
162 OP_CFLAGS+=-fomit-frame-pointer
163 BASE_LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
167 BASE_LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
170 ifeq ($(HAVE_GCC3_OPTIONS),yes)
171 # very important to generate a return at the end of every operation
172 OP_CFLAGS+=-fno-reorder-blocks -fno-optimize-sibling-calls
175 ifeq ($(CONFIG_DARWIN),yes)
179 ifdef CONFIG_DARWIN_USER
180 # Leave some space for the regular program loading zone
181 BASE_LDFLAGS+=-Wl,-segaddr,__STD_PROG_ZONE,0x1000 -image_base 0x0e000000
184 OP_CFLAGS+=$(OS_CFLAGS)
186 #########################################################
188 CPPFLAGS+=-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D__user=
190 ifndef CONFIG_USER_ONLY
194 LIBS+=-lwinmm -lws2_32 -liphlpapi
197 LIBS+=-lsocket -lnsl -lresolv
203 main.o: BASE_CFLAGS+=-p
206 ifdef CONFIG_LINUX_USER
207 OBJS= main.o syscall.o mmap.o signal.o path.o osdep.o thunk.o \
208 elfload.o linuxload.o
209 ifdef TARGET_HAS_BFLT
213 ifeq ($(TARGET_ARCH), i386)
216 ifeq ($(TARGET_ARCH), arm)
217 OBJS+=nwfpe/fpa11.o nwfpe/fpa11_cpdo.o \
218 nwfpe/fpa11_cpdt.o nwfpe/fpa11_cprt.o nwfpe/fpopcode.o nwfpe/single_cpdo.o \
219 nwfpe/double_cpdo.o nwfpe/extended_cpdo.o arm-semi.o
221 ifeq ($(TARGET_ARCH), m68k)
222 OBJS+= m68k-sim.o m68k-semi.o
224 endif #CONFIG_LINUX_USER
226 ifdef CONFIG_DARWIN_USER
227 OBJS= main.o commpage.o machload.o mmap.o osdep.o signal.o syscall.o thunk.o
233 # cpu emulator library
234 LIBOBJS=exec.o kqemu.o qemu-kvm.o translate-op.o translate-all.o cpu-exec.o\
235 translate.o op.o qemu-kvm-helper.o
236 ifdef CONFIG_SOFTFLOAT
237 LIBOBJS+=fpu/softfloat.o
239 LIBOBJS+=fpu/softfloat-native.o
241 CPPFLAGS+=-I$(SRC_PATH)/fpu
243 ifeq ($(TARGET_ARCH), i386)
244 LIBOBJS+=helper.o helper2.o
246 LIBOBJS+=translate-copy.o
250 ifeq ($(TARGET_ARCH), x86_64)
251 LIBOBJS+=helper.o helper2.o
254 ifeq ($(TARGET_BASE_ARCH), ppc)
255 LIBOBJS+= op_helper.o helper.o
258 ifeq ($(TARGET_ARCH), mips)
259 LIBOBJS+= op_helper.o helper.o
262 ifeq ($(TARGET_BASE_ARCH), sparc)
263 LIBOBJS+= op_helper.o helper.o
266 ifeq ($(TARGET_BASE_ARCH), arm)
267 LIBOBJS+= op_helper.o helper.o
270 ifeq ($(TARGET_BASE_ARCH), sh4)
271 LIBOBJS+= op_helper.o helper.o
274 ifeq ($(TARGET_BASE_ARCH), m68k)
278 # NOTE: the disassembler code is only needed for debugging
280 ifeq ($(findstring i386, $(TARGET_ARCH) $(ARCH)),i386)
283 ifeq ($(findstring x86_64, $(TARGET_ARCH) $(ARCH)),x86_64)
289 ifeq ($(findstring alpha, $(TARGET_ARCH) $(ARCH)),alpha)
292 ifeq ($(findstring ppc, $(TARGET_BASE_ARCH) $(ARCH)),ppc)
295 ifeq ($(findstring mips, $(TARGET_ARCH) $(ARCH)),mips)
298 ifeq ($(findstring sparc, $(TARGET_BASE_ARCH) $(ARCH)),sparc)
301 ifeq ($(findstring arm, $(TARGET_ARCH) $(ARCH)),arm)
304 ifeq ($(findstring m68k, $(TARGET_ARCH) $(ARCH)),m68k)
307 ifeq ($(findstring sh4, $(TARGET_ARCH) $(ARCH)),sh4)
317 $(QEMU_USER): $(OBJS)
318 $(CC) $(LDFLAGS) $(BASE_LDFLAGS) -o $@ $^ $(LIBS)
320 # Mark as 32 bit binary, i. e. it will be mapped into the low 31 bit of
321 # the address space (31 bit so sign extending doesn't matter)
322 echo -ne '\001\000\000\000' | dd of=qemu bs=1 seek=48 count=4 conv=notrunc
325 # must use static linking to avoid leaving stuff in virtual address space
326 VL_OBJS=vl.o osdep.o readline.o monitor.o pci.o console.o loader.o isa_mmio.o
327 VL_OBJS+=cutils.o migration.o
328 VL_OBJS+=block.o block-raw.o
329 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 block-qcow2.o
334 SOUND_HW = sb16.o es1370.o
335 AUDIODRV = audio.o noaudio.o wavaudio.o
337 AUDIODRV += sdlaudio.o
340 AUDIODRV += ossaudio.o
342 ifdef CONFIG_COREAUDIO
343 AUDIODRV += coreaudio.o
346 AUDIODRV += alsaaudio.o
350 AUDIODRV += dsoundaudio.o
351 LIBS += -lole32 -ldxguid
354 AUDIODRV += fmodaudio.o
355 audio.o fmodaudio.o: CPPFLAGS := -I$(CONFIG_FMOD_INC) $(CPPFLAGS)
356 LIBS += $(CONFIG_FMOD_LIB)
359 SOUND_HW += fmopl.o adlib.o
361 AUDIODRV+= wavcapture.o
362 ifdef CONFIG_KVM_KERNEL_INC
363 CFLAGS += -I $(CONFIG_KVM_KERNEL_INC)
365 DEPLIBS += ../user/libkvm.a
369 VL_OBJS+= scsi-disk.o cdrom.o lsi53c895a.o
372 VL_OBJS+= usb.o usb-hub.o usb-linux.o usb-hid.o usb-ohci.o usb-msd.o
375 VL_OBJS+= ne2000.o rtl8139.o pcnet.o
378 VL_OBJS+= hypercall.o
380 ifeq ($(TARGET_BASE_ARCH), i386)
382 VL_OBJS+= ide.o pckbd.o ps2.o vga.o $(SOUND_HW) dma.o $(AUDIODRV)
383 VL_OBJS+= fdc.o mc146818rtc.o serial.o i8259.o i8254.o pcspk.o pc.o
384 VL_OBJS+= cirrus_vga.o mixeng.o apic.o parallel.o acpi.o piix_pci.o
385 VL_OBJS+= usb-uhci.o smbus_eeprom.o
386 CPPFLAGS += -DHAS_AUDIO
388 ifeq ($(TARGET_BASE_ARCH), ppc)
389 VL_OBJS+= ppc.o ide.o pckbd.o ps2.o vga.o $(SOUND_HW) dma.o $(AUDIODRV)
390 VL_OBJS+= mc146818rtc.o serial.o i8259.o i8254.o fdc.o m48t59.o
391 VL_OBJS+= ppc_prep.o ppc_chrp.o cuda.o adb.o openpic.o heathrow_pic.o mixeng.o
392 VL_OBJS+= grackle_pci.o prep_pci.o unin_pci.o
393 CPPFLAGS += -DHAS_AUDIO
395 ifeq ($(TARGET_ARCH), mips)
396 VL_OBJS+= mips_r4k.o mips_malta.o mips_timer.o mips_int.o dma.o vga.o serial.o i8254.o i8259.o
397 VL_OBJS+= ide.o gt64xxx.o pckbd.o ps2.o fdc.o mc146818rtc.o usb-uhci.o acpi.o
398 VL_OBJS+= piix_pci.o parallel.o mixeng.o cirrus_vga.o $(SOUND_HW) $(AUDIODRV)
399 DEFINES += -DHAS_AUDIO
401 ifeq ($(TARGET_BASE_ARCH), sparc)
402 ifeq ($(TARGET_ARCH), sparc64)
403 VL_OBJS+= sun4u.o ide.o pckbd.o ps2.o vga.o apb_pci.o
404 VL_OBJS+= fdc.o mc146818rtc.o serial.o m48t59.o
405 VL_OBJS+= cirrus_vga.o parallel.o
407 VL_OBJS+= sun4m.o tcx.o pcnet.o iommu.o m48t59.o slavio_intctl.o
408 VL_OBJS+= slavio_timer.o slavio_serial.o slavio_misc.o fdc.o esp.o sparc32_dma.o
412 ifeq ($(TARGET_BASE_ARCH), arm)
413 VL_OBJS+= integratorcp.o versatilepb.o ps2.o smc91c111.o arm_pic.o arm_timer.o
414 VL_OBJS+= arm_boot.o pl011.o pl050.o pl080.o pl110.o pl190.o
415 VL_OBJS+= versatile_pci.o
416 VL_OBJS+= arm_gic.o realview.o arm_sysctl.o
419 ifeq ($(TARGET_BASE_ARCH), sh4)
420 VL_OBJS+= shix.o sh7750.o sh7750_regnames.o tc58128.o
426 VL_OBJS+=sdl.o x_keymap.o
431 COCOA_LIBS=-F/System/Library/Frameworks -framework Cocoa -framework IOKit
432 ifdef CONFIG_COREAUDIO
433 COCOA_LIBS+=-framework CoreAudio
437 CPPFLAGS+=-I$(SRC_PATH)/slirp
438 SLIRP_OBJS=cksum.o if.o ip_icmp.o ip_input.o ip_output.o \
439 slirp.o mbuf.o misc.o sbuf.o socket.o tcp_input.o tcp_output.o \
440 tcp_subr.o tcp_timer.o udp.o bootp.o debug.o tftp.o
441 VL_OBJS+=$(addprefix slirp/, $(SLIRP_OBJS))
444 VL_LDFLAGS=$(LDFLAGS_BASE)
445 # specific flags are needed for non soft mmu emulator
449 ifndef CONFIG_SOFTMMU
450 VL_LDFLAGS+=-Wl,-T,$(SRC_PATH)/i386-vl.ld
454 ifndef CONFIG_SOLARIS
460 vl.o: BASE_CFLAGS+=-p
465 VL_LDFLAGS+=-Wl,-G0 -Wl,-T,$(SRC_PATH)/ia64.ld
468 ifeq ($(ARCH),sparc64)
470 VL_LDFLAGS+=-Wl,-T,$(SRC_PATH)/sparc64.ld
474 SDL_LIBS := $(filter-out -mwindows, $(SDL_LIBS)) -mconsole
477 $(QEMU_SYSTEM): $(VL_OBJS) libqemu.a $(DEPLIBS)
478 $(CC) $(VL_LDFLAGS) -o $@ $^ $(LIBS) $(SDL_LIBS) $(COCOA_LIBS) $(VL_LIBS)
481 $(CC) $(CFLAGS) $(CPPFLAGS) $(BASE_CFLAGS) -c -o $@ $<
483 sdl.o: sdl.c keymaps.c sdl_keysym.h
484 $(CC) $(CFLAGS) $(CPPFLAGS) $(SDL_CFLAGS) $(BASE_CFLAGS) -c -o $@ $<
486 vnc.o: vnc.c keymaps.c sdl_keysym.h vnchextile.h
487 $(CC) $(CFLAGS) $(CPPFLAGS) $(BASE_CFLAGS) -c -o $@ $<
489 sdlaudio.o: sdlaudio.c
490 $(CC) $(CFLAGS) $(CPPFLAGS) $(SDL_CFLAGS) $(BASE_CFLAGS) -c -o $@ $<
493 $(CC) -MM $(CFLAGS) $(CPPFLAGS) $(BASE_CFLAGS) $^ 1>.depend
495 vldepend: $(VL_OBJS:.o=.c)
496 $(CC) -MM $(CFLAGS) $(CPPFLAGS) $(BASE_CFLAGS) $^ 1>.depend
500 libqemu.a: $(LIBOBJS)
502 $(AR) rcs $@ $(LIBOBJS)
504 translate.o: translate.c gen-op.h opc.h cpu.h
506 translate-all.o: translate-all.c opc.h cpu.h
508 translate-op.o: translate-all.c op.h opc.h cpu.h
513 opc.h: op.o $(DYNGEN)
514 $(DYNGEN) -c -o $@ $<
516 gen-op.h: op.o $(DYNGEN)
517 $(DYNGEN) -g -o $@ $<
520 $(CC) $(OP_CFLAGS) $(CPPFLAGS) -c -o $@ $<
522 # HELPER_CFLAGS is used for all the code compiled with static register
524 ifeq ($(TARGET_BASE_ARCH), i386)
525 # XXX: rename helper.c to op_helper.c
527 $(CC) $(HELPER_CFLAGS) $(CPPFLAGS) $(BASE_CFLAGS) -c -o $@ $<
529 op_helper.o: op_helper.c
530 $(CC) $(HELPER_CFLAGS) $(CPPFLAGS) $(BASE_CFLAGS) -c -o $@ $<
533 cpu-exec.o: cpu-exec.c
534 $(CC) $(HELPER_CFLAGS) $(CPPFLAGS) $(BASE_CFLAGS) -c -o $@ $<
536 qemu-kvm.o: qemu-kvm.c qemu-kvm.h
538 qemu-kvm-helper.o: qemu-kvm-helper.c
539 $(CC) $(HELPER_CFLAGS) $(CPPFLAGS) $(BASE_CFLAGS) -c -o $@ $<
541 # Note: this is a workaround. The real fix is to avoid compiling
542 # cpu_signal_handler() in cpu-exec.c.
544 $(CC) $(HELPER_CFLAGS) $(CPPFLAGS) $(BASE_CFLAGS) -c -o $@ $<
546 ifeq ($(TARGET_BASE_ARCH), i386)
547 op.o: op.c opreg_template.h ops_template.h ops_template_mem.h ops_mem.h ops_sse.h
550 ifeq ($(TARGET_ARCH), arm)
551 op.o: op.c op_template.h
552 pl110.o: pl110_template.h
555 ifeq ($(TARGET_BASE_ARCH), sparc)
556 op.o: op.c op_template.h op_mem.h fop_template.h fbranch_template.h
557 magic_load.o: elf_op.h
560 ifeq ($(TARGET_BASE_ARCH), ppc)
561 op.o: op.c op_template.h op_mem.h
562 op_helper.o: op_helper_mem.h
563 translate.o: translate.c translate_init.c
566 ifeq ($(TARGET_ARCH), mips)
567 op.o: op.c op_template.c fop_template.c op_mem.c
568 op_helper.o: op_helper_mem.c
571 loader.o: loader.c elf_ops.h
573 ifeq ($(TARGET_ARCH), sh4)
574 op.o: op.c op_mem.c cpu.h
575 op_helper.o: op_helper.c exec.h cpu.h
576 helper.o: helper.c exec.h cpu.h
577 sh7750.o: sh7750.c sh7750_regs.h sh7750_regnames.h cpu.h
578 shix.o: shix.c sh7750_regs.h sh7750_regnames.h
579 sh7750_regnames.o: sh7750_regnames.c sh7750_regnames.h sh7750_regs.h
583 $(OBJS) $(LIBOBJS) $(VL_OBJS): config.h ../config-host.h
586 $(CC) $(CFLAGS) $(CPPFLAGS) $(BASE_CFLAGS) -c -o $@ $<
589 $(CC) $(CPPFLAGS) -c -o $@ $<
592 rm -f *.o *.a *~ $(PROGS) gen-op.h opc.h op.h nwfpe/*.o slirp/*.o fpu/*.o
596 $(INSTALL) -m 755 $(PROGS) "$(DESTDIR)$(bindir)"
599 ifneq ($(wildcard .depend),)
604 audio.o sdlaudio.o dsoundaudio.o ossaudio.o wavaudio.o noaudio.o \
605 fmodaudio.o alsaaudio.o mixeng.o sb16.o es1370.o gus.o adlib.o: \
606 CFLAGS := $(CFLAGS) -Wall -Werror -W -Wsign-compare