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