2 include $(SRC_PATH)/rules.mak
4 ifndef TARGET_BASE_ARCH
5 TARGET_BASE_ARCH:=$(TARGET_ARCH)
8 TARGET_PATH=$(SRC_PATH)/target-$(TARGET_BASE_ARCH)
9 VPATH=$(SRC_PATH):$(TARGET_PATH):$(SRC_PATH)/hw
10 CPPFLAGS=-I. -I.. -I$(TARGET_PATH) -I$(SRC_PATH) -MMD -MT $@ -MP -DNEED_CPU_H
15 TARGET_ARCH2=$(TARGET_ARCH)
18 ifdef CONFIG_USER_ONLY
20 QEMU_PROG=qemu-$(TARGET_ARCH2)
22 # system emulator name
23 ifeq ($(TARGET_ARCH), i386)
24 QEMU_PROG=qemu$(EXESUF)
26 QEMU_PROG=qemu-system-$(TARGET_ARCH2)$(EXESUF)
33 # Usage: CFLAGS+=$(call cc-option, $(CFLAGS), -falign-functions=0, -malign-functions=0)
35 cc-option = $(shell if $(CC) $(1) $(2) -S -o /dev/null -xc /dev/null \
36 > /dev/null 2>&1; then echo "$(2)"; else echo "$(3)"; fi ;)
41 HELPER_CFLAGS+=-fomit-frame-pointer
44 ifeq ($(subst ppc64,ppc,$(ARCH))$(TARGET_BASE_ARCH),ppcppc)
45 translate.o: CFLAGS := $(CFLAGS) $(call cc-option, $(CFLAGS), -fno-unit-at-a-time,)
49 ifneq ($(CONFIG_SOLARIS),y)
50 HELPER_CFLAGS+=-ffixed-i0
55 # Ensure there's only a single GP
63 CFLAGS+= $(ARCH_CFLAGS)
64 LDFLAGS+= $(ARCH_LDFLAGS)
66 CPPFLAGS+=-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
67 CPPFLAGS+=-U_FORTIFY_SOURCE
70 LIBS+=-lwinmm -lws2_32 -liphlpapi
73 LIBS+=-lsocket -lnsl -lresolv
74 ifdef NEEDS_LIBSUNMATH
76 LDFLAGS+=-L/opt/SUNWspro/prod/lib -R/opt/SUNWspro/prod/lib
77 CFLAGS+=-I/opt/SUNWspro/prod/include/cc
81 kvm.o: CFLAGS+=$(KVM_CFLAGS)
82 kvm-all.o: CFLAGS+=$(KVM_CFLAGS)
85 # Dummy command so that make thinks it has done something
88 #########################################################
89 # cpu emulator library
90 libobj-y = exec.o translate-all.o cpu-exec.o translate.o host-utils.o
91 libobj-$(CONFIG_KQEMU) += kqemu.o
93 libobj-y += tcg/tcg.o tcg/tcg-runtime.o
94 CPPFLAGS+=-I$(SRC_PATH)/tcg -I$(SRC_PATH)/tcg/$(ARCH)
95 ifeq ($(ARCH),sparc64)
96 CPPFLAGS+=-I$(SRC_PATH)/tcg/sparc
98 ifdef CONFIG_SOFTFLOAT
99 libobj-y += fpu/softfloat.o
101 libobj-y += fpu/softfloat-native.o
103 CPPFLAGS+=-I$(SRC_PATH)/fpu
104 libobj-y += op_helper.o helper.o
106 ifeq ($(TARGET_BASE_ARCH), arm)
107 libobj-y += neon_helper.o iwmmxt_helper.o
110 ifeq ($(TARGET_BASE_ARCH), alpha)
111 libobj-y += alpha_palcode.o
114 ifeq ($(TARGET_BASE_ARCH), cris)
115 libobj-y += cris-dis.o
117 ifndef CONFIG_USER_ONLY
122 # NOTE: the disassembler code is only needed for debugging
124 ifeq ($(findstring i386, $(TARGET_ARCH) $(ARCH)),i386)
127 ifeq ($(findstring x86_64, $(TARGET_ARCH) $(ARCH)),x86_64)
130 libobj-$(USE_I386_DIS) += i386-dis.o
131 ifeq ($(findstring alpha, $(TARGET_ARCH) $(ARCH)),alpha)
132 libobj-y += alpha-dis.o
134 ifeq ($(findstring ppc, $(TARGET_BASE_ARCH) $(ARCH)),ppc)
135 libobj-y += ppc-dis.o
137 ifeq ($(findstring microblaze, $(TARGET_BASE_ARCH) $(ARCH)),microblaze)
138 libobj-y += microblaze-dis.o
139 ifndef CONFIG_USER_ONLY
143 ifeq ($(findstring mips, $(TARGET_BASE_ARCH) $(ARCH)),mips)
144 libobj-y += mips-dis.o
146 ifeq ($(findstring sparc, $(TARGET_BASE_ARCH) $(ARCH)),sparc)
147 libobj-y += sparc-dis.o
149 ifeq ($(findstring arm, $(TARGET_ARCH) $(ARCH)),arm)
150 libobj-y += arm-dis.o
152 ifeq ($(findstring m68k, $(TARGET_ARCH) $(ARCH)),m68k)
153 libobj-y += m68k-dis.o
155 ifeq ($(findstring sh4, $(TARGET_ARCH) $(ARCH)),sh4)
156 libobj-y += sh4-dis.o
158 ifeq ($(findstring hppa, $(TARGET_BASE_ARCH) $(ARCH)),hppa)
159 libobj-y += hppa-dis.o
161 ifeq ($(findstring s390, $(TARGET_ARCH) $(ARCH)),s390)
162 libobj-y += s390-dis.o
167 libqemu.a: $(libobj-y)
169 translate.o: translate.c cpu.h
171 translate-all.o: translate-all.c cpu.h
175 # HELPER_CFLAGS is used for all the code compiled with static register
177 op_helper.o: CFLAGS += $(HELPER_CFLAGS)
179 cpu-exec.o: CFLAGS += $(HELPER_CFLAGS)
181 #########################################################
182 # Linux user emulator target
184 ifdef CONFIG_LINUX_USER
186 ifndef TARGET_ABI_DIR
187 TARGET_ABI_DIR=$(TARGET_ARCH)
189 VPATH+=:$(SRC_PATH)/linux-user:$(SRC_PATH)/linux-user/$(TARGET_ABI_DIR)
190 CPPFLAGS+=-I$(SRC_PATH)/linux-user -I$(SRC_PATH)/linux-user/$(TARGET_ABI_DIR)
204 LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
206 # WARNING: this LDFLAGS is _very_ tricky : qemu is an ELF shared object
207 # that the kernel ELF loader considers as an executable. I think this
208 # is the simplest way to make it self virtualizable!
213 ifeq ($(ARCH),x86_64)
214 LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
218 LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
222 LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
226 LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
230 # -static is used to avoid g1/g3 usage by the dynamic linker
231 LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld -static
234 ifeq ($(ARCH),sparc64)
235 LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
239 LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
243 LDFLAGS+=-Wl,-G0 -Wl,-T,$(SRC_PATH)/$(ARCH).ld
247 LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
251 LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
255 ifeq ($(WORDS_BIGENDIAN),yes)
256 LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
258 LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH)el.ld
262 ifeq ($(ARCH),mips64)
263 ifeq ($(WORDS_BIGENDIAN),yes)
264 LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
266 LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH)el.ld
276 obj-y = main.o syscall.o strace.o mmap.o signal.o path.o thunk.o \
277 elfload.o linuxload.o uaccess.o envlist.o gdbstub.o gdbstub-xml.o \
279 LIBS+= $(PTHREADLIBS)
281 obj-$(TARGET_HAS_BFLT) += flatload.o
283 ifdef TARGET_HAS_ELFLOAD32
284 elfload32.o: elfload.c
286 obj-$(TARGET_HAS_ELFLOAD32) += elfload32.o
288 ifeq ($(TARGET_ARCH), i386)
292 nwfpe-obj-y := fpa11.o fpa11_cpdo.o fpa11_cpdt.o fpa11_cprt.o fpopcode.o
293 nwfpe-obj-y += single_cpdo.o double_cpdo.o extended_cpdo.o
294 obj-arm-y += $(addprefix nwfpe/, $(nwfpe-obj-y))
295 obj-arm-y += arm-semi.o
297 obj-m68k-y += m68k-sim.o m68k-semi.o
299 # Note: this is a workaround. The real fix is to avoid compiling
300 # cpu_signal_handler() in cpu-exec.c.
301 signal.o: CFLAGS += $(HELPER_CFLAGS)
303 ARLIBS=../libqemu_user.a libqemu.a
304 endif #CONFIG_LINUX_USER
306 #########################################################
307 # Darwin user emulator target
309 ifdef CONFIG_DARWIN_USER
311 VPATH+=:$(SRC_PATH)/darwin-user
312 CPPFLAGS+=-I$(SRC_PATH)/darwin-user -I$(SRC_PATH)/darwin-user/$(TARGET_ARCH)
314 # Leave some space for the regular program loading zone
315 LDFLAGS+=-Wl,-segaddr,__STD_PROG_ZONE,0x1000 -image_base 0x0e000000
319 obj-y = main.o commpage.o machload.o mmap.o signal.o syscall.o thunk.o \
320 gdbstub.o gdbstub-xml.o ioport-user.o
322 # Note: this is a workaround. The real fix is to avoid compiling
323 # cpu_signal_handler() in cpu-exec.c.
324 signal.o: CFLAGS += $(HELPER_CFLAGS)
328 endif #CONFIG_DARWIN_USER
330 #########################################################
331 # BSD user emulator target
333 ifdef CONFIG_BSD_USER
335 VPATH+=:$(SRC_PATH)/bsd-user
336 CPPFLAGS+=-I$(SRC_PATH)/bsd-user -I$(SRC_PATH)/bsd-user/$(TARGET_ARCH)
350 LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
352 # WARNING: this LDFLAGS is _very_ tricky : qemu is an ELF shared object
353 # that the kernel ELF loader considers as an executable. I think this
354 # is the simplest way to make it self virtualizable!
359 ifeq ($(ARCH),x86_64)
360 LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
364 LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
368 LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
372 LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
376 # -static is used to avoid g1/g3 usage by the dynamic linker
377 LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld -static
380 ifeq ($(ARCH),sparc64)
381 LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
385 LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
389 LDFLAGS+=-Wl,-G0 -Wl,-T,$(SRC_PATH)/$(ARCH).ld
393 LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
397 LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
401 ifeq ($(WORDS_BIGENDIAN),yes)
402 LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
404 LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH)el.ld
408 ifeq ($(ARCH),mips64)
409 ifeq ($(WORDS_BIGENDIAN),yes)
410 LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld
412 LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH)el.ld
416 obj-y = main.o bsdload.o elfload.o mmap.o path.o signal.o strace.o syscall.o \
417 gdbstub.o gdbstub-xml.o ioport-user.o
420 # Note: this is a workaround. The real fix is to avoid compiling
421 # cpu_signal_handler() in cpu-exec.c.
422 signal.o: CFLAGS += $(HELPER_CFLAGS)
424 ARLIBS=libqemu.a ../libqemu_user.a
426 endif #CONFIG_BSD_USER
428 #########################################################
429 # System emulator target
430 ifndef CONFIG_USER_ONLY
432 obj-y = vl.o osdep.o monitor.o pci.o loader.o isa_mmio.o machine.o \
433 gdbstub.o gdbstub-xml.o msix.o ioport.o
434 # virtio has to be here due to weird dependency between PCI and virtio-net.
435 # need to fix this properly
436 obj-y += virtio-blk.o virtio-balloon.o virtio-net.o virtio-console.o
437 obj-$(CONFIG_KVM) += kvm.o kvm-all.o
447 LIBS += -lpulse-simple
450 LIBS += -lole32 -ldxguid
453 LIBS += $(CONFIG_FMOD_LIB)
456 LIBS += $(CONFIG_OSS_LIB)
460 sound-obj-$(CONFIG_SB16) += sb16.o
461 sound-obj-$(CONFIG_ES1370) += es1370.o
462 sound-obj-$(CONFIG_AC97) += ac97.o
463 sound-obj-$(CONFIG_ADLIB) += fmopl.o adlib.o
464 sound-obj-$(CONFIG_GUS) += gus.o gusemu_hal.o gusemu_mixer.o
465 sound-obj-$(CONFIG_CS4231A) += cs4231a.o
468 adlib.o fmopl.o: CFLAGS := ${CFLAGS} -DBUILD_Y8950=0
472 CPPFLAGS += $(CONFIG_VNC_TLS_CFLAGS)
473 LIBS += $(CONFIG_VNC_TLS_LIBS)
476 ifdef CONFIG_VNC_SASL
477 CPPFLAGS += $(CONFIG_VNC_SASL_CFLAGS)
478 LIBS += $(CONFIG_VNC_SASL_LIBS)
482 LIBS += $(CONFIG_BLUEZ_LIBS)
485 # xen backend driver support
486 obj-$(CONFIG_XEN) += xen_machine_pv.o xen_domainbuild.o
487 ifeq ($(CONFIG_XEN), y)
501 # Generic watchdog support and some watchdog devices
502 obj-y += wdt_ib700.o wdt_i6300esb.o
505 obj-i386-y = ide.o pckbd.o vga.o $(sound-obj-y) dma.o
506 obj-i386-y += fdc.o mc146818rtc.o serial.o i8259.o i8254.o pcspk.o pc.o
507 obj-i386-y += cirrus_vga.o apic.o ioapic.o parallel.o acpi.o piix_pci.o
508 obj-i386-y += usb-uhci.o vmmouse.o vmport.o vmware_vga.o hpet.o
509 obj-i386-y += device-hotplug.o pci-hotplug.o smbios.o
511 ifeq ($(TARGET_BASE_ARCH), i386)
512 CPPFLAGS += -DHAS_AUDIO -DHAS_AUDIO_CHOICE
516 obj-ppc-y = ppc.o ide.o vga.o $(sound-obj-y) dma.o openpic.o
518 obj-ppc-y += pckbd.o serial.o i8259.o i8254.o fdc.o mc146818rtc.o
519 obj-ppc-y += prep_pci.o ppc_prep.o
521 obj-ppc-y += macio.o cuda.o adb.o mac_nvram.o mac_dbdma.o
523 obj-ppc-y += heathrow_pic.o grackle_pci.o ppc_oldworld.o
525 obj-ppc-y += unin_pci.o ppc_newworld.o
527 obj-ppc-y += pflash_cfi02.o ppc4xx_devs.o ppc4xx_pci.o ppc405_uc.o ppc405_boards.o
528 obj-ppc-y += ppc440.o ppc440_bamboo.o
529 # PowerPC E500 boards
530 obj-ppc-y += ppce500_pci.o ppce500_mpc8544ds.o
531 obj-ppc-$(CONFIG_KVM) += kvm_ppc.o
533 ifeq ($(TARGET_BASE_ARCH), ppc)
534 CPPFLAGS += -DHAS_AUDIO -DHAS_AUDIO_CHOICE
538 obj-ppc-y += device_tree.o
542 obj-mips-y = mips_r4k.o mips_jazz.o mips_malta.o mips_mipssim.o
543 obj-mips-y += mips_timer.o mips_int.o dma.o vga.o serial.o i8254.o i8259.o rc4030.o
544 obj-mips-y += g364fb.o jazz_led.o dp8393x.o
545 obj-mips-y += ide.o gt64xxx.o pckbd.o fdc.o mc146818rtc.o usb-uhci.o acpi.o ds1225y.o
546 obj-mips-y += piix_pci.o parallel.o cirrus_vga.o pcspk.o $(sound-obj-y)
547 obj-mips-y += mipsnet.o
548 obj-mips-y += pflash_cfi01.o
549 obj-mips-y += vmware_vga.o
551 ifeq ($(TARGET_BASE_ARCH), mips)
552 CPPFLAGS += -DHAS_AUDIO -DHAS_AUDIO_CHOICE
555 obj-microblaze-y = petalogix_s3adsp1800_mmu.o
557 obj-microblaze-y += microblaze_pic_cpu.o
558 obj-microblaze-y += xilinx_intc.o
559 obj-microblaze-y += xilinx_timer.o
560 obj-microblaze-y += xilinx_uartlite.o
561 obj-microblaze-y += xilinx_ethlite.o
563 obj-microblaze-y += pflash_cfi02.o
566 obj-microblaze-y += device_tree.o
571 obj-cris-y = cris_pic_cpu.o etraxfs.o axis_dev88.o
574 obj-cris-y += etraxfs_dma.o
575 obj-cris-y += etraxfs_pic.o
576 obj-cris-y += etraxfs_eth.o
577 obj-cris-y += etraxfs_timer.o
578 obj-cris-y += etraxfs_ser.o
580 obj-cris-y += pflash_cfi02.o
582 ifeq ($(TARGET_ARCH), sparc64)
583 obj-sparc-y = sun4u.o ide.o pckbd.o vga.o apb_pci.o
584 obj-sparc-y += fdc.o mc146818rtc.o serial.o
585 obj-sparc-y += cirrus_vga.o parallel.o
587 obj-sparc-y = sun4m.o tcx.o iommu.o slavio_intctl.o
588 obj-sparc-y += slavio_timer.o slavio_misc.o fdc.o sparc32_dma.o
589 obj-sparc-y += cs4231.o eccmemctl.o sbi.o sun4c_intctl.o
592 obj-arm-y = integratorcp.o versatilepb.o smc91c111.o arm_pic.o arm_timer.o
593 obj-arm-y += arm_boot.o pl011.o pl031.o pl050.o pl080.o pl110.o pl181.o pl190.o
594 obj-arm-y += versatile_pci.o
595 obj-arm-y += realview_gic.o realview.o arm_sysctl.o mpcore.o
596 obj-arm-y += armv7m.o armv7m_nvic.o stellaris.o pl022.o stellaris_enet.o
598 obj-arm-y += arm-semi.o
599 obj-arm-y += pxa2xx.o pxa2xx_pic.o pxa2xx_gpio.o pxa2xx_timer.o pxa2xx_dma.o
600 obj-arm-y += pxa2xx_lcd.o pxa2xx_mmci.o pxa2xx_pcmcia.o pxa2xx_keypad.o
601 obj-arm-y += pflash_cfi01.o gumstix.o
602 obj-arm-y += zaurus.o ide.o serial.o spitz.o tosa.o tc6393xb.o
603 obj-arm-y += omap1.o omap_lcdc.o omap_dma.o omap_clk.o omap_mmc.o omap_i2c.o
604 obj-arm-y += omap2.o omap_dss.o soc_dma.o
605 obj-arm-y += omap_sx1.o palm.o tsc210x.o
606 obj-arm-y += nseries.o blizzard.o onenand.o vga.o cbus.o tusb6010.o usb-musb.o
607 obj-arm-y += mst_fpga.o mainstone.o
608 obj-arm-y += musicpal.o pflash_cfi02.o
609 obj-arm-y += framebuffer.o
610 obj-arm-y += syborg.o syborg_fb.o syborg_interrupt.o syborg_keyboard.o
611 obj-arm-y += syborg_serial.o syborg_timer.o syborg_pointer.o syborg_rtc.o
612 obj-arm-y += syborg_virtio.o
614 ifeq ($(TARGET_BASE_ARCH), arm)
615 CPPFLAGS += -DHAS_AUDIO
618 obj-sh4-y = shix.o r2d.o sh7750.o sh7750_regnames.o tc58128.o
619 obj-sh4-y += sh_timer.o sh_serial.o sh_intc.o sh_pci.o sm501.o serial.o
622 obj-m68k-y = an5206.o mcf5206.o mcf_uart.o mcf_intc.o mcf5208.o mcf_fec.o
623 obj-m68k-y += m68k-semi.o dummy_m68k.o
626 COCOA_LIBS=-F/System/Library/Frameworks -framework Cocoa -framework IOKit
627 ifdef CONFIG_COREAUDIO
628 COCOA_LIBS+=-framework CoreAudio
632 CPPFLAGS+=-I$(SRC_PATH)/slirp
635 # specific flags are needed for non soft mmu emulator
641 ifndef CONFIG_SOLARIS
654 LDFLAGS+=-Wl,-G0 -Wl,-T,$(SRC_PATH)/ia64.ld
658 SDL_LIBS := $(filter-out -mwindows, $(SDL_LIBS)) -mconsole
667 vl.o: CFLAGS+=$(SDL_CFLAGS)
671 monitor.o: qemu-monitor.h
673 LIBS += $(SDL_LIBS) $(COCOA_LIBS) $(CURSES_LIBS) $(BRLAPI_LIBS) $(VDE_LIBS) $(CURL_LIBS)
674 ARLIBS=../libqemu_common.a libqemu.a $(HWLIB)
676 endif # !CONFIG_USER_ONLY
678 $(QEMU_PROG): $(obj-y) $(obj-$(TARGET_BASE_ARCH)-y) $(ARLIBS)
679 $(call LINK,$(obj-y) $(obj-$(TARGET_BASE_ARCH)-y))
682 gdbstub-xml.c: $(TARGET_XML_FILES) feature_to_c.sh
683 ifeq ($(TARGET_XML_FILES),)
684 $(call quiet-command,rm -f $@ && echo > $@," GEN $(TARGET_DIR)$@")
686 $(call quiet-command,rm -f $@ && $(SHELL) $(SRC_PATH)/feature_to_c.sh $@ $(TARGET_XML_FILES)," GEN $(TARGET_DIR)$@")
689 qemu-options.h: $(SRC_PATH)/qemu-options.hx
690 $(call quiet-command,sh $(SRC_PATH)/hxtool -h < $< > $@," GEN $(TARGET_DIR)$@")
692 qemu-monitor.h: $(SRC_PATH)/qemu-monitor.hx
693 $(call quiet-command,sh $(SRC_PATH)/hxtool -h < $< > $@," GEN $(TARGET_DIR)$@")
696 rm -f *.o *.a *~ $(PROGS) nwfpe/*.o fpu/*.o
697 rm -f *.d */*.d tcg/*.o
698 rm -f qemu-options.h qemu-monitor.h gdbstub-xml.c
702 $(INSTALL) -m 755 $(STRIP_OPT) $(PROGS) "$(DESTDIR)$(bindir)"
705 # Include automatically generated dependency files
706 -include $(wildcard *.d */*.d)