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