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