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