]> git.ipfire.org Git - thirdparty/qemu.git/blame - Makefile
block: Avoid memleak on qcow2 image info failure
[thirdparty/qemu.git] / Makefile
CommitLineData
0cb3fb1e
PB
1# Makefile for QEMU.
2
4ace32e2
AO
3ifneq ($(words $(subst :, ,$(CURDIR))), 1)
4 $(error main directory cannot contain spaces nor colons)
5endif
6
519e1693
SW
7# Always point to the root of the build tree (needs GNU make).
8BUILD_DIR=$(CURDIR)
388d4758 9
eaa2ddbb
FZ
10# Before including a proper config-host.mak, assume we are in the source tree
11SRC_PATH=.
12
28fa2927
PMD
13UNCHECKED_GOALS := %clean TAGS cscope ctags dist \
14 html info pdf txt \
de1da442 15 help check-help print-% \
4f2f6276 16 docker docker-% vm-help vm-test vm-build-%
eaa2ddbb 17
250b086e 18# All following code might depend on configuration variables
55d7e8f6 19ifneq ($(wildcard config-host.mak),)
1ad2134f 20# Put the all: rule here so that config-host.mak can contain dependencies.
8f67aa82 21all:
ad064840 22include config-host.mak
d1bd2423 23
aef45d51
DB
24git-submodule-update:
25
26.PHONY: git-submodule-update
27
c4b01c7c
DB
28git_module_status := $(shell \
29 cd '$(SRC_PATH)' && \
30 GIT="$(GIT)" ./scripts/git-submodule.sh status $(GIT_SUBMODULES); \
31 echo $$?; \
32)
aef45d51
DB
33
34ifeq (1,$(git_module_status))
f62bbee5
DB
35ifeq (no,$(GIT_UPDATE))
36git-submodule-update:
37 $(call quiet-command, \
38 echo && \
39 echo "GIT submodule checkout is out of date. Please run" && \
40 echo " scripts/git-submodule.sh update $(GIT_SUBMODULES)" && \
41 echo "from the source directory checkout $(SRC_PATH)" && \
42 echo && \
43 exit 1)
44else
aef45d51
DB
45git-submodule-update:
46 $(call quiet-command, \
cc84d63a 47 (cd $(SRC_PATH) && GIT="$(GIT)" ./scripts/git-submodule.sh update $(GIT_SUBMODULES)), \
aef45d51
DB
48 "GIT","$(GIT_SUBMODULES)")
49endif
50endif
51
92712822 52.git-submodule-status: git-submodule-update config-host.mak
aef45d51 53
d1bd2423
PM
54# Check that we're not trying to do an out-of-tree build from
55# a tree that's been used for an in-tree build.
56ifneq ($(realpath $(SRC_PATH)),$(realpath .))
57ifneq ($(wildcard $(SRC_PATH)/config-host.mak),)
58$(error This is an out of tree build but your source tree ($(SRC_PATH)) \
59seems to have been used for an in-tree build. You can fix this by running \
b98a3bae 60"$(MAKE) distclean && rm -rf *-linux-user *-softmmu" in your source tree)
d1bd2423
PM
61endif
62endif
63
2b1f35b9
AB
64CONFIG_SOFTMMU := $(if $(filter %-softmmu,$(TARGET_DIRS)),y)
65CONFIG_USER_ONLY := $(if $(filter %-user,$(TARGET_DIRS)),y)
6b827cca 66CONFIG_XEN := $(CONFIG_XEN_BACKEND)
f3aa844b
PB
67CONFIG_ALL=y
68-include config-all-devices.mak
69-include config-all-disas.mak
70
3a6b016d 71config-host.mak: $(SRC_PATH)/configure $(SRC_PATH)/pc-bios $(SRC_PATH)/VERSION
e5efe7f5 72 @echo $@ is out-of-date, running configure
cdb69b08 73 @./config.status
26fffe29
EC
74
75# Force configure to re-run if the API symbols are updated
76ifeq ($(CONFIG_PLUGIN),y)
77config-host.mak: $(SRC_PATH)/plugins/qemu-plugins.symbols
78endif
79
55d7e8f6
AJ
80else
81config-host.mak:
eaa2ddbb 82ifneq ($(filter-out $(UNCHECKED_GOALS),$(MAKECMDGOALS)),$(if $(MAKECMDGOALS),,fail))
55d7e8f6
AJ
83 @echo "Please call configure before running make!"
84 @exit 1
85endif
7748b8cb 86endif
766a487a 87
fb57c881
FZ
88include $(SRC_PATH)/rules.mak
89
c932ce31 90# lor is defined in rules.mak
29de2804
LV
91CONFIG_BLOCK := $(call lor,$(CONFIG_SOFTMMU),$(CONFIG_TOOLS))
92
57b49737
PM
93# Create QEMU_PKGVERSION and FULL_VERSION strings
94# If PKGVERSION is set, use that; otherwise get version and -dirty status from git
95QEMU_PKGVERSION := $(if $(PKGVERSION),$(PKGVERSION),$(shell \
96 cd $(SRC_PATH); \
97 if test -e .git; then \
98 git describe --match 'v*' 2>/dev/null | tr -d '\n'; \
99 if ! git diff-index --quiet HEAD &>/dev/null; then \
100 echo "-dirty"; \
101 fi; \
102 fi))
103
104# Either "version (pkgversion)", or just "version" if pkgversion not set
105FULL_VERSION := $(if $(QEMU_PKGVERSION),$(VERSION) ($(QEMU_PKGVERSION)),$(VERSION))
106
3dff199c 107generated-files-y = qemu-version.h config-host.h qemu-options.def
bf582c34 108
bf582c34
EB
109GENERATED_QAPI_FILES = qapi/qapi-builtin-types.h qapi/qapi-builtin-types.c
110GENERATED_QAPI_FILES += qapi/qapi-types.h qapi/qapi-types.c
111GENERATED_QAPI_FILES += $(QAPI_MODULES:%=qapi/qapi-types-%.h)
112GENERATED_QAPI_FILES += $(QAPI_MODULES:%=qapi/qapi-types-%.c)
113GENERATED_QAPI_FILES += qapi/qapi-builtin-visit.h qapi/qapi-builtin-visit.c
114GENERATED_QAPI_FILES += qapi/qapi-visit.h qapi/qapi-visit.c
115GENERATED_QAPI_FILES += $(QAPI_MODULES:%=qapi/qapi-visit-%.h)
116GENERATED_QAPI_FILES += $(QAPI_MODULES:%=qapi/qapi-visit-%.c)
00ca24ff 117GENERATED_QAPI_FILES += qapi/qapi-init-commands.h qapi/qapi-init-commands.c
bf582c34
EB
118GENERATED_QAPI_FILES += qapi/qapi-commands.h qapi/qapi-commands.c
119GENERATED_QAPI_FILES += $(QAPI_MODULES:%=qapi/qapi-commands-%.h)
120GENERATED_QAPI_FILES += $(QAPI_MODULES:%=qapi/qapi-commands-%.c)
5d75648b 121GENERATED_QAPI_FILES += qapi/qapi-emit-events.h qapi/qapi-emit-events.c
bf582c34
EB
122GENERATED_QAPI_FILES += qapi/qapi-events.h qapi/qapi-events.c
123GENERATED_QAPI_FILES += $(QAPI_MODULES:%=qapi/qapi-events-%.h)
124GENERATED_QAPI_FILES += $(QAPI_MODULES:%=qapi/qapi-events-%.c)
125GENERATED_QAPI_FILES += qapi/qapi-introspect.c qapi/qapi-introspect.h
126GENERATED_QAPI_FILES += qapi/qapi-doc.texi
127
2af282ec
KW
128# The following list considers only the storage daemon main module. All other
129# modules are currently shared with the main schema, so we don't actually
130# generate additional files.
131
132GENERATED_STORAGE_DAEMON_QAPI_FILES = storage-daemon/qapi/qapi-commands.h
133GENERATED_STORAGE_DAEMON_QAPI_FILES += storage-daemon/qapi/qapi-commands.c
134GENERATED_STORAGE_DAEMON_QAPI_FILES += storage-daemon/qapi/qapi-emit-events.h
135GENERATED_STORAGE_DAEMON_QAPI_FILES += storage-daemon/qapi/qapi-emit-events.c
136GENERATED_STORAGE_DAEMON_QAPI_FILES += storage-daemon/qapi/qapi-events.h
137GENERATED_STORAGE_DAEMON_QAPI_FILES += storage-daemon/qapi/qapi-events.c
138GENERATED_STORAGE_DAEMON_QAPI_FILES += storage-daemon/qapi/qapi-init-commands.h
139GENERATED_STORAGE_DAEMON_QAPI_FILES += storage-daemon/qapi/qapi-init-commands.c
140GENERATED_STORAGE_DAEMON_QAPI_FILES += storage-daemon/qapi/qapi-introspect.h
141GENERATED_STORAGE_DAEMON_QAPI_FILES += storage-daemon/qapi/qapi-introspect.c
142GENERATED_STORAGE_DAEMON_QAPI_FILES += storage-daemon/qapi/qapi-types.h
143GENERATED_STORAGE_DAEMON_QAPI_FILES += storage-daemon/qapi/qapi-types.c
144GENERATED_STORAGE_DAEMON_QAPI_FILES += storage-daemon/qapi/qapi-visit.h
145GENERATED_STORAGE_DAEMON_QAPI_FILES += storage-daemon/qapi/qapi-visit.c
146GENERATED_STORAGE_DAEMON_QAPI_FILES += storage-daemon/qapi/qapi-doc.texi
147
3dff199c 148generated-files-y += $(GENERATED_QAPI_FILES)
2af282ec 149generated-files-y += $(GENERATED_STORAGE_DAEMON_QAPI_FILES)
eac236ea 150
3dff199c 151generated-files-y += trace/generated-tcg-tracers.h
465830fb 152
3dff199c
LV
153generated-files-y += trace/generated-helpers-wrappers.h
154generated-files-y += trace/generated-helpers.h
155generated-files-y += trace/generated-helpers.c
707c8a98 156
3dff199c
LV
157generated-files-$(CONFIG_TRACE_UST) += trace-ust-all.h
158generated-files-$(CONFIG_TRACE_UST) += trace-ust-all.c
e6bf23f8 159
3dff199c 160generated-files-y += module_block.h
0c0c1fd9 161
0ab8ed18
DB
162TRACE_HEADERS = trace-root.h $(trace-events-subdirs:%=%/trace.h)
163TRACE_SOURCES = trace-root.c $(trace-events-subdirs:%=%/trace.c)
164TRACE_DTRACE =
165ifdef CONFIG_TRACE_DTRACE
166TRACE_HEADERS += trace-dtrace-root.h $(trace-events-subdirs:%=%/trace-dtrace.h)
167TRACE_DTRACE += trace-dtrace-root.dtrace $(trace-events-subdirs:%=%/trace-dtrace.dtrace)
168endif
169ifdef CONFIG_TRACE_UST
170TRACE_HEADERS += trace-ust-root.h $(trace-events-subdirs:%=%/trace-ust.h)
171endif
172
3dff199c
LV
173generated-files-y += $(TRACE_HEADERS)
174generated-files-y += $(TRACE_SOURCES)
175generated-files-y += $(BUILD_DIR)/trace-events-all
176generated-files-y += .git-submodule-status
0ab8ed18
DB
177
178trace-group-name = $(shell dirname $1 | sed -e 's/[^a-zA-Z0-9]/_/g')
179
8755b4af
DB
180tracetool-y = $(SRC_PATH)/scripts/tracetool.py
181tracetool-y += $(shell find $(SRC_PATH)/scripts/tracetool -name "*.py")
182
0ab8ed18
DB
183%/trace.h: %/trace.h-timestamp
184 @cmp $< $@ >/dev/null 2>&1 || cp $< $@
57b7bdf4 185%/trace.h-timestamp: $(SRC_PATH)/%/trace-events $(tracetool-y) $(BUILD_DIR)/config-host.mak
0ab8ed18
DB
186 $(call quiet-command,$(TRACETOOL) \
187 --group=$(call trace-group-name,$@) \
188 --format=h \
189 --backends=$(TRACE_BACKENDS) \
190 $< > $@,"GEN","$(@:%-timestamp=%)")
191
192%/trace.c: %/trace.c-timestamp
193 @cmp $< $@ >/dev/null 2>&1 || cp $< $@
57b7bdf4 194%/trace.c-timestamp: $(SRC_PATH)/%/trace-events $(tracetool-y) $(BUILD_DIR)/config-host.mak
0ab8ed18
DB
195 $(call quiet-command,$(TRACETOOL) \
196 --group=$(call trace-group-name,$@) \
197 --format=c \
198 --backends=$(TRACE_BACKENDS) \
199 $< > $@,"GEN","$(@:%-timestamp=%)")
200
201%/trace-ust.h: %/trace-ust.h-timestamp
202 @cmp $< $@ >/dev/null 2>&1 || cp $< $@
57b7bdf4 203%/trace-ust.h-timestamp: $(SRC_PATH)/%/trace-events $(tracetool-y) $(BUILD_DIR)/config-host.mak
0ab8ed18
DB
204 $(call quiet-command,$(TRACETOOL) \
205 --group=$(call trace-group-name,$@) \
206 --format=ust-events-h \
207 --backends=$(TRACE_BACKENDS) \
208 $< > $@,"GEN","$(@:%-timestamp=%)")
209
210%/trace-dtrace.dtrace: %/trace-dtrace.dtrace-timestamp
211 @cmp $< $@ >/dev/null 2>&1 || cp $< $@
212%/trace-dtrace.dtrace-timestamp: $(SRC_PATH)/%/trace-events $(BUILD_DIR)/config-host.mak $(tracetool-y)
213 $(call quiet-command,$(TRACETOOL) \
214 --group=$(call trace-group-name,$@) \
215 --format=d \
216 --backends=$(TRACE_BACKENDS) \
217 $< > $@,"GEN","$(@:%-timestamp=%)")
218
219%/trace-dtrace.h: %/trace-dtrace.dtrace $(tracetool-y)
220 $(call quiet-command,dtrace -o $@ -h -s $<, "GEN","$@")
221
222%/trace-dtrace.o: %/trace-dtrace.dtrace $(tracetool-y)
223
224
225trace-root.h: trace-root.h-timestamp
226 @cmp $< $@ >/dev/null 2>&1 || cp $< $@
57b7bdf4 227trace-root.h-timestamp: $(SRC_PATH)/trace-events $(tracetool-y) $(BUILD_DIR)/config-host.mak
0ab8ed18
DB
228 $(call quiet-command,$(TRACETOOL) \
229 --group=root \
230 --format=h \
231 --backends=$(TRACE_BACKENDS) \
232 $< > $@,"GEN","$(@:%-timestamp=%)")
233
234trace-root.c: trace-root.c-timestamp
235 @cmp $< $@ >/dev/null 2>&1 || cp $< $@
57b7bdf4 236trace-root.c-timestamp: $(SRC_PATH)/trace-events $(tracetool-y) $(BUILD_DIR)/config-host.mak
0ab8ed18
DB
237 $(call quiet-command,$(TRACETOOL) \
238 --group=root \
239 --format=c \
240 --backends=$(TRACE_BACKENDS) \
241 $< > $@,"GEN","$(@:%-timestamp=%)")
242
243trace-ust-root.h: trace-ust-root.h-timestamp
244 @cmp $< $@ >/dev/null 2>&1 || cp $< $@
57b7bdf4 245trace-ust-root.h-timestamp: $(SRC_PATH)/trace-events $(tracetool-y) $(BUILD_DIR)/config-host.mak
0ab8ed18
DB
246 $(call quiet-command,$(TRACETOOL) \
247 --group=root \
248 --format=ust-events-h \
249 --backends=$(TRACE_BACKENDS) \
250 $< > $@,"GEN","$(@:%-timestamp=%)")
251
252trace-ust-all.h: trace-ust-all.h-timestamp
253 @cmp $< $@ >/dev/null 2>&1 || cp $< $@
57b7bdf4 254trace-ust-all.h-timestamp: $(trace-events-files) $(tracetool-y) $(BUILD_DIR)/config-host.mak
0ab8ed18
DB
255 $(call quiet-command,$(TRACETOOL) \
256 --group=all \
257 --format=ust-events-h \
258 --backends=$(TRACE_BACKENDS) \
259 $(trace-events-files) > $@,"GEN","$(@:%-timestamp=%)")
260
261trace-ust-all.c: trace-ust-all.c-timestamp
262 @cmp $< $@ >/dev/null 2>&1 || cp $< $@
57b7bdf4 263trace-ust-all.c-timestamp: $(trace-events-files) $(tracetool-y) $(BUILD_DIR)/config-host.mak
0ab8ed18
DB
264 $(call quiet-command,$(TRACETOOL) \
265 --group=all \
266 --format=ust-events-c \
267 --backends=$(TRACE_BACKENDS) \
268 $(trace-events-files) > $@,"GEN","$(@:%-timestamp=%)")
269
270trace-dtrace-root.dtrace: trace-dtrace-root.dtrace-timestamp
271 @cmp $< $@ >/dev/null 2>&1 || cp $< $@
272trace-dtrace-root.dtrace-timestamp: $(SRC_PATH)/trace-events $(BUILD_DIR)/config-host.mak $(tracetool-y)
273 $(call quiet-command,$(TRACETOOL) \
274 --group=root \
275 --format=d \
276 --backends=$(TRACE_BACKENDS) \
277 $< > $@,"GEN","$(@:%-timestamp=%)")
278
279trace-dtrace-root.h: trace-dtrace-root.dtrace
280 $(call quiet-command,dtrace -o $@ -h -s $<, "GEN","$@")
281
282trace-dtrace-root.o: trace-dtrace-root.dtrace
283
92712822
DB
284KEYCODEMAP_GEN = $(SRC_PATH)/ui/keycodemapdb/tools/keymap-gen
285KEYCODEMAP_CSV = $(SRC_PATH)/ui/keycodemapdb/data/keymaps.csv
286
287KEYCODEMAP_FILES = \
2ec78706 288 ui/input-keymap-atset1-to-qcode.c \
bcd5ac9b 289 ui/input-keymap-linux-to-qcode.c \
ab8f9d49
DB
290 ui/input-keymap-qcode-to-atset1.c \
291 ui/input-keymap-qcode-to-atset2.c \
292 ui/input-keymap-qcode-to-atset3.c \
5a15e6b1 293 ui/input-keymap-qcode-to-linux.c \
bcd5ac9b 294 ui/input-keymap-qcode-to-qnum.c \
e709a61a 295 ui/input-keymap-qcode-to-sun.c \
bcd5ac9b 296 ui/input-keymap-qnum-to-qcode.c \
ed7b2624 297 ui/input-keymap-usb-to-qcode.c \
2ec78706
DB
298 ui/input-keymap-win32-to-qcode.c \
299 ui/input-keymap-x11-to-qcode.c \
300 ui/input-keymap-xorgevdev-to-qcode.c \
301 ui/input-keymap-xorgkbd-to-qcode.c \
302 ui/input-keymap-xorgxquartz-to-qcode.c \
303 ui/input-keymap-xorgxwin-to-qcode.c \
656282d2 304 ui/input-keymap-osx-to-qcode.c \
92712822
DB
305 $(NULL)
306
3dff199c 307generated-files-$(CONFIG_SOFTMMU) += $(KEYCODEMAP_FILES)
92712822
DB
308
309ui/input-keymap-%.c: $(KEYCODEMAP_GEN) $(KEYCODEMAP_CSV) $(SRC_PATH)/ui/Makefile.objs
310 $(call quiet-command,\
6809df1d 311 stem=$* && src=$${stem%-to-*} dst=$${stem#*-to-} && \
92712822
DB
312 test -e $(KEYCODEMAP_GEN) && \
313 $(PYTHON) $(KEYCODEMAP_GEN) \
314 --lang glib2 \
315 --varname qemu_input_map_$${src}_to_$${dst} \
316 code-map $(KEYCODEMAP_CSV) $${src} $${dst} \
317 > $@ || rm -f $@, "GEN", "$@")
318
319$(KEYCODEMAP_GEN): .git-submodule-status
320$(KEYCODEMAP_CSV): .git-submodule-status
321
26ce90fd
LE
322edk2-decompressed = $(basename $(wildcard pc-bios/edk2-*.fd.bz2))
323pc-bios/edk2-%.fd: pc-bios/edk2-%.fd.bz2
324 $(call quiet-command,bzip2 -d -c $< > $@,"BUNZIP2",$<)
325
d9ace8b3
JQ
326# Don't try to regenerate Makefile or configure
327# We don't generate any of them
328Makefile: ;
329configure: ;
330
bd3f5706 331.PHONY: all clean cscope distclean html info install install-doc \
7c3d1917 332 pdf txt recurse-all dist msi FORCE
0cb3fb1e 333
fec90ff0 334$(call set-vpath, $(SRC_PATH))
8c462f8f 335
3e2e0e6b 336LIBS+=-lz $(LIBS_TOOLS)
67c0f08d 337
d52c454a
MAL
338vhost-user-json-y =
339HELPERS-y =
340
206d1b9c 341HELPERS-$(call land,$(CONFIG_SOFTMMU),$(CONFIG_LINUX)) = qemu-bridge-helper$(EXESUF)
7b93fadf 342
57589bc4 343ifeq ($(CONFIG_LINUX)$(CONFIG_VIRGL)$(CONFIG_GBM)$(CONFIG_TOOLS),yyyy)
d52c454a
MAL
344HELPERS-y += vhost-user-gpu$(EXESUF)
345vhost-user-json-y += contrib/vhost-user-gpu/50-qemu-gpu.json
346endif
d52c454a 347
2405f3c0 348ifeq ($(CONFIG_LINUX)$(CONFIG_SECCOMP)$(CONFIG_LIBCAP_NG),yyy)
81bfc42d 349HELPERS-y += virtiofsd$(EXESUF)
315616ed 350vhost-user-json-y += tools/virtiofsd/50-qemu-virtiofsd.json
81bfc42d
DDAG
351endif
352
b53c54c6
PM
353# Sphinx does not allow building manuals into the same directory as
354# the source files, so if we're doing an in-tree QEMU build we must
355# build the manuals into a subdirectory (and then install them from
356# there for 'make install'). For an out-of-tree build we can just
357# use the docs/ subdirectory in the build tree as normal.
358ifeq ($(realpath $(SRC_PATH)),$(realpath .))
359MANUAL_BUILDDIR := docs/built
360else
361MANUAL_BUILDDIR := docs
362endif
363
cc8ae6de 364ifdef BUILD_DOCS
d06118bf 365DOCS+=$(MANUAL_BUILDDIR)/system/qemu.1
a08b4a9f
PM
366DOCS+=$(MANUAL_BUILDDIR)/tools/qemu-img.1
367DOCS+=$(MANUAL_BUILDDIR)/tools/qemu-nbd.8
87c0868f 368DOCS+=$(MANUAL_BUILDDIR)/interop/qemu-ga.8
6a7e2bbe 369ifeq ($(CONFIG_LINUX)$(CONFIG_SECCOMP)$(CONFIG_LIBCAP_NG),yyy)
a08b4a9f 370DOCS+=$(MANUAL_BUILDDIR)/tools/virtiofsd.1
6a7e2bbe 371endif
acab923d 372DOCS+=$(MANUAL_BUILDDIR)/system/qemu-block-drivers.7
d59157ea
PB
373DOCS+=docs/interop/qemu-qmp-ref.html docs/interop/qemu-qmp-ref.txt docs/interop/qemu-qmp-ref.7
374DOCS+=docs/interop/qemu-ga-ref.html docs/interop/qemu-ga-ref.txt docs/interop/qemu-ga-ref.7
1bf84a1e 375DOCS+=$(MANUAL_BUILDDIR)/system/qemu-cpu-models.7
22108f33 376DOCS+=$(MANUAL_BUILDDIR)/index.html
983eef5a 377ifdef CONFIG_VIRTFS
a08b4a9f 378DOCS+=$(MANUAL_BUILDDIR)/tools/virtfs-proxy-helper.1
983eef5a 379endif
62dd1048 380ifdef CONFIG_TRACE_SYSTEMTAP
a08b4a9f 381DOCS+=$(MANUAL_BUILDDIR)/tools/qemu-trace-stap.1
62dd1048 382endif
cc8ae6de
PB
383else
384DOCS=
385endif
aa05ae6f 386
8cc357b5 387SUBDIR_MAKEFLAGS=$(if $(V),,--no-print-directory --quiet) BUILD_DIR=$(BUILD_DIR)
e0e312f3
PB
388SUBDIR_DEVICES_MAK=$(patsubst %, %/config-devices.mak, $(filter %-softmmu, $(TARGET_DIRS)))
389SUBDIR_DEVICES_MAK_DEP=$(patsubst %, %.d, $(SUBDIR_DEVICES_MAK))
1f3d3c8f 390
8bdd3d49 391ifeq ($(SUBDIR_DEVICES_MAK),)
b7c11e57 392config-all-devices.mak: config-host.mak
0bdb12c7 393 $(call quiet-command,echo '# no devices' > $@,"GEN","$@")
8bdd3d49 394else
b7c11e57 395config-all-devices.mak: $(SUBDIR_DEVICES_MAK) config-host.mak
bb585a78
PB
396 $(call quiet-command, sed -n \
397 's|^\([^=]*\)=\(.*\)$$|\1:=$$(findstring y,$$(\1)\2)|p' \
398 $(SUBDIR_DEVICES_MAK) | sort -u > $@, \
0bdb12c7 399 "GEN","$@")
8bdd3d49 400endif
1f3d3c8f 401
bd9141bb
PB
402-include $(SUBDIR_DEVICES_MAK_DEP)
403
e0e312f3
PB
404# This has to be kept in sync with Kconfig.host.
405MINIKCONF_ARGS = \
f3494749 406 $(CONFIG_MINIKCONF_MODE) \
bb768f71 407 $@ $*/config-devices.mak.d $< $(MINIKCONF_INPUTS) \
e0e312f3
PB
408 CONFIG_KVM=$(CONFIG_KVM) \
409 CONFIG_SPICE=$(CONFIG_SPICE) \
410 CONFIG_IVSHMEM=$(CONFIG_IVSHMEM) \
411 CONFIG_TPM=$(CONFIG_TPM) \
412 CONFIG_XEN=$(CONFIG_XEN) \
413 CONFIG_OPENGL=$(CONFIG_OPENGL) \
414 CONFIG_X11=$(CONFIG_X11) \
415 CONFIG_VHOST_USER=$(CONFIG_VHOST_USER) \
21c6b0c8 416 CONFIG_VHOST_KERNEL=$(CONFIG_VHOST_KERNEL) \
e0e312f3 417 CONFIG_VIRTFS=$(CONFIG_VIRTFS) \
d6c1bd4a
PB
418 CONFIG_LINUX=$(CONFIG_LINUX) \
419 CONFIG_PVRDMA=$(CONFIG_PVRDMA)
e0e312f3 420
ea763fd2
TH
421MINIKCONF_INPUTS = $(SRC_PATH)/Kconfig.host $(SRC_PATH)/hw/Kconfig
422MINIKCONF_DEPS = $(MINIKCONF_INPUTS) $(wildcard $(SRC_PATH)/hw/*/Kconfig)
e0e312f3
PB
423MINIKCONF = $(PYTHON) $(SRC_PATH)/scripts/minikconf.py \
424
ea763fd2 425$(SUBDIR_DEVICES_MAK): %/config-devices.mak: default-configs/%.mak $(MINIKCONF_DEPS) $(BUILD_DIR)/config-host.mak
e0e312f3 426 $(call quiet-command, $(MINIKCONF) $(MINIKCONF_ARGS) > $@.tmp, "GEN", "$@.tmp")
12ccfec9 427 $(call quiet-command, if test -f $@; then \
904fe1fb 428 if cmp -s $@.old $@; then \
bd9141bb
PB
429 mv $@.tmp $@; \
430 cp -p $@ $@.old; \
012f0879
SW
431 else \
432 if test -f $@.old; then \
433 echo "WARNING: $@ (user modified) out of date.";\
434 else \
435 echo "WARNING: $@ out of date.";\
436 fi; \
b98a3bae 437 echo "Run \"$(MAKE) defconfig\" to regenerate."; \
012f0879
SW
438 rm $@.tmp; \
439 fi; \
a992fe3d 440 else \
012f0879
SW
441 mv $@.tmp $@; \
442 cp -p $@ $@.old; \
0bdb12c7 443 fi,"GEN","$@");
a992fe3d
PB
444
445defconfig:
446 rm -f config-all-devices.mak $(SUBDIR_DEVICES_MAK)
447
992aeb8e
PB
448ifneq ($(wildcard config-host.mak),)
449include $(SRC_PATH)/Makefile.objs
ba1183da
FZ
450endif
451
452dummy := $(call unnest-vars,, \
453 stub-obj-y \
5b76dd13 454 authz-obj-y \
32d955a4 455 chardev-obj-y \
ba1183da
FZ
456 util-obj-y \
457 qga-obj-y \
3fa2d384 458 elf2dmp-obj-y \
a75eb03b
DM
459 ivshmem-client-obj-y \
460 ivshmem-server-obj-y \
81bfc42d 461 virtiofsd-obj-y \
a5d2f6f8 462 rdmacm-mux-obj-y \
7b2e5c65 463 libvhost-user-obj-y \
49cc0340 464 vhost-user-scsi-obj-y \
406d2aa2 465 vhost-user-blk-obj-y \
06914c97 466 vhost-user-input-obj-y \
d52c454a 467 vhost-user-gpu-obj-y \
577a6723 468 qga-vss-dll-obj-y \
ba1183da 469 block-obj-y \
cc475698 470 block-obj-m \
14837c64
KW
471 storage-daemon-obj-y \
472 storage-daemon-obj-m \
fb37726d 473 crypto-obj-y \
0c7012e0 474 qom-obj-y \
666a3af9 475 io-obj-y \
cc475698 476 common-obj-y \
0ab8ed18 477 common-obj-m \
675b9b53 478 trace-obj-y)
ba1183da 479
46e7b706 480include $(SRC_PATH)/tests/Makefile.include
992aeb8e 481
d52c454a 482all: $(DOCS) $(if $(BUILD_DOCS),sphinxdocs) $(TOOLS) $(HELPERS-y) recurse-all modules $(vhost-user-json-y)
b9dea4fb 483
67a1de0d
FZ
484qemu-version.h: FORCE
485 $(call quiet-command, \
57b49737
PM
486 (printf '#define QEMU_PKGVERSION "$(QEMU_PKGVERSION)"\n'; \
487 printf '#define QEMU_FULL_VERSION "$(FULL_VERSION)"\n'; \
7e563bfb 488 ) > $@.tmp)
d9e73d32
LM
489 $(call quiet-command, if ! cmp -s $@ $@.tmp; then \
490 mv $@.tmp $@; \
491 else \
492 rm $@.tmp; \
493 fi)
67a1de0d 494
1215c6e7
JQ
495config-host.h: config-host.h-timestamp
496config-host.h-timestamp: config-host.mak
077de81a 497qemu-options.def: $(SRC_PATH)/qemu-options.hx $(SRC_PATH)/scripts/hxtool
0bdb12c7 498 $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@,"GEN","$@")
1215c6e7 499
c621dc3e 500TARGET_DIRS_RULES := $(foreach t, all fuzz clean install, $(addsuffix /$(t), $(TARGET_DIRS)))
916359f6 501
1338a4b7
MA
502SOFTMMU_ALL_RULES=$(filter %-softmmu/all, $(TARGET_DIRS_RULES))
503$(SOFTMMU_ALL_RULES): $(authz-obj-y)
504$(SOFTMMU_ALL_RULES): $(block-obj-y)
14837c64 505$(SOFTMMU_ALL_RULES): $(storage-daemon-obj-y)
1338a4b7
MA
506$(SOFTMMU_ALL_RULES): $(chardev-obj-y)
507$(SOFTMMU_ALL_RULES): $(crypto-obj-y)
508$(SOFTMMU_ALL_RULES): $(io-obj-y)
509$(SOFTMMU_ALL_RULES): config-all-devices.mak
05dfa22b 510ifdef DECOMPRESS_EDK2_BLOBS
1338a4b7 511$(SOFTMMU_ALL_RULES): $(edk2-decompressed)
05dfa22b 512endif
cec7d0b6 513
c621dc3e
AB
514SOFTMMU_FUZZ_RULES=$(filter %-softmmu/fuzz, $(TARGET_DIRS_RULES))
515$(SOFTMMU_FUZZ_RULES): $(authz-obj-y)
516$(SOFTMMU_FUZZ_RULES): $(block-obj-y)
517$(SOFTMMU_FUZZ_RULES): $(chardev-obj-y)
518$(SOFTMMU_FUZZ_RULES): $(crypto-obj-y)
519$(SOFTMMU_FUZZ_RULES): $(io-obj-y)
520$(SOFTMMU_FUZZ_RULES): config-all-devices.mak
521$(SOFTMMU_FUZZ_RULES): $(edk2-decompressed)
522
1338a4b7
MA
523.PHONY: $(TARGET_DIRS_RULES)
524# The $(TARGET_DIRS_RULES) are of the form SUBDIR/GOAL, so that
525# $(dir $@) yields the sub-directory, and $(notdir $@) yields the sub-goal
526$(TARGET_DIRS_RULES):
527 $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C $(dir $@) V="$(V)" TARGET_DIR="$(dir $@)" $(notdir $@),)
4aa42531 528
a540f158 529DTC_MAKE_ARGS=-I$(SRC_PATH)/dtc VPATH=$(SRC_PATH)/dtc -C dtc V="$(V)" LIBFDT_srcdir=$(SRC_PATH)/dtc/libfdt
965f486c
PM
530DTC_CFLAGS=$(CFLAGS) $(QEMU_CFLAGS)
531DTC_CPPFLAGS=-I$(BUILD_DIR)/dtc -I$(SRC_PATH)/dtc -I$(SRC_PATH)/dtc/libfdt
a540f158 532
3b8593ee
MA
533.PHONY: dtc/all
534dtc/all: .git-submodule-status dtc/libfdt dtc/tests
db5adeaa 535 $(call quiet-command,$(MAKE) $(DTC_MAKE_ARGS) CPPFLAGS="$(DTC_CPPFLAGS)" CFLAGS="$(DTC_CFLAGS)" LDFLAGS="$(QEMU_LDFLAGS)" ARFLAGS="$(ARFLAGS)" CC="$(CC)" AR="$(AR)" LD="$(LD)" $(SUBDIR_MAKEFLAGS) libfdt/libfdt.a,)
a540f158 536
00525864 537dtc/%: .git-submodule-status
814e1110 538 @mkdir -p $@
a540f158 539
e219c499
RH
540# Overriding CFLAGS causes us to lose defines added in the sub-makefile.
541# Not overriding CFLAGS leads to mis-matches between compilation modes.
542# Therefore we replicate some of the logic in the sub-makefile.
543# Remove all the extra -Warning flags that QEMU uses that Capstone doesn't;
544# no need to annoy QEMU developers with such things.
545CAP_CFLAGS = $(patsubst -W%,,$(CFLAGS) $(QEMU_CFLAGS))
546CAP_CFLAGS += -DCAPSTONE_USE_SYS_DYN_MEM
547CAP_CFLAGS += -DCAPSTONE_HAS_ARM
548CAP_CFLAGS += -DCAPSTONE_HAS_ARM64
549CAP_CFLAGS += -DCAPSTONE_HAS_POWERPC
550CAP_CFLAGS += -DCAPSTONE_HAS_X86
551
3b8593ee
MA
552.PHONY: capstone/all
553capstone/all: .git-submodule-status
9f81aeb5 554 $(call quiet-command,$(MAKE) -C $(SRC_PATH)/capstone CAPSTONE_SHARED=no BUILDDIR="$(BUILD_DIR)/capstone" CC="$(CC)" AR="$(AR)" LD="$(LD)" RANLIB="$(RANLIB)" CFLAGS="$(CAP_CFLAGS)" $(SUBDIR_MAKEFLAGS) $(BUILD_DIR)/capstone/$(LIBCAPSTONE))
e219c499 555
3b8593ee
MA
556.PHONY: slirp/all
557slirp/all: .git-submodule-status
daa79d9a
AB
558 $(call quiet-command,$(MAKE) -C $(SRC_PATH)/slirp \
559 BUILD_DIR="$(BUILD_DIR)/slirp" \
560 PKG_CONFIG="$(PKG_CONFIG)" \
561 CC="$(CC)" AR="$(AR)" LD="$(LD)" RANLIB="$(RANLIB)" \
db5adeaa 562 CFLAGS="$(QEMU_CFLAGS) $(CFLAGS)" LDFLAGS="$(QEMU_LDFLAGS)")
675b9b53 563
3b8593ee
MA
564# Compatibility gunk to keep make working across the rename of targets
565# for recursion, to be removed some time after 4.1.
566subdir-dtc: dtc/all
567subdir-capstone: capstone/all
568subdir-slirp: slirp/all
569
1338a4b7 570$(filter %/all, $(TARGET_DIRS_RULES)): libqemuutil.a $(common-obj-y) \
b8d89ba8 571 $(qom-obj-y)
add16157 572
c621dc3e
AB
573$(filter %/fuzz, $(TARGET_DIRS_RULES)): libqemuutil.a $(common-obj-y) \
574 $(qom-obj-y) $(crypto-user-obj-$(CONFIG_USER_ONLY))
575
3b8593ee 576ROM_DIRS = $(addprefix pc-bios/, $(ROMS))
1338a4b7 577ROM_DIRS_RULES=$(foreach t, all clean, $(addsuffix /$(t), $(ROM_DIRS)))
a9c87304 578# Only keep -O and -g cflags
1338a4b7
MA
579.PHONY: $(ROM_DIRS_RULES)
580$(ROM_DIRS_RULES):
581 $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C $(dir $@) V="$(V)" TARGET_DIR="$(dir $@)" CFLAGS="$(filter -O% -g%,$(CFLAGS))" $(notdir $@),)
c05ac895 582
8d358a5e 583.PHONY: recurse-all recurse-clean recurse-install
1338a4b7 584recurse-all: $(addsuffix /all, $(TARGET_DIRS) $(ROM_DIRS))
c621dc3e 585recurse-fuzz: $(addsuffix /fuzz, $(TARGET_DIRS) $(ROM_DIRS))
1338a4b7
MA
586recurse-clean: $(addsuffix /clean, $(TARGET_DIRS) $(ROM_DIRS))
587recurse-install: $(addsuffix /install, $(TARGET_DIRS))
47ae060e 588$(addsuffix /install, $(TARGET_DIRS)): all
83f64091 589
c17a18ef 590$(BUILD_DIR)/version.o: $(SRC_PATH)/version.rc config-host.h
0bdb12c7 591 $(call quiet-command,$(WINDRES) -I$(BUILD_DIR) -o $@ $<,"RC","version.o")
5354e4d2 592
c17a18ef 593Makefile: $(version-obj-y)
3bc2f570
PB
594
595######################################################################
8a090705 596# Build libraries
3bc2f570 597
ebedb37c 598libqemuutil.a: $(util-obj-y) $(trace-obj-y) $(stub-obj-y)
5f9ff1ef 599libvhost-user.a: $(libvhost-user-obj-y) $(util-obj-y) $(stub-obj-y)
3bc2f570 600
44dc0ca3 601######################################################################
4fb240a4 602
ebedb37c 603COMMON_LDADDS = libqemuutil.a
0ab8ed18 604
3c089e15 605qemu-img.o: qemu-img-cmds.h
153859be 606
5b76dd13
DB
607qemu-img$(EXESUF): qemu-img.o $(authz-obj-y) $(block-obj-y) $(crypto-obj-y) $(io-obj-y) $(qom-obj-y) $(COMMON_LDADDS)
608qemu-nbd$(EXESUF): qemu-nbd.o $(authz-obj-y) $(block-obj-y) $(crypto-obj-y) $(io-obj-y) $(qom-obj-y) $(COMMON_LDADDS)
609qemu-io$(EXESUF): qemu-io.o $(authz-obj-y) $(block-obj-y) $(crypto-obj-y) $(io-obj-y) $(qom-obj-y) $(COMMON_LDADDS)
5e6911cf 610qemu-storage-daemon$(EXESUF): qemu-storage-daemon.o $(authz-obj-y) $(block-obj-y) $(crypto-obj-y) $(chardev-obj-y) $(io-obj-y) $(qom-obj-y) $(storage-daemon-obj-y) $(COMMON_LDADDS)
0a8e1acd 611
0ab8ed18 612qemu-bridge-helper$(EXESUF): qemu-bridge-helper.o $(COMMON_LDADDS)
7b93fadf 613
6a021536
GH
614qemu-keymap$(EXESUF): qemu-keymap.o ui/input-keymap.o $(COMMON_LDADDS)
615
72d277a7
GH
616qemu-edid$(EXESUF): qemu-edid.o hw/display/edid-generate.o $(COMMON_LDADDS)
617
0ab8ed18 618fsdev/virtfs-proxy-helper$(EXESUF): fsdev/virtfs-proxy-helper.o fsdev/9p-marshal.o fsdev/9p-iov-marshal.o $(COMMON_LDADDS)
17bff52b 619
5b76dd13 620scsi/qemu-pr-helper$(EXESUF): scsi/qemu-pr-helper.o scsi/utils.o $(authz-obj-y) $(crypto-obj-y) $(io-obj-y) $(qom-obj-y) $(COMMON_LDADDS)
fe8fc5ae
PB
621ifdef CONFIG_MPATH
622scsi/qemu-pr-helper$(EXESUF): LIBS += -ludev -lmultipath -lmpathpersist
623endif
b855f8d1 624
077de81a 625qemu-img-cmds.h: $(SRC_PATH)/qemu-img-cmds.hx $(SRC_PATH)/scripts/hxtool
0bdb12c7 626 $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@,"GEN","$@")
153859be 627
957f1f99 628qemu-ga$(EXESUF): LIBS = $(LIBS_QGA)
54c2e502 629qemu-ga$(EXESUF): QEMU_CFLAGS += -I qga/qapi-generated
640e5404 630
6a021536
GH
631qemu-keymap$(EXESUF): LIBS += $(XKBCOMMON_LIBS)
632qemu-keymap$(EXESUF): QEMU_CFLAGS += $(XKBCOMMON_CFLAGS)
633
e6c42b96
MA
634qapi-py = $(SRC_PATH)/scripts/qapi/__init__.py \
635$(SRC_PATH)/scripts/qapi/commands.py \
636$(SRC_PATH)/scripts/qapi/common.py \
637$(SRC_PATH)/scripts/qapi/doc.py \
638$(SRC_PATH)/scripts/qapi/error.py \
fb0bc835 639$(SRC_PATH)/scripts/qapi/events.py \
e6c42b96
MA
640$(SRC_PATH)/scripts/qapi/expr.py \
641$(SRC_PATH)/scripts/qapi/gen.py \
fb0bc835 642$(SRC_PATH)/scripts/qapi/introspect.py \
e6c42b96
MA
643$(SRC_PATH)/scripts/qapi/parser.py \
644$(SRC_PATH)/scripts/qapi/schema.py \
645$(SRC_PATH)/scripts/qapi/source.py \
fb0bc835
MA
646$(SRC_PATH)/scripts/qapi/types.py \
647$(SRC_PATH)/scripts/qapi/visit.py \
fb0bc835
MA
648$(SRC_PATH)/scripts/qapi-gen.py
649
650qga/qapi-generated/qga-qapi-types.c qga/qapi-generated/qga-qapi-types.h \
651qga/qapi-generated/qga-qapi-visit.c qga/qapi-generated/qga-qapi-visit.h \
eb815e24 652qga/qapi-generated/qga-qapi-commands.h qga/qapi-generated/qga-qapi-commands.c \
00ca24ff 653qga/qapi-generated/qga-qapi-init-commands.h qga/qapi-generated/qga-qapi-init-commands.c \
fb0bc835
MA
654qga/qapi-generated/qga-qapi-doc.texi: \
655qga/qapi-generated/qapi-gen-timestamp ;
656qga/qapi-generated/qapi-gen-timestamp: $(SRC_PATH)/qga/qapi-schema.json $(qapi-py)
0d6b93de 657 $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-gen.py \
fb0bc835
MA
658 -o qga/qapi-generated -p "qga-" $<, \
659 "GEN","$(@:%-timestamp=%)")
660 @>$@
e3d4d252 661
bf582c34
EB
662qapi-modules = $(SRC_PATH)/qapi/qapi-schema.json \
663 $(QAPI_MODULES:%=$(SRC_PATH)/qapi/%.json)
664
665$(GENERATED_QAPI_FILES): qapi-gen-timestamp ;
fb0bc835 666qapi-gen-timestamp: $(qapi-modules) $(qapi-py)
0d6b93de 667 $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-gen.py \
eb815e24 668 -o "qapi" -b $<, \
fb0bc835
MA
669 "GEN","$(@:%-timestamp=%)")
670 @>$@
e3193601 671
2af282ec
KW
672qapi-modules-storage-daemon = \
673 $(SRC_PATH)/storage-daemon/qapi/qapi-schema.json \
674 $(QAPI_MODULES_STORAGE_DAEMON:%=$(SRC_PATH)/qapi/%.json)
675
676$(GENERATED_STORAGE_DAEMON_QAPI_FILES): storage-daemon/qapi/qapi-gen-timestamp ;
677storage-daemon/qapi/qapi-gen-timestamp: $(qapi-modules-storage-daemon) $(qapi-py)
678 $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-gen.py \
679 -o "storage-daemon/qapi" $<, \
680 "GEN","$(@:%-timestamp=%)")
681 @>$@
682
00ca24ff 683QGALIB_GEN=$(addprefix qga/qapi-generated/, qga-qapi-types.h qga-qapi-visit.h qga-qapi-commands.h qga-qapi-init-commands.h)
7a0b7eba 684$(qga-obj-y): $(QGALIB_GEN)
957f1f99 685
0ab8ed18 686qemu-ga$(EXESUF): $(qga-obj-y) $(COMMON_LDADDS)
fafcaf1d 687 $(call LINK, $^)
48ff7a62 688
9dacf32d
YH
689ifdef QEMU_GA_MSI_ENABLED
690QEMU_GA_MSI=qemu-ga-$(ARCH).msi
691
0a18750f 692msi: $(QEMU_GA_MSI)
9dacf32d 693
fafcaf1d 694$(QEMU_GA_MSI): qemu-ga.exe $(QGA_VSS_PROVIDER)
9dacf32d 695
9dacf32d
YH
696$(QEMU_GA_MSI): config-host.mak
697
decdfbd2
LB
698$(QEMU_GA_MSI): $(SRC_PATH)/qga/installer/qemu-ga.wxs
699 $(call quiet-command,QEMU_GA_VERSION="$(QEMU_GA_VERSION)" QEMU_GA_MANUFACTURER="$(QEMU_GA_MANUFACTURER)" QEMU_GA_DISTRO="$(QEMU_GA_DISTRO)" BUILD_DIR="$(BUILD_DIR)" \
0bdb12c7 700 wixl -o $@ $(QEMU_GA_MSI_ARCH) $(QEMU_GA_MSI_WITH_VSS) $(QEMU_GA_MSI_MINGW_DLL_PATH) $<,"WIXL","$@")
9dacf32d
YH
701else
702msi:
15b19ed8 703 @echo "MSI build not configured or dependency resolution failed (reconfigure with --enable-guest-agent-msi option)"
9dacf32d
YH
704endif
705
fafcaf1d
MR
706ifneq ($(EXESUF),)
707.PHONY: qemu-ga
708qemu-ga: qemu-ga$(EXESUF) $(QGA_VSS_PROVIDER) $(QEMU_GA_MSI)
709endif
710
1b9d35f3 711elf2dmp$(EXESUF): $(elf2dmp-obj-y)
3fa2d384
VP
712 $(call LINK, $^)
713
b1449edb 714ifdef CONFIG_IVSHMEM
0ab8ed18 715ivshmem-client$(EXESUF): $(ivshmem-client-obj-y) $(COMMON_LDADDS)
a75eb03b 716 $(call LINK, $^)
0ab8ed18 717ivshmem-server$(EXESUF): $(ivshmem-server-obj-y) $(COMMON_LDADDS)
a75eb03b 718 $(call LINK, $^)
b1449edb 719endif
d59a031c 720vhost-user-scsi$(EXESUF): $(vhost-user-scsi-obj-y) libvhost-user.a
49cc0340 721 $(call LINK, $^)
406d2aa2
CL
722vhost-user-blk$(EXESUF): $(vhost-user-blk-obj-y) libvhost-user.a
723 $(call LINK, $^)
0f645ba1
MA
724
725rdmacm-mux$(EXESUF): LIBS += "-libumad"
a5d2f6f8
YS
726rdmacm-mux$(EXESUF): $(rdmacm-mux-obj-y) $(COMMON_LDADDS)
727 $(call LINK, $^)
a75eb03b 728
4f8bde99 729# relies on Linux-specific syscalls
2405f3c0 730ifeq ($(CONFIG_LINUX)$(CONFIG_SECCOMP)$(CONFIG_LIBCAP_NG),yyy)
81bfc42d
DDAG
731virtiofsd$(EXESUF): $(virtiofsd-obj-y) libvhost-user.a $(COMMON_LDADDS)
732 $(call LINK, $^)
733endif
734
d52c454a
MAL
735vhost-user-gpu$(EXESUF): $(vhost-user-gpu-obj-y) $(libvhost-user-obj-y) libqemuutil.a libqemustub.a
736 $(call LINK, $^)
737
06914c97
MAL
738ifdef CONFIG_VHOST_USER_INPUT
739ifdef CONFIG_LINUX
740vhost-user-input$(EXESUF): $(vhost-user-input-obj-y) libvhost-user.a libqemuutil.a
741 $(call LINK, $^)
742
743# build by default, do not install
744all: vhost-user-input$(EXESUF)
745endif
746endif
747
0c0c1fd9
MM
748module_block.h: $(SRC_PATH)/scripts/modules/module_block.py config-host.mak
749 $(call quiet-command,$(PYTHON) $< $@ \
750 $(addprefix $(SRC_PATH)/,$(patsubst %.mo,%.c,$(block-obj-m))), \
0bdb12c7 751 "GEN","$@")
0c0c1fd9 752
990e6a27
AB
753ifdef CONFIG_GCOV
754.PHONY: clean-coverage
755clean-coverage:
756 $(call quiet-command, \
757 find . \( -name '*.gcda' -o -name '*.gcov' \) -type f -exec rm {} +, \
758 "CLEAN", "coverage files")
759endif
760
1338a4b7 761clean: recurse-clean
2d80ae89 762# avoid old build problems by removing potentially incorrect old files
25be210f 763 rm -f config.mak op-i386.h opc-i386.h gen-op-i386.h op-arm.h opc-arm.h gen-op-arm.h
df2943ba 764 rm -f qemu-options.def
9dacf32d 765 rm -f *.msi
23858f40
LE
766 find . \( -name '*.so' -o -name '*.dll' -o -name '*.mo' -o -name '*.[oda]' \) -type f \
767 ! -path ./roms/edk2/ArmPkg/Library/GccLto/liblto-aarch64.a \
768 ! -path ./roms/edk2/ArmPkg/Library/GccLto/liblto-arm.a \
769 ! -path ./roms/edk2/BaseTools/Source/Python/UPT/Dll/sqlite3.dll \
770 -exec rm {} +
26ce90fd 771 rm -f $(edk2-decompressed)
0814465a 772 rm -f $(filter-out %.tlb,$(TOOLS)) $(HELPERS-y) TAGS cscope.* *.pod *~ */*~
b855f8d1 773 rm -f fsdev/*.pod scsi/*.pod
07b44ce9 774 rm -f qemu-img-cmds.h
d98bc0b6 775 rm -f ui/shader/*-vert.h ui/shader/*-frag.h
3dff199c 776 @# May not be present in generated-files-y
eac236ea
LV
777 rm -f trace/generated-tracers-dtrace.dtrace*
778 rm -f trace/generated-tracers-dtrace.h*
3dff199c 779 rm -f $(foreach f,$(generated-files-y),$(f) $(f)-timestamp)
fb0bc835 780 rm -f qapi-gen-timestamp
2af282ec 781 rm -f storage-daemon/qapi/qapi-gen-timestamp
54c2e502 782 rm -rf qga/qapi-generated
e92af6ec 783 rm -f config-all-devices.mak
31e31b8a 784
34bb443e
AL
785VERSION ?= $(shell cat VERSION)
786
787dist: qemu-$(VERSION).tar.bz2
788
34bb443e
AL
789qemu-%.tar.bz2:
790 $(SRC_PATH)/scripts/make-release "$(SRC_PATH)" "$(patsubst qemu-%.tar.bz2,%,$@)"
791
5f71eac0 792define clean-manual =
1290e671
PM
793rm -rf $(MANUAL_BUILDDIR)/$1/_static
794rm -f $(MANUAL_BUILDDIR)/$1/objects.inv $(MANUAL_BUILDDIR)/$1/searchindex.js $(MANUAL_BUILDDIR)/$1/*.html
5f71eac0
PM
795endef
796
7d13299d 797distclean: clean
d1055e3a 798 rm -f config-host.mak config-host.h* config-host.ld $(DOCS)
2038f8c8 799 rm -f tests/tcg/config-*.mak
ae219359 800 rm -f config-all-devices.mak config-all-disas.mak config.status
e92af6ec 801 rm -f $(SUBDIR_DEVICES_MAK)
ae219359 802 rm -f po/*.mo tests/qemu-iotests/common.env
fc8e320e 803 rm -f roms/seabios/config.mak roms/vgabios/config.mak
26fffe29 804 rm -f qemu-plugins-ld.symbols qemu-plugins-ld64.symbols
793553ac 805 rm -f config.log
67ed96f9 806 rm -f linux-headers/asm
d59157ea
PB
807 rm -f docs/version.texi
808 rm -f docs/interop/qemu-ga-qapi.texi docs/interop/qemu-qmp-qapi.texi
809 rm -f docs/interop/qemu-qmp-ref.7 docs/interop/qemu-ga-ref.7
810 rm -f docs/interop/qemu-qmp-ref.txt docs/interop/qemu-ga-ref.txt
811 rm -f docs/interop/qemu-qmp-ref.pdf docs/interop/qemu-ga-ref.pdf
812 rm -f docs/interop/qemu-qmp-ref.html docs/interop/qemu-ga-ref.html
81f33401 813 rm -rf .doctrees
5f71eac0
PM
814 $(call clean-manual,devel)
815 $(call clean-manual,interop)
0783a732 816 $(call clean-manual,specs)
0928523a 817 $(call clean-manual,system)
65c3542b 818 $(call clean-manual,tools)
09147930 819 $(call clean-manual,user)
2b1f35b9 820 for d in $(TARGET_DIRS); do \
bc1b050d 821 rm -rf $$d || exit 1 ; \
76bc6838 822 done
d9840e25 823 rm -Rf .sdk
fb8597bb 824 if test -f dtc/version_gen.h; then $(MAKE) $(DTC_MAKE_ARGS) clean; fi
7d13299d 825
06e7772f 826KEYMAPS=da en-gb et fr fr-ch is lt no pt-br sv \
fed4a9ad 827ar de en-us fi fr-be hr it lv nl pl ru th \
26b1cbf8 828de-ch es fo fr-ca hu ja mk pt sl tr \
3751e722 829bepo cz
fed4a9ad 830
77755340 831ifdef INSTALL_BLOBS
32eb2da3 832BLOBS=bios.bin bios-256k.bin bios-microvm.bin sgabios.bin vgabios.bin vgabios-cirrus.bin \
7a4dfd1e 833vgabios-stdvga.bin vgabios-vmware.bin vgabios-qxl.bin vgabios-virtio.bin \
0a87fd69 834vgabios-ramfb.bin vgabios-bochs-display.bin vgabios-ati.bin \
b2ce76a0 835openbios-sparc32 openbios-sparc64 openbios-ppc QEMU,tcx.bin QEMU,cgthree.bin \
5ee8ad71
AW
836pxe-e1000.rom pxe-eepro100.rom pxe-ne2k_pci.rom \
837pxe-pcnet.rom pxe-rtl8139.rom pxe-virtio.rom \
9fd02979
SE
838efi-e1000.rom efi-eepro100.rom efi-ne2k_pci.rom \
839efi-pcnet.rom efi-rtl8139.rom efi-virtio.rom \
45027808 840efi-e1000e.rom efi-vmxnet3.rom \
b3ce38dc 841qemu-nsis.bmp \
4b387f9e 842bamboo.dtb canyonlands.dtb petalogix-s3adsp1800.dtb petalogix-ml605.dtb \
2785dc7b 843multiboot.bin linuxboot.bin linuxboot_dma.bin kvmvapic.bin pvh.bin \
6c5359e1 844s390-ccw.img s390-netboot.img \
744a928c 845slof.bin skiboot.lid \
0c6ab8c9 846palcode-clipper \
82e65fe0 847u-boot.e500 u-boot-sam460-20100605.bin \
43ad2564 848qemu_vga.ndrv \
26ce90fd 849edk2-licenses.txt \
91f3a2f0 850hppa-firmware.img \
a6fcc80b 851opensbi-riscv32-sifive_u-fw_jump.bin opensbi-riscv32-virt-fw_jump.bin \
91f3a2f0
AF
852opensbi-riscv64-sifive_u-fw_jump.bin opensbi-riscv64-virt-fw_jump.bin
853
26ce90fd
LE
854
855DESCS=50-edk2-i386-secure.json 50-edk2-x86_64-secure.json \
85660-edk2-aarch64.json 60-edk2-arm.json 60-edk2-i386.json 60-edk2-x86_64.json
77755340
TS
857else
858BLOBS=
26ce90fd 859DESCS=
77755340
TS
860endif
861
336cfef4 862# Note that we manually filter-out the non-Sphinx documentation which
27a296fc
PM
863# is currently built into the docs/interop directory in the build tree,
864# and also any sphinx-built manpages.
5f71eac0 865define install-manual =
1290e671 866for d in $$(cd $(MANUAL_BUILDDIR) && find $1 -type d); do $(INSTALL_DIR) "$(DESTDIR)$(qemu_docdir)/$$d"; done
27a296fc 867for f in $$(cd $(MANUAL_BUILDDIR) && find $1 -type f -a '!' '(' -name '*.[0-9]' -o -name 'qemu-*-qapi.*' -o -name 'qemu-*-ref.*' ')' ); do $(INSTALL_DATA) "$(MANUAL_BUILDDIR)/$$f" "$(DESTDIR)$(qemu_docdir)/$$f"; done
5f71eac0
PM
868endef
869
870# Note that we deliberately do not install the "devel" manual: it is
871# for QEMU developers, and not interesting to our users.
872.PHONY: install-sphinxdocs
873install-sphinxdocs: sphinxdocs
874 $(call install-manual,interop)
0783a732 875 $(call install-manual,specs)
0928523a 876 $(call install-manual,system)
65c3542b 877 $(call install-manual,tools)
09147930 878 $(call install-manual,user)
5f71eac0
PM
879
880install-doc: $(DOCS) install-sphinxdocs
d7dd65ba 881 $(INSTALL_DIR) "$(DESTDIR)$(qemu_docdir)"
22108f33 882 $(INSTALL_DATA) $(MANUAL_BUILDDIR)/index.html "$(DESTDIR)$(qemu_docdir)"
d59157ea
PB
883 $(INSTALL_DATA) docs/interop/qemu-qmp-ref.html "$(DESTDIR)$(qemu_docdir)"
884 $(INSTALL_DATA) docs/interop/qemu-qmp-ref.txt "$(DESTDIR)$(qemu_docdir)"
96d409eb 885ifdef CONFIG_POSIX
58f8aead 886 $(INSTALL_DIR) "$(DESTDIR)$(mandir)/man1"
d06118bf 887 $(INSTALL_DATA) $(MANUAL_BUILDDIR)/system/qemu.1 "$(DESTDIR)$(mandir)/man1"
56e8bdd4 888 $(INSTALL_DIR) "$(DESTDIR)$(mandir)/man7"
d59157ea 889 $(INSTALL_DATA) docs/interop/qemu-qmp-ref.7 "$(DESTDIR)$(mandir)/man7"
acab923d 890 $(INSTALL_DATA) $(MANUAL_BUILDDIR)/system/qemu-block-drivers.7 "$(DESTDIR)$(mandir)/man7"
1bf84a1e 891 $(INSTALL_DATA) $(MANUAL_BUILDDIR)/system/qemu-cpu-models.7 "$(DESTDIR)$(mandir)/man7"
c932ce31 892ifeq ($(CONFIG_TOOLS),y)
a08b4a9f 893 $(INSTALL_DATA) $(MANUAL_BUILDDIR)/tools/qemu-img.1 "$(DESTDIR)$(mandir)/man1"
58f8aead 894 $(INSTALL_DIR) "$(DESTDIR)$(mandir)/man8"
a08b4a9f 895 $(INSTALL_DATA) $(MANUAL_BUILDDIR)/tools/qemu-nbd.8 "$(DESTDIR)$(mandir)/man8"
38954dca 896endif
62dd1048 897ifdef CONFIG_TRACE_SYSTEMTAP
a08b4a9f 898 $(INSTALL_DATA) $(MANUAL_BUILDDIR)/tools/qemu-trace-stap.1 "$(DESTDIR)$(mandir)/man1"
62dd1048 899endif
665b5d0d 900ifneq (,$(findstring qemu-ga,$(TOOLS)))
b53c54c6 901 $(INSTALL_DATA) $(MANUAL_BUILDDIR)/interop/qemu-ga.8 "$(DESTDIR)$(mandir)/man8"
d59157ea
PB
902 $(INSTALL_DATA) docs/interop/qemu-ga-ref.html "$(DESTDIR)$(qemu_docdir)"
903 $(INSTALL_DATA) docs/interop/qemu-ga-ref.txt "$(DESTDIR)$(qemu_docdir)"
904 $(INSTALL_DATA) docs/interop/qemu-ga-ref.7 "$(DESTDIR)$(mandir)/man7"
665b5d0d 905endif
8a3e8f7f 906endif
a2d8f1be
MK
907ifdef CONFIG_VIRTFS
908 $(INSTALL_DIR) "$(DESTDIR)$(mandir)/man1"
a08b4a9f 909 $(INSTALL_DATA) $(MANUAL_BUILDDIR)/tools/virtfs-proxy-helper.1 "$(DESTDIR)$(mandir)/man1"
a2d8f1be 910endif
6a7e2bbe 911ifeq ($(CONFIG_LINUX)$(CONFIG_SECCOMP)$(CONFIG_LIBCAP_NG),yyy)
a08b4a9f 912 $(INSTALL_DATA) $(MANUAL_BUILDDIR)/tools/virtiofsd.1 "$(DESTDIR)$(mandir)/man1"
6a7e2bbe 913endif
e2d87bff
EH
914
915install-datadir:
916 $(INSTALL_DIR) "$(DESTDIR)$(qemu_datadir)"
917
f2e3978b
LE
918install-localstatedir:
919ifdef CONFIG_POSIX
920ifneq (,$(findstring qemu-ga,$(TOOLS)))
921 $(INSTALL_DIR) "$(DESTDIR)$(qemu_localstatedir)"/run
922endif
923endif
924
a8260d38 925ICON_SIZES=16x16 24x24 32x32 48x48 64x64 128x128 256x256 512x512
e2d87bff 926
54cb65d8
EC
927install-includedir:
928 $(INSTALL_DIR) "$(DESTDIR)$(includedir)"
929
930install: all $(if $(BUILD_DOCS),install-doc) \
931 install-datadir install-localstatedir install-includedir \
1338a4b7
MA
932 $(if $(INSTALL_BLOBS),$(edk2-decompressed)) \
933 recurse-install
932a79df 934ifneq ($(TOOLS),)
0814465a 935 $(call install-prog,$(TOOLS),$(DESTDIR)$(bindir))
932a79df 936endif
e3be6f0e
FZ
937ifneq ($(CONFIG_MODULES),)
938 $(INSTALL_DIR) "$(DESTDIR)$(qemu_moddir)"
2115182f
MT
939 for s in $(modules-m:.mo=$(DSOSUF)); do \
940 t="$(DESTDIR)$(qemu_moddir)/$$(echo $$s | tr / -)"; \
264f8b4f 941 $(INSTALL_LIB) $$s "$$t"; \
2115182f 942 test -z "$(STRIP)" || $(STRIP) "$$t"; \
e3be6f0e
FZ
943 done
944endif
7b93fadf 945ifneq ($(HELPERS-y),)
0d659426 946 $(call install-prog,$(HELPERS-y),$(DESTDIR)$(libexecdir))
7b93fadf 947endif
d52c454a
MAL
948ifneq ($(vhost-user-json-y),)
949 $(INSTALL_DIR) "$(DESTDIR)$(qemu_datadir)/vhost-user/"
950 for x in $(vhost-user-json-y); do \
951 $(INSTALL_DATA) $$x "$(DESTDIR)$(qemu_datadir)/vhost-user/"; \
952 done
953endif
62dd1048
DB
954ifdef CONFIG_TRACE_SYSTEMTAP
955 $(INSTALL_PROG) "scripts/qemu-trace-stap" $(DESTDIR)$(bindir)
956endif
77755340 957ifneq ($(BLOBS),)
77755340 958 set -e; for x in $(BLOBS); do \
6aae2a2e 959 $(INSTALL_DATA) $(SRC_PATH)/pc-bios/$$x "$(DESTDIR)$(qemu_datadir)"; \
ad064840 960 done
26ce90fd
LE
961endif
962ifdef INSTALL_BLOBS
963 set -e; for x in $(edk2-decompressed); do \
964 $(INSTALL_DATA) $$x "$(DESTDIR)$(qemu_datadir)"; \
965 done
966endif
967ifneq ($(DESCS),)
968 $(INSTALL_DIR) "$(DESTDIR)$(qemu_datadir)/firmware"
969 set -e; tmpf=$$(mktemp); trap 'rm -f -- "$$tmpf"' EXIT; \
970 for x in $(DESCS); do \
177cd674 971 sed -e 's,@DATADIR@,$(qemu_datadir),' \
26ce90fd
LE
972 "$(SRC_PATH)/pc-bios/descriptors/$$x" > "$$tmpf"; \
973 $(INSTALL_DATA) "$$tmpf" \
974 "$(DESTDIR)$(qemu_datadir)/firmware/$$x"; \
975 done
834574ea 976endif
a8260d38 977 for s in $(ICON_SIZES); do \
6c11dda9 978 mkdir -p "$(DESTDIR)$(qemu_icondir)/hicolor/$${s}/apps"; \
a8260d38 979 $(INSTALL_DATA) $(SRC_PATH)/ui/icons/qemu_$${s}.png \
6c11dda9 980 "$(DESTDIR)$(qemu_icondir)/hicolor/$${s}/apps/qemu.png"; \
a8260d38 981 done; \
6c11dda9 982 mkdir -p "$(DESTDIR)$(qemu_icondir)/hicolor/32x32/apps"; \
a8260d38 983 $(INSTALL_DATA) $(SRC_PATH)/ui/icons/qemu_32x32.bmp \
6c11dda9
SH
984 "$(DESTDIR)$(qemu_icondir)/hicolor/32x32/apps/qemu.bmp"; \
985 mkdir -p "$(DESTDIR)$(qemu_icondir)/hicolor/scalable/apps"; \
a8260d38 986 $(INSTALL_DATA) $(SRC_PATH)/ui/icons/qemu.svg \
6c11dda9
SH
987 "$(DESTDIR)$(qemu_icondir)/hicolor/scalable/apps/qemu.svg"
988 mkdir -p "$(DESTDIR)$(qemu_desktopdir)"
67ea9546 989 $(INSTALL_DATA) $(SRC_PATH)/ui/qemu.desktop \
6c11dda9 990 "$(DESTDIR)$(qemu_desktopdir)/qemu.desktop"
2a6b5372 991ifdef CONFIG_GTK
834574ea 992 $(MAKE) -C po $@
54cb65d8
EC
993endif
994ifeq ($(CONFIG_PLUGIN),y)
995 $(INSTALL_DATA) $(SRC_PATH)/include/qemu/qemu-plugin.h "$(DESTDIR)$(includedir)/qemu-plugin.h"
77755340 996endif
6aae2a2e 997 $(INSTALL_DIR) "$(DESTDIR)$(qemu_datadir)/keymaps"
18be8d77 998 set -e; for x in $(KEYMAPS); do \
6aae2a2e 999 $(INSTALL_DATA) $(SRC_PATH)/pc-bios/keymaps/$$x "$(DESTDIR)$(qemu_datadir)/keymaps"; \
ad064840 1000 done
1412cf58 1001 $(INSTALL_DATA) $(BUILD_DIR)/trace-events-all "$(DESTDIR)$(qemu_datadir)/trace-events-all"
612384d7 1002
ae5fdc81
FZ
1003.PHONY: ctags
1004ctags:
ac99c624 1005 rm -f tags
ae5fdc81
FZ
1006 find "$(SRC_PATH)" -name '*.[hc]' -exec ctags --append {} +
1007
21d4e8e3 1008.PHONY: TAGS
5fafdf24 1009TAGS:
ac99c624 1010 rm -f TAGS
b1999e87 1011 find "$(SRC_PATH)" -name '*.[hc]' -exec etags --append {} +
31e31b8a 1012
6688bc6d 1013cscope:
eaa2ddbb
FZ
1014 rm -f "$(SRC_PATH)"/cscope.*
1015 find "$(SRC_PATH)/" -name "*.[chsS]" -print | sed 's,^\./,,' > "$(SRC_PATH)/cscope.files"
1016 cscope -b -i"$(SRC_PATH)/cscope.files"
6688bc6d 1017
d98bc0b6
GH
1018# opengl shader programs
1019ui/shader/%-vert.h: $(SRC_PATH)/ui/shader/%.vert $(SRC_PATH)/scripts/shaderinclude.pl
1020 @mkdir -p $(dir $@)
1021 $(call quiet-command,\
1022 perl $(SRC_PATH)/scripts/shaderinclude.pl $< > $@,\
0bdb12c7 1023 "VERT","$@")
d98bc0b6
GH
1024
1025ui/shader/%-frag.h: $(SRC_PATH)/ui/shader/%.frag $(SRC_PATH)/scripts/shaderinclude.pl
1026 @mkdir -p $(dir $@)
1027 $(call quiet-command,\
1028 perl $(SRC_PATH)/scripts/shaderinclude.pl $< > $@,\
0bdb12c7 1029 "FRAG","$@")
d98bc0b6 1030
46e19e14 1031ui/shader.o: $(SRC_PATH)/ui/shader.c \
2e1d70b9
GH
1032 ui/shader/texture-blit-vert.h \
1033 ui/shader/texture-blit-flip-vert.h \
1034 ui/shader/texture-blit-frag.h
cd2bc889 1035
3ef693a0 1036# documentation
e8518c92 1037MAKEINFO=makeinfo
d59157ea
PB
1038MAKEINFOINCLUDES= -I docs -I $(<D) -I $(@D)
1039MAKEINFOFLAGS=--no-split --number-sections $(MAKEINFOINCLUDES)
e8338fdb 1040TEXI2PODFLAGS=$(MAKEINFOINCLUDES) -DVERSION="$(VERSION)" -DCONFDIR="$(qemu_confdir)"
d59157ea 1041TEXI2PDFFLAGS=$(if $(V),,--quiet) -I $(SRC_PATH) $(MAKEINFOINCLUDES)
56e8bdd4 1042
e8338fdb
MAL
1043docs/version.texi: $(SRC_PATH)/VERSION config-host.mak
1044 $(call quiet-command,(\
1045 echo "@set VERSION $(VERSION)" && \
1046 echo "@set CONFDIR $(qemu_confdir)" \
1047 )> $@,"GEN","$@")
fea346f5 1048
44cb280d 1049%.html: %.texi docs/version.texi
e9ee06bd
MAL
1050 $(call quiet-command,LC_ALL=C $(MAKEINFO) $(MAKEINFOFLAGS) --no-headers \
1051 --html $< -o $@,"GEN","$@")
3ef693a0 1052
44cb280d 1053%.info: %.texi docs/version.texi
e9ee06bd 1054 $(call quiet-command,$(MAKEINFO) $(MAKEINFOFLAGS) $< -o $@,"GEN","$@")
f3548328 1055
44cb280d 1056%.txt: %.texi docs/version.texi
f8bab10b
MAL
1057 $(call quiet-command,LC_ALL=C $(MAKEINFO) $(MAKEINFOFLAGS) --no-headers \
1058 --plaintext $< -o $@,"GEN","$@")
1059
44cb280d 1060%.pdf: %.texi docs/version.texi
d59157ea 1061 $(call quiet-command,texi2pdf $(TEXI2PDFFLAGS) $< -o $@,"GEN","$@")
bd7f9747 1062
5f71eac0
PM
1063# Sphinx builds all its documentation at once in one invocation
1064# and handles "don't rebuild things unless necessary" itself.
1065# The '.doctrees' files are cached information to speed this up.
1066.PHONY: sphinxdocs
0928523a
PM
1067sphinxdocs: $(MANUAL_BUILDDIR)/devel/index.html \
1068 $(MANUAL_BUILDDIR)/interop/index.html \
1069 $(MANUAL_BUILDDIR)/specs/index.html \
65c3542b 1070 $(MANUAL_BUILDDIR)/system/index.html \
09147930
PB
1071 $(MANUAL_BUILDDIR)/tools/index.html \
1072 $(MANUAL_BUILDDIR)/user/index.html
5f71eac0
PM
1073
1074# Canned command to build a single manual
27a296fc 1075# Arguments: $1 = manual name, $2 = Sphinx builder ('html' or 'man')
6bda415c
EH
1076# Note the use of different doctree for each (manual, builder) tuple;
1077# this works around Sphinx not handling parallel invocation on
1078# a single doctree: https://github.com/sphinx-doc/sphinx/issues/2946
2eb054c2 1079build-manual = $(call quiet-command,CONFDIR="$(qemu_confdir)" $(SPHINX_BUILD) $(if $(V),,-q) -W -b $2 -D version=$(VERSION) -D release="$(FULL_VERSION)" -d .doctrees/$1-$2 $(SRC_PATH)/docs/$1 $(MANUAL_BUILDDIR)/$1 ,"SPHINX","$(MANUAL_BUILDDIR)/$1")
5f71eac0 1080# We assume all RST files in the manual's directory are used in it
814e068f 1081manual-deps = $(wildcard $(SRC_PATH)/docs/$1/*.rst $(SRC_PATH)/docs/$1/*/*.rst) \
de1572ca 1082 $(SRC_PATH)/docs/defs.rst.inc \
9165d323
PM
1083 $(SRC_PATH)/docs/$1/conf.py $(SRC_PATH)/docs/conf.py \
1084 $(SRC_PATH)/docs/sphinx/*.py
e0f3728d
PM
1085# Macro to write out the rule and dependencies for building manpages
1086# Usage: $(call define-manpage-rule,manualname,manpage1 manpage2...[,extradeps])
1087# 'extradeps' is optional, and specifies extra files (eg .hx files) that
1088# the manual page depends on.
1089define define-manpage-rule
1090$(call atomic,$(foreach manpage,$2,$(MANUAL_BUILDDIR)/$1/$(manpage)),$(call manual-deps,$1) $3)
1091 $(call build-manual,$1,man)
1092endef
5f71eac0 1093
1290e671 1094$(MANUAL_BUILDDIR)/devel/index.html: $(call manual-deps,devel)
27a296fc 1095 $(call build-manual,devel,html)
5f71eac0 1096
a08b4a9f 1097$(MANUAL_BUILDDIR)/interop/index.html: $(call manual-deps,interop)
27a296fc 1098 $(call build-manual,interop,html)
5f71eac0 1099
0783a732 1100$(MANUAL_BUILDDIR)/specs/index.html: $(call manual-deps,specs)
27a296fc
PM
1101 $(call build-manual,specs,html)
1102
09ce5f2d 1103$(MANUAL_BUILDDIR)/system/index.html: $(call manual-deps,system) $(SRC_PATH)/hmp-commands.hx $(SRC_PATH)/hmp-commands-info.hx $(SRC_PATH)/qemu-options.hx
0928523a
PM
1104 $(call build-manual,system,html)
1105
a08b4a9f 1106$(MANUAL_BUILDDIR)/tools/index.html: $(call manual-deps,tools) $(SRC_PATH)/qemu-img-cmds.hx $(SRC_PATH)/docs/qemu-option-trace.rst.inc
65c3542b
PM
1107 $(call build-manual,tools,html)
1108
09147930
PB
1109$(MANUAL_BUILDDIR)/user/index.html: $(call manual-deps,user)
1110 $(call build-manual,user,html)
1111
a08b4a9f 1112$(call define-manpage-rule,interop,qemu-ga.8)
87c0868f 1113
d06118bf 1114$(call define-manpage-rule,system,qemu.1 qemu-block-drivers.7 qemu-cpu-models.7)
acab923d 1115
a08b4a9f
PM
1116$(call define-manpage-rule,tools,\
1117 qemu-img.1 qemu-nbd.8 qemu-trace-stap.1\
1118 virtiofsd.1 virtfs-proxy-helper.1,\
1119 $(SRC_PATH)/qemu-img-cmds.hx $(SRC_PATH)/docs/qemu-option-trace.rst.inc)
1120
22108f33 1121$(MANUAL_BUILDDIR)/index.html: $(SRC_PATH)/docs/index.html.in qemu-version.h
d83bbeda 1122 @mkdir -p "$(MANUAL_BUILDDIR)"
22108f33
SH
1123 $(call quiet-command, sed "s|@@VERSION@@|${VERSION}|g" $< >$@, \
1124 "GEN","$@")
1125
eb815e24 1126docs/interop/qemu-qmp-qapi.texi: qapi/qapi-doc.texi
fb0bc835 1127 @cp -p $< $@
4afeeb57 1128
fb0bc835
MA
1129docs/interop/qemu-ga-qapi.texi: qga/qapi-generated/qga-qapi-doc.texi
1130 @cp -p $< $@
56e8bdd4 1131
5b1d0e92
PM
1132html: docs/interop/qemu-qmp-ref.html docs/interop/qemu-ga-ref.html sphinxdocs
1133info: docs/interop/qemu-qmp-ref.info docs/interop/qemu-ga-ref.info
1134pdf: docs/interop/qemu-qmp-ref.pdf docs/interop/qemu-ga-ref.pdf
1135txt: docs/interop/qemu-qmp-ref.txt docs/interop/qemu-ga-ref.txt
818220f5 1136
d59157ea
PB
1137docs/interop/qemu-ga-ref.dvi docs/interop/qemu-ga-ref.html \
1138 docs/interop/qemu-ga-ref.info docs/interop/qemu-ga-ref.pdf \
1139 docs/interop/qemu-ga-ref.txt docs/interop/qemu-ga-ref.7: \
1140 docs/interop/qemu-ga-ref.texi docs/interop/qemu-ga-qapi.texi
56e8bdd4 1141
d59157ea
PB
1142docs/interop/qemu-qmp-ref.dvi docs/interop/qemu-qmp-ref.html \
1143 docs/interop/qemu-qmp-ref.info docs/interop/qemu-qmp-ref.pdf \
1144 docs/interop/qemu-qmp-ref.txt docs/interop/qemu-qmp-ref.7: \
1145 docs/interop/qemu-qmp-ref.texi docs/interop/qemu-qmp-qapi.texi
56e8bdd4 1146
ae560cc3
EB
1147$(filter %.1 %.7 %.8,$(DOCS)): scripts/texi2pod.pl
1148
fe8bf5f6
AB
1149# Reports/Analysis
1150
1151%/coverage-report.html:
1152 @mkdir -p $*
1153 $(call quiet-command,\
5eda6e42
AB
1154 gcovr -r $(SRC_PATH) \
1155 $(foreach t, $(TARGET_DIRS), --object-directory $(BUILD_DIR)/$(t)) \
1156 --object-directory $(BUILD_DIR) \
337f2311 1157 -p --html --html-details -o $@, \
fe8bf5f6
AB
1158 "GEN", "coverage-report.html")
1159
1160.PHONY: coverage-report
1161coverage-report: $(CURDIR)/reports/coverage/coverage-report.html
56e8bdd4 1162
f53ec699
SW
1163ifdef CONFIG_WIN32
1164
1165INSTALLER = qemu-setup-$(VERSION)$(EXESUF)
1166
1167nsisflags = -V2 -NOCD
1168
1169ifneq ($(wildcard $(SRC_PATH)/dll),)
1170ifeq ($(ARCH),x86_64)
1171# 64 bit executables
1172DLL_PATH = $(SRC_PATH)/dll/w64
1173nsisflags += -DW64
1174else
1175# 32 bit executables
1176DLL_PATH = $(SRC_PATH)/dll/w32
1177endif
1178endif
1179
1180.PHONY: installer
1181installer: $(INSTALLER)
1182
1183INSTDIR=/tmp/qemu-nsis
1184
f84f9f75 1185$(INSTALLER): install-doc $(SRC_PATH)/qemu.nsi
fb8597bb 1186 $(MAKE) install prefix=${INSTDIR}
f53ec699
SW
1187ifdef SIGNCODE
1188 (cd ${INSTDIR}; \
1189 for i in *.exe; do \
1190 $(SIGNCODE) $${i}; \
1191 done \
1192 )
1193endif # SIGNCODE
1194 (cd ${INSTDIR}; \
1195 for i in qemu-system-*.exe; do \
1196 arch=$${i%.exe}; \
1197 arch=$${arch#qemu-system-}; \
1198 echo Section \"$$arch\" Section_$$arch; \
1199 echo SetOutPath \"\$$INSTDIR\"; \
1200 echo File \"\$${BINDIR}\\$$i\"; \
1201 echo SectionEnd; \
1202 done \
1203 ) >${INSTDIR}/system-emulations.nsh
1204 makensis $(nsisflags) \
1205 $(if $(BUILD_DOCS),-DCONFIG_DOCUMENTATION="y") \
1206 $(if $(CONFIG_GTK),-DCONFIG_GTK="y") \
1207 -DBINDIR="${INSTDIR}" \
1208 $(if $(DLL_PATH),-DDLLDIR="$(DLL_PATH)") \
1209 -DSRCDIR="$(SRC_PATH)" \
1210 -DOUTFILE="$(INSTALLER)" \
805d8a67 1211 -DDISPLAYVERSION="$(VERSION)" \
f53ec699
SW
1212 $(SRC_PATH)/qemu.nsi
1213 rm -r ${INSTDIR}
1214ifdef SIGNCODE
1215 $(SIGNCODE) $(INSTALLER)
1216endif # SIGNCODE
1217endif # CONFIG_WIN
1218
cb5fc67d
AL
1219# Add a dependency on the generated files, so that they are always
1220# rebuilt before other object files
428952cf 1221ifneq ($(wildcard config-host.mak),)
eaa2ddbb 1222ifneq ($(filter-out $(UNCHECKED_GOALS),$(MAKECMDGOALS)),$(if $(MAKECMDGOALS),,fail))
3dff199c 1223Makefile: $(generated-files-y)
7748b8cb 1224endif
428952cf 1225endif
cb5fc67d 1226
0ab8ed18
DB
1227.SECONDARY: $(TRACE_HEADERS) $(TRACE_HEADERS:%=%-timestamp) \
1228 $(TRACE_SOURCES) $(TRACE_SOURCES:%=%-timestamp) \
1229 $(TRACE_DTRACE) $(TRACE_DTRACE:%=%-timestamp)
1230
4fb240a4 1231# Include automatically generated dependency files
1435ddb8
PB
1232# Dependencies in Makefile.objs files come from our recursive subdir rules
1233-include $(wildcard *.d tests/*.d)
324027c2
FZ
1234
1235include $(SRC_PATH)/tests/docker/Makefile.include
b1fb9a63 1236include $(SRC_PATH)/tests/vm/Makefile.include
0d8e065f 1237
c355de59
PMD
1238print-help-run = printf " %-30s - %s\\n" "$1" "$2"
1239print-help = $(quiet-@)$(call print-help-run,$1,$2)
1240
0d8e065f
MAL
1241.PHONY: help
1242help:
1243 @echo 'Generic targets:'
c355de59 1244 $(call print-help,all,Build all)
0decdfe2 1245ifdef CONFIG_MODULES
c355de59 1246 $(call print-help,modules,Build all modules)
0decdfe2 1247endif
c355de59
PMD
1248 $(call print-help,dir/file.o,Build specified target only)
1249 $(call print-help,install,Install QEMU, documentation and tools)
1250 $(call print-help,ctags/TAGS,Generate tags file for editors)
1251 $(call print-help,cscope,Generate cscope index)
0d8e065f 1252 @echo ''
2b1f35b9 1253 @$(if $(TARGET_DIRS), \
0d8e065f 1254 echo 'Architecture specific targets:'; \
2b1f35b9 1255 $(foreach t, $(TARGET_DIRS), \
c355de59 1256 $(call print-help-run,$(t)/all,Build for $(t));) \
0d8e065f 1257 echo '')
81ed0a57
PMD
1258 @$(if $(TOOLS), \
1259 echo 'Tools targets:'; \
1260 $(foreach t, $(TOOLS), \
1261 $(call print-help-run,$(t),Build $(shell basename $(t)) tool);) \
0d8e065f
MAL
1262 echo '')
1263 @echo 'Cleaning targets:'
c355de59 1264 $(call print-help,clean,Remove most generated files but keep the config)
990e6a27 1265ifdef CONFIG_GCOV
c355de59 1266 $(call print-help,clean-coverage,Remove coverage files)
990e6a27 1267endif
c355de59
PMD
1268 $(call print-help,distclean,Remove all generated files)
1269 $(call print-help,dist,Build a distributable tarball)
0d8e065f
MAL
1270 @echo ''
1271 @echo 'Test targets:'
c355de59
PMD
1272 $(call print-help,check,Run all tests (check-help for details))
1273 $(call print-help,docker,Help about targets running tests inside containers)
1274 $(call print-help,vm-help,Help about targets running tests inside VM)
0d8e065f
MAL
1275 @echo ''
1276 @echo 'Documentation targets:'
c355de59 1277 $(call print-help,html info pdf txt,Build documentation in specified format)
fe8bf5f6 1278ifdef CONFIG_GCOV
c355de59 1279 $(call print-help,coverage-report,Create code coverage report)
fe8bf5f6 1280endif
0d8e065f
MAL
1281 @echo ''
1282ifdef CONFIG_WIN32
1283 @echo 'Windows targets:'
c355de59 1284 $(call print-help,installer,Build NSIS-based installer for QEMU)
0d8e065f 1285ifdef QEMU_GA_MSI_ENABLED
c355de59 1286 $(call print-help,msi,Build MSI-based installer for qemu-ga)
0d8e065f
MAL
1287endif
1288 @echo ''
1289endif
c355de59
PMD
1290 $(call print-help,$(MAKE) [targets],(quiet build, default))
1291 $(call print-help,$(MAKE) V=1 [targets],(verbose build))