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