]> git.proxmox.com Git - mirror_qemu.git/blob - Makefile
meson: qemu-pr-helper
[mirror_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 generated-files-y += target/s390x/gen-features.h
125 target/s390x/gen-features.h: Makefile.ninja
126
127 generated-files-y += .git-submodule-status
128
129 # Don't try to regenerate Makefile or configure
130 # We don't generate any of them
131 Makefile: ;
132 configure: ;
133
134 .PHONY: all clean cscope distclean html info install install-doc \
135 pdf txt recurse-all dist msi FORCE
136
137 $(call set-vpath, $(SRC_PATH))
138
139 LIBS+=-lz $(LIBS_TOOLS)
140
141 HELPERS-y =
142
143 # Sphinx does not allow building manuals into the same directory as
144 # the source files, so if we're doing an in-tree QEMU build we must
145 # build the manuals into a subdirectory (and then install them from
146 # there for 'make install'). For an out-of-tree build we can just
147 # use the docs/ subdirectory in the build tree as normal.
148 ifeq ($(realpath $(SRC_PATH)),$(realpath .))
149 MANUAL_BUILDDIR := docs/built
150 else
151 MANUAL_BUILDDIR := docs
152 endif
153
154 ifdef BUILD_DOCS
155 DOCS+=$(MANUAL_BUILDDIR)/system/qemu.1
156 DOCS+=$(MANUAL_BUILDDIR)/tools/qemu-img.1
157 DOCS+=$(MANUAL_BUILDDIR)/tools/qemu-nbd.8
158 DOCS+=$(MANUAL_BUILDDIR)/interop/qemu-ga.8
159 ifeq ($(CONFIG_LINUX)$(CONFIG_SECCOMP)$(CONFIG_LIBCAP_NG),yyy)
160 DOCS+=$(MANUAL_BUILDDIR)/tools/virtiofsd.1
161 endif
162 DOCS+=$(MANUAL_BUILDDIR)/system/qemu-block-drivers.7
163 DOCS+=docs/interop/qemu-qmp-ref.html docs/interop/qemu-qmp-ref.txt docs/interop/qemu-qmp-ref.7
164 DOCS+=docs/interop/qemu-ga-ref.html docs/interop/qemu-ga-ref.txt docs/interop/qemu-ga-ref.7
165 DOCS+=$(MANUAL_BUILDDIR)/system/qemu-cpu-models.7
166 DOCS+=$(MANUAL_BUILDDIR)/index.html
167 ifdef CONFIG_VIRTFS
168 DOCS+=$(MANUAL_BUILDDIR)/tools/virtfs-proxy-helper.1
169 endif
170 ifdef CONFIG_TRACE_SYSTEMTAP
171 DOCS+=$(MANUAL_BUILDDIR)/tools/qemu-trace-stap.1
172 endif
173 else
174 DOCS=
175 endif
176
177 SUBDIR_MAKEFLAGS=$(if $(V),,--no-print-directory --quiet) BUILD_DIR=$(BUILD_DIR)
178
179 ifneq ($(wildcard config-host.mak),)
180 include $(SRC_PATH)/Makefile.objs
181 endif
182
183 dummy := $(call unnest-vars,, \
184 storage-daemon-obj-y \
185 storage-daemon-obj-m \
186 common-obj-y \
187 common-obj-m)
188
189 include $(SRC_PATH)/tests/Makefile.include
190
191 all: $(DOCS) $(if $(BUILD_DOCS),sphinxdocs) $(TOOLS) $(HELPERS-y) recurse-all modules
192
193 config-host.h: config-host.h-timestamp
194 config-host.h-timestamp: config-host.mak
195
196 TARGET_DIRS_RULES := $(foreach t, all fuzz clean install, $(addsuffix /$(t), $(TARGET_DIRS)))
197
198 SOFTMMU_ALL_RULES=$(filter %-softmmu/all, $(TARGET_DIRS_RULES))
199 $(SOFTMMU_ALL_RULES): $(authz-obj-y)
200 $(SOFTMMU_ALL_RULES): $(block-obj-y)
201 $(SOFTMMU_ALL_RULES): $(storage-daemon-obj-y)
202 $(SOFTMMU_ALL_RULES): $(chardev-obj-y)
203 $(SOFTMMU_ALL_RULES): $(crypto-obj-y)
204 $(SOFTMMU_ALL_RULES): $(io-obj-y)
205 $(SOFTMMU_ALL_RULES): $(qom-obj-y)
206 $(SOFTMMU_ALL_RULES): config-all-devices.mak
207
208 SOFTMMU_FUZZ_RULES=$(filter %-softmmu/fuzz, $(TARGET_DIRS_RULES))
209 $(SOFTMMU_FUZZ_RULES): $(authz-obj-y)
210 $(SOFTMMU_FUZZ_RULES): $(block-obj-y)
211 $(SOFTMMU_FUZZ_RULES): $(chardev-obj-y)
212 $(SOFTMMU_FUZZ_RULES): $(crypto-obj-y)
213 $(SOFTMMU_FUZZ_RULES): $(io-obj-y)
214 $(SOFTMMU_FUZZ_RULES): config-all-devices.mak
215 $(SOFTMMU_FUZZ_RULES): $(edk2-decompressed)
216
217 # meson: this is sub-optimal but going away after conversion
218 TARGET_DEPS = $(patsubst %,%-config-target.h, $(TARGET_DIRS))
219 TARGET_DEPS += $(patsubst %,%-config-devices.h, $(filter %-softmmu,$(TARGET_DIRS)))
220 TARGET_DEPS += $(patsubst %,libqemu-%.fa, $(TARGET_DIRS))
221
222 .PHONY: $(TARGET_DIRS_RULES)
223 # The $(TARGET_DIRS_RULES) are of the form SUBDIR/GOAL, so that
224 # $(dir $@) yields the sub-directory, and $(notdir $@) yields the sub-goal
225 $(TARGET_DIRS_RULES): $(TARGET_DEPS)
226 $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C $(dir $@) V="$(V)" TARGET_DIR="$(dir $@)" $(notdir $@),)
227
228 # LIBFDT_lib="": avoid breaking existing trees with objects requiring -fPIC
229 DTC_MAKE_ARGS=-I$(SRC_PATH)/dtc VPATH=$(SRC_PATH)/dtc -C dtc V="$(V)" LIBFDT_lib=""
230 DTC_CFLAGS=$(CFLAGS) $(QEMU_CFLAGS)
231 DTC_CPPFLAGS=-I$(SRC_PATH)/dtc/libfdt
232
233 .PHONY: dtc/all
234 dtc/all: .git-submodule-status dtc/libfdt
235 $(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,)
236
237 dtc/%: .git-submodule-status
238 @mkdir -p $@
239
240 # Overriding CFLAGS causes us to lose defines added in the sub-makefile.
241 # Not overriding CFLAGS leads to mis-matches between compilation modes.
242 # Therefore we replicate some of the logic in the sub-makefile.
243 # Remove all the extra -Warning flags that QEMU uses that Capstone doesn't;
244 # no need to annoy QEMU developers with such things.
245 CAP_CFLAGS = $(patsubst -W%,,$(CFLAGS) $(QEMU_CFLAGS))
246 CAP_CFLAGS += -DCAPSTONE_USE_SYS_DYN_MEM
247 CAP_CFLAGS += -DCAPSTONE_HAS_ARM
248 CAP_CFLAGS += -DCAPSTONE_HAS_ARM64
249 CAP_CFLAGS += -DCAPSTONE_HAS_POWERPC
250 CAP_CFLAGS += -DCAPSTONE_HAS_X86
251
252 .PHONY: capstone/all
253 capstone/all: .git-submodule-status
254 $(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))
255
256 .PHONY: slirp/all
257 slirp/all: .git-submodule-status
258 $(call quiet-command,$(MAKE) -C $(SRC_PATH)/slirp \
259 BUILD_DIR="$(BUILD_DIR)/slirp" \
260 PKG_CONFIG="$(PKG_CONFIG)" \
261 CC="$(CC)" AR="$(AR)" LD="$(LD)" RANLIB="$(RANLIB)" \
262 CFLAGS="$(QEMU_CFLAGS) $(CFLAGS)" LDFLAGS="$(QEMU_LDFLAGS)")
263
264 $(filter %/all, $(TARGET_DIRS_RULES)): libqemuutil.a $(common-obj-y) \
265 $(qom-obj-y) block.syms qemu.syms
266
267 $(filter %/fuzz, $(TARGET_DIRS_RULES)): libqemuutil.a $(common-obj-y) \
268 $(qom-obj-y) $(crypto-user-obj-$(CONFIG_USER_ONLY))
269
270 ROM_DIRS = $(addprefix pc-bios/, $(ROMS))
271 ROM_DIRS_RULES=$(foreach t, all clean, $(addsuffix /$(t), $(ROM_DIRS)))
272 # Only keep -O and -g cflags
273 .PHONY: $(ROM_DIRS_RULES)
274 $(ROM_DIRS_RULES):
275 $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C $(dir $@) V="$(V)" TARGET_DIR="$(dir $@)" CFLAGS="$(filter -O% -g%,$(CFLAGS))" $(notdir $@),)
276
277 .PHONY: recurse-all recurse-clean recurse-install
278 recurse-all: $(addsuffix /all, $(TARGET_DIRS) $(ROM_DIRS))
279 recurse-clean: $(addsuffix /clean, $(TARGET_DIRS) $(ROM_DIRS))
280 recurse-install: $(addsuffix /install, $(TARGET_DIRS))
281 $(addsuffix /install, $(TARGET_DIRS)): all
282
283 $(BUILD_DIR)/version.o: $(SRC_PATH)/version.rc config-host.h
284 $(call quiet-command,$(WINDRES) -I$(BUILD_DIR) -o $@ $<,"RC","version.o")
285
286 Makefile: $(version-obj-y)
287
288 ######################################################################
289
290 COMMON_LDADDS = libqemuutil.a
291
292 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)
293
294 clean: recurse-clean ninja-clean clean-ctlist
295 -test -f ninjatool && ./ninjatool $(if $(V),-v,) -t clean
296 # avoid old build problems by removing potentially incorrect old files
297 rm -f config.mak op-i386.h opc-i386.h gen-op-i386.h op-arm.h opc-arm.h gen-op-arm.h
298 find . \( -name '*.so' -o -name '*.dll' -o -name '*.mo' -o -name '*.[oda]' \) -type f \
299 ! -path ./roms/edk2/ArmPkg/Library/GccLto/liblto-aarch64.a \
300 ! -path ./roms/edk2/ArmPkg/Library/GccLto/liblto-arm.a \
301 ! -path ./roms/edk2/BaseTools/Source/Python/UPT/Dll/sqlite3.dll \
302 -exec rm {} +
303 rm -f $(filter-out %.tlb,$(TOOLS)) $(HELPERS-y) TAGS cscope.* *.pod *~ */*~
304 rm -f fsdev/*.pod scsi/*.pod
305 rm -f $(foreach f,$(generated-files-y),$(f) $(f)-timestamp)
306
307 VERSION ?= $(shell cat VERSION)
308
309 dist: qemu-$(VERSION).tar.bz2
310
311 qemu-%.tar.bz2:
312 $(SRC_PATH)/scripts/make-release "$(SRC_PATH)" "$(patsubst qemu-%.tar.bz2,%,$@)"
313
314 define clean-manual =
315 rm -rf $(MANUAL_BUILDDIR)/$1/_static
316 rm -f $(MANUAL_BUILDDIR)/$1/objects.inv $(MANUAL_BUILDDIR)/$1/searchindex.js $(MANUAL_BUILDDIR)/$1/*.html
317 endef
318
319 distclean: clean ninja-distclean
320 -test -f ninjatool && ./ninjatool $(if $(V),-v,) -t clean -g
321 rm -f config-host.mak config-host.h* $(DOCS)
322 rm -f tests/tcg/config-*.mak
323 rm -f config-all-disas.mak config.status
324 rm -f po/*.mo tests/qemu-iotests/common.env
325 rm -f roms/seabios/config.mak roms/vgabios/config.mak
326 rm -f qemu-plugins-ld.symbols qemu-plugins-ld64.symbols
327 rm -rf meson-private meson-logs meson-info compile_commands.json
328 rm -f Makefile.ninja ninjatool ninjatool.stamp Makefile.mtest
329 rm -f config.log
330 rm -f linux-headers/asm
331 rm -f docs/version.texi
332 rm -f docs/interop/qemu-ga-qapi.texi docs/interop/qemu-qmp-qapi.texi
333 rm -f docs/interop/qemu-qmp-ref.7 docs/interop/qemu-ga-ref.7
334 rm -f docs/interop/qemu-qmp-ref.txt docs/interop/qemu-ga-ref.txt
335 rm -f docs/interop/qemu-qmp-ref.pdf docs/interop/qemu-ga-ref.pdf
336 rm -f docs/interop/qemu-qmp-ref.html docs/interop/qemu-ga-ref.html
337 rm -rf .doctrees
338 $(call clean-manual,devel)
339 $(call clean-manual,interop)
340 $(call clean-manual,specs)
341 $(call clean-manual,system)
342 $(call clean-manual,tools)
343 $(call clean-manual,user)
344 for d in $(TARGET_DIRS); do \
345 rm -rf $$d || exit 1 ; \
346 done
347 rm -Rf .sdk
348
349 KEYMAPS=da en-gb et fr fr-ch is lt no pt-br sv \
350 ar de en-us fi fr-be hr it lv nl pl ru th \
351 de-ch es fo fr-ca hu ja mk pt sl tr \
352 bepo cz
353
354 ifdef INSTALL_BLOBS
355 BLOBS=bios.bin bios-256k.bin bios-microvm.bin sgabios.bin vgabios.bin vgabios-cirrus.bin \
356 vgabios-stdvga.bin vgabios-vmware.bin vgabios-qxl.bin vgabios-virtio.bin \
357 vgabios-ramfb.bin vgabios-bochs-display.bin vgabios-ati.bin \
358 openbios-sparc32 openbios-sparc64 openbios-ppc QEMU,tcx.bin QEMU,cgthree.bin \
359 pxe-e1000.rom pxe-eepro100.rom pxe-ne2k_pci.rom \
360 pxe-pcnet.rom pxe-rtl8139.rom pxe-virtio.rom \
361 efi-e1000.rom efi-eepro100.rom efi-ne2k_pci.rom \
362 efi-pcnet.rom efi-rtl8139.rom efi-virtio.rom \
363 efi-e1000e.rom efi-vmxnet3.rom \
364 qemu-nsis.bmp \
365 bamboo.dtb canyonlands.dtb petalogix-s3adsp1800.dtb petalogix-ml605.dtb \
366 multiboot.bin linuxboot.bin linuxboot_dma.bin kvmvapic.bin pvh.bin \
367 s390-ccw.img s390-netboot.img \
368 slof.bin skiboot.lid \
369 palcode-clipper \
370 u-boot.e500 u-boot-sam460-20100605.bin \
371 qemu_vga.ndrv \
372 edk2-licenses.txt \
373 hppa-firmware.img \
374 opensbi-riscv32-sifive_u-fw_jump.bin opensbi-riscv32-virt-fw_jump.bin \
375 opensbi-riscv64-sifive_u-fw_jump.bin opensbi-riscv64-virt-fw_jump.bin
376 else
377 BLOBS=
378 endif
379
380 # Note that we manually filter-out the non-Sphinx documentation which
381 # is currently built into the docs/interop directory in the build tree,
382 # and also any sphinx-built manpages.
383 define install-manual =
384 for d in $$(cd $(MANUAL_BUILDDIR) && find $1 -type d); do $(INSTALL_DIR) "$(DESTDIR)$(qemu_docdir)/$$d"; done
385 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
386 endef
387
388 # Note that we deliberately do not install the "devel" manual: it is
389 # for QEMU developers, and not interesting to our users.
390 .PHONY: install-sphinxdocs
391 install-sphinxdocs: sphinxdocs
392 $(call install-manual,interop)
393 $(call install-manual,specs)
394 $(call install-manual,system)
395 $(call install-manual,tools)
396 $(call install-manual,user)
397
398 install-doc: $(DOCS) install-sphinxdocs
399 $(INSTALL_DIR) "$(DESTDIR)$(qemu_docdir)"
400 $(INSTALL_DATA) $(MANUAL_BUILDDIR)/index.html "$(DESTDIR)$(qemu_docdir)"
401 $(INSTALL_DIR) "$(DESTDIR)$(qemu_docdir)/interop"
402 $(INSTALL_DATA) docs/interop/qemu-qmp-ref.html "$(DESTDIR)$(qemu_docdir)/interop"
403 $(INSTALL_DATA) docs/interop/qemu-qmp-ref.txt "$(DESTDIR)$(qemu_docdir)/interop"
404 ifdef CONFIG_POSIX
405 $(INSTALL_DIR) "$(DESTDIR)$(mandir)/man1"
406 $(INSTALL_DATA) $(MANUAL_BUILDDIR)/system/qemu.1 "$(DESTDIR)$(mandir)/man1"
407 $(INSTALL_DIR) "$(DESTDIR)$(mandir)/man7"
408 $(INSTALL_DATA) docs/interop/qemu-qmp-ref.7 "$(DESTDIR)$(mandir)/man7"
409 $(INSTALL_DATA) $(MANUAL_BUILDDIR)/system/qemu-block-drivers.7 "$(DESTDIR)$(mandir)/man7"
410 $(INSTALL_DATA) $(MANUAL_BUILDDIR)/system/qemu-cpu-models.7 "$(DESTDIR)$(mandir)/man7"
411 ifeq ($(CONFIG_TOOLS),y)
412 $(INSTALL_DATA) $(MANUAL_BUILDDIR)/tools/qemu-img.1 "$(DESTDIR)$(mandir)/man1"
413 $(INSTALL_DIR) "$(DESTDIR)$(mandir)/man8"
414 $(INSTALL_DATA) $(MANUAL_BUILDDIR)/tools/qemu-nbd.8 "$(DESTDIR)$(mandir)/man8"
415 endif
416 ifdef CONFIG_TRACE_SYSTEMTAP
417 $(INSTALL_DATA) $(MANUAL_BUILDDIR)/tools/qemu-trace-stap.1 "$(DESTDIR)$(mandir)/man1"
418 endif
419 ifeq ($(CONFIG_GUEST_AGENT),y)
420 $(INSTALL_DATA) $(MANUAL_BUILDDIR)/interop/qemu-ga.8 "$(DESTDIR)$(mandir)/man8"
421 $(INSTALL_DIR) "$(DESTDIR)$(qemu_docdir)/interop"
422 $(INSTALL_DATA) docs/interop/qemu-ga-ref.html "$(DESTDIR)$(qemu_docdir)/interop"
423 $(INSTALL_DATA) docs/interop/qemu-ga-ref.txt "$(DESTDIR)$(qemu_docdir)/interop"
424 $(INSTALL_DATA) docs/interop/qemu-ga-ref.7 "$(DESTDIR)$(mandir)/man7"
425 endif
426 endif
427 ifdef CONFIG_VIRTFS
428 $(INSTALL_DIR) "$(DESTDIR)$(mandir)/man1"
429 $(INSTALL_DATA) $(MANUAL_BUILDDIR)/tools/virtfs-proxy-helper.1 "$(DESTDIR)$(mandir)/man1"
430 endif
431 ifeq ($(CONFIG_LINUX)$(CONFIG_SECCOMP)$(CONFIG_LIBCAP_NG),yyy)
432 $(INSTALL_DATA) $(MANUAL_BUILDDIR)/tools/virtiofsd.1 "$(DESTDIR)$(mandir)/man1"
433 endif
434
435 install-datadir:
436 $(INSTALL_DIR) "$(DESTDIR)$(qemu_datadir)"
437
438 install-localstatedir:
439 ifdef CONFIG_POSIX
440 ifeq ($(CONFIG_GUEST_AGENT),y)
441 $(INSTALL_DIR) "$(DESTDIR)$(qemu_localstatedir)"/run
442 endif
443 endif
444
445 ICON_SIZES=16x16 24x24 32x32 48x48 64x64 128x128 256x256 512x512
446
447 install-includedir:
448 $(INSTALL_DIR) "$(DESTDIR)$(includedir)"
449
450 # Needed by "meson install"
451 export DESTDIR
452 install: all $(if $(BUILD_DOCS),install-doc) \
453 install-datadir install-localstatedir install-includedir \
454 recurse-install
455 ifneq ($(TOOLS),)
456 $(call install-prog,$(TOOLS),$(DESTDIR)$(bindir))
457 endif
458 ifneq ($(HELPERS-y),)
459 $(call install-prog,$(HELPERS-y),$(DESTDIR)$(libexecdir))
460 endif
461 ifdef CONFIG_TRACE_SYSTEMTAP
462 $(INSTALL_PROG) "scripts/qemu-trace-stap" $(DESTDIR)$(bindir)
463 endif
464 ifneq ($(BLOBS),)
465 set -e; for x in $(BLOBS); do \
466 $(INSTALL_DATA) $(SRC_PATH)/pc-bios/$$x "$(DESTDIR)$(qemu_datadir)"; \
467 done
468 endif
469 for s in $(ICON_SIZES); do \
470 mkdir -p "$(DESTDIR)$(qemu_icondir)/hicolor/$${s}/apps"; \
471 $(INSTALL_DATA) $(SRC_PATH)/ui/icons/qemu_$${s}.png \
472 "$(DESTDIR)$(qemu_icondir)/hicolor/$${s}/apps/qemu.png"; \
473 done; \
474 mkdir -p "$(DESTDIR)$(qemu_icondir)/hicolor/32x32/apps"; \
475 $(INSTALL_DATA) $(SRC_PATH)/ui/icons/qemu_32x32.bmp \
476 "$(DESTDIR)$(qemu_icondir)/hicolor/32x32/apps/qemu.bmp"; \
477 mkdir -p "$(DESTDIR)$(qemu_icondir)/hicolor/scalable/apps"; \
478 $(INSTALL_DATA) $(SRC_PATH)/ui/icons/qemu.svg \
479 "$(DESTDIR)$(qemu_icondir)/hicolor/scalable/apps/qemu.svg"
480 mkdir -p "$(DESTDIR)$(qemu_desktopdir)"
481 $(INSTALL_DATA) $(SRC_PATH)/ui/qemu.desktop \
482 "$(DESTDIR)$(qemu_desktopdir)/qemu.desktop"
483 ifdef CONFIG_GTK
484 $(MAKE) -C po $@
485 endif
486 ifeq ($(CONFIG_PLUGIN),y)
487 $(INSTALL_DATA) $(SRC_PATH)/include/qemu/qemu-plugin.h "$(DESTDIR)$(includedir)/qemu-plugin.h"
488 endif
489 $(INSTALL_DIR) "$(DESTDIR)$(qemu_datadir)/keymaps"
490 set -e; for x in $(KEYMAPS); do \
491 $(INSTALL_DATA) $(SRC_PATH)/pc-bios/keymaps/$$x "$(DESTDIR)$(qemu_datadir)/keymaps"; \
492 done
493 for d in $(TARGET_DIRS); do \
494 $(MAKE) $(SUBDIR_MAKEFLAGS) TARGET_DIR=$$d/ -C $$d $@ || exit 1 ; \
495 done
496
497 # documentation
498 MAKEINFO=makeinfo
499 MAKEINFOINCLUDES= -I docs -I $(<D) -I $(@D)
500 MAKEINFOFLAGS=--no-split --number-sections $(MAKEINFOINCLUDES)
501 TEXI2PODFLAGS=$(MAKEINFOINCLUDES) -DVERSION="$(VERSION)" -DCONFDIR="$(qemu_confdir)"
502 TEXI2PDFFLAGS=$(if $(V),,--quiet) -I $(SRC_PATH) $(MAKEINFOINCLUDES)
503
504 docs/version.texi: $(SRC_PATH)/VERSION config-host.mak
505 $(call quiet-command,(\
506 echo "@set VERSION $(VERSION)" && \
507 echo "@set CONFDIR $(qemu_confdir)" \
508 )> $@,"GEN","$@")
509
510 %.html: %.texi docs/version.texi
511 $(call quiet-command,LC_ALL=C $(MAKEINFO) $(MAKEINFOFLAGS) --no-headers \
512 --html $< -o $@,"GEN","$@")
513
514 %.info: %.texi docs/version.texi
515 $(call quiet-command,$(MAKEINFO) $(MAKEINFOFLAGS) $< -o $@,"GEN","$@")
516
517 %.txt: %.texi docs/version.texi
518 $(call quiet-command,LC_ALL=C $(MAKEINFO) $(MAKEINFOFLAGS) --no-headers \
519 --plaintext $< -o $@,"GEN","$@")
520
521 %.pdf: %.texi docs/version.texi
522 $(call quiet-command,texi2pdf $(TEXI2PDFFLAGS) $< -o $@,"GEN","$@")
523
524 # Sphinx builds all its documentation at once in one invocation
525 # and handles "don't rebuild things unless necessary" itself.
526 # The '.doctrees' files are cached information to speed this up.
527 .PHONY: sphinxdocs
528 sphinxdocs: $(MANUAL_BUILDDIR)/devel/index.html \
529 $(MANUAL_BUILDDIR)/interop/index.html \
530 $(MANUAL_BUILDDIR)/specs/index.html \
531 $(MANUAL_BUILDDIR)/system/index.html \
532 $(MANUAL_BUILDDIR)/tools/index.html \
533 $(MANUAL_BUILDDIR)/user/index.html
534
535 # Canned command to build a single manual
536 # Arguments: $1 = manual name, $2 = Sphinx builder ('html' or 'man')
537 # Note the use of different doctree for each (manual, builder) tuple;
538 # this works around Sphinx not handling parallel invocation on
539 # a single doctree: https://github.com/sphinx-doc/sphinx/issues/2946
540 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")
541 # We assume all RST files in the manual's directory are used in it
542 manual-deps = $(wildcard $(SRC_PATH)/docs/$1/*.rst $(SRC_PATH)/docs/$1/*/*.rst) \
543 $(SRC_PATH)/docs/defs.rst.inc \
544 $(SRC_PATH)/docs/$1/conf.py $(SRC_PATH)/docs/conf.py \
545 $(SRC_PATH)/docs/sphinx/*.py
546 # Macro to write out the rule and dependencies for building manpages
547 # Usage: $(call define-manpage-rule,manualname,manpage1 manpage2...[,extradeps])
548 # 'extradeps' is optional, and specifies extra files (eg .hx files) that
549 # the manual page depends on.
550 define define-manpage-rule
551 $(call atomic,$(foreach manpage,$2,$(MANUAL_BUILDDIR)/$1/$(manpage)),$(call manual-deps,$1) $3)
552 $(call build-manual,$1,man)
553 endef
554
555 $(MANUAL_BUILDDIR)/devel/index.html: $(call manual-deps,devel)
556 $(call build-manual,devel,html)
557
558 $(MANUAL_BUILDDIR)/interop/index.html: $(call manual-deps,interop)
559 $(call build-manual,interop,html)
560
561 $(MANUAL_BUILDDIR)/specs/index.html: $(call manual-deps,specs)
562 $(call build-manual,specs,html)
563
564 $(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
565 $(call build-manual,system,html)
566
567 $(MANUAL_BUILDDIR)/tools/index.html: $(call manual-deps,tools) $(SRC_PATH)/qemu-img-cmds.hx $(SRC_PATH)/docs/qemu-option-trace.rst.inc
568 $(call build-manual,tools,html)
569
570 $(MANUAL_BUILDDIR)/user/index.html: $(call manual-deps,user)
571 $(call build-manual,user,html)
572
573 $(call define-manpage-rule,interop,qemu-ga.8)
574
575 $(call define-manpage-rule,system,qemu.1 qemu-block-drivers.7 qemu-cpu-models.7)
576
577 $(call define-manpage-rule,tools,\
578 qemu-img.1 qemu-nbd.8 qemu-trace-stap.1\
579 virtiofsd.1 virtfs-proxy-helper.1,\
580 $(SRC_PATH)/qemu-img-cmds.hx $(SRC_PATH)/docs/qemu-option-trace.rst.inc)
581
582 $(MANUAL_BUILDDIR)/index.html: $(SRC_PATH)/docs/index.html.in qemu-version.h
583 @mkdir -p "$(MANUAL_BUILDDIR)"
584 $(call quiet-command, sed "s|@@VERSION@@|${VERSION}|g" $< >$@, \
585 "GEN","$@")
586
587 docs/interop/qemu-qmp-qapi.texi: qapi/qapi-doc.texi
588 @cp -p $< $@
589
590 docs/interop/qemu-ga-qapi.texi: qga/qga-qapi-doc.texi
591 @cp -p $< $@
592
593 html: docs/interop/qemu-qmp-ref.html docs/interop/qemu-ga-ref.html sphinxdocs
594 info: docs/interop/qemu-qmp-ref.info docs/interop/qemu-ga-ref.info
595 pdf: docs/interop/qemu-qmp-ref.pdf docs/interop/qemu-ga-ref.pdf
596 txt: docs/interop/qemu-qmp-ref.txt docs/interop/qemu-ga-ref.txt
597
598 docs/interop/qemu-ga-ref.dvi docs/interop/qemu-ga-ref.html \
599 docs/interop/qemu-ga-ref.info docs/interop/qemu-ga-ref.pdf \
600 docs/interop/qemu-ga-ref.txt docs/interop/qemu-ga-ref.7: \
601 docs/interop/qemu-ga-ref.texi docs/interop/qemu-ga-qapi.texi
602
603 docs/interop/qemu-qmp-ref.dvi docs/interop/qemu-qmp-ref.html \
604 docs/interop/qemu-qmp-ref.info docs/interop/qemu-qmp-ref.pdf \
605 docs/interop/qemu-qmp-ref.txt docs/interop/qemu-qmp-ref.7: \
606 docs/interop/qemu-qmp-ref.texi docs/interop/qemu-qmp-qapi.texi
607
608 $(filter %.1 %.7 %.8,$(DOCS)): scripts/texi2pod.pl
609
610 # Reports/Analysis
611
612 %/coverage-report.html:
613 @mkdir -p $*
614 $(call quiet-command,\
615 gcovr -r $(SRC_PATH) \
616 $(foreach t, $(TARGET_DIRS), --object-directory $(BUILD_DIR)/$(t)) \
617 --object-directory $(BUILD_DIR) \
618 -p --html --html-details -o $@, \
619 "GEN", "coverage-report.html")
620
621 .PHONY: coverage-report
622 coverage-report: $(CURDIR)/reports/coverage/coverage-report.html
623
624 ifdef CONFIG_WIN32
625
626 INSTALLER = qemu-setup-$(VERSION)$(EXESUF)
627
628 nsisflags = -V2 -NOCD
629
630 ifneq ($(wildcard $(SRC_PATH)/dll),)
631 ifeq ($(ARCH),x86_64)
632 # 64 bit executables
633 DLL_PATH = $(SRC_PATH)/dll/w64
634 nsisflags += -DW64
635 else
636 # 32 bit executables
637 DLL_PATH = $(SRC_PATH)/dll/w32
638 endif
639 endif
640
641 .PHONY: installer
642 installer: $(INSTALLER)
643
644 INSTDIR=/tmp/qemu-nsis
645
646 $(INSTALLER): $(SRC_PATH)/qemu.nsi
647 $(MAKE) install DESTDIR=${INSTDIR}
648 ifdef SIGNCODE
649 (cd ${INSTDIR}/${bindir}; \
650 for i in *.exe; do \
651 $(SIGNCODE) $${i}; \
652 done \
653 )
654 endif # SIGNCODE
655 (cd ${INSTDIR}/${bindir}; \
656 for i in qemu-system-*.exe; do \
657 arch=$${i%.exe}; \
658 arch=$${arch#qemu-system-}; \
659 echo Section \"$$arch\" Section_$$arch; \
660 echo SetOutPath \"\$$INSTDIR\"; \
661 echo File \"\$${BINDIR}\\$$i\"; \
662 echo SectionEnd; \
663 done \
664 ) >${INSTDIR}/${bindir}/system-emulations.nsh
665 makensis $(nsisflags) \
666 $(if $(BUILD_DOCS),-DCONFIG_DOCUMENTATION="y") \
667 $(if $(CONFIG_GTK),-DCONFIG_GTK="y") \
668 -DBINDIR="${INSTDIR}/${bindir}" \
669 $(if $(DLL_PATH),-DDLLDIR="$(DLL_PATH)") \
670 -DSRCDIR="$(SRC_PATH)" \
671 -DOUTFILE="$(INSTALLER)" \
672 -DDISPLAYVERSION="$(VERSION)" \
673 $(SRC_PATH)/qemu.nsi
674 rm -r ${INSTDIR}
675 ifdef SIGNCODE
676 $(SIGNCODE) $(INSTALLER)
677 endif # SIGNCODE
678 endif # CONFIG_WIN
679
680 # Add a dependency on the generated files, so that they are always
681 # rebuilt before other object files
682 ifneq ($(wildcard config-host.mak),)
683 ifneq ($(filter-out $(UNCHECKED_GOALS),$(MAKECMDGOALS)),$(if $(MAKECMDGOALS),,fail))
684 Makefile: $(generated-files-y)
685 endif
686 endif
687
688 # Include automatically generated dependency files
689 # Dependencies in Makefile.objs files come from our recursive subdir rules
690 -include $(wildcard *.d tests/*.d)
691
692 include $(SRC_PATH)/tests/docker/Makefile.include
693 include $(SRC_PATH)/tests/vm/Makefile.include
694
695 print-help-run = printf " %-30s - %s\\n" "$1" "$2"
696 print-help = $(quiet-@)$(call print-help-run,$1,$2)
697
698 .PHONY: help
699 help:
700 @echo 'Generic targets:'
701 $(call print-help,all,Build all)
702 ifdef CONFIG_MODULES
703 $(call print-help,modules,Build all modules)
704 endif
705 $(call print-help,dir/file.o,Build specified target only)
706 $(call print-help,install,Install QEMU, documentation and tools)
707 $(call print-help,ctags/TAGS,Generate tags file for editors)
708 $(call print-help,cscope,Generate cscope index)
709 $(call print-help,sparse,Run sparse on the QEMU source)
710 @echo ''
711 @$(if $(TARGET_DIRS), \
712 echo 'Architecture specific targets:'; \
713 $(foreach t, $(TARGET_DIRS), \
714 $(call print-help-run,$(t)/all,Build for $(t)); \
715 $(if $(CONFIG_FUZZ), \
716 $(if $(findstring softmmu,$(t)), \
717 $(call print-help-run,$(t)/fuzz,Build fuzzer for $(t)); \
718 ))) \
719 echo '')
720 @$(if $(HELPERS-y), \
721 echo 'Helper targets:'; \
722 $(foreach t, $(HELPERS-y), \
723 $(call print-help-run,$(t),Build $(shell basename $(t)));) \
724 echo '')
725 @$(if $(TOOLS), \
726 echo 'Tools targets:'; \
727 $(foreach t, $(TOOLS), \
728 $(call print-help-run,$(t),Build $(shell basename $(t)) tool);) \
729 echo '')
730 @echo 'Cleaning targets:'
731 $(call print-help,clean,Remove most generated files but keep the config)
732 $(call print-help,distclean,Remove all generated files)
733 $(call print-help,dist,Build a distributable tarball)
734 @echo ''
735 @echo 'Test targets:'
736 $(call print-help,check,Run all tests (check-help for details))
737 $(call print-help,docker,Help about targets running tests inside containers)
738 $(call print-help,vm-help,Help about targets running tests inside VM)
739 @echo ''
740 @echo 'Documentation targets:'
741 $(call print-help,html info pdf txt,Build documentation in specified format)
742 @echo ''
743 ifdef CONFIG_WIN32
744 @echo 'Windows targets:'
745 $(call print-help,installer,Build NSIS-based installer for QEMU)
746 ifdef QEMU_GA_MSI_ENABLED
747 $(call print-help,msi,Build MSI-based installer for qemu-ga)
748 endif
749 @echo ''
750 endif
751 $(call print-help,$(MAKE) [targets],(quiet build, default))
752 $(call print-help,$(MAKE) V=1 [targets],(verbose build))