1 # -*- Mode: makefile -*-
3 BUILD_DIR?=$(CURDIR)/..
5 include ../config-host.mak
6 include config-target.mak
7 include $(SRC_PATH)/rules.mak
10 include config-devices.mak
13 $(call set-vpath, $(SRC_PATH):$(BUILD_DIR))
15 QEMU_CFLAGS += -isystem ../linux-headers
17 QEMU_CFLAGS += -iquote .. -iquote $(SRC_PATH)/target/$(TARGET_BASE_ARCH) -DNEED_CPU_H
19 QEMU_CFLAGS+=-iquote $(SRC_PATH)/include
21 ifdef CONFIG_USER_ONLY
23 QEMU_PROG=qemu-$(TARGET_NAME)
24 QEMU_PROG_BUILD = $(QEMU_PROG)
26 # system emulator name
27 QEMU_PROG=qemu-system-$(TARGET_NAME)$(EXESUF)
28 ifneq (,$(findstring -mwindows,$(SDL_LIBS)))
29 # Terminate program name with a 'w' because the linker builds a windows executable.
30 QEMU_PROGW=qemu-system-$(TARGET_NAME)w$(EXESUF)
31 $(QEMU_PROG): $(QEMU_PROGW)
32 $(call quiet-command,$(OBJCOPY) --subsystem console $(QEMU_PROGW) $(QEMU_PROG),"GEN","$(TARGET_DIR)$(QEMU_PROG)")
33 QEMU_PROG_BUILD = $(QEMU_PROGW)
35 QEMU_PROG_BUILD = $(QEMU_PROG)
39 PROGS=$(QEMU_PROG) $(QEMU_PROGW)
42 config-target.h: config-target.h-timestamp
43 config-target.h-timestamp: config-target.mak
45 config-devices.h: config-devices.h-timestamp
46 config-devices.h-timestamp: config-devices.mak
48 ifdef CONFIG_TRACE_SYSTEMTAP
49 stap: $(QEMU_PROG).stp-installed $(QEMU_PROG).stp $(QEMU_PROG)-simpletrace.stp $(QEMU_PROG)-log.stp
51 ifdef CONFIG_USER_ONLY
57 tracetool-y = $(SRC_PATH)/scripts/tracetool.py
58 tracetool-y += $(shell find $(SRC_PATH)/scripts/tracetool -name "*.py")
60 $(QEMU_PROG).stp-installed: $(BUILD_DIR)/trace-events-all $(tracetool-y)
61 $(call quiet-command,$(TRACETOOL) \
64 --backends=$(TRACE_BACKENDS) \
65 --binary=$(bindir)/$(QEMU_PROG) \
66 --target-name=$(TARGET_NAME) \
67 --target-type=$(TARGET_TYPE) \
68 $< > $@,"GEN","$(TARGET_DIR)$(QEMU_PROG).stp-installed")
70 $(QEMU_PROG).stp: $(BUILD_DIR)/trace-events-all $(tracetool-y)
71 $(call quiet-command,$(TRACETOOL) \
74 --backends=$(TRACE_BACKENDS) \
75 --binary=$(realpath .)/$(QEMU_PROG) \
76 --target-name=$(TARGET_NAME) \
77 --target-type=$(TARGET_TYPE) \
78 $< > $@,"GEN","$(TARGET_DIR)$(QEMU_PROG).stp")
80 $(QEMU_PROG)-simpletrace.stp: $(BUILD_DIR)/trace-events-all $(tracetool-y)
81 $(call quiet-command,$(TRACETOOL) \
83 --format=simpletrace-stap \
84 --backends=$(TRACE_BACKENDS) \
85 --probe-prefix=qemu.$(TARGET_TYPE).$(TARGET_NAME) \
86 $< > $@,"GEN","$(TARGET_DIR)$(QEMU_PROG)-simpletrace.stp")
88 $(QEMU_PROG)-log.stp: $(BUILD_DIR)/trace-events-all $(tracetool-y)
89 $(call quiet-command,$(TRACETOOL) \
92 --backends=$(TRACE_BACKENDS) \
93 --probe-prefix=qemu.$(TARGET_TYPE).$(TARGET_NAME) \
94 $< > $@,"GEN","$(TARGET_DIR)$(QEMU_PROG)-log.stp")
103 # Dummy command so that make thinks it has done something
108 #########################################################
109 # cpu emulator library
110 obj-y += exec.o exec-vary.o
112 obj-$(CONFIG_TCG) += tcg/tcg.o tcg/tcg-op.o tcg/tcg-op-vec.o tcg/tcg-op-gvec.o
113 obj-$(CONFIG_TCG) += tcg/tcg-common.o tcg/optimize.o
114 obj-$(CONFIG_TCG_INTERPRETER) += tcg/tci.o
115 obj-$(CONFIG_TCG_INTERPRETER) += disas/tci.o
116 obj-$(CONFIG_TCG) += fpu/softfloat.o
117 obj-y += target/$(TARGET_BASE_ARCH)/
119 obj-$(call notempty,$(TARGET_XML_FILES)) += gdbstub-xml.o
120 LIBS := $(libs_cpu) $(LIBS)
122 obj-$(CONFIG_PLUGIN) += plugins/
124 #########################################################
125 # Linux user emulator target
127 ifdef CONFIG_LINUX_USER
129 QEMU_CFLAGS+=-I$(SRC_PATH)/linux-user/$(TARGET_ABI_DIR) \
130 -I$(SRC_PATH)/linux-user/host/$(ARCH) \
131 -I$(SRC_PATH)/linux-user \
132 -Ilinux-user/$(TARGET_ABI_DIR)
135 obj-y += gdbstub.o thunk.o
137 endif #CONFIG_LINUX_USER
139 #########################################################
140 # BSD user emulator target
142 ifdef CONFIG_BSD_USER
144 QEMU_CFLAGS+=-I$(SRC_PATH)/bsd-user -I$(SRC_PATH)/bsd-user/$(TARGET_ABI_DIR) \
145 -I$(SRC_PATH)/bsd-user/$(HOST_VARIANT_DIR)
150 endif #CONFIG_BSD_USER
152 #########################################################
153 # System emulator target
155 obj-y += arch_init.o cpus.o gdbstub.o balloon.o ioport.o
162 obj-y += memory_mapping.o
163 obj-y += migration/ram.o
165 LIBS := $(libs_softmmu) $(LIBS)
168 ifeq ($(TARGET_NAME), sparc64)
171 obj-y += hw/$(TARGET_BASE_ARCH)/
174 generated-files-y += hmp-commands.h hmp-commands-info.h
175 generated-files-y += config-devices.h
177 endif # CONFIG_SOFTMMU
179 dummy := $(call unnest-vars,,obj-y)
180 all-obj-y := $(obj-y)
183 # common-obj-m has some crap here, probably as side effect from
184 # unnest-vars recursing into target directories to fill obj-y and not
185 # properly handling the -m case.
187 # Clear common-obj-m as workaround. Fixes suspious dependency errors
188 # when building devices as modules. A bit hackish, but should be ok
189 # as long as we do not have any target-specific modules.
191 # The meson-based build system currently in development doesn't need
192 # unnest-vars and will obsolete this workaround.
196 include $(SRC_PATH)/Makefile.objs
197 dummy := $(call unnest-vars,.., \
207 all-obj-y += $(common-obj-y)
208 all-obj-y += $(qom-obj-y)
209 all-obj-$(CONFIG_SOFTMMU) += $(authz-obj-y)
210 all-obj-$(CONFIG_SOFTMMU) += $(block-obj-y) $(chardev-obj-y)
211 all-obj-$(CONFIG_SOFTMMU) += $(crypto-obj-y)
212 all-obj-$(CONFIG_SOFTMMU) += $(io-obj-y)
215 $(QEMU_PROG_BUILD): config-devices.mak
218 COMMON_LDADDS = ../libqemuutil.a
220 # build either PROG or PROGW
221 $(QEMU_PROG_BUILD): $(all-obj-y) $(COMMON_LDADDS) $(softmmu-main-y)
222 $(call LINK, $(filter-out %.mak, $^))
224 $(call quiet-command,Rez -append $(SRC_PATH)/pc-bios/qemu.rsrc -o $@,"REZ","$(TARGET_DIR)$@")
225 $(call quiet-command,SetFile -a C $@,"SETFILE","$(TARGET_DIR)$@")
228 gdbstub-xml.c: $(TARGET_XML_FILES) $(SRC_PATH)/scripts/feature_to_c.sh
229 $(call quiet-command,rm -f $@ && $(SHELL) $(SRC_PATH)/scripts/feature_to_c.sh $@ $(TARGET_XML_FILES),"GEN","$(TARGET_DIR)$@")
231 hmp-commands.h: $(SRC_PATH)/hmp-commands.hx $(SRC_PATH)/scripts/hxtool
232 $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@,"GEN","$(TARGET_DIR)$@")
234 hmp-commands-info.h: $(SRC_PATH)/hmp-commands-info.hx $(SRC_PATH)/scripts/hxtool
235 $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@,"GEN","$(TARGET_DIR)$@")
238 rm -f *.a *~ $(PROGS)
239 rm -f $(shell find . -name '*.[od]')
240 rm -f hmp-commands.h gdbstub-xml.c
241 rm -f trace/generated-helpers.c trace/generated-helpers.c-timestamp
242 ifdef CONFIG_TRACE_SYSTEMTAP
247 include $(SRC_PATH)/tests/qtest/fuzz/Makefile.include
248 include $(SRC_PATH)/tests/qtest/Makefile.include
251 fuzz-vars: QEMU_CFLAGS := $(FUZZ_CFLAGS) $(QEMU_CFLAGS)
252 fuzz-vars: QEMU_LDFLAGS := $(FUZZ_LDFLAGS) $(QEMU_LDFLAGS)
253 fuzz-vars: $(QEMU_PROG_FUZZ)
254 dummy := $(call unnest-vars,, fuzz-obj-y)
257 $(QEMU_PROG_FUZZ): config-devices.mak $(all-obj-y) $(COMMON_LDADDS) $(fuzz-obj-y)
258 $(call LINK, $(filter-out %.mak, $^))
264 $(call install-prog,$(PROGS),$(DESTDIR)$(bindir))
266 ifdef CONFIG_TRACE_SYSTEMTAP
267 $(INSTALL_DIR) "$(DESTDIR)$(qemu_datadir)/../systemtap/tapset"
268 $(INSTALL_DATA) $(QEMU_PROG).stp-installed "$(DESTDIR)$(qemu_datadir)/../systemtap/tapset/$(QEMU_PROG).stp"
269 $(INSTALL_DATA) $(QEMU_PROG)-simpletrace.stp "$(DESTDIR)$(qemu_datadir)/../systemtap/tapset/$(QEMU_PROG)-simpletrace.stp"
270 $(INSTALL_DATA) $(QEMU_PROG)-log.stp "$(DESTDIR)$(qemu_datadir)/../systemtap/tapset/$(QEMU_PROG)-log.stp"
273 generated-files-y += config-target.h
274 Makefile: $(generated-files-y)
278 # The target specific coverage report only cares about target specific
279 # blobs and not the shared code.
282 %/coverage-report.html:
284 $(call quiet-command,\
285 gcovr -r $(SRC_PATH) --object-directory $(CURDIR) \
286 -p --html --html-details -o $@, \
287 "GEN", "coverage-report.html")
289 .PHONY: coverage-report
290 coverage-report: $(CURDIR)/reports/coverage/coverage-report.html