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