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