Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging
[qemu.git] / Makefile
1 # Makefile for QEMU.
2
3 ifneq ($(words $(subst :, ,$(CURDIR))), 1)
4 $(error main directory cannot contain spaces nor colons)
5 endif
6
7 # Always point to the root of the build tree (needs GNU make).
8 BUILD_DIR=$(CURDIR)
9
10 # Before including a proper config-host.mak, assume we are in the source tree
11 SRC_PATH=.
12
13 UNCHECKED_GOALS := %clean TAGS cscope ctags dist \
14 html info pdf txt \
15 help check-help print-% \
16 docker docker-% vm-help vm-test vm-build-%
17
18 print-%:
19 @echo '$*=$($*)'
20
21 # All following code might depend on configuration variables
22 ifneq ($(wildcard config-host.mak),)
23 # Put the all: rule here so that config-host.mak can contain dependencies.
24 all:
25 include config-host.mak
26
27 git-submodule-update:
28
29 .PHONY: git-submodule-update
30
31 git_module_status := $(shell \
32 cd '$(SRC_PATH)' && \
33 GIT="$(GIT)" ./scripts/git-submodule.sh status $(GIT_SUBMODULES); \
34 echo $$?; \
35 )
36
37 ifeq (1,$(git_module_status))
38 ifeq (no,$(GIT_UPDATE))
39 git-submodule-update:
40 $(call quiet-command, \
41 echo && \
42 echo "GIT submodule checkout is out of date. Please run" && \
43 echo " scripts/git-submodule.sh update $(GIT_SUBMODULES)" && \
44 echo "from the source directory checkout $(SRC_PATH)" && \
45 echo && \
46 exit 1)
47 else
48 git-submodule-update:
49 $(call quiet-command, \
50 (cd $(SRC_PATH) && GIT="$(GIT)" ./scripts/git-submodule.sh update $(GIT_SUBMODULES)), \
51 "GIT","$(GIT_SUBMODULES)")
52 endif
53 endif
54
55 .git-submodule-status: git-submodule-update config-host.mak
56
57 # Check that we're not trying to do an out-of-tree build from
58 # a tree that's been used for an in-tree build.
59 ifneq ($(realpath $(SRC_PATH)),$(realpath .))
60 ifneq ($(wildcard $(SRC_PATH)/config-host.mak),)
61 $(error This is an out of tree build but your source tree ($(SRC_PATH)) \
62 seems to have been used for an in-tree build. You can fix this by running \
63 "$(MAKE) distclean && rm -rf *-linux-user *-softmmu" in your source tree)
64 endif
65 endif
66
67 CONFIG_SOFTMMU := $(if $(filter %-softmmu,$(TARGET_DIRS)),y)
68 CONFIG_USER_ONLY := $(if $(filter %-user,$(TARGET_DIRS)),y)
69 CONFIG_XEN := $(CONFIG_XEN_BACKEND)
70 CONFIG_ALL=y
71 -include config-all-devices.mak
72 -include config-all-disas.mak
73
74 config-host.mak: $(SRC_PATH)/configure $(SRC_PATH)/pc-bios $(SRC_PATH)/VERSION
75 @echo $@ is out-of-date, running configure
76 @./config.status
77
78 # Force configure to re-run if the API symbols are updated
79 ifeq ($(CONFIG_PLUGIN),y)
80 config-host.mak: $(SRC_PATH)/plugins/qemu-plugins.symbols
81 endif
82
83 else
84 config-host.mak:
85 ifneq ($(filter-out $(UNCHECKED_GOALS),$(MAKECMDGOALS)),$(if $(MAKECMDGOALS),,fail))
86 @echo "Please call configure before running make!"
87 @exit 1
88 endif
89 endif
90
91 include $(SRC_PATH)/rules.mak
92
93 # lor is defined in rules.mak
94 CONFIG_BLOCK := $(call lor,$(CONFIG_SOFTMMU),$(CONFIG_TOOLS))
95
96 # Create QEMU_PKGVERSION and FULL_VERSION strings
97 # If PKGVERSION is set, use that; otherwise get version and -dirty status from git
98 QEMU_PKGVERSION := $(if $(PKGVERSION),$(PKGVERSION),$(shell \
99 cd $(SRC_PATH); \
100 if test -e .git; then \
101 git describe --match 'v*' 2>/dev/null | tr -d '\n'; \
102 if ! git diff-index --quiet HEAD &>/dev/null; then \
103 echo "-dirty"; \
104 fi; \
105 fi))
106
107 # Either "version (pkgversion)", or just "version" if pkgversion not set
108 FULL_VERSION := $(if $(QEMU_PKGVERSION),$(VERSION) ($(QEMU_PKGVERSION)),$(VERSION))
109
110 generated-files-y = qemu-version.h config-host.h qemu-options.def
111
112 GENERATED_QAPI_FILES = qapi/qapi-builtin-types.h qapi/qapi-builtin-types.c
113 GENERATED_QAPI_FILES += qapi/qapi-types.h qapi/qapi-types.c
114 GENERATED_QAPI_FILES += $(QAPI_MODULES:%=qapi/qapi-types-%.h)
115 GENERATED_QAPI_FILES += $(QAPI_MODULES:%=qapi/qapi-types-%.c)
116 GENERATED_QAPI_FILES += qapi/qapi-builtin-visit.h qapi/qapi-builtin-visit.c
117 GENERATED_QAPI_FILES += qapi/qapi-visit.h qapi/qapi-visit.c
118 GENERATED_QAPI_FILES += $(QAPI_MODULES:%=qapi/qapi-visit-%.h)
119 GENERATED_QAPI_FILES += $(QAPI_MODULES:%=qapi/qapi-visit-%.c)
120 GENERATED_QAPI_FILES += qapi/qapi-commands.h qapi/qapi-commands.c
121 GENERATED_QAPI_FILES += $(QAPI_MODULES:%=qapi/qapi-commands-%.h)
122 GENERATED_QAPI_FILES += $(QAPI_MODULES:%=qapi/qapi-commands-%.c)
123 GENERATED_QAPI_FILES += qapi/qapi-emit-events.h qapi/qapi-emit-events.c
124 GENERATED_QAPI_FILES += qapi/qapi-events.h qapi/qapi-events.c
125 GENERATED_QAPI_FILES += $(QAPI_MODULES:%=qapi/qapi-events-%.h)
126 GENERATED_QAPI_FILES += $(QAPI_MODULES:%=qapi/qapi-events-%.c)
127 GENERATED_QAPI_FILES += qapi/qapi-introspect.c qapi/qapi-introspect.h
128 GENERATED_QAPI_FILES += qapi/qapi-doc.texi
129
130 generated-files-y += $(GENERATED_QAPI_FILES)
131
132 generated-files-y += trace/generated-tcg-tracers.h
133
134 generated-files-y += trace/generated-helpers-wrappers.h
135 generated-files-y += trace/generated-helpers.h
136 generated-files-y += trace/generated-helpers.c
137
138 generated-files-$(CONFIG_TRACE_UST) += trace-ust-all.h
139 generated-files-$(CONFIG_TRACE_UST) += trace-ust-all.c
140
141 generated-files-y += module_block.h
142
143 TRACE_HEADERS = trace-root.h $(trace-events-subdirs:%=%/trace.h)
144 TRACE_SOURCES = trace-root.c $(trace-events-subdirs:%=%/trace.c)
145 TRACE_DTRACE =
146 ifdef CONFIG_TRACE_DTRACE
147 TRACE_HEADERS += trace-dtrace-root.h $(trace-events-subdirs:%=%/trace-dtrace.h)
148 TRACE_DTRACE += trace-dtrace-root.dtrace $(trace-events-subdirs:%=%/trace-dtrace.dtrace)
149 endif
150 ifdef CONFIG_TRACE_UST
151 TRACE_HEADERS += trace-ust-root.h $(trace-events-subdirs:%=%/trace-ust.h)
152 endif
153
154 generated-files-y += $(TRACE_HEADERS)
155 generated-files-y += $(TRACE_SOURCES)
156 generated-files-y += $(BUILD_DIR)/trace-events-all
157 generated-files-y += .git-submodule-status
158
159 trace-group-name = $(shell dirname $1 | sed -e 's/[^a-zA-Z0-9]/_/g')
160
161 tracetool-y = $(SRC_PATH)/scripts/tracetool.py
162 tracetool-y += $(shell find $(SRC_PATH)/scripts/tracetool -name "*.py")
163
164 %/trace.h: %/trace.h-timestamp
165 @cmp $< $@ >/dev/null 2>&1 || cp $< $@
166 %/trace.h-timestamp: $(SRC_PATH)/%/trace-events $(tracetool-y) $(BUILD_DIR)/config-host.mak
167 $(call quiet-command,$(TRACETOOL) \
168 --group=$(call trace-group-name,$@) \
169 --format=h \
170 --backends=$(TRACE_BACKENDS) \
171 $< > $@,"GEN","$(@:%-timestamp=%)")
172
173 %/trace.c: %/trace.c-timestamp
174 @cmp $< $@ >/dev/null 2>&1 || cp $< $@
175 %/trace.c-timestamp: $(SRC_PATH)/%/trace-events $(tracetool-y) $(BUILD_DIR)/config-host.mak
176 $(call quiet-command,$(TRACETOOL) \
177 --group=$(call trace-group-name,$@) \
178 --format=c \
179 --backends=$(TRACE_BACKENDS) \
180 $< > $@,"GEN","$(@:%-timestamp=%)")
181
182 %/trace-ust.h: %/trace-ust.h-timestamp
183 @cmp $< $@ >/dev/null 2>&1 || cp $< $@
184 %/trace-ust.h-timestamp: $(SRC_PATH)/%/trace-events $(tracetool-y) $(BUILD_DIR)/config-host.mak
185 $(call quiet-command,$(TRACETOOL) \
186 --group=$(call trace-group-name,$@) \
187 --format=ust-events-h \
188 --backends=$(TRACE_BACKENDS) \
189 $< > $@,"GEN","$(@:%-timestamp=%)")
190
191 %/trace-dtrace.dtrace: %/trace-dtrace.dtrace-timestamp
192 @cmp $< $@ >/dev/null 2>&1 || cp $< $@
193 %/trace-dtrace.dtrace-timestamp: $(SRC_PATH)/%/trace-events $(BUILD_DIR)/config-host.mak $(tracetool-y)
194 $(call quiet-command,$(TRACETOOL) \
195 --group=$(call trace-group-name,$@) \
196 --format=d \
197 --backends=$(TRACE_BACKENDS) \
198 $< > $@,"GEN","$(@:%-timestamp=%)")
199
200 %/trace-dtrace.h: %/trace-dtrace.dtrace $(tracetool-y)
201 $(call quiet-command,dtrace -o $@ -h -s $<, "GEN","$@")
202
203 %/trace-dtrace.o: %/trace-dtrace.dtrace $(tracetool-y)
204
205
206 trace-root.h: trace-root.h-timestamp
207 @cmp $< $@ >/dev/null 2>&1 || cp $< $@
208 trace-root.h-timestamp: $(SRC_PATH)/trace-events $(tracetool-y) $(BUILD_DIR)/config-host.mak
209 $(call quiet-command,$(TRACETOOL) \
210 --group=root \
211 --format=h \
212 --backends=$(TRACE_BACKENDS) \
213 $< > $@,"GEN","$(@:%-timestamp=%)")
214
215 trace-root.c: trace-root.c-timestamp
216 @cmp $< $@ >/dev/null 2>&1 || cp $< $@
217 trace-root.c-timestamp: $(SRC_PATH)/trace-events $(tracetool-y) $(BUILD_DIR)/config-host.mak
218 $(call quiet-command,$(TRACETOOL) \
219 --group=root \
220 --format=c \
221 --backends=$(TRACE_BACKENDS) \
222 $< > $@,"GEN","$(@:%-timestamp=%)")
223
224 trace-ust-root.h: trace-ust-root.h-timestamp
225 @cmp $< $@ >/dev/null 2>&1 || cp $< $@
226 trace-ust-root.h-timestamp: $(SRC_PATH)/trace-events $(tracetool-y) $(BUILD_DIR)/config-host.mak
227 $(call quiet-command,$(TRACETOOL) \
228 --group=root \
229 --format=ust-events-h \
230 --backends=$(TRACE_BACKENDS) \
231 $< > $@,"GEN","$(@:%-timestamp=%)")
232
233 trace-ust-all.h: trace-ust-all.h-timestamp
234 @cmp $< $@ >/dev/null 2>&1 || cp $< $@
235 trace-ust-all.h-timestamp: $(trace-events-files) $(tracetool-y) $(BUILD_DIR)/config-host.mak
236 $(call quiet-command,$(TRACETOOL) \
237 --group=all \
238 --format=ust-events-h \
239 --backends=$(TRACE_BACKENDS) \
240 $(trace-events-files) > $@,"GEN","$(@:%-timestamp=%)")
241
242 trace-ust-all.c: trace-ust-all.c-timestamp
243 @cmp $< $@ >/dev/null 2>&1 || cp $< $@
244 trace-ust-all.c-timestamp: $(trace-events-files) $(tracetool-y) $(BUILD_DIR)/config-host.mak
245 $(call quiet-command,$(TRACETOOL) \
246 --group=all \
247 --format=ust-events-c \
248 --backends=$(TRACE_BACKENDS) \
249 $(trace-events-files) > $@,"GEN","$(@:%-timestamp=%)")
250
251 trace-dtrace-root.dtrace: trace-dtrace-root.dtrace-timestamp
252 @cmp $< $@ >/dev/null 2>&1 || cp $< $@
253 trace-dtrace-root.dtrace-timestamp: $(SRC_PATH)/trace-events $(BUILD_DIR)/config-host.mak $(tracetool-y)
254 $(call quiet-command,$(TRACETOOL) \
255 --group=root \
256 --format=d \
257 --backends=$(TRACE_BACKENDS) \
258 $< > $@,"GEN","$(@:%-timestamp=%)")
259
260 trace-dtrace-root.h: trace-dtrace-root.dtrace
261 $(call quiet-command,dtrace -o $@ -h -s $<, "GEN","$@")
262
263 trace-dtrace-root.o: trace-dtrace-root.dtrace
264
265 KEYCODEMAP_GEN = $(SRC_PATH)/ui/keycodemapdb/tools/keymap-gen
266 KEYCODEMAP_CSV = $(SRC_PATH)/ui/keycodemapdb/data/keymaps.csv
267
268 KEYCODEMAP_FILES = \
269 ui/input-keymap-atset1-to-qcode.c \
270 ui/input-keymap-linux-to-qcode.c \
271 ui/input-keymap-qcode-to-atset1.c \
272 ui/input-keymap-qcode-to-atset2.c \
273 ui/input-keymap-qcode-to-atset3.c \
274 ui/input-keymap-qcode-to-linux.c \
275 ui/input-keymap-qcode-to-qnum.c \
276 ui/input-keymap-qcode-to-sun.c \
277 ui/input-keymap-qnum-to-qcode.c \
278 ui/input-keymap-usb-to-qcode.c \
279 ui/input-keymap-win32-to-qcode.c \
280 ui/input-keymap-x11-to-qcode.c \
281 ui/input-keymap-xorgevdev-to-qcode.c \
282 ui/input-keymap-xorgkbd-to-qcode.c \
283 ui/input-keymap-xorgxquartz-to-qcode.c \
284 ui/input-keymap-xorgxwin-to-qcode.c \
285 ui/input-keymap-osx-to-qcode.c \
286 $(NULL)
287
288 generated-files-$(CONFIG_SOFTMMU) += $(KEYCODEMAP_FILES)
289
290 ui/input-keymap-%.c: $(KEYCODEMAP_GEN) $(KEYCODEMAP_CSV) $(SRC_PATH)/ui/Makefile.objs
291 $(call quiet-command,\
292 stem=$* && src=$${stem%-to-*} dst=$${stem#*-to-} && \
293 test -e $(KEYCODEMAP_GEN) && \
294 $(PYTHON) $(KEYCODEMAP_GEN) \
295 --lang glib2 \
296 --varname qemu_input_map_$${src}_to_$${dst} \
297 code-map $(KEYCODEMAP_CSV) $${src} $${dst} \
298 > $@ || rm -f $@, "GEN", "$@")
299
300 $(KEYCODEMAP_GEN): .git-submodule-status
301 $(KEYCODEMAP_CSV): .git-submodule-status
302
303 edk2-decompressed = $(basename $(wildcard pc-bios/edk2-*.fd.bz2))
304 pc-bios/edk2-%.fd: pc-bios/edk2-%.fd.bz2
305 $(call quiet-command,bzip2 -d -c $< > $@,"BUNZIP2",$<)
306
307 # Don't try to regenerate Makefile or configure
308 # We don't generate any of them
309 Makefile: ;
310 configure: ;
311
312 .PHONY: all clean cscope distclean html info install install-doc \
313 pdf txt recurse-all dist msi FORCE
314
315 $(call set-vpath, $(SRC_PATH))
316
317 LIBS+=-lz $(LIBS_TOOLS)
318
319 vhost-user-json-y =
320 HELPERS-y =
321
322 HELPERS-$(call land,$(CONFIG_SOFTMMU),$(CONFIG_LINUX)) = qemu-bridge-helper$(EXESUF)
323
324 ifdef CONFIG_LINUX
325 ifdef CONFIG_VIRGL
326 ifdef CONFIG_GBM
327 HELPERS-y += vhost-user-gpu$(EXESUF)
328 vhost-user-json-y += contrib/vhost-user-gpu/50-qemu-gpu.json
329 endif
330 endif
331 endif
332
333 # Sphinx does not allow building manuals into the same directory as
334 # the source files, so if we're doing an in-tree QEMU build we must
335 # build the manuals into a subdirectory (and then install them from
336 # there for 'make install'). For an out-of-tree build we can just
337 # use the docs/ subdirectory in the build tree as normal.
338 ifeq ($(realpath $(SRC_PATH)),$(realpath .))
339 MANUAL_BUILDDIR := docs/built
340 else
341 MANUAL_BUILDDIR := docs
342 endif
343
344 ifdef BUILD_DOCS
345 DOCS=qemu-doc.html qemu-doc.txt qemu.1 qemu-img.1 qemu-nbd.8 $(MANUAL_BUILDDIR)/interop/qemu-ga.8
346 DOCS+=docs/interop/qemu-qmp-ref.html docs/interop/qemu-qmp-ref.txt docs/interop/qemu-qmp-ref.7
347 DOCS+=docs/interop/qemu-ga-ref.html docs/interop/qemu-ga-ref.txt docs/interop/qemu-ga-ref.7
348 DOCS+=docs/qemu-block-drivers.7
349 DOCS+=docs/qemu-cpu-models.7
350 ifdef CONFIG_VIRTFS
351 DOCS+=fsdev/virtfs-proxy-helper.1
352 endif
353 ifdef CONFIG_TRACE_SYSTEMTAP
354 DOCS+=scripts/qemu-trace-stap.1
355 endif
356 else
357 DOCS=
358 endif
359
360 SUBDIR_MAKEFLAGS=$(if $(V),,--no-print-directory --quiet) BUILD_DIR=$(BUILD_DIR)
361 SUBDIR_DEVICES_MAK=$(patsubst %, %/config-devices.mak, $(filter %-softmmu, $(TARGET_DIRS)))
362 SUBDIR_DEVICES_MAK_DEP=$(patsubst %, %.d, $(SUBDIR_DEVICES_MAK))
363
364 ifeq ($(SUBDIR_DEVICES_MAK),)
365 config-all-devices.mak: config-host.mak
366 $(call quiet-command,echo '# no devices' > $@,"GEN","$@")
367 else
368 config-all-devices.mak: $(SUBDIR_DEVICES_MAK) config-host.mak
369 $(call quiet-command, sed -n \
370 's|^\([^=]*\)=\(.*\)$$|\1:=$$(findstring y,$$(\1)\2)|p' \
371 $(SUBDIR_DEVICES_MAK) | sort -u > $@, \
372 "GEN","$@")
373 endif
374
375 -include $(SUBDIR_DEVICES_MAK_DEP)
376
377 # This has to be kept in sync with Kconfig.host.
378 MINIKCONF_ARGS = \
379 $(CONFIG_MINIKCONF_MODE) \
380 $@ $*/config-devices.mak.d $< $(MINIKCONF_INPUTS) \
381 CONFIG_KVM=$(CONFIG_KVM) \
382 CONFIG_SPICE=$(CONFIG_SPICE) \
383 CONFIG_IVSHMEM=$(CONFIG_IVSHMEM) \
384 CONFIG_TPM=$(CONFIG_TPM) \
385 CONFIG_XEN=$(CONFIG_XEN) \
386 CONFIG_OPENGL=$(CONFIG_OPENGL) \
387 CONFIG_X11=$(CONFIG_X11) \
388 CONFIG_VHOST_USER=$(CONFIG_VHOST_USER) \
389 CONFIG_VIRTFS=$(CONFIG_VIRTFS) \
390 CONFIG_LINUX=$(CONFIG_LINUX) \
391 CONFIG_PVRDMA=$(CONFIG_PVRDMA)
392
393 MINIKCONF_INPUTS = $(SRC_PATH)/Kconfig.host $(SRC_PATH)/hw/Kconfig \
394 $(wildcard $(SRC_PATH)/hw/*/Kconfig)
395 MINIKCONF = $(PYTHON) $(SRC_PATH)/scripts/minikconf.py \
396
397 $(SUBDIR_DEVICES_MAK): %/config-devices.mak: default-configs/%.mak $(MINIKCONF_INPUTS) $(BUILD_DIR)/config-host.mak
398 $(call quiet-command, $(MINIKCONF) $(MINIKCONF_ARGS) > $@.tmp, "GEN", "$@.tmp")
399 $(call quiet-command, if test -f $@; then \
400 if cmp -s $@.old $@; then \
401 mv $@.tmp $@; \
402 cp -p $@ $@.old; \
403 else \
404 if test -f $@.old; then \
405 echo "WARNING: $@ (user modified) out of date.";\
406 else \
407 echo "WARNING: $@ out of date.";\
408 fi; \
409 echo "Run \"$(MAKE) defconfig\" to regenerate."; \
410 rm $@.tmp; \
411 fi; \
412 else \
413 mv $@.tmp $@; \
414 cp -p $@ $@.old; \
415 fi,"GEN","$@");
416
417 defconfig:
418 rm -f config-all-devices.mak $(SUBDIR_DEVICES_MAK)
419
420 ifneq ($(wildcard config-host.mak),)
421 include $(SRC_PATH)/Makefile.objs
422 endif
423
424 dummy := $(call unnest-vars,, \
425 stub-obj-y \
426 authz-obj-y \
427 chardev-obj-y \
428 util-obj-y \
429 qga-obj-y \
430 elf2dmp-obj-y \
431 ivshmem-client-obj-y \
432 ivshmem-server-obj-y \
433 rdmacm-mux-obj-y \
434 libvhost-user-obj-y \
435 vhost-user-scsi-obj-y \
436 vhost-user-blk-obj-y \
437 vhost-user-input-obj-y \
438 vhost-user-gpu-obj-y \
439 qga-vss-dll-obj-y \
440 block-obj-y \
441 block-obj-m \
442 crypto-obj-y \
443 crypto-user-obj-y \
444 qom-obj-y \
445 io-obj-y \
446 common-obj-y \
447 common-obj-m \
448 ui-obj-y \
449 ui-obj-m \
450 audio-obj-y \
451 audio-obj-m \
452 trace-obj-y)
453
454 include $(SRC_PATH)/tests/Makefile.include
455
456 all: $(DOCS) $(if $(BUILD_DOCS),sphinxdocs) $(TOOLS) $(HELPERS-y) recurse-all modules $(vhost-user-json-y)
457
458 qemu-version.h: FORCE
459 $(call quiet-command, \
460 (printf '#define QEMU_PKGVERSION "$(QEMU_PKGVERSION)"\n'; \
461 printf '#define QEMU_FULL_VERSION "$(FULL_VERSION)"\n'; \
462 ) > $@.tmp)
463 $(call quiet-command, if ! cmp -s $@ $@.tmp; then \
464 mv $@.tmp $@; \
465 else \
466 rm $@.tmp; \
467 fi)
468
469 config-host.h: config-host.h-timestamp
470 config-host.h-timestamp: config-host.mak
471 qemu-options.def: $(SRC_PATH)/qemu-options.hx $(SRC_PATH)/scripts/hxtool
472 $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@,"GEN","$@")
473
474 TARGET_DIRS_RULES := $(foreach t, all clean install, $(addsuffix /$(t), $(TARGET_DIRS)))
475
476 SOFTMMU_ALL_RULES=$(filter %-softmmu/all, $(TARGET_DIRS_RULES))
477 $(SOFTMMU_ALL_RULES): $(authz-obj-y)
478 $(SOFTMMU_ALL_RULES): $(block-obj-y)
479 $(SOFTMMU_ALL_RULES): $(chardev-obj-y)
480 $(SOFTMMU_ALL_RULES): $(crypto-obj-y)
481 $(SOFTMMU_ALL_RULES): $(io-obj-y)
482 $(SOFTMMU_ALL_RULES): config-all-devices.mak
483 ifdef DECOMPRESS_EDK2_BLOBS
484 $(SOFTMMU_ALL_RULES): $(edk2-decompressed)
485 endif
486
487 .PHONY: $(TARGET_DIRS_RULES)
488 # The $(TARGET_DIRS_RULES) are of the form SUBDIR/GOAL, so that
489 # $(dir $@) yields the sub-directory, and $(notdir $@) yields the sub-goal
490 $(TARGET_DIRS_RULES):
491 $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C $(dir $@) V="$(V)" TARGET_DIR="$(dir $@)" $(notdir $@),)
492
493 DTC_MAKE_ARGS=-I$(SRC_PATH)/dtc VPATH=$(SRC_PATH)/dtc -C dtc V="$(V)" LIBFDT_srcdir=$(SRC_PATH)/dtc/libfdt
494 DTC_CFLAGS=$(CFLAGS) $(QEMU_CFLAGS)
495 DTC_CPPFLAGS=-I$(BUILD_DIR)/dtc -I$(SRC_PATH)/dtc -I$(SRC_PATH)/dtc/libfdt
496
497 .PHONY: dtc/all
498 dtc/all: .git-submodule-status dtc/libfdt dtc/tests
499 $(call quiet-command,$(MAKE) $(DTC_MAKE_ARGS) CPPFLAGS="$(DTC_CPPFLAGS)" CFLAGS="$(DTC_CFLAGS)" LDFLAGS="$(LDFLAGS)" ARFLAGS="$(ARFLAGS)" CC="$(CC)" AR="$(AR)" LD="$(LD)" $(SUBDIR_MAKEFLAGS) libfdt/libfdt.a,)
500
501 dtc/%: .git-submodule-status
502 @mkdir -p $@
503
504 # Overriding CFLAGS causes us to lose defines added in the sub-makefile.
505 # Not overriding CFLAGS leads to mis-matches between compilation modes.
506 # Therefore we replicate some of the logic in the sub-makefile.
507 # Remove all the extra -Warning flags that QEMU uses that Capstone doesn't;
508 # no need to annoy QEMU developers with such things.
509 CAP_CFLAGS = $(patsubst -W%,,$(CFLAGS) $(QEMU_CFLAGS))
510 CAP_CFLAGS += -DCAPSTONE_USE_SYS_DYN_MEM
511 CAP_CFLAGS += -DCAPSTONE_HAS_ARM
512 CAP_CFLAGS += -DCAPSTONE_HAS_ARM64
513 CAP_CFLAGS += -DCAPSTONE_HAS_POWERPC
514 CAP_CFLAGS += -DCAPSTONE_HAS_X86
515
516 .PHONY: capstone/all
517 capstone/all: .git-submodule-status
518 $(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))
519
520 .PHONY: slirp/all
521 slirp/all: .git-submodule-status
522 $(call quiet-command,$(MAKE) -C $(SRC_PATH)/slirp \
523 BUILD_DIR="$(BUILD_DIR)/slirp" \
524 PKG_CONFIG="$(PKG_CONFIG)" \
525 CC="$(CC)" AR="$(AR)" LD="$(LD)" RANLIB="$(RANLIB)" \
526 CFLAGS="$(QEMU_CFLAGS) $(CFLAGS)" LDFLAGS="$(LDFLAGS)")
527
528 # Compatibility gunk to keep make working across the rename of targets
529 # for recursion, to be removed some time after 4.1.
530 subdir-dtc: dtc/all
531 subdir-capstone: capstone/all
532 subdir-slirp: slirp/all
533
534 $(filter %/all, $(TARGET_DIRS_RULES)): libqemuutil.a $(common-obj-y) \
535 $(qom-obj-y) $(crypto-user-obj-$(CONFIG_USER_ONLY))
536
537 ROM_DIRS = $(addprefix pc-bios/, $(ROMS))
538 ROM_DIRS_RULES=$(foreach t, all clean, $(addsuffix /$(t), $(ROM_DIRS)))
539 # Only keep -O and -g cflags
540 .PHONY: $(ROM_DIRS_RULES)
541 $(ROM_DIRS_RULES):
542 $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C $(dir $@) V="$(V)" TARGET_DIR="$(dir $@)" CFLAGS="$(filter -O% -g%,$(CFLAGS))" $(notdir $@),)
543
544 .PHONY: recurse-all recurse-clean recurse-install
545 recurse-all: $(addsuffix /all, $(TARGET_DIRS) $(ROM_DIRS))
546 recurse-clean: $(addsuffix /clean, $(TARGET_DIRS) $(ROM_DIRS))
547 recurse-install: $(addsuffix /install, $(TARGET_DIRS))
548 $(addsuffix /install, $(TARGET_DIRS)): all
549
550 $(BUILD_DIR)/version.o: $(SRC_PATH)/version.rc config-host.h
551 $(call quiet-command,$(WINDRES) -I$(BUILD_DIR) -o $@ $<,"RC","version.o")
552
553 Makefile: $(version-obj-y)
554
555 ######################################################################
556 # Build libraries
557
558 libqemuutil.a: $(util-obj-y) $(trace-obj-y) $(stub-obj-y)
559 libvhost-user.a: $(libvhost-user-obj-y) $(util-obj-y) $(stub-obj-y)
560
561 ######################################################################
562
563 COMMON_LDADDS = libqemuutil.a
564
565 qemu-img.o: qemu-img-cmds.h
566
567 qemu-img$(EXESUF): qemu-img.o $(authz-obj-y) $(block-obj-y) $(crypto-obj-y) $(io-obj-y) $(qom-obj-y) $(COMMON_LDADDS)
568 qemu-nbd$(EXESUF): qemu-nbd.o $(authz-obj-y) $(block-obj-y) $(crypto-obj-y) $(io-obj-y) $(qom-obj-y) $(COMMON_LDADDS)
569 qemu-io$(EXESUF): qemu-io.o $(authz-obj-y) $(block-obj-y) $(crypto-obj-y) $(io-obj-y) $(qom-obj-y) $(COMMON_LDADDS)
570
571 qemu-bridge-helper$(EXESUF): qemu-bridge-helper.o $(COMMON_LDADDS)
572
573 qemu-keymap$(EXESUF): qemu-keymap.o ui/input-keymap.o $(COMMON_LDADDS)
574
575 qemu-edid$(EXESUF): qemu-edid.o hw/display/edid-generate.o $(COMMON_LDADDS)
576
577 fsdev/virtfs-proxy-helper$(EXESUF): fsdev/virtfs-proxy-helper.o fsdev/9p-marshal.o fsdev/9p-iov-marshal.o $(COMMON_LDADDS)
578 fsdev/virtfs-proxy-helper$(EXESUF): LIBS += -lcap
579
580 scsi/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)
581 ifdef CONFIG_MPATH
582 scsi/qemu-pr-helper$(EXESUF): LIBS += -ludev -lmultipath -lmpathpersist
583 endif
584
585 qemu-img-cmds.h: $(SRC_PATH)/qemu-img-cmds.hx $(SRC_PATH)/scripts/hxtool
586 $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@,"GEN","$@")
587
588 qemu-ga$(EXESUF): LIBS = $(LIBS_QGA)
589 qemu-ga$(EXESUF): QEMU_CFLAGS += -I qga/qapi-generated
590
591 qemu-keymap$(EXESUF): LIBS += $(XKBCOMMON_LIBS)
592 qemu-keymap$(EXESUF): QEMU_CFLAGS += $(XKBCOMMON_CFLAGS)
593
594 qapi-py = $(SRC_PATH)/scripts/qapi/__init__.py \
595 $(SRC_PATH)/scripts/qapi/commands.py \
596 $(SRC_PATH)/scripts/qapi/common.py \
597 $(SRC_PATH)/scripts/qapi/doc.py \
598 $(SRC_PATH)/scripts/qapi/error.py \
599 $(SRC_PATH)/scripts/qapi/events.py \
600 $(SRC_PATH)/scripts/qapi/expr.py \
601 $(SRC_PATH)/scripts/qapi/gen.py \
602 $(SRC_PATH)/scripts/qapi/introspect.py \
603 $(SRC_PATH)/scripts/qapi/parser.py \
604 $(SRC_PATH)/scripts/qapi/schema.py \
605 $(SRC_PATH)/scripts/qapi/source.py \
606 $(SRC_PATH)/scripts/qapi/types.py \
607 $(SRC_PATH)/scripts/qapi/visit.py \
608 $(SRC_PATH)/scripts/qapi-gen.py
609
610 qga/qapi-generated/qga-qapi-types.c qga/qapi-generated/qga-qapi-types.h \
611 qga/qapi-generated/qga-qapi-visit.c qga/qapi-generated/qga-qapi-visit.h \
612 qga/qapi-generated/qga-qapi-commands.h qga/qapi-generated/qga-qapi-commands.c \
613 qga/qapi-generated/qga-qapi-doc.texi: \
614 qga/qapi-generated/qapi-gen-timestamp ;
615 qga/qapi-generated/qapi-gen-timestamp: $(SRC_PATH)/qga/qapi-schema.json $(qapi-py)
616 $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-gen.py \
617 -o qga/qapi-generated -p "qga-" $<, \
618 "GEN","$(@:%-timestamp=%)")
619 @>$@
620
621 qapi-modules = $(SRC_PATH)/qapi/qapi-schema.json \
622 $(QAPI_MODULES:%=$(SRC_PATH)/qapi/%.json)
623
624 $(GENERATED_QAPI_FILES): qapi-gen-timestamp ;
625 qapi-gen-timestamp: $(qapi-modules) $(qapi-py)
626 $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-gen.py \
627 -o "qapi" -b $<, \
628 "GEN","$(@:%-timestamp=%)")
629 @>$@
630
631 QGALIB_GEN=$(addprefix qga/qapi-generated/, qga-qapi-types.h qga-qapi-visit.h qga-qapi-commands.h)
632 $(qga-obj-y): $(QGALIB_GEN)
633
634 qemu-ga$(EXESUF): $(qga-obj-y) $(COMMON_LDADDS)
635 $(call LINK, $^)
636
637 ifdef QEMU_GA_MSI_ENABLED
638 QEMU_GA_MSI=qemu-ga-$(ARCH).msi
639
640 msi: $(QEMU_GA_MSI)
641
642 $(QEMU_GA_MSI): qemu-ga.exe $(QGA_VSS_PROVIDER)
643
644 $(QEMU_GA_MSI): config-host.mak
645
646 $(QEMU_GA_MSI): $(SRC_PATH)/qga/installer/qemu-ga.wxs
647 $(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)" \
648 wixl -o $@ $(QEMU_GA_MSI_ARCH) $(QEMU_GA_MSI_WITH_VSS) $(QEMU_GA_MSI_MINGW_DLL_PATH) $<,"WIXL","$@")
649 else
650 msi:
651 @echo "MSI build not configured or dependency resolution failed (reconfigure with --enable-guest-agent-msi option)"
652 endif
653
654 ifneq ($(EXESUF),)
655 .PHONY: qemu-ga
656 qemu-ga: qemu-ga$(EXESUF) $(QGA_VSS_PROVIDER) $(QEMU_GA_MSI)
657 endif
658
659 elf2dmp$(EXESUF): $(elf2dmp-obj-y)
660 $(call LINK, $^)
661
662 ifdef CONFIG_IVSHMEM
663 ivshmem-client$(EXESUF): $(ivshmem-client-obj-y) $(COMMON_LDADDS)
664 $(call LINK, $^)
665 ivshmem-server$(EXESUF): $(ivshmem-server-obj-y) $(COMMON_LDADDS)
666 $(call LINK, $^)
667 endif
668 vhost-user-scsi$(EXESUF): $(vhost-user-scsi-obj-y) libvhost-user.a
669 $(call LINK, $^)
670 vhost-user-blk$(EXESUF): $(vhost-user-blk-obj-y) libvhost-user.a
671 $(call LINK, $^)
672
673 rdmacm-mux$(EXESUF): LIBS += "-libumad"
674 rdmacm-mux$(EXESUF): $(rdmacm-mux-obj-y) $(COMMON_LDADDS)
675 $(call LINK, $^)
676
677 vhost-user-gpu$(EXESUF): $(vhost-user-gpu-obj-y) $(libvhost-user-obj-y) libqemuutil.a libqemustub.a
678 $(call LINK, $^)
679
680 ifdef CONFIG_VHOST_USER_INPUT
681 ifdef CONFIG_LINUX
682 vhost-user-input$(EXESUF): $(vhost-user-input-obj-y) libvhost-user.a libqemuutil.a
683 $(call LINK, $^)
684
685 # build by default, do not install
686 all: vhost-user-input$(EXESUF)
687 endif
688 endif
689
690 module_block.h: $(SRC_PATH)/scripts/modules/module_block.py config-host.mak
691 $(call quiet-command,$(PYTHON) $< $@ \
692 $(addprefix $(SRC_PATH)/,$(patsubst %.mo,%.c,$(block-obj-m))), \
693 "GEN","$@")
694
695 ifdef CONFIG_GCOV
696 .PHONY: clean-coverage
697 clean-coverage:
698 $(call quiet-command, \
699 find . \( -name '*.gcda' -o -name '*.gcov' \) -type f -exec rm {} +, \
700 "CLEAN", "coverage files")
701 endif
702
703 clean: recurse-clean
704 # avoid old build problems by removing potentially incorrect old files
705 rm -f config.mak op-i386.h opc-i386.h gen-op-i386.h op-arm.h opc-arm.h gen-op-arm.h
706 rm -f qemu-options.def
707 rm -f *.msi
708 find . \( -name '*.so' -o -name '*.dll' -o -name '*.mo' -o -name '*.[oda]' \) -type f \
709 ! -path ./roms/edk2/ArmPkg/Library/GccLto/liblto-aarch64.a \
710 ! -path ./roms/edk2/ArmPkg/Library/GccLto/liblto-arm.a \
711 ! -path ./roms/edk2/BaseTools/Source/Python/UPT/Dll/sqlite3.dll \
712 -exec rm {} +
713 rm -f $(edk2-decompressed)
714 rm -f $(filter-out %.tlb,$(TOOLS)) $(HELPERS-y) TAGS cscope.* *.pod *~ */*~
715 rm -f fsdev/*.pod scsi/*.pod
716 rm -f qemu-img-cmds.h
717 rm -f ui/shader/*-vert.h ui/shader/*-frag.h
718 @# May not be present in generated-files-y
719 rm -f trace/generated-tracers-dtrace.dtrace*
720 rm -f trace/generated-tracers-dtrace.h*
721 rm -f $(foreach f,$(generated-files-y),$(f) $(f)-timestamp)
722 rm -f qapi-gen-timestamp
723 rm -rf qga/qapi-generated
724 rm -f config-all-devices.mak
725
726 VERSION ?= $(shell cat VERSION)
727
728 dist: qemu-$(VERSION).tar.bz2
729
730 qemu-%.tar.bz2:
731 $(SRC_PATH)/scripts/make-release "$(SRC_PATH)" "$(patsubst qemu-%.tar.bz2,%,$@)"
732
733 define clean-manual =
734 rm -rf $(MANUAL_BUILDDIR)/$1/_static
735 rm -f $(MANUAL_BUILDDIR)/$1/objects.inv $(MANUAL_BUILDDIR)/$1/searchindex.js $(MANUAL_BUILDDIR)/$1/*.html
736 endef
737
738 distclean: clean
739 rm -f config-host.mak config-host.h* config-host.ld $(DOCS) qemu-options.texi qemu-img-cmds.texi qemu-monitor.texi qemu-monitor-info.texi
740 rm -f tests/tcg/config-*.mak
741 rm -f config-all-devices.mak config-all-disas.mak config.status
742 rm -f $(SUBDIR_DEVICES_MAK)
743 rm -f po/*.mo tests/qemu-iotests/common.env
744 rm -f roms/seabios/config.mak roms/vgabios/config.mak
745 rm -f qemu-doc.info qemu-doc.aux qemu-doc.cp qemu-doc.cps
746 rm -f qemu-doc.fn qemu-doc.fns qemu-doc.info qemu-doc.ky qemu-doc.kys
747 rm -f qemu-doc.log qemu-doc.pdf qemu-doc.pg qemu-doc.toc qemu-doc.tp
748 rm -f qemu-doc.vr qemu-doc.txt
749 rm -f qemu-plugins-ld.symbols qemu-plugins-ld64.symbols
750 rm -f config.log
751 rm -f linux-headers/asm
752 rm -f docs/version.texi
753 rm -f docs/interop/qemu-ga-qapi.texi docs/interop/qemu-qmp-qapi.texi
754 rm -f docs/interop/qemu-qmp-ref.7 docs/interop/qemu-ga-ref.7
755 rm -f docs/interop/qemu-qmp-ref.txt docs/interop/qemu-ga-ref.txt
756 rm -f docs/interop/qemu-qmp-ref.pdf docs/interop/qemu-ga-ref.pdf
757 rm -f docs/interop/qemu-qmp-ref.html docs/interop/qemu-ga-ref.html
758 rm -f docs/qemu-block-drivers.7
759 rm -f docs/qemu-cpu-models.7
760 rm -rf .doctrees
761 $(call clean-manual,devel)
762 $(call clean-manual,interop)
763 $(call clean-manual,specs)
764 for d in $(TARGET_DIRS); do \
765 rm -rf $$d || exit 1 ; \
766 done
767 rm -Rf .sdk
768 if test -f dtc/version_gen.h; then $(MAKE) $(DTC_MAKE_ARGS) clean; fi
769
770 KEYMAPS=da en-gb et fr fr-ch is lt no pt-br sv \
771 ar de en-us fi fr-be hr it lv nl pl ru th \
772 de-ch es fo fr-ca hu ja mk pt sl tr \
773 bepo cz
774
775 ifdef INSTALL_BLOBS
776 BLOBS=bios.bin bios-256k.bin bios-microvm.bin sgabios.bin vgabios.bin vgabios-cirrus.bin \
777 vgabios-stdvga.bin vgabios-vmware.bin vgabios-qxl.bin vgabios-virtio.bin \
778 vgabios-ramfb.bin vgabios-bochs-display.bin vgabios-ati.bin \
779 ppc_rom.bin openbios-sparc32 openbios-sparc64 openbios-ppc QEMU,tcx.bin QEMU,cgthree.bin \
780 pxe-e1000.rom pxe-eepro100.rom pxe-ne2k_pci.rom \
781 pxe-pcnet.rom pxe-rtl8139.rom pxe-virtio.rom \
782 efi-e1000.rom efi-eepro100.rom efi-ne2k_pci.rom \
783 efi-pcnet.rom efi-rtl8139.rom efi-virtio.rom \
784 efi-e1000e.rom efi-vmxnet3.rom \
785 qemu-nsis.bmp \
786 bamboo.dtb canyonlands.dtb petalogix-s3adsp1800.dtb petalogix-ml605.dtb \
787 multiboot.bin linuxboot.bin linuxboot_dma.bin kvmvapic.bin pvh.bin \
788 s390-ccw.img s390-netboot.img \
789 slof.bin skiboot.lid \
790 palcode-clipper \
791 u-boot.e500 u-boot-sam460-20100605.bin \
792 qemu_vga.ndrv \
793 edk2-licenses.txt \
794 hppa-firmware.img \
795 opensbi-riscv32-virt-fw_jump.bin \
796 opensbi-riscv64-sifive_u-fw_jump.bin opensbi-riscv64-virt-fw_jump.bin
797
798
799 DESCS=50-edk2-i386-secure.json 50-edk2-x86_64-secure.json \
800 60-edk2-aarch64.json 60-edk2-arm.json 60-edk2-i386.json 60-edk2-x86_64.json
801 else
802 BLOBS=
803 DESCS=
804 endif
805
806 # Note that we manually filter-out the non-Sphinx documentation which
807 # is currently built into the docs/interop directory in the build tree,
808 # and also any sphinx-built manpages.
809 define install-manual =
810 for d in $$(cd $(MANUAL_BUILDDIR) && find $1 -type d); do $(INSTALL_DIR) "$(DESTDIR)$(qemu_docdir)/$$d"; done
811 for 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
812 endef
813
814 # Note that we deliberately do not install the "devel" manual: it is
815 # for QEMU developers, and not interesting to our users.
816 .PHONY: install-sphinxdocs
817 install-sphinxdocs: sphinxdocs
818 $(call install-manual,interop)
819 $(call install-manual,specs)
820
821 install-doc: $(DOCS) install-sphinxdocs
822 $(INSTALL_DIR) "$(DESTDIR)$(qemu_docdir)"
823 $(INSTALL_DATA) qemu-doc.html "$(DESTDIR)$(qemu_docdir)"
824 $(INSTALL_DATA) qemu-doc.txt "$(DESTDIR)$(qemu_docdir)"
825 $(INSTALL_DATA) docs/interop/qemu-qmp-ref.html "$(DESTDIR)$(qemu_docdir)"
826 $(INSTALL_DATA) docs/interop/qemu-qmp-ref.txt "$(DESTDIR)$(qemu_docdir)"
827 ifdef CONFIG_POSIX
828 $(INSTALL_DIR) "$(DESTDIR)$(mandir)/man1"
829 $(INSTALL_DATA) qemu.1 "$(DESTDIR)$(mandir)/man1"
830 $(INSTALL_DIR) "$(DESTDIR)$(mandir)/man7"
831 $(INSTALL_DATA) docs/interop/qemu-qmp-ref.7 "$(DESTDIR)$(mandir)/man7"
832 $(INSTALL_DATA) docs/qemu-block-drivers.7 "$(DESTDIR)$(mandir)/man7"
833 $(INSTALL_DATA) docs/qemu-cpu-models.7 "$(DESTDIR)$(mandir)/man7"
834 ifeq ($(CONFIG_TOOLS),y)
835 $(INSTALL_DATA) qemu-img.1 "$(DESTDIR)$(mandir)/man1"
836 $(INSTALL_DIR) "$(DESTDIR)$(mandir)/man8"
837 $(INSTALL_DATA) qemu-nbd.8 "$(DESTDIR)$(mandir)/man8"
838 endif
839 ifdef CONFIG_TRACE_SYSTEMTAP
840 $(INSTALL_DATA) scripts/qemu-trace-stap.1 "$(DESTDIR)$(mandir)/man1"
841 endif
842 ifneq (,$(findstring qemu-ga,$(TOOLS)))
843 $(INSTALL_DATA) $(MANUAL_BUILDDIR)/interop/qemu-ga.8 "$(DESTDIR)$(mandir)/man8"
844 $(INSTALL_DATA) docs/interop/qemu-ga-ref.html "$(DESTDIR)$(qemu_docdir)"
845 $(INSTALL_DATA) docs/interop/qemu-ga-ref.txt "$(DESTDIR)$(qemu_docdir)"
846 $(INSTALL_DATA) docs/interop/qemu-ga-ref.7 "$(DESTDIR)$(mandir)/man7"
847 endif
848 endif
849 ifdef CONFIG_VIRTFS
850 $(INSTALL_DIR) "$(DESTDIR)$(mandir)/man1"
851 $(INSTALL_DATA) fsdev/virtfs-proxy-helper.1 "$(DESTDIR)$(mandir)/man1"
852 endif
853
854 install-datadir:
855 $(INSTALL_DIR) "$(DESTDIR)$(qemu_datadir)"
856
857 install-localstatedir:
858 ifdef CONFIG_POSIX
859 ifneq (,$(findstring qemu-ga,$(TOOLS)))
860 $(INSTALL_DIR) "$(DESTDIR)$(qemu_localstatedir)"/run
861 endif
862 endif
863
864 ICON_SIZES=16x16 24x24 32x32 48x48 64x64 128x128 256x256 512x512
865
866 install-includedir:
867 $(INSTALL_DIR) "$(DESTDIR)$(includedir)"
868
869 install: all $(if $(BUILD_DOCS),install-doc) \
870 install-datadir install-localstatedir install-includedir \
871 $(if $(INSTALL_BLOBS),$(edk2-decompressed)) \
872 recurse-install
873 ifneq ($(TOOLS),)
874 $(call install-prog,$(TOOLS),$(DESTDIR)$(bindir))
875 endif
876 ifneq ($(CONFIG_MODULES),)
877 $(INSTALL_DIR) "$(DESTDIR)$(qemu_moddir)"
878 for s in $(modules-m:.mo=$(DSOSUF)); do \
879 t="$(DESTDIR)$(qemu_moddir)/$$(echo $$s | tr / -)"; \
880 $(INSTALL_LIB) $$s "$$t"; \
881 test -z "$(STRIP)" || $(STRIP) "$$t"; \
882 done
883 endif
884 ifneq ($(HELPERS-y),)
885 $(call install-prog,$(HELPERS-y),$(DESTDIR)$(libexecdir))
886 endif
887 ifneq ($(vhost-user-json-y),)
888 $(INSTALL_DIR) "$(DESTDIR)$(qemu_datadir)/vhost-user/"
889 for x in $(vhost-user-json-y); do \
890 $(INSTALL_DATA) $$x "$(DESTDIR)$(qemu_datadir)/vhost-user/"; \
891 done
892 endif
893 ifdef CONFIG_TRACE_SYSTEMTAP
894 $(INSTALL_PROG) "scripts/qemu-trace-stap" $(DESTDIR)$(bindir)
895 endif
896 ifneq ($(BLOBS),)
897 set -e; for x in $(BLOBS); do \
898 $(INSTALL_DATA) $(SRC_PATH)/pc-bios/$$x "$(DESTDIR)$(qemu_datadir)"; \
899 done
900 endif
901 ifdef INSTALL_BLOBS
902 set -e; for x in $(edk2-decompressed); do \
903 $(INSTALL_DATA) $$x "$(DESTDIR)$(qemu_datadir)"; \
904 done
905 endif
906 ifneq ($(DESCS),)
907 $(INSTALL_DIR) "$(DESTDIR)$(qemu_datadir)/firmware"
908 set -e; tmpf=$$(mktemp); trap 'rm -f -- "$$tmpf"' EXIT; \
909 for x in $(DESCS); do \
910 sed -e 's,@DATADIR@,$(qemu_datadir),' \
911 "$(SRC_PATH)/pc-bios/descriptors/$$x" > "$$tmpf"; \
912 $(INSTALL_DATA) "$$tmpf" \
913 "$(DESTDIR)$(qemu_datadir)/firmware/$$x"; \
914 done
915 endif
916 for s in $(ICON_SIZES); do \
917 mkdir -p "$(DESTDIR)$(qemu_icondir)/hicolor/$${s}/apps"; \
918 $(INSTALL_DATA) $(SRC_PATH)/ui/icons/qemu_$${s}.png \
919 "$(DESTDIR)$(qemu_icondir)/hicolor/$${s}/apps/qemu.png"; \
920 done; \
921 mkdir -p "$(DESTDIR)$(qemu_icondir)/hicolor/32x32/apps"; \
922 $(INSTALL_DATA) $(SRC_PATH)/ui/icons/qemu_32x32.bmp \
923 "$(DESTDIR)$(qemu_icondir)/hicolor/32x32/apps/qemu.bmp"; \
924 mkdir -p "$(DESTDIR)$(qemu_icondir)/hicolor/scalable/apps"; \
925 $(INSTALL_DATA) $(SRC_PATH)/ui/icons/qemu.svg \
926 "$(DESTDIR)$(qemu_icondir)/hicolor/scalable/apps/qemu.svg"
927 mkdir -p "$(DESTDIR)$(qemu_desktopdir)"
928 $(INSTALL_DATA) $(SRC_PATH)/ui/qemu.desktop \
929 "$(DESTDIR)$(qemu_desktopdir)/qemu.desktop"
930 ifdef CONFIG_GTK
931 $(MAKE) -C po $@
932 endif
933 ifeq ($(CONFIG_PLUGIN),y)
934 $(INSTALL_DATA) $(SRC_PATH)/include/qemu/qemu-plugin.h "$(DESTDIR)$(includedir)/qemu-plugin.h"
935 endif
936 $(INSTALL_DIR) "$(DESTDIR)$(qemu_datadir)/keymaps"
937 set -e; for x in $(KEYMAPS); do \
938 $(INSTALL_DATA) $(SRC_PATH)/pc-bios/keymaps/$$x "$(DESTDIR)$(qemu_datadir)/keymaps"; \
939 done
940 $(INSTALL_DATA) $(BUILD_DIR)/trace-events-all "$(DESTDIR)$(qemu_datadir)/trace-events-all"
941
942 .PHONY: ctags
943 ctags:
944 rm -f tags
945 find "$(SRC_PATH)" -name '*.[hc]' -exec ctags --append {} +
946
947 .PHONY: TAGS
948 TAGS:
949 rm -f TAGS
950 find "$(SRC_PATH)" -name '*.[hc]' -exec etags --append {} +
951
952 cscope:
953 rm -f "$(SRC_PATH)"/cscope.*
954 find "$(SRC_PATH)/" -name "*.[chsS]" -print | sed 's,^\./,,' > "$(SRC_PATH)/cscope.files"
955 cscope -b -i"$(SRC_PATH)/cscope.files"
956
957 # opengl shader programs
958 ui/shader/%-vert.h: $(SRC_PATH)/ui/shader/%.vert $(SRC_PATH)/scripts/shaderinclude.pl
959 @mkdir -p $(dir $@)
960 $(call quiet-command,\
961 perl $(SRC_PATH)/scripts/shaderinclude.pl $< > $@,\
962 "VERT","$@")
963
964 ui/shader/%-frag.h: $(SRC_PATH)/ui/shader/%.frag $(SRC_PATH)/scripts/shaderinclude.pl
965 @mkdir -p $(dir $@)
966 $(call quiet-command,\
967 perl $(SRC_PATH)/scripts/shaderinclude.pl $< > $@,\
968 "FRAG","$@")
969
970 ui/shader.o: $(SRC_PATH)/ui/shader.c \
971 ui/shader/texture-blit-vert.h \
972 ui/shader/texture-blit-flip-vert.h \
973 ui/shader/texture-blit-frag.h
974
975 # documentation
976 MAKEINFO=makeinfo
977 MAKEINFOINCLUDES= -I docs -I $(<D) -I $(@D)
978 MAKEINFOFLAGS=--no-split --number-sections $(MAKEINFOINCLUDES)
979 TEXI2PODFLAGS=$(MAKEINFOINCLUDES) -DVERSION="$(VERSION)" -DCONFDIR="$(qemu_confdir)"
980 TEXI2PDFFLAGS=$(if $(V),,--quiet) -I $(SRC_PATH) $(MAKEINFOINCLUDES)
981
982 docs/version.texi: $(SRC_PATH)/VERSION config-host.mak
983 $(call quiet-command,(\
984 echo "@set VERSION $(VERSION)" && \
985 echo "@set CONFDIR $(qemu_confdir)" \
986 )> $@,"GEN","$@")
987
988 %.html: %.texi docs/version.texi
989 $(call quiet-command,LC_ALL=C $(MAKEINFO) $(MAKEINFOFLAGS) --no-headers \
990 --html $< -o $@,"GEN","$@")
991
992 %.info: %.texi docs/version.texi
993 $(call quiet-command,$(MAKEINFO) $(MAKEINFOFLAGS) $< -o $@,"GEN","$@")
994
995 %.txt: %.texi docs/version.texi
996 $(call quiet-command,LC_ALL=C $(MAKEINFO) $(MAKEINFOFLAGS) --no-headers \
997 --plaintext $< -o $@,"GEN","$@")
998
999 %.pdf: %.texi docs/version.texi
1000 $(call quiet-command,texi2pdf $(TEXI2PDFFLAGS) $< -o $@,"GEN","$@")
1001
1002 # Sphinx builds all its documentation at once in one invocation
1003 # and handles "don't rebuild things unless necessary" itself.
1004 # The '.doctrees' files are cached information to speed this up.
1005 .PHONY: sphinxdocs
1006 sphinxdocs: $(MANUAL_BUILDDIR)/devel/index.html $(MANUAL_BUILDDIR)/interop/index.html $(MANUAL_BUILDDIR)/specs/index.html
1007
1008 # Canned command to build a single manual
1009 # Arguments: $1 = manual name, $2 = Sphinx builder ('html' or 'man')
1010 # Note the use of different doctree for each (manual, builder) tuple;
1011 # this works around Sphinx not handling parallel invocation on
1012 # a single doctree: https://github.com/sphinx-doc/sphinx/issues/2946
1013 build-manual = $(call quiet-command,CONFDIR="$(qemu_confdir)" sphinx-build $(if $(V),,-q) -W -n -b $2 -D version=$(VERSION) -D release="$(FULL_VERSION)" -d .doctrees/$1-$2 $(SRC_PATH)/docs/$1 $(MANUAL_BUILDDIR)/$1 ,"SPHINX","$(MANUAL_BUILDDIR)/$1")
1014 # We assume all RST files in the manual's directory are used in it
1015 manual-deps = $(wildcard $(SRC_PATH)/docs/$1/*.rst) $(SRC_PATH)/docs/$1/conf.py $(SRC_PATH)/docs/conf.py
1016
1017 $(MANUAL_BUILDDIR)/devel/index.html: $(call manual-deps,devel)
1018 $(call build-manual,devel,html)
1019
1020 $(MANUAL_BUILDDIR)/interop/index.html: $(call manual-deps,interop)
1021 $(call build-manual,interop,html)
1022
1023 $(MANUAL_BUILDDIR)/specs/index.html: $(call manual-deps,specs)
1024 $(call build-manual,specs,html)
1025
1026 $(MANUAL_BUILDDIR)/interop/qemu-ga.8: $(call manual-deps,interop)
1027 $(call build-manual,interop,man)
1028
1029 qemu-options.texi: $(SRC_PATH)/qemu-options.hx $(SRC_PATH)/scripts/hxtool
1030 $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -t < $< > $@,"GEN","$@")
1031
1032 qemu-monitor.texi: $(SRC_PATH)/hmp-commands.hx $(SRC_PATH)/scripts/hxtool
1033 $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -t < $< > $@,"GEN","$@")
1034
1035 qemu-monitor-info.texi: $(SRC_PATH)/hmp-commands-info.hx $(SRC_PATH)/scripts/hxtool
1036 $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -t < $< > $@,"GEN","$@")
1037
1038 qemu-img-cmds.texi: $(SRC_PATH)/qemu-img-cmds.hx $(SRC_PATH)/scripts/hxtool
1039 $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -t < $< > $@,"GEN","$@")
1040
1041 docs/interop/qemu-qmp-qapi.texi: qapi/qapi-doc.texi
1042 @cp -p $< $@
1043
1044 docs/interop/qemu-ga-qapi.texi: qga/qapi-generated/qga-qapi-doc.texi
1045 @cp -p $< $@
1046
1047 qemu.1: qemu-doc.texi qemu-options.texi qemu-monitor.texi qemu-monitor-info.texi
1048 qemu.1: qemu-option-trace.texi
1049 qemu-img.1: qemu-img.texi qemu-option-trace.texi qemu-img-cmds.texi
1050 fsdev/virtfs-proxy-helper.1: fsdev/virtfs-proxy-helper.texi
1051 qemu-nbd.8: qemu-nbd.texi qemu-option-trace.texi
1052 docs/qemu-block-drivers.7: docs/qemu-block-drivers.texi
1053 docs/qemu-cpu-models.7: docs/qemu-cpu-models.texi
1054 scripts/qemu-trace-stap.1: scripts/qemu-trace-stap.texi
1055
1056 html: qemu-doc.html docs/interop/qemu-qmp-ref.html docs/interop/qemu-ga-ref.html sphinxdocs
1057 info: qemu-doc.info docs/interop/qemu-qmp-ref.info docs/interop/qemu-ga-ref.info
1058 pdf: qemu-doc.pdf docs/interop/qemu-qmp-ref.pdf docs/interop/qemu-ga-ref.pdf
1059 txt: qemu-doc.txt docs/interop/qemu-qmp-ref.txt docs/interop/qemu-ga-ref.txt
1060
1061 qemu-doc.html qemu-doc.info qemu-doc.pdf qemu-doc.txt: \
1062 qemu-img.texi qemu-nbd.texi qemu-options.texi \
1063 qemu-tech.texi qemu-option-trace.texi \
1064 qemu-deprecated.texi qemu-monitor.texi qemu-img-cmds.texi \
1065 qemu-monitor-info.texi docs/qemu-block-drivers.texi \
1066 docs/qemu-cpu-models.texi docs/security.texi
1067
1068 docs/interop/qemu-ga-ref.dvi docs/interop/qemu-ga-ref.html \
1069 docs/interop/qemu-ga-ref.info docs/interop/qemu-ga-ref.pdf \
1070 docs/interop/qemu-ga-ref.txt docs/interop/qemu-ga-ref.7: \
1071 docs/interop/qemu-ga-ref.texi docs/interop/qemu-ga-qapi.texi
1072
1073 docs/interop/qemu-qmp-ref.dvi docs/interop/qemu-qmp-ref.html \
1074 docs/interop/qemu-qmp-ref.info docs/interop/qemu-qmp-ref.pdf \
1075 docs/interop/qemu-qmp-ref.txt docs/interop/qemu-qmp-ref.7: \
1076 docs/interop/qemu-qmp-ref.texi docs/interop/qemu-qmp-qapi.texi
1077
1078 $(filter %.1 %.7 %.8,$(DOCS)): scripts/texi2pod.pl
1079
1080 # Reports/Analysis
1081
1082 %/coverage-report.html:
1083 @mkdir -p $*
1084 $(call quiet-command,\
1085 gcovr -r $(SRC_PATH) \
1086 $(foreach t, $(TARGET_DIRS), --object-directory $(BUILD_DIR)/$(t)) \
1087 --object-directory $(BUILD_DIR) \
1088 -p --html --html-details -o $@, \
1089 "GEN", "coverage-report.html")
1090
1091 .PHONY: coverage-report
1092 coverage-report: $(CURDIR)/reports/coverage/coverage-report.html
1093
1094 ifdef CONFIG_WIN32
1095
1096 INSTALLER = qemu-setup-$(VERSION)$(EXESUF)
1097
1098 nsisflags = -V2 -NOCD
1099
1100 ifneq ($(wildcard $(SRC_PATH)/dll),)
1101 ifeq ($(ARCH),x86_64)
1102 # 64 bit executables
1103 DLL_PATH = $(SRC_PATH)/dll/w64
1104 nsisflags += -DW64
1105 else
1106 # 32 bit executables
1107 DLL_PATH = $(SRC_PATH)/dll/w32
1108 endif
1109 endif
1110
1111 .PHONY: installer
1112 installer: $(INSTALLER)
1113
1114 INSTDIR=/tmp/qemu-nsis
1115
1116 $(INSTALLER): install-doc $(SRC_PATH)/qemu.nsi
1117 $(MAKE) install prefix=${INSTDIR}
1118 ifdef SIGNCODE
1119 (cd ${INSTDIR}; \
1120 for i in *.exe; do \
1121 $(SIGNCODE) $${i}; \
1122 done \
1123 )
1124 endif # SIGNCODE
1125 (cd ${INSTDIR}; \
1126 for i in qemu-system-*.exe; do \
1127 arch=$${i%.exe}; \
1128 arch=$${arch#qemu-system-}; \
1129 echo Section \"$$arch\" Section_$$arch; \
1130 echo SetOutPath \"\$$INSTDIR\"; \
1131 echo File \"\$${BINDIR}\\$$i\"; \
1132 echo SectionEnd; \
1133 done \
1134 ) >${INSTDIR}/system-emulations.nsh
1135 makensis $(nsisflags) \
1136 $(if $(BUILD_DOCS),-DCONFIG_DOCUMENTATION="y") \
1137 $(if $(CONFIG_GTK),-DCONFIG_GTK="y") \
1138 -DBINDIR="${INSTDIR}" \
1139 $(if $(DLL_PATH),-DDLLDIR="$(DLL_PATH)") \
1140 -DSRCDIR="$(SRC_PATH)" \
1141 -DOUTFILE="$(INSTALLER)" \
1142 -DDISPLAYVERSION="$(VERSION)" \
1143 $(SRC_PATH)/qemu.nsi
1144 rm -r ${INSTDIR}
1145 ifdef SIGNCODE
1146 $(SIGNCODE) $(INSTALLER)
1147 endif # SIGNCODE
1148 endif # CONFIG_WIN
1149
1150 # Add a dependency on the generated files, so that they are always
1151 # rebuilt before other object files
1152 ifneq ($(wildcard config-host.mak),)
1153 ifneq ($(filter-out $(UNCHECKED_GOALS),$(MAKECMDGOALS)),$(if $(MAKECMDGOALS),,fail))
1154 Makefile: $(generated-files-y)
1155 endif
1156 endif
1157
1158 .SECONDARY: $(TRACE_HEADERS) $(TRACE_HEADERS:%=%-timestamp) \
1159 $(TRACE_SOURCES) $(TRACE_SOURCES:%=%-timestamp) \
1160 $(TRACE_DTRACE) $(TRACE_DTRACE:%=%-timestamp)
1161
1162 # Include automatically generated dependency files
1163 # Dependencies in Makefile.objs files come from our recursive subdir rules
1164 -include $(wildcard *.d tests/*.d)
1165
1166 include $(SRC_PATH)/tests/docker/Makefile.include
1167 include $(SRC_PATH)/tests/vm/Makefile.include
1168
1169 .PHONY: help
1170 help:
1171 @echo 'Generic targets:'
1172 @echo ' all - Build all'
1173 ifdef CONFIG_MODULES
1174 @echo ' modules - Build all modules'
1175 endif
1176 @echo ' dir/file.o - Build specified target only'
1177 @echo ' install - Install QEMU, documentation and tools'
1178 @echo ' ctags/TAGS - Generate tags file for editors'
1179 @echo ' cscope - Generate cscope index'
1180 @echo ''
1181 @$(if $(TARGET_DIRS), \
1182 echo 'Architecture specific targets:'; \
1183 $(foreach t, $(TARGET_DIRS), \
1184 printf " %-30s - Build for %s\\n" $(t)/all $(t);) \
1185 echo '')
1186 @echo 'Cleaning targets:'
1187 @echo ' clean - Remove most generated files but keep the config'
1188 ifdef CONFIG_GCOV
1189 @echo ' clean-coverage - Remove coverage files'
1190 endif
1191 @echo ' distclean - Remove all generated files'
1192 @echo ' dist - Build a distributable tarball'
1193 @echo ''
1194 @echo 'Test targets:'
1195 @echo ' check - Run all tests (check-help for details)'
1196 @echo ' docker - Help about targets running tests inside containers'
1197 @echo ' vm-help - Help about targets running tests inside VM'
1198 @echo ''
1199 @echo 'Documentation targets:'
1200 @echo ' html info pdf txt'
1201 @echo ' - Build documentation in specified format'
1202 ifdef CONFIG_GCOV
1203 @echo ' coverage-report - Create code coverage report'
1204 endif
1205 @echo ''
1206 ifdef CONFIG_WIN32
1207 @echo 'Windows targets:'
1208 @echo ' installer - Build NSIS-based installer for QEMU'
1209 ifdef QEMU_GA_MSI_ENABLED
1210 @echo ' msi - Build MSI-based installer for qemu-ga'
1211 endif
1212 @echo ''
1213 endif
1214 @echo ' $(MAKE) [targets] (quiet build, default)'
1215 @echo ' $(MAKE) V=1 [targets] (verbose build)'