1 # -*- Mode: makefile -*-
3 include ../config-host.mak
4 include config-target.mak
5 include config-devices.mak
6 include $(SRC_PATH)/rules.mak
8 $(call set-vpath, $(SRC_PATH))
10 QEMU_CFLAGS += -I../linux-headers
12 QEMU_CFLAGS += -I.. -I$(SRC_PATH)/target-$(TARGET_BASE_ARCH) -DNEED_CPU_H
14 QEMU_CFLAGS+=-I$(SRC_PATH)/include
16 ifdef CONFIG_USER_ONLY
18 QEMU_PROG=qemu-$(TARGET_NAME)
19 QEMU_PROG_BUILD = $(QEMU_PROG)
21 # system emulator name
22 QEMU_PROG=qemu-system-$(TARGET_NAME)$(EXESUF)
23 ifneq (,$(findstring -mwindows,$(libs_softmmu)))
24 # Terminate program name with a 'w' because the linker builds a windows executable.
25 QEMU_PROGW=qemu-system-$(TARGET_NAME)w$(EXESUF)
26 $(QEMU_PROG): $(QEMU_PROGW)
27 $(call quiet-command,$(OBJCOPY) --subsystem console $(QEMU_PROGW) $(QEMU_PROG)," GEN $(TARGET_DIR)$(QEMU_PROG)")
28 QEMU_PROG_BUILD = $(QEMU_PROGW)
30 QEMU_PROG_BUILD = $(QEMU_PROG)
34 PROGS=$(QEMU_PROG) $(QEMU_PROGW)
37 ifeq ($(CONFIG_RUBY),y)
39 ifneq ($(wildcard /usr/lib/ruby/1.8/i486-linux/ruby.h),)
40 CPPFLAGS += -I/usr/lib/ruby/1.8/i486-linux -DCONFIG_RUBY
52 config-target.h: config-target.h-timestamp
53 config-target.h-timestamp: config-target.mak
55 ifdef CONFIG_TRACE_SYSTEMTAP
56 stap: $(QEMU_PROG).stp-installed $(QEMU_PROG).stp $(QEMU_PROG)-simpletrace.stp
58 ifdef CONFIG_USER_ONLY
64 $(QEMU_PROG).stp-installed: $(SRC_PATH)/trace-events
65 $(call quiet-command,$(TRACETOOL) \
67 --backends=$(TRACE_BACKENDS) \
68 --binary=$(bindir)/$(QEMU_PROG) \
69 --target-name=$(TARGET_NAME) \
70 --target-type=$(TARGET_TYPE) \
71 < $< > $@," GEN $(TARGET_DIR)$(QEMU_PROG).stp-installed")
73 $(QEMU_PROG).stp: $(SRC_PATH)/trace-events
74 $(call quiet-command,$(TRACETOOL) \
76 --backends=$(TRACE_BACKENDS) \
77 --binary=$(realpath .)/$(QEMU_PROG) \
78 --target-name=$(TARGET_NAME) \
79 --target-type=$(TARGET_TYPE) \
80 < $< > $@," GEN $(TARGET_DIR)$(QEMU_PROG).stp")
82 $(QEMU_PROG)-simpletrace.stp: $(SRC_PATH)/trace-events
83 $(call quiet-command,$(TRACETOOL) \
84 --format=simpletrace-stap \
85 --backends=$(TRACE_BACKENDS) \
86 --probe-prefix=qemu.$(TARGET_TYPE).$(TARGET_NAME) \
87 < $< > $@," GEN $(TARGET_DIR)$(QEMU_PROG)-simpletrace.stp")
95 # Dummy command so that make thinks it has done something
98 #########################################################
99 # cpu emulator library
100 obj-y = exec.o translate-all.o cpu-exec.o
101 obj-y += tcg/tcg.o tcg/optimize.o
102 obj-$(CONFIG_TCG_INTERPRETER) += tci.o
103 obj-$(CONFIG_TCG_INTERPRETER) += disas/tci.o
104 obj-y += fpu/softfloat.o
105 obj-y += target-$(TARGET_BASE_ARCH)/
107 obj-$(call notempty,$(TARGET_XML_FILES)) += gdbstub-xml.o
108 obj-$(call lnot,$(CONFIG_KVM)) += kvm-stub.o
110 obj-$(CONFIG_LIBDECNUMBER) += libdecnumber/decContext.o
111 obj-$(CONFIG_LIBDECNUMBER) += libdecnumber/decNumber.o
112 obj-$(CONFIG_LIBDECNUMBER) += libdecnumber/dpd/decimal32.o
113 obj-$(CONFIG_LIBDECNUMBER) += libdecnumber/dpd/decimal64.o
114 obj-$(CONFIG_LIBDECNUMBER) += libdecnumber/dpd/decimal128.o
116 #########################################################
117 # Linux user emulator target
119 ifdef CONFIG_LINUX_USER
121 QEMU_CFLAGS+=-I$(SRC_PATH)/linux-user/$(TARGET_ABI_DIR) -I$(SRC_PATH)/linux-user
124 obj-y += gdbstub.o thunk.o user-exec.o
126 endif #CONFIG_LINUX_USER
128 #########################################################
129 # BSD user emulator target
131 ifdef CONFIG_BSD_USER
133 QEMU_CFLAGS+=-I$(SRC_PATH)/bsd-user -I$(SRC_PATH)/bsd-user/$(TARGET_ABI_DIR) \
134 -I$(SRC_PATH)/bsd-user/$(HOST_VARIANT_DIR)
137 obj-y += gdbstub.o user-exec.o
139 endif #CONFIG_BSD_USER
141 #########################################################
142 # System emulator target
144 obj-y += arch_init.o cpus.o monitor.o gdbstub.o balloon.o ioport.o numa.o
147 obj-$(CONFIG_FDT) += device_tree.o
148 obj-$(CONFIG_KVM) += kvm-all.o
149 obj-y += memory.o savevm.o cputlb.o
150 obj-y += memory_mapping.o
152 LIBS+=$(libs_softmmu)
155 obj-$(CONFIG_XEN) += xen-common.o
156 obj-$(CONFIG_XEN_I386) += xen-hvm.o xen-mapcache.o
157 obj-$(call lnot,$(CONFIG_XEN)) += xen-common-stub.o
158 obj-$(call lnot,$(CONFIG_XEN_I386)) += xen-hvm-stub.o
161 ifeq ($(TARGET_NAME), sparc64)
164 obj-y += hw/$(TARGET_BASE_ARCH)/
168 $(QEMU_RUBY): $(OBJS) libqemu.a
169 $(CC) -shared $(VL_LDFLAGS) -o $(QEMU_RUBY) $^ $(LIBS) $(SDL_LIBS) $(COCOA_LIBS) $(VL_LIBS)
172 GENERATED_HEADERS += hmp-commands.h qmp-commands-old.h
174 endif # CONFIG_SOFTMMU
176 # Workaround for http://gcc.gnu.org/PR55489, see configure.
177 %/translate.o: QEMU_CFLAGS += $(TRANSLATE_OPT_CFLAGS)
179 dummy := $(call unnest-vars,,obj-y)
180 all-obj-y := $(obj-y)
185 include $(SRC_PATH)/Makefile.objs
186 dummy := $(call unnest-vars,,target-obj-y)
187 target-obj-y-save := $(target-obj-y)
188 dummy := $(call unnest-vars,.., \
193 target-obj-y := $(target-obj-y-save)
194 all-obj-y += $(common-obj-y)
195 all-obj-y += $(target-obj-y)
196 all-obj-$(CONFIG_SOFTMMU) += $(block-obj-y)
198 # build either PROG or PROGW
199 $(QEMU_PROG_BUILD): $(all-obj-y) ../libqemuutil.a ../libqemustub.a
202 gdbstub-xml.c: $(TARGET_XML_FILES) $(SRC_PATH)/scripts/feature_to_c.sh
203 $(call quiet-command,rm -f $@ && $(SHELL) $(SRC_PATH)/scripts/feature_to_c.sh $@ $(TARGET_XML_FILES)," GEN $(TARGET_DIR)$@")
205 hmp-commands.h: $(SRC_PATH)/hmp-commands.hx
206 $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@," GEN $(TARGET_DIR)$@")
208 qmp-commands-old.h: $(SRC_PATH)/qmp-commands.hx
209 $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@," GEN $(TARGET_DIR)$@")
212 rm -f *.a *~ $(PROGS)
213 rm -f $(shell find . -name '*.[od]')
214 rm -f hmp-commands.h qmp-commands-old.h gdbstub-xml.c
215 ifdef CONFIG_TRACE_SYSTEMTAP
221 $(call install-prog,$(PROGS),$(DESTDIR)$(bindir))
223 ifdef CONFIG_TRACE_SYSTEMTAP
224 $(INSTALL_DIR) "$(DESTDIR)$(qemu_datadir)/../systemtap/tapset"
225 $(INSTALL_DATA) $(QEMU_PROG).stp-installed "$(DESTDIR)$(qemu_datadir)/../systemtap/tapset/$(QEMU_PROG).stp"
226 $(INSTALL_DATA) $(QEMU_PROG)-simpletrace.stp "$(DESTDIR)$(qemu_datadir)/../systemtap/tapset/$(QEMU_PROG)-simpletrace.stp"
229 GENERATED_HEADERS += config-target.h
230 Makefile: $(GENERATED_HEADERS)