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 -MP -DNEED_CPU_H
28 ifdef CONFIG_DARWIN_USER
29 VPATH+=:$(SRC_PATH)/darwin-user
30 CPPFLAGS+=-I$(SRC_PATH)/darwin-user -I$(SRC_PATH)/darwin-user/$(TARGET_ARCH)
32 ifdef CONFIG_LINUX_USER
33 VPATH+=:$(SRC_PATH)/linux-user
35 TARGET_ABI_DIR=$(TARGET_ARCH)
37 CPPFLAGS+=-I$(SRC_PATH)/linux-user -I$(SRC_PATH)/linux-user/$(TARGET_ABI_DIR)
43 HELPER_CFLAGS=$(CFLAGS)
44 DYNGEN=../dyngen$(EXESUF)
46 TARGET_ARCH2=$(TARGET_ARCH)
47 ifeq ($(TARGET_ARCH),arm)
48 ifeq ($(TARGET_WORDS_BIGENDIAN),yes)
52 ifeq ($(TARGET_ARCH),sh4)
53 ifeq ($(TARGET_WORDS_BIGENDIAN),yes)
57 ifeq ($(TARGET_ARCH),mips)
58 ifneq ($(TARGET_WORDS_BIGENDIAN),yes)
62 ifeq ($(TARGET_ARCH),mipsn32)
63 ifneq ($(TARGET_WORDS_BIGENDIAN),yes)
64 TARGET_ARCH2=mipsn32el
67 ifeq ($(TARGET_ARCH),mips64)
68 ifneq ($(TARGET_WORDS_BIGENDIAN),yes)
72 ifeq ($(TARGET_ARCH),sparc64)
73 ifeq ($(TARGET_ABI_DIR),sparc)
74 TARGET_ARCH2=sparc32plus
77 QEMU_USER=qemu-$(TARGET_ARCH2)
78 # system emulator name
80 ifeq ($(TARGET_ARCH), i386)
81 QEMU_SYSTEM=qemu$(EXESUF)
83 QEMU_SYSTEM=qemu-system-$(TARGET_ARCH2)$(EXESUF)
89 ifdef CONFIG_USER_ONLY
96 endif # !CONFIG_USER_ONLY
102 # We require -O2 to avoid the stack setup prologue in EXIT_TB
103 OP_CFLAGS := -Wall -O2 -g -fno-strict-aliasing
106 # Usage: OP_CFLAGS+=$(call cc-option, -falign-functions=0, -malign-functions=0)
108 cc-option = $(shell if $(CC) $(OP_CFLAGS) $(1) -S -o /dev/null -xc /dev/null \
109 > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;)
111 OP_CFLAGS+=$(call cc-option, -fno-reorder-blocks, "")
112 OP_CFLAGS+=$(call cc-option, -fno-gcse, "")
113 OP_CFLAGS+=$(call cc-option, -fno-tree-ch, "")
114 OP_CFLAGS+=$(call cc-option, -fno-optimize-sibling-calls, "")
115 OP_CFLAGS+=$(call cc-option, -fno-crossjumping, "")
116 OP_CFLAGS+=$(call cc-option, -fno-align-labels, "")
117 OP_CFLAGS+=$(call cc-option, -fno-align-jumps, "")
118 OP_CFLAGS+=$(call cc-option, -fno-align-functions, $(call cc-option, -malign-functions=0, ""))
119 OP_CFLAGS+=$(call cc-option, -fno-section-anchors, "")
122 HELPER_CFLAGS+=-fomit-frame-pointer
123 OP_CFLAGS+=-mpreferred-stack-boundary=2 -fomit-frame-pointer
131 BASE_LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
133 ifdef CONFIG_LINUX_USER
134 # WARNING: this LDFLAGS is _very_ tricky : qemu is an ELF shared object
135 # that the kernel ELF loader considers as an executable. I think this
136 # is the simplest way to make it self virtualizable!
137 BASE_LDFLAGS+=-Wl,-shared
142 ifeq ($(ARCH),x86_64)
143 ifneq ($(CONFIG_SOLARIS),yes)
144 BASE_LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
149 CPPFLAGS+= -D__powerpc__
150 BASE_LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
154 BASE_LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
158 BASE_CFLAGS+=-ffixed-g2 -ffixed-g3
159 OP_CFLAGS+=-fno-delayed-branch -ffixed-i0
160 ifeq ($(CONFIG_SOLARIS),yes)
161 OP_CFLAGS+=-fno-omit-frame-pointer
163 BASE_CFLAGS+=-ffixed-g1 -ffixed-g6
164 HELPER_CFLAGS=$(CFLAGS) -ffixed-i0
165 # -static is used to avoid g1/g3 usage by the dynamic linker
166 BASE_LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld -static
170 ifeq ($(ARCH),sparc64)
171 BASE_CFLAGS+=-ffixed-g1 -ffixed-g4 -ffixed-g5 -ffixed-g7
172 OP_CFLAGS+=-mcpu=ultrasparc -m64 -fno-delayed-branch -ffixed-i0
173 ifneq ($(CONFIG_SOLARIS),yes)
174 BASE_LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
175 OP_CFLAGS+=-ffixed-g1 -ffixed-g4 -ffixed-g5 -ffixed-g7
180 # -msmall-data is not used for OP_CFLAGS because we want two-instruction
181 # relocations for the constant constructions
182 # Ensure there's only a single GP
183 BASE_CFLAGS+=-msmall-data
184 BASE_LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
188 BASE_CFLAGS+=-mno-sdata
189 OP_CFLAGS+=-mno-sdata
190 BASE_LDFLAGS+=-Wl,-G0 -Wl,-T,$(SRC_PATH)/$(ARCH).ld
194 OP_CFLAGS+=-mno-sched-prolog -fno-omit-frame-pointer
195 BASE_LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
199 OP_CFLAGS+=-fomit-frame-pointer
200 BASE_LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
204 OP_CFLAGS+=-mabi=32 -G0 -fno-PIC -mno-abicalls -fomit-frame-pointer -fno-delayed-branch -Wa,-O0
205 ifeq ($(WORDS_BIGENDIAN),yes)
206 BASE_LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
208 BASE_LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH)el.ld
212 ifeq ($(ARCH),mips64)
213 OP_CFLAGS+=-mabi=n32 -G0 -fno-PIC -mno-abicalls -fomit-frame-pointer -fno-delayed-branch -Wa,-O0
214 ifeq ($(WORDS_BIGENDIAN),yes)
215 BASE_LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
217 BASE_LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH)el.ld
221 ifeq ($(CONFIG_DARWIN),yes)
225 ifdef CONFIG_DARWIN_USER
226 # Leave some space for the regular program loading zone
227 BASE_LDFLAGS+=-Wl,-segaddr,__STD_PROG_ZONE,0x1000 -image_base 0x0e000000
230 BASE_CFLAGS+=$(OS_CFLAGS) $(ARCH_CFLAGS)
231 BASE_LDFLAGS+=$(OS_LDFLAGS) $(ARCH_LDFLAGS)
232 OP_CFLAGS+=$(OS_CFLAGS) $(ARCH_CFLAGS)
233 OP_LDFLAGS+=$(OS_LDFLAGS) $(ARCH_LDFLAGS)
235 #########################################################
237 CPPFLAGS+=-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
239 ifndef CONFIG_USER_ONLY
243 LIBS+=-lwinmm -lws2_32 -liphlpapi
246 LIBS+=-lsocket -lnsl -lresolv
247 ifdef NEEDS_LIBSUNMATH
249 LDFLAGS+=-L/opt/SUNWspro/prod/lib -R/opt/SUNWspro/prod/lib
250 OP_CFLAGS+=-I/opt/SUNWspro/prod/include/cc
251 BASE_CFLAGS+=-I/opt/SUNWspro/prod/include/cc
258 main.o: BASE_CFLAGS+=-p
261 ifdef CONFIG_LINUX_USER
262 OBJS= main.o syscall.o strace.o mmap.o signal.o path.o osdep.o thunk.o \
263 elfload.o linuxload.o uaccess.o
265 ifdef TARGET_HAS_BFLT
268 ifdef TARGET_HAS_ELFLOAD32
270 elfload32.o: elfload.c
273 ifeq ($(TARGET_ARCH), i386)
276 ifeq ($(TARGET_ARCH), arm)
277 OBJS+=nwfpe/fpa11.o nwfpe/fpa11_cpdo.o \
278 nwfpe/fpa11_cpdt.o nwfpe/fpa11_cprt.o nwfpe/fpopcode.o nwfpe/single_cpdo.o \
279 nwfpe/double_cpdo.o nwfpe/extended_cpdo.o arm-semi.o
281 ifeq ($(TARGET_ARCH), m68k)
282 OBJS+= m68k-sim.o m68k-semi.o
284 endif #CONFIG_LINUX_USER
286 ifdef CONFIG_DARWIN_USER
287 OBJS= main.o commpage.o machload.o mmap.o osdep.o signal.o syscall.o thunk.o
293 # cpu emulator library
294 LIBOBJS=exec.o kqemu.o translate-op.o translate-all.o cpu-exec.o\
295 translate.o op.o host-utils.o
296 ifdef CONFIG_SOFTFLOAT
297 LIBOBJS+=fpu/softfloat.o
299 LIBOBJS+=fpu/softfloat-native.o
301 CPPFLAGS+=-I$(SRC_PATH)/fpu
303 ifeq ($(TARGET_ARCH), i386)
304 LIBOBJS+=helper.o helper2.o
307 ifeq ($(TARGET_ARCH), x86_64)
308 LIBOBJS+=helper.o helper2.o
311 ifeq ($(TARGET_BASE_ARCH), ppc)
312 LIBOBJS+= op_helper.o helper.o
315 ifeq ($(TARGET_BASE_ARCH), mips)
316 LIBOBJS+= op_helper.o helper.o
319 ifeq ($(TARGET_BASE_ARCH), sparc)
320 LIBOBJS+= op_helper.o helper.o
323 ifeq ($(TARGET_BASE_ARCH), arm)
324 LIBOBJS+= op_helper.o helper.o
327 ifeq ($(TARGET_BASE_ARCH), sh4)
328 LIBOBJS+= op_helper.o helper.o
331 ifeq ($(TARGET_BASE_ARCH), m68k)
332 LIBOBJS+= op_helper.o helper.o
335 ifeq ($(TARGET_BASE_ARCH), alpha)
336 LIBOBJS+= op_helper.o helper.o alpha_palcode.o
339 ifeq ($(TARGET_BASE_ARCH), cris)
340 LIBOBJS+= op_helper.o helper.o
343 ifndef CONFIG_USER_ONLY
348 # NOTE: the disassembler code is only needed for debugging
350 ifeq ($(findstring i386, $(TARGET_ARCH) $(ARCH)),i386)
353 ifeq ($(findstring x86_64, $(TARGET_ARCH) $(ARCH)),x86_64)
359 ifeq ($(findstring alpha, $(TARGET_ARCH) $(ARCH)),alpha)
362 ifeq ($(findstring ppc, $(TARGET_BASE_ARCH) $(ARCH)),ppc)
365 ifeq ($(findstring mips, $(TARGET_BASE_ARCH) $(ARCH)),mips)
368 ifeq ($(findstring sparc, $(TARGET_BASE_ARCH) $(ARCH)),sparc)
371 ifeq ($(findstring arm, $(TARGET_ARCH) $(ARCH)),arm)
374 ifeq ($(findstring m68k, $(TARGET_ARCH) $(ARCH)),m68k)
377 ifeq ($(findstring sh4, $(TARGET_ARCH) $(ARCH)),sh4)
380 ifeq ($(findstring s390, $(TARGET_ARCH) $(ARCH)),s390)
390 $(QEMU_USER): $(OBJS)
391 $(CC) $(LDFLAGS) $(BASE_LDFLAGS) -o $@ $^ $(LIBS)
393 # Mark as 32 bit binary, i. e. it will be mapped into the low 31 bit of
394 # the address space (31 bit so sign extending doesn't matter)
395 echo -ne '\001\000\000\000' | dd of=qemu bs=1 seek=48 count=4 conv=notrunc
398 # must use static linking to avoid leaving stuff in virtual address space
399 VL_OBJS=vl.o osdep.o monitor.o pci.o loader.o isa_mmio.o
400 # XXX: suppress QEMU_TOOL tests
402 VL_OBJS+=block-raw-win32.o
404 VL_OBJS+=block-raw-posix.o
411 LIBS += -lole32 -ldxguid
414 LIBS += $(CONFIG_FMOD_LIB)
417 SOUND_HW = sb16.o es1370.o
419 SOUND_HW += fmopl.o adlib.o
423 CPPFLAGS += $(CONFIG_VNC_TLS_CFLAGS)
424 LIBS += $(CONFIG_VNC_TLS_LIBS)
428 VL_OBJS+= lsi53c895a.o
434 VL_OBJS += eeprom93xx.o
437 VL_OBJS += eepro100.o
442 ifeq ($(TARGET_BASE_ARCH), i386)
444 VL_OBJS+= ide.o pckbd.o ps2.o vga.o $(SOUND_HW) dma.o
445 VL_OBJS+= fdc.o mc146818rtc.o serial.o i8259.o i8254.o pcspk.o pc.o
446 VL_OBJS+= cirrus_vga.o apic.o parallel.o acpi.o piix_pci.o
447 VL_OBJS+= usb-uhci.o vmmouse.o vmport.o vmware_vga.o
448 CPPFLAGS += -DHAS_AUDIO -DHAS_AUDIO_CHOICE
450 ifeq ($(TARGET_BASE_ARCH), ppc)
451 CPPFLAGS += -DHAS_AUDIO -DHAS_AUDIO_CHOICE
453 VL_OBJS+= ppc.o ide.o vga.o $(SOUND_HW) dma.o openpic.o
455 VL_OBJS+= pckbd.o ps2.o serial.o i8259.o i8254.o fdc.o m48t59.o mc146818rtc.o
456 VL_OBJS+= prep_pci.o ppc_prep.o
458 VL_OBJS+= macio.o cuda.o adb.o mac_nvram.o mac_dbdma.o
460 VL_OBJS+= heathrow_pic.o grackle_pci.o ppc_oldworld.o
462 VL_OBJS+= unin_pci.o ppc_chrp.o
464 VL_OBJS+= pflash_cfi02.o ppc4xx_devs.o ppc405_uc.o ppc405_boards.o
466 ifeq ($(TARGET_BASE_ARCH), mips)
467 VL_OBJS+= mips_r4k.o mips_malta.o mips_pica61.o mips_mipssim.o
468 VL_OBJS+= mips_timer.o mips_int.o dma.o vga.o serial.o i8254.o i8259.o
470 VL_OBJS+= ide.o gt64xxx.o pckbd.o ps2.o fdc.o mc146818rtc.o usb-uhci.o acpi.o ds1225y.o
471 VL_OBJS+= piix_pci.o parallel.o cirrus_vga.o $(SOUND_HW)
473 CPPFLAGS += -DHAS_AUDIO
475 ifeq ($(TARGET_BASE_ARCH), cris)
478 VL_OBJS+= etraxfs_timer.o
479 VL_OBJS+= etraxfs_ser.o
481 ifeq ($(TARGET_BASE_ARCH), sparc)
482 ifeq ($(TARGET_ARCH), sparc64)
483 VL_OBJS+= sun4u.o ide.o pckbd.o ps2.o vga.o apb_pci.o
484 VL_OBJS+= fdc.o mc146818rtc.o serial.o m48t59.o
485 VL_OBJS+= cirrus_vga.o parallel.o ptimer.o
487 VL_OBJS+= sun4m.o tcx.o pcnet.o iommu.o m48t59.o slavio_intctl.o
488 VL_OBJS+= slavio_timer.o slavio_serial.o slavio_misc.o fdc.o esp.o sparc32_dma.o
489 VL_OBJS+= cs4231.o ptimer.o eccmemctl.o
492 ifeq ($(TARGET_BASE_ARCH), arm)
493 VL_OBJS+= integratorcp.o versatilepb.o ps2.o smc91c111.o arm_pic.o arm_timer.o
494 VL_OBJS+= arm_boot.o pl011.o pl031.o pl050.o pl080.o pl110.o pl181.o pl190.o
495 VL_OBJS+= versatile_pci.o ptimer.o
496 VL_OBJS+= realview_gic.o realview.o arm_sysctl.o mpcore.o
497 VL_OBJS+= armv7m.o armv7m_nvic.o stellaris.o pl022.o stellaris_enet.o
500 VL_OBJS+= pxa2xx.o pxa2xx_pic.o pxa2xx_gpio.o pxa2xx_timer.o pxa2xx_dma.o
501 VL_OBJS+= pxa2xx_lcd.o pxa2xx_mmci.o pxa2xx_pcmcia.o pxa2xx_keypad.o
502 VL_OBJS+= pflash_cfi01.o gumstix.o
503 VL_OBJS+= spitz.o ide.o serial.o nand.o ecc.o
504 VL_OBJS+= omap.o omap_lcdc.o omap1_clk.o omap_mmc.o omap_i2c.o
505 VL_OBJS+= palm.o tsc210x.o
506 VL_OBJS+= mst_fpga.o mainstone.o
507 CPPFLAGS += -DHAS_AUDIO
509 ifeq ($(TARGET_BASE_ARCH), sh4)
510 VL_OBJS+= shix.o r2d.o sh7750.o sh7750_regnames.o tc58128.o
511 VL_OBJS+= sh_timer.o ptimer.o sh_serial.o sh_intc.o
513 ifeq ($(TARGET_BASE_ARCH), m68k)
514 VL_OBJS+= an5206.o mcf5206.o ptimer.o mcf_uart.o mcf_intc.o mcf5208.o mcf_fec.o
515 VL_OBJS+= m68k-semi.o dummy_m68k.o
521 COCOA_LIBS=-F/System/Library/Frameworks -framework Cocoa -framework IOKit
522 ifdef CONFIG_COREAUDIO
523 COCOA_LIBS+=-framework CoreAudio
527 CPPFLAGS+=-I$(SRC_PATH)/slirp
530 VL_LDFLAGS=$(VL_OS_LDFLAGS)
532 # specific flags are needed for non soft mmu emulator
536 ifndef CONFIG_SOFTMMU
537 VL_LDFLAGS+=-Wl,-T,$(SRC_PATH)/i386-vl.ld
541 ifndef CONFIG_SOLARIS
547 vl.o: BASE_CFLAGS+=-p
552 VL_LDFLAGS+=-Wl,-G0 -Wl,-T,$(SRC_PATH)/ia64.ld
555 ifeq ($(ARCH),sparc64)
557 ifneq ($(CONFIG_SOLARIS),yes)
558 VL_LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
562 ifeq ($(ARCH),x86_64)
564 ifneq ($(CONFIG_SOLARIS),yes)
565 VL_LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
570 SDL_LIBS := $(filter-out -mwindows, $(SDL_LIBS)) -mconsole
573 $(QEMU_SYSTEM): $(VL_OBJS) ../libqemu_common.a libqemu.a
574 $(CC) $(VL_LDFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) $(SDL_LIBS) $(COCOA_LIBS) $(VL_LIBS)
577 $(CC) -MM $(CFLAGS) $(CPPFLAGS) $(BASE_CFLAGS) $^ 1>.depend
579 vldepend: $(VL_OBJS:.o=.c)
580 $(CC) -MM $(CFLAGS) $(CPPFLAGS) $(BASE_CFLAGS) $^ 1>.depend
584 libqemu.a: $(LIBOBJS)
586 $(AR) rcs $@ $(LIBOBJS)
588 translate.o: translate.c gen-op.h opc.h cpu.h
590 translate-all.o: translate-all.c opc.h cpu.h
592 translate-op.o: translate-all.c op.h opc.h cpu.h
597 opc.h: op.o $(DYNGEN)
598 $(DYNGEN) -c -o $@ $<
600 gen-op.h: op.o $(DYNGEN)
601 $(DYNGEN) -g -o $@ $<
604 $(CC) $(OP_CFLAGS) $(CPPFLAGS) -c -o $@ $<
606 # HELPER_CFLAGS is used for all the code compiled with static register
608 ifeq ($(TARGET_BASE_ARCH), i386)
609 # XXX: rename helper.c to op_helper.c
611 $(CC) $(HELPER_CFLAGS) $(CPPFLAGS) $(BASE_CFLAGS) -c -o $@ $<
613 op_helper.o: op_helper.c
614 $(CC) $(HELPER_CFLAGS) $(CPPFLAGS) $(BASE_CFLAGS) -c -o $@ $<
617 cpu-exec.o: cpu-exec.c
618 $(CC) $(HELPER_CFLAGS) $(CPPFLAGS) $(BASE_CFLAGS) -c -o $@ $<
620 # Note: this is a workaround. The real fix is to avoid compiling
621 # cpu_signal_handler() in cpu-exec.c.
623 $(CC) $(HELPER_CFLAGS) $(CPPFLAGS) $(BASE_CFLAGS) -c -o $@ $<
626 $(CC) $(CFLAGS) $(CPPFLAGS) $(BASE_CFLAGS) -c -o $@ $<
629 $(CC) $(CPPFLAGS) -c -o $@ $<
632 rm -f *.o *.a *~ $(PROGS) gen-op.h opc.h op.h nwfpe/*.o fpu/*.o
637 $(INSTALL) -m 755 -s $(PROGS) "$(DESTDIR)$(bindir)"
640 ifneq ($(wildcard .depend),)
645 audio.o sdlaudio.o dsoundaudio.o ossaudio.o wavaudio.o noaudio.o \
646 fmodaudio.o alsaaudio.o mixeng.o sb16.o es1370.o gus.o adlib.o: \
647 CFLAGS := $(CFLAGS) -Wall -Werror -W -Wsign-compare
650 # Include automatically generated dependency files
651 -include $(wildcard *.d */*.d)