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