3 TARGET_BASE_ARCH:=$(TARGET_ARCH)
4 ifeq ($(TARGET_ARCH), x86_64)
7 ifeq ($(TARGET_ARCH), mipsn32)
10 ifeq ($(TARGET_ARCH), mips64)
11 TARGET_BASE_ARCH:=mips
13 ifeq ($(TARGET_ARCH), ppc64)
16 ifeq ($(TARGET_ARCH), ppc64h)
19 ifeq ($(TARGET_ARCH), ppcemb)
22 ifeq ($(TARGET_ARCH), sparc64)
23 TARGET_BASE_ARCH:=sparc
25 TARGET_PATH=$(SRC_PATH)/target-$(TARGET_BASE_ARCH)
26 VPATH=$(SRC_PATH):$(TARGET_PATH):$(SRC_PATH)/hw
27 CPPFLAGS=-I. -I.. -I$(TARGET_PATH) -I$(SRC_PATH) -MMD -MT $@ -MP -DNEED_CPU_H
30 DYNGEN=../dyngen$(EXESUF)
33 TARGET_ARCH2=$(TARGET_ARCH)
35 ifeq ($(TARGET_ARCH),arm)
36 ifeq ($(TARGET_WORDS_BIGENDIAN),yes)
40 ifeq ($(TARGET_ARCH),sh4)
41 ifeq ($(TARGET_WORDS_BIGENDIAN),yes)
45 ifeq ($(TARGET_ARCH),mips)
46 ifneq ($(TARGET_WORDS_BIGENDIAN),yes)
50 ifeq ($(TARGET_ARCH),mipsn32)
51 ifneq ($(TARGET_WORDS_BIGENDIAN),yes)
52 TARGET_ARCH2=mipsn32el
55 ifeq ($(TARGET_ARCH),mips64)
56 ifneq ($(TARGET_WORDS_BIGENDIAN),yes)
61 ifdef CONFIG_USER_ONLY
63 QEMU_PROG=qemu-$(TARGET_ARCH2)
65 # system emulator name
66 ifeq ($(TARGET_ARCH), i386)
67 QEMU_PROG=qemu$(EXESUF)
69 QEMU_PROG=qemu-system-$(TARGET_ARCH2)$(EXESUF)
75 # We require -O2 to avoid the stack setup prologue in EXIT_TB
76 OP_CFLAGS := -Wall -O2 -g -fno-strict-aliasing
79 # Usage: OP_CFLAGS+=$(call cc-option, -falign-functions=0, -malign-functions=0)
81 cc-option = $(shell if $(CC) $(OP_CFLAGS) $(1) -S -o /dev/null -xc /dev/null \
82 > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;)
84 OP_CFLAGS+=$(call cc-option, -fno-reorder-blocks, "")
85 OP_CFLAGS+=$(call cc-option, -fno-gcse, "")
86 OP_CFLAGS+=$(call cc-option, -fno-tree-ch, "")
87 OP_CFLAGS+=$(call cc-option, -fno-optimize-sibling-calls, "")
88 OP_CFLAGS+=$(call cc-option, -fno-crossjumping, "")
89 OP_CFLAGS+=$(call cc-option, -fno-align-labels, "")
90 OP_CFLAGS+=$(call cc-option, -fno-align-jumps, "")
91 OP_CFLAGS+=$(call cc-option, -fno-align-functions, $(call cc-option, -malign-functions=0, ""))
92 OP_CFLAGS+=$(call cc-option, -fno-section-anchors, "")
97 HELPER_CFLAGS+=-fomit-frame-pointer
98 OP_CFLAGS+=-mpreferred-stack-boundary=2 -fomit-frame-pointer
99 # op.c and helper.c need this on 32-bit x86 system to avoid
100 # a compiler spill error. This can probably go away
101 # once the SSE ops have been converted to TCG
102 ifeq ($(HAVE_GT_GCC_3_3), true)
103 I386_CFLAGS=-march=i586 -mtune=i686
108 CPPFLAGS+= -D__powerpc__
109 OP_CFLAGS+= -mlongcall
113 CFLAGS+=-ffixed-g2 -ffixed-g3
114 OP_CFLAGS+=-fno-delayed-branch -ffixed-i0
115 ifeq ($(CONFIG_SOLARIS),yes)
116 OP_CFLAGS+=-fno-omit-frame-pointer
118 CFLAGS+=-ffixed-g1 -ffixed-g6
119 HELPER_CFLAGS+=-ffixed-i0
123 ifeq ($(ARCH),sparc64)
124 CFLAGS+=-ffixed-g1 -ffixed-g4 -ffixed-g5 -ffixed-g7
125 OP_CFLAGS+=-mcpu=ultrasparc -m64 -fno-delayed-branch -ffixed-i0
126 ifneq ($(CONFIG_SOLARIS),yes)
127 OP_CFLAGS+=-ffixed-g1 -ffixed-g4 -ffixed-g5 -ffixed-g7
132 # -msmall-data is not used for OP_CFLAGS because we want two-instruction
133 # relocations for the constant constructions
134 # Ensure there's only a single GP
139 OP_CFLAGS=-O1 -fno-delayed-branch
140 BASE_LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
145 OP_CFLAGS+=-mno-sdata
149 OP_CFLAGS+=-mno-sched-prolog -fno-omit-frame-pointer
153 OP_CFLAGS+=-fomit-frame-pointer
157 OP_CFLAGS+=-mabi=32 -G0 -fno-PIC -mno-abicalls -fomit-frame-pointer -fno-delayed-branch -Wa,-O0
160 ifeq ($(ARCH),mips64)
161 OP_CFLAGS+=-mabi=n32 -G0 -fno-PIC -mno-abicalls -fomit-frame-pointer -fno-delayed-branch -Wa,-O0
164 CFLAGS+=$(OS_CFLAGS) $(ARCH_CFLAGS)
165 LDFLAGS+=$(OS_LDFLAGS) $(ARCH_LDFLAGS)
166 OP_CFLAGS+=$(OS_CFLAGS) $(ARCH_CFLAGS)
168 CPPFLAGS+=-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
171 LIBS+=-lwinmm -lws2_32 -liphlpapi
174 LIBS+=-lsocket -lnsl -lresolv
175 ifdef NEEDS_LIBSUNMATH
177 LDFLAGS+=-L/opt/SUNWspro/prod/lib -R/opt/SUNWspro/prod/lib
178 OP_CFLAGS+=-I/opt/SUNWspro/prod/include/cc
179 CFLAGS+=-I/opt/SUNWspro/prod/include/cc
185 #########################################################
186 # cpu emulator library
187 LIBOBJS=exec.o kqemu.o translate-all.o cpu-exec.o\
188 translate.o host-utils.o
189 ifdef CONFIG_DYNGEN_OP
194 LIBOBJS+= tcg/tcg.o tcg/tcg-dyngen.o tcg/tcg-runtime.o
195 CPPFLAGS+=-I$(SRC_PATH)/tcg -I$(SRC_PATH)/tcg/$(ARCH)
196 ifeq ($(ARCH),sparc64)
197 CPPFLAGS+=-I$(SRC_PATH)/tcg/sparc
199 ifdef CONFIG_SOFTFLOAT
200 LIBOBJS+=fpu/softfloat.o
202 LIBOBJS+=fpu/softfloat-native.o
204 CPPFLAGS+=-I$(SRC_PATH)/fpu
205 LIBOBJS+= op_helper.o helper.o
207 ifeq ($(TARGET_BASE_ARCH), arm)
208 LIBOBJS+= neon_helper.o iwmmxt_helper.o
211 ifeq ($(TARGET_BASE_ARCH), alpha)
212 LIBOBJS+= alpha_palcode.o
215 ifeq ($(TARGET_BASE_ARCH), cris)
218 ifndef CONFIG_USER_ONLY
223 # NOTE: the disassembler code is only needed for debugging
225 ifeq ($(findstring i386, $(TARGET_ARCH) $(ARCH)),i386)
228 ifeq ($(findstring x86_64, $(TARGET_ARCH) $(ARCH)),x86_64)
234 ifeq ($(findstring alpha, $(TARGET_ARCH) $(ARCH)),alpha)
237 ifeq ($(findstring ppc, $(TARGET_BASE_ARCH) $(ARCH)),ppc)
240 ifeq ($(findstring mips, $(TARGET_BASE_ARCH) $(ARCH)),mips)
243 ifeq ($(findstring sparc, $(TARGET_BASE_ARCH) $(ARCH)),sparc)
246 ifeq ($(findstring arm, $(TARGET_ARCH) $(ARCH)),arm)
249 ifeq ($(findstring m68k, $(TARGET_ARCH) $(ARCH)),m68k)
252 ifeq ($(findstring sh4, $(TARGET_ARCH) $(ARCH)),sh4)
255 ifeq ($(findstring hppa, $(TARGET_BASE_ARCH) $(ARCH)),hppa)
258 ifeq ($(findstring s390, $(TARGET_ARCH) $(ARCH)),s390)
264 ifdef CONFIG_DYNGEN_OP
265 OPC_H = gen-op.h dyngen-opc.h op.h
268 libqemu.a: $(LIBOBJS)
270 $(AR) rcs $@ $(LIBOBJS)
272 translate.o: translate.c cpu.h $(OPC_H)
274 translate-all.o: translate-all.c cpu.h $(OPC_H)
276 tcg/tcg.o: cpu.h $(OPC_H)
278 tcg/tcg-dyngen.o: $(OPC_H)
280 tcg/tcg-runtime.o: $(OPC_H)
285 dyngen-opc.h: op.o $(DYNGEN)
286 $(DYNGEN) -c -o $@ $<
288 gen-op.h: op.o $(DYNGEN)
289 $(DYNGEN) -g -o $@ $<
292 $(CC) $(OP_CFLAGS) $(CPPFLAGS) $(I386_CFLAGS) -c -o $@ $<
295 $(CC) $(OP_CFLAGS) $(CPPFLAGS) -c -o $@ $<
297 # HELPER_CFLAGS is used for all the code compiled with static register
299 op_helper.o: op_helper.c
300 $(CC) $(HELPER_CFLAGS) $(CPPFLAGS) $(CFLAGS) $(I386_CFLAGS) -c -o $@ $<
302 cpu-exec.o: cpu-exec.c $(OPC_H)
303 $(CC) $(HELPER_CFLAGS) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
305 #########################################################
306 # Linux user emulator target
308 ifdef CONFIG_LINUX_USER
310 ifndef TARGET_ABI_DIR
311 TARGET_ABI_DIR=$(TARGET_ARCH)
313 VPATH+=:$(SRC_PATH)/linux-user:$(SRC_PATH)/linux-user/$(TARGET_ABI_DIR)
314 CPPFLAGS+=-I$(SRC_PATH)/linux-user -I$(SRC_PATH)/linux-user/$(TARGET_ABI_DIR)
328 LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
330 # WARNING: this LDFLAGS is _very_ tricky : qemu is an ELF shared object
331 # that the kernel ELF loader considers as an executable. I think this
332 # is the simplest way to make it self virtualizable!
337 ifeq ($(ARCH),x86_64)
338 LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
342 LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
346 LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
350 # -static is used to avoid g1/g3 usage by the dynamic linker
351 LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld -static
354 ifeq ($(ARCH),sparc64)
355 LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
359 LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
363 LDFLAGS+=-Wl,-G0 -Wl,-T,$(SRC_PATH)/$(ARCH).ld
367 LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
371 LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
375 ifeq ($(WORDS_BIGENDIAN),yes)
376 LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
378 LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH)el.ld
382 ifeq ($(ARCH),mips64)
383 ifeq ($(WORDS_BIGENDIAN),yes)
384 LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
386 LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH)el.ld
390 OBJS= main.o syscall.o strace.o mmap.o signal.o path.o thunk.o \
391 elfload.o linuxload.o uaccess.o
393 ifdef TARGET_HAS_BFLT
396 ifdef TARGET_HAS_ELFLOAD32
398 elfload32.o: elfload.c
401 ifeq ($(TARGET_ARCH), i386)
404 ifeq ($(TARGET_ARCH), arm)
405 OBJS+=nwfpe/fpa11.o nwfpe/fpa11_cpdo.o \
406 nwfpe/fpa11_cpdt.o nwfpe/fpa11_cprt.o nwfpe/fpopcode.o nwfpe/single_cpdo.o \
407 nwfpe/double_cpdo.o nwfpe/extended_cpdo.o arm-semi.o
409 ifeq ($(TARGET_ARCH), m68k)
410 OBJS+= m68k-sim.o m68k-semi.o
419 # Note: this is a workaround. The real fix is to avoid compiling
420 # cpu_signal_handler() in cpu-exec.c.
422 $(CC) $(HELPER_CFLAGS) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
424 $(QEMU_PROG): $(OBJS) ../libqemu_user.a
425 $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
427 # Mark as 32 bit binary, i. e. it will be mapped into the low 31 bit of
428 # the address space (31 bit so sign extending doesn't matter)
429 echo -ne '\001\000\000\000' | dd of=qemu bs=1 seek=48 count=4 conv=notrunc
432 endif #CONFIG_LINUX_USER
434 #########################################################
435 # Darwin user emulator target
437 ifdef CONFIG_DARWIN_USER
439 VPATH+=:$(SRC_PATH)/darwin-user
440 CPPFLAGS+=-I$(SRC_PATH)/darwin-user -I$(SRC_PATH)/darwin-user/$(TARGET_ARCH)
442 # Leave some space for the regular program loading zone
443 LDFLAGS+=-Wl,-segaddr,__STD_PROG_ZONE,0x1000 -image_base 0x0e000000
447 OBJS= main.o commpage.o machload.o mmap.o signal.o syscall.o thunk.o
455 # Note: this is a workaround. The real fix is to avoid compiling
456 # cpu_signal_handler() in cpu-exec.c.
458 $(CC) $(HELPER_CFLAGS) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
460 $(QEMU_PROG): $(OBJS)
461 $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
463 endif #CONFIG_DARWIN_USER
465 #########################################################
466 # System emulator target
467 ifndef CONFIG_USER_ONLY
469 OBJS=vl.o osdep.o monitor.o pci.o loader.o isa_mmio.o machine.o
471 OBJS+=block-raw-win32.o
473 OBJS+=block-raw-posix.o
484 LIBS += -lole32 -ldxguid
487 LIBS += $(CONFIG_FMOD_LIB)
490 SOUND_HW = sb16.o es1370.o
495 SOUND_HW += fmopl.o adlib.o
498 SOUND_HW += gus.o gusemu_hal.o gusemu_mixer.o
501 SOUND_HW += cs4231a.o
505 CPPFLAGS += $(CONFIG_VNC_TLS_CFLAGS)
506 LIBS += $(CONFIG_VNC_TLS_LIBS)
510 OBJS+= lsi53c895a.o esp.o
525 ifeq ($(TARGET_BASE_ARCH), i386)
527 OBJS+= ide.o pckbd.o ps2.o vga.o $(SOUND_HW) dma.o
528 OBJS+= fdc.o mc146818rtc.o serial.o i8259.o i8254.o pcspk.o pc.o
529 OBJS+= cirrus_vga.o apic.o parallel.o acpi.o piix_pci.o
530 OBJS+= usb-uhci.o vmmouse.o vmport.o vmware_vga.o
531 CPPFLAGS += -DHAS_AUDIO -DHAS_AUDIO_CHOICE
533 ifeq ($(TARGET_BASE_ARCH), ppc)
534 CPPFLAGS += -DHAS_AUDIO -DHAS_AUDIO_CHOICE
536 OBJS+= ppc.o ide.o vga.o $(SOUND_HW) dma.o openpic.o
538 OBJS+= pckbd.o ps2.o serial.o i8259.o i8254.o fdc.o m48t59.o mc146818rtc.o
539 OBJS+= prep_pci.o ppc_prep.o
541 OBJS+= macio.o cuda.o adb.o mac_nvram.o mac_dbdma.o
543 OBJS+= heathrow_pic.o grackle_pci.o ppc_oldworld.o
545 OBJS+= unin_pci.o ppc_chrp.o
547 OBJS+= pflash_cfi02.o ppc4xx_devs.o ppc405_uc.o ppc405_boards.o
549 ifeq ($(TARGET_BASE_ARCH), mips)
550 OBJS+= mips_r4k.o mips_jazz.o mips_malta.o mips_mipssim.o
551 OBJS+= mips_timer.o mips_int.o dma.o vga.o serial.o i8254.o i8259.o rc4030.o
552 OBJS+= g364fb.o jazz_led.o
553 OBJS+= ide.o gt64xxx.o pckbd.o ps2.o fdc.o mc146818rtc.o usb-uhci.o acpi.o ds1225y.o
554 OBJS+= piix_pci.o parallel.o cirrus_vga.o pcspk.o $(SOUND_HW)
556 OBJS+= pflash_cfi01.o
557 CPPFLAGS += -DHAS_AUDIO -DHAS_AUDIO_CHOICE
559 ifeq ($(TARGET_BASE_ARCH), cris)
564 OBJS+= etraxfs_timer.o
568 OBJS+= pflash_cfi02.o
570 ifeq ($(TARGET_BASE_ARCH), sparc)
571 ifeq ($(TARGET_ARCH), sparc64)
572 OBJS+= sun4u.o ide.o pckbd.o ps2.o vga.o apb_pci.o
573 OBJS+= fdc.o mc146818rtc.o serial.o m48t59.o
574 OBJS+= cirrus_vga.o parallel.o ptimer.o
576 OBJS+= sun4m.o tcx.o pcnet.o iommu.o m48t59.o slavio_intctl.o
577 OBJS+= slavio_timer.o slavio_serial.o slavio_misc.o fdc.o sparc32_dma.o
578 OBJS+= cs4231.o ptimer.o eccmemctl.o sbi.o sun4c_intctl.o
581 ifeq ($(TARGET_BASE_ARCH), arm)
582 OBJS+= integratorcp.o versatilepb.o ps2.o smc91c111.o arm_pic.o arm_timer.o
583 OBJS+= arm_boot.o pl011.o pl031.o pl050.o pl080.o pl110.o pl181.o pl190.o
584 OBJS+= versatile_pci.o ptimer.o
585 OBJS+= realview_gic.o realview.o arm_sysctl.o mpcore.o
586 OBJS+= armv7m.o armv7m_nvic.o stellaris.o pl022.o stellaris_enet.o
589 OBJS+= pxa2xx.o pxa2xx_pic.o pxa2xx_gpio.o pxa2xx_timer.o pxa2xx_dma.o
590 OBJS+= pxa2xx_lcd.o pxa2xx_mmci.o pxa2xx_pcmcia.o pxa2xx_keypad.o
591 OBJS+= pflash_cfi01.o gumstix.o
592 OBJS+= zaurus.o ide.o serial.o nand.o ecc.o spitz.o tosa.o tc6393xb.o
593 OBJS+= omap1.o omap_lcdc.o omap_dma.o omap_clk.o omap_mmc.o omap_i2c.o
594 OBJS+= omap2.o omap_dss.o
595 OBJS+= palm.o tsc210x.o
596 OBJS+= nseries.o blizzard.o onenand.o vga.o cbus.o tusb6010.o usb-musb.o
598 OBJS+= mst_fpga.o mainstone.o
599 OBJS+= musicpal.o pflash_cfi02.o
600 CPPFLAGS += -DHAS_AUDIO
602 ifeq ($(TARGET_BASE_ARCH), sh4)
603 OBJS+= shix.o r2d.o sh7750.o sh7750_regnames.o tc58128.o
604 OBJS+= sh_timer.o ptimer.o sh_serial.o sh_intc.o
606 ifeq ($(TARGET_BASE_ARCH), m68k)
607 OBJS+= an5206.o mcf5206.o ptimer.o mcf_uart.o mcf_intc.o mcf5208.o mcf_fec.o
608 OBJS+= m68k-semi.o dummy_m68k.o
614 COCOA_LIBS=-F/System/Library/Frameworks -framework Cocoa -framework IOKit
615 ifdef CONFIG_COREAUDIO
616 COCOA_LIBS+=-framework CoreAudio
620 CPPFLAGS+=-I$(SRC_PATH)/slirp
624 # specific flags are needed for non soft mmu emulator
630 ifndef CONFIG_SOLARIS
641 LDFLAGS+=-Wl,-G0 -Wl,-T,$(SRC_PATH)/ia64.ld
645 SDL_LIBS := $(filter-out -mwindows, $(SDL_LIBS)) -mconsole
654 $(QEMU_PROG): $(OBJS) ../libqemu_common.a libqemu.a
655 $(CC) $(LDFLAGS) -o $@ $^ $(LIBS) $(SDL_LIBS) $(COCOA_LIBS) $(CURSES_LIBS) $(BRLAPI_LIBS)
657 endif # !CONFIG_USER_ONLY
660 $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
663 $(CC) $(CPPFLAGS) -c -o $@ $<
666 rm -f *.o *.a *~ $(PROGS) gen-op.h dyngen-opc.h op.h nwfpe/*.o fpu/*.o
667 rm -f *.d */*.d tcg/*.o
671 $(INSTALL) -m 755 -s $(PROGS) "$(DESTDIR)$(bindir)"
674 # Include automatically generated dependency files
675 -include $(wildcard *.d */*.d)