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