meson: convert target/s390x/gen-features.h
[qemu.git] / Makefile
1 # Makefile for QEMU.
2
3 ifneq ($(words $(subst :, ,$(CURDIR))), 1)
4 $(error main directory cannot contain spaces nor colons)
5 endif
6
7 # Always point to the root of the build tree (needs GNU make).
8 BUILD_DIR=$(CURDIR)
9
10 # Before including a proper config-host.mak, assume we are in the source tree
11 SRC_PATH=.
12
13 UNCHECKED_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
19 ifneq ($(wildcard config-host.mak),)
20 # Put the all: rule here so that config-host.mak can contain dependencies.
21 all:
22 include config-host.mak
23
24 git-submodule-update:
25
26 .PHONY: git-submodule-update
27
28 git_module_status := $(shell \
29 cd '$(SRC_PATH)' && \
30 GIT="$(GIT)" ./scripts/git-submodule.sh status $(GIT_SUBMODULES); \
31 echo $$?; \
32 )
33
34 ifeq (1,$(git_module_status))
35 ifeq (no,$(GIT_UPDATE))
36 git-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)
44 else
45 git-submodule-update:
46 $(call quiet-command, \
47 (cd $(SRC_PATH) && GIT="$(GIT)" ./scripts/git-submodule.sh update $(GIT_SUBMODULES)), \
48 "GIT","$(GIT_SUBMODULES)")
49 endif
50 endif
51
52 export NINJA=./ninjatool
53
54 # Running meson regenerates both build.ninja and ninjatool, and that is
55 # enough to prime the rest of the build.
56 ninjatool: build.ninja
57
58 # Only needed in case Makefile.ninja does not exist.
59 .PHONY: ninja-clean ninja-distclean clean-ctlist
60 clean-ctlist:
61 ninja-clean::
62 ninja-distclean::
63 build.ninja: config-host.mak
64
65 Makefile.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).
73 ifneq ($(MESON),)
74 Makefile.mtest: build.ninja scripts/mtest2make.py
75 $(MESON) introspect --tests | $(PYTHON) scripts/mtest2make.py > $@
76 -include Makefile.mtest
77 endif
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.
83 ifneq ($(realpath $(SRC_PATH)),$(realpath .))
84 ifneq ($(wildcard $(SRC_PATH)/config-host.mak),)
85 $(error This is an out of tree build but your source tree ($(SRC_PATH)) \
86 seems 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)
88 endif
89 endif
90
91 CONFIG_SOFTMMU := $(if $(filter %-softmmu,$(TARGET_DIRS)),y)
92 CONFIG_USER_ONLY := $(if $(filter %-user,$(TARGET_DIRS)),y)
93 CONFIG_XEN := $(CONFIG_XEN_BACKEND)
94 CONFIG_ALL=y
95 -include config-all-devices.mak
96 -include config-all-disas.mak
97
98 config-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
107 ifeq ($(CONFIG_PLUGIN),y)
108 config-host.mak: $(SRC_PATH)/plugins/qemu-plugins.symbols
109 endif
110
111 else
112 config-host.mak:
113 ifneq ($(filter-out $(UNCHECKED_GOALS),$(MAKECMDGOALS)),$(if $(MAKECMDGOALS),,fail))
114 @echo "Please call configure before running make!"
115 @exit 1
116 endif
117 endif
118
119 include $(SRC_PATH)/rules.mak
120
121 # lor is defined in rules.mak
122 CONFIG_BLOCK := $(call lor,$(CONFIG_SOFTMMU),$(CONFIG_TOOLS))
123
124 generated-files-y = config-host.h
125
126 generated-files-y += module_block.h
127 generated-files-y += target/s390x/gen-features.h
128 target/s390x/gen-features.h: Makefile.ninja
129
130 generated-files-y += .git-submodule-status
131
132 # Don't try to regenerate Makefile or configure
133 # We don't generate any of them
134 Makefile: ;
135 configure: ;
136
137 .PHONY: all clean cscope distclean html info install install-doc \
138 pdf txt recurse-all dist msi FORCE
139
140 $(call set-vpath, $(SRC_PATH))
141
142 LIBS+=-lz $(LIBS_TOOLS)
143
144 HELPERS-y = $(HELPERS)
145
146 # Sphinx does not allow building manuals into the same directory as
147 # the source files, so if we're doing an in-tree QEMU build we must
148 # build the manuals into a subdirectory (and then install them from
149 # there for 'make install'). For an out-of-tree build we can just
150 # use the docs/ subdirectory in the build tree as normal.
151 ifeq ($(realpath $(SRC_PATH)),$(realpath .))
152 MANUAL_BUILDDIR := docs/built
153 else
154 MANUAL_BUILDDIR := docs
155 endif
156
157 ifdef BUILD_DOCS
158 DOCS+=$(MANUAL_BUILDDIR)/system/qemu.1
159 DOCS+=$(MANUAL_BUILDDIR)/tools/qemu-img.1
160 DOCS+=$(MANUAL_BUILDDIR)/tools/qemu-nbd.8
161 DOCS+=$(MANUAL_BUILDDIR)/interop/qemu-ga.8
162 ifeq ($(CONFIG_LINUX)$(CONFIG_SECCOMP)$(CONFIG_LIBCAP_NG),yyy)
163 DOCS+=$(MANUAL_BUILDDIR)/tools/virtiofsd.1
164 endif
165 DOCS+=$(MANUAL_BUILDDIR)/system/qemu-block-drivers.7
166 DOCS+=docs/interop/qemu-qmp-ref.html docs/interop/qemu-qmp-ref.txt docs/interop/qemu-qmp-ref.7
167 DOCS+=docs/interop/qemu-ga-ref.html docs/interop/qemu-ga-ref.txt docs/interop/qemu-ga-ref.7
168 DOCS+=$(MANUAL_BUILDDIR)/system/qemu-cpu-models.7
169 DOCS+=$(MANUAL_BUILDDIR)/index.html
170 ifdef CONFIG_VIRTFS
171 DOCS+=$(MANUAL_BUILDDIR)/tools/virtfs-proxy-helper.1
172 endif
173 ifdef CONFIG_TRACE_SYSTEMTAP
174 DOCS+=$(MANUAL_BUILDDIR)/tools/qemu-trace-stap.1
175 endif
176 else
177 DOCS=
178 endif
179
180 SUBDIR_MAKEFLAGS=$(if $(V),,--no-print-directory --quiet) BUILD_DIR=$(BUILD_DIR)
181 SUBDIR_DEVICES_MAK=$(patsubst %, %/config-devices.mak, $(filter %-softmmu, $(TARGET_DIRS)))
182 SUBDIR_DEVICES_MAK_DEP=$(patsubst %, %.d, $(SUBDIR_DEVICES_MAK))
183
184 ifeq ($(SUBDIR_DEVICES_MAK),)
185 config-all-devices.mak: config-host.mak
186 $(call quiet-command,echo '# no devices' > $@,"GEN","$@")
187 else
188 config-all-devices.mak: $(SUBDIR_DEVICES_MAK) config-host.mak
189 $(call quiet-command, sed -n \
190 's|^\([^=]*\)=\(.*\)$$|\1:=$$(findstring y,$$(\1)\2)|p' \
191 $(SUBDIR_DEVICES_MAK) | sort -u > $@, \
192 "GEN","$@")
193 endif
194
195 -include $(SUBDIR_DEVICES_MAK_DEP)
196
197 # This has to be kept in sync with Kconfig.host.
198 MINIKCONF_ARGS = \
199 $(CONFIG_MINIKCONF_MODE) \
200 $@ $*/config-devices.mak.d $< $(SRC_PATH)/Kconfig \
201 CONFIG_TCG=$(CONFIG_TCG) \
202 CONFIG_KVM=$(CONFIG_KVM) \
203 CONFIG_SPICE=$(CONFIG_SPICE) \
204 CONFIG_IVSHMEM=$(CONFIG_IVSHMEM) \
205 CONFIG_TPM=$(CONFIG_TPM) \
206 CONFIG_XEN=$(CONFIG_XEN) \
207 CONFIG_OPENGL=$(CONFIG_OPENGL) \
208 CONFIG_X11=$(CONFIG_X11) \
209 CONFIG_VHOST_USER=$(CONFIG_VHOST_USER) \
210 CONFIG_VHOST_KERNEL=$(CONFIG_VHOST_KERNEL) \
211 CONFIG_VIRTFS=$(CONFIG_VIRTFS) \
212 CONFIG_LINUX=$(CONFIG_LINUX) \
213 CONFIG_PVRDMA=$(CONFIG_PVRDMA)
214
215 MINIKCONF = $(PYTHON) $(SRC_PATH)/scripts/minikconf.py
216
217 $(SUBDIR_DEVICES_MAK): %/config-devices.mak: default-configs/%.mak $(SRC_PATH)/Kconfig $(BUILD_DIR)/config-host.mak
218 $(call quiet-command, $(MINIKCONF) $(MINIKCONF_ARGS) \
219 > $@.tmp, "GEN", "$@.tmp")
220 $(call quiet-command, if test -f $@; then \
221 if cmp -s $@.old $@; then \
222 mv $@.tmp $@; \
223 cp -p $@ $@.old; \
224 else \
225 if test -f $@.old; then \
226 echo "WARNING: $@ (user modified) out of date.";\
227 else \
228 echo "WARNING: $@ out of date.";\
229 fi; \
230 echo "Run \"$(MAKE) defconfig\" to regenerate."; \
231 rm $@.tmp; \
232 fi; \
233 else \
234 mv $@.tmp $@; \
235 cp -p $@ $@.old; \
236 fi,"GEN","$@");
237
238 defconfig:
239 rm -f config-all-devices.mak $(SUBDIR_DEVICES_MAK)
240
241 ifneq ($(wildcard config-host.mak),)
242 include $(SRC_PATH)/Makefile.objs
243 endif
244
245 dummy := $(call unnest-vars,, \
246 chardev-obj-y \
247 block-obj-y \
248 block-obj-m \
249 storage-daemon-obj-y \
250 storage-daemon-obj-m \
251 common-obj-y \
252 common-obj-m)
253
254 include $(SRC_PATH)/tests/Makefile.include
255
256 all: $(DOCS) $(if $(BUILD_DOCS),sphinxdocs) $(TOOLS) $(HELPERS-y) recurse-all modules
257
258 config-host.h: config-host.h-timestamp
259 config-host.h-timestamp: config-host.mak
260
261 TARGET_DIRS_RULES := $(foreach t, all fuzz clean install, $(addsuffix /$(t), $(TARGET_DIRS)))
262
263 SOFTMMU_ALL_RULES=$(filter %-softmmu/all, $(TARGET_DIRS_RULES))
264 $(SOFTMMU_ALL_RULES): $(authz-obj-y)
265 $(SOFTMMU_ALL_RULES): $(block-obj-y)
266 $(SOFTMMU_ALL_RULES): $(storage-daemon-obj-y)
267 $(SOFTMMU_ALL_RULES): $(chardev-obj-y)
268 $(SOFTMMU_ALL_RULES): $(crypto-obj-y)
269 $(SOFTMMU_ALL_RULES): $(io-obj-y)
270 $(SOFTMMU_ALL_RULES): $(qom-obj-y)
271 $(SOFTMMU_ALL_RULES): config-all-devices.mak
272
273 SOFTMMU_FUZZ_RULES=$(filter %-softmmu/fuzz, $(TARGET_DIRS_RULES))
274 $(SOFTMMU_FUZZ_RULES): $(authz-obj-y)
275 $(SOFTMMU_FUZZ_RULES): $(block-obj-y)
276 $(SOFTMMU_FUZZ_RULES): $(chardev-obj-y)
277 $(SOFTMMU_FUZZ_RULES): $(crypto-obj-y)
278 $(SOFTMMU_FUZZ_RULES): $(io-obj-y)
279 $(SOFTMMU_FUZZ_RULES): config-all-devices.mak
280 $(SOFTMMU_FUZZ_RULES): $(edk2-decompressed)
281
282 .PHONY: $(TARGET_DIRS_RULES)
283 # The $(TARGET_DIRS_RULES) are of the form SUBDIR/GOAL, so that
284 # $(dir $@) yields the sub-directory, and $(notdir $@) yields the sub-goal
285 $(TARGET_DIRS_RULES):
286 $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C $(dir $@) V="$(V)" TARGET_DIR="$(dir $@)" $(notdir $@),)
287
288 # LIBFDT_lib="": avoid breaking existing trees with objects requiring -fPIC
289 DTC_MAKE_ARGS=-I$(SRC_PATH)/dtc VPATH=$(SRC_PATH)/dtc -C dtc V="$(V)" LIBFDT_lib=""
290 DTC_CFLAGS=$(CFLAGS) $(QEMU_CFLAGS)
291 DTC_CPPFLAGS=-I$(SRC_PATH)/dtc/libfdt
292
293 .PHONY: dtc/all
294 dtc/all: .git-submodule-status dtc/libfdt
295 $(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,)
296
297 dtc/%: .git-submodule-status
298 @mkdir -p $@
299
300 # Overriding CFLAGS causes us to lose defines added in the sub-makefile.
301 # Not overriding CFLAGS leads to mis-matches between compilation modes.
302 # Therefore we replicate some of the logic in the sub-makefile.
303 # Remove all the extra -Warning flags that QEMU uses that Capstone doesn't;
304 # no need to annoy QEMU developers with such things.
305 CAP_CFLAGS = $(patsubst -W%,,$(CFLAGS) $(QEMU_CFLAGS))
306 CAP_CFLAGS += -DCAPSTONE_USE_SYS_DYN_MEM
307 CAP_CFLAGS += -DCAPSTONE_HAS_ARM
308 CAP_CFLAGS += -DCAPSTONE_HAS_ARM64
309 CAP_CFLAGS += -DCAPSTONE_HAS_POWERPC
310 CAP_CFLAGS += -DCAPSTONE_HAS_X86
311
312 .PHONY: capstone/all
313 capstone/all: .git-submodule-status
314 $(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))
315
316 .PHONY: slirp/all
317 slirp/all: .git-submodule-status
318 $(call quiet-command,$(MAKE) -C $(SRC_PATH)/slirp \
319 BUILD_DIR="$(BUILD_DIR)/slirp" \
320 PKG_CONFIG="$(PKG_CONFIG)" \
321 CC="$(CC)" AR="$(AR)" LD="$(LD)" RANLIB="$(RANLIB)" \
322 CFLAGS="$(QEMU_CFLAGS) $(CFLAGS)" LDFLAGS="$(QEMU_LDFLAGS)")
323
324 $(filter %/all, $(TARGET_DIRS_RULES)): libqemuutil.a $(common-obj-y) \
325 $(qom-obj-y)
326
327 $(filter %/fuzz, $(TARGET_DIRS_RULES)): libqemuutil.a $(common-obj-y) \
328 $(qom-obj-y) $(crypto-user-obj-$(CONFIG_USER_ONLY))
329
330 ROM_DIRS = $(addprefix pc-bios/, $(ROMS))
331 ROM_DIRS_RULES=$(foreach t, all clean, $(addsuffix /$(t), $(ROM_DIRS)))
332 # Only keep -O and -g cflags
333 .PHONY: $(ROM_DIRS_RULES)
334 $(ROM_DIRS_RULES):
335 $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C $(dir $@) V="$(V)" TARGET_DIR="$(dir $@)" CFLAGS="$(filter -O% -g%,$(CFLAGS))" $(notdir $@),)
336
337 .PHONY: recurse-all recurse-clean recurse-install
338 recurse-all: $(addsuffix /all, $(TARGET_DIRS) $(ROM_DIRS))
339 recurse-clean: $(addsuffix /clean, $(TARGET_DIRS) $(ROM_DIRS))
340 recurse-install: $(addsuffix /install, $(TARGET_DIRS))
341 $(addsuffix /install, $(TARGET_DIRS)): all
342
343 $(BUILD_DIR)/version.o: $(SRC_PATH)/version.rc config-host.h
344 $(call quiet-command,$(WINDRES) -I$(BUILD_DIR) -o $@ $<,"RC","version.o")
345
346 Makefile: $(version-obj-y)
347
348 ######################################################################
349
350 COMMON_LDADDS = libqemuutil.a
351
352 qemu-img.o: qemu-img-cmds.h
353
354 qemu-img$(EXESUF): qemu-img.o $(authz-obj-y) $(block-obj-y) $(crypto-obj-y) $(io-obj-y) $(qom-obj-y) $(COMMON_LDADDS)
355 qemu-nbd$(EXESUF): qemu-nbd.o $(authz-obj-y) $(block-obj-y) $(crypto-obj-y) $(io-obj-y) $(qom-obj-y) $(COMMON_LDADDS)
356 qemu-io$(EXESUF): qemu-io.o $(authz-obj-y) $(block-obj-y) $(crypto-obj-y) $(io-obj-y) $(qom-obj-y) $(COMMON_LDADDS)
357 qemu-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)
358
359 scsi/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)
360 ifdef CONFIG_MPATH
361 scsi/qemu-pr-helper$(EXESUF): LIBS += -ludev -lmultipath -lmpathpersist
362 endif
363
364 module_block.h: $(SRC_PATH)/scripts/modules/module_block.py config-host.mak
365 $(call quiet-command,$(PYTHON) $< $@ \
366 $(addprefix $(SRC_PATH)/,$(patsubst %.mo,%.c,$(block-obj-m))), \
367 "GEN","$@")
368
369 clean: recurse-clean ninja-clean clean-ctlist
370 -test -f ninjatool && ./ninjatool $(if $(V),-v,) -t clean
371 # avoid old build problems by removing potentially incorrect old files
372 rm -f config.mak op-i386.h opc-i386.h gen-op-i386.h op-arm.h opc-arm.h gen-op-arm.h
373 rm -f qemu-options.def
374 find . \( -name '*.so' -o -name '*.dll' -o -name '*.mo' -o -name '*.[oda]' \) -type f \
375 ! -path ./roms/edk2/ArmPkg/Library/GccLto/liblto-aarch64.a \
376 ! -path ./roms/edk2/ArmPkg/Library/GccLto/liblto-arm.a \
377 ! -path ./roms/edk2/BaseTools/Source/Python/UPT/Dll/sqlite3.dll \
378 -exec rm {} +
379 rm -f $(filter-out %.tlb,$(TOOLS)) $(HELPERS-y) TAGS cscope.* *.pod *~ */*~
380 rm -f fsdev/*.pod scsi/*.pod
381 rm -f $(foreach f,$(generated-files-y),$(f) $(f)-timestamp)
382 rm -f config-all-devices.mak
383 rm -f $(SUBDIR_DEVICES_MAK)
384
385 VERSION ?= $(shell cat VERSION)
386
387 dist: qemu-$(VERSION).tar.bz2
388
389 qemu-%.tar.bz2:
390 $(SRC_PATH)/scripts/make-release "$(SRC_PATH)" "$(patsubst qemu-%.tar.bz2,%,$@)"
391
392 define clean-manual =
393 rm -rf $(MANUAL_BUILDDIR)/$1/_static
394 rm -f $(MANUAL_BUILDDIR)/$1/objects.inv $(MANUAL_BUILDDIR)/$1/searchindex.js $(MANUAL_BUILDDIR)/$1/*.html
395 endef
396
397 distclean: clean ninja-distclean
398 -test -f ninjatool && ./ninjatool $(if $(V),-v,) -t clean -g
399 rm -f config-host.mak config-host.h* $(DOCS)
400 rm -f tests/tcg/config-*.mak
401 rm -f config-all-devices.mak config-all-disas.mak config.status
402 rm -f $(SUBDIR_DEVICES_MAK)
403 rm -f po/*.mo tests/qemu-iotests/common.env
404 rm -f roms/seabios/config.mak roms/vgabios/config.mak
405 rm -f qemu-plugins-ld.symbols qemu-plugins-ld64.symbols
406 rm -rf meson-private meson-logs meson-info compile_commands.json
407 rm -f Makefile.ninja ninjatool ninjatool.stamp Makefile.mtest
408 rm -f config.log
409 rm -f linux-headers/asm
410 rm -f docs/version.texi
411 rm -f docs/interop/qemu-ga-qapi.texi docs/interop/qemu-qmp-qapi.texi
412 rm -f docs/interop/qemu-qmp-ref.7 docs/interop/qemu-ga-ref.7
413 rm -f docs/interop/qemu-qmp-ref.txt docs/interop/qemu-ga-ref.txt
414 rm -f docs/interop/qemu-qmp-ref.pdf docs/interop/qemu-ga-ref.pdf
415 rm -f docs/interop/qemu-qmp-ref.html docs/interop/qemu-ga-ref.html
416 rm -rf .doctrees
417 $(call clean-manual,devel)
418 $(call clean-manual,interop)
419 $(call clean-manual,specs)
420 $(call clean-manual,system)
421 $(call clean-manual,tools)
422 $(call clean-manual,user)
423 for d in $(TARGET_DIRS); do \
424 rm -rf $$d || exit 1 ; \
425 done
426 rm -Rf .sdk
427
428 KEYMAPS=da en-gb et fr fr-ch is lt no pt-br sv \
429 ar de en-us fi fr-be hr it lv nl pl ru th \
430 de-ch es fo fr-ca hu ja mk pt sl tr \
431 bepo cz
432
433 ifdef INSTALL_BLOBS
434 BLOBS=bios.bin bios-256k.bin bios-microvm.bin sgabios.bin vgabios.bin vgabios-cirrus.bin \
435 vgabios-stdvga.bin vgabios-vmware.bin vgabios-qxl.bin vgabios-virtio.bin \
436 vgabios-ramfb.bin vgabios-bochs-display.bin vgabios-ati.bin \
437 openbios-sparc32 openbios-sparc64 openbios-ppc QEMU,tcx.bin QEMU,cgthree.bin \
438 pxe-e1000.rom pxe-eepro100.rom pxe-ne2k_pci.rom \
439 pxe-pcnet.rom pxe-rtl8139.rom pxe-virtio.rom \
440 efi-e1000.rom efi-eepro100.rom efi-ne2k_pci.rom \
441 efi-pcnet.rom efi-rtl8139.rom efi-virtio.rom \
442 efi-e1000e.rom efi-vmxnet3.rom \
443 qemu-nsis.bmp \
444 bamboo.dtb canyonlands.dtb petalogix-s3adsp1800.dtb petalogix-ml605.dtb \
445 multiboot.bin linuxboot.bin linuxboot_dma.bin kvmvapic.bin pvh.bin \
446 s390-ccw.img s390-netboot.img \
447 slof.bin skiboot.lid \
448 palcode-clipper \
449 u-boot.e500 u-boot-sam460-20100605.bin \
450 qemu_vga.ndrv \
451 edk2-licenses.txt \
452 hppa-firmware.img \
453 opensbi-riscv32-sifive_u-fw_jump.bin opensbi-riscv32-virt-fw_jump.bin \
454 opensbi-riscv64-sifive_u-fw_jump.bin opensbi-riscv64-virt-fw_jump.bin
455 else
456 BLOBS=
457 endif
458
459 # Note that we manually filter-out the non-Sphinx documentation which
460 # is currently built into the docs/interop directory in the build tree,
461 # and also any sphinx-built manpages.
462 define install-manual =
463 for d in $$(cd $(MANUAL_BUILDDIR) && find $1 -type d); do $(INSTALL_DIR) "$(DESTDIR)$(qemu_docdir)/$$d"; done
464 for 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
465 endef
466
467 # Note that we deliberately do not install the "devel" manual: it is
468 # for QEMU developers, and not interesting to our users.
469 .PHONY: install-sphinxdocs
470 install-sphinxdocs: sphinxdocs
471 $(call install-manual,interop)
472 $(call install-manual,specs)
473 $(call install-manual,system)
474 $(call install-manual,tools)
475 $(call install-manual,user)
476
477 install-doc: $(DOCS) install-sphinxdocs
478 $(INSTALL_DIR) "$(DESTDIR)$(qemu_docdir)"
479 $(INSTALL_DATA) $(MANUAL_BUILDDIR)/index.html "$(DESTDIR)$(qemu_docdir)"
480 $(INSTALL_DIR) "$(DESTDIR)$(qemu_docdir)/interop"
481 $(INSTALL_DATA) docs/interop/qemu-qmp-ref.html "$(DESTDIR)$(qemu_docdir)/interop"
482 $(INSTALL_DATA) docs/interop/qemu-qmp-ref.txt "$(DESTDIR)$(qemu_docdir)/interop"
483 ifdef CONFIG_POSIX
484 $(INSTALL_DIR) "$(DESTDIR)$(mandir)/man1"
485 $(INSTALL_DATA) $(MANUAL_BUILDDIR)/system/qemu.1 "$(DESTDIR)$(mandir)/man1"
486 $(INSTALL_DIR) "$(DESTDIR)$(mandir)/man7"
487 $(INSTALL_DATA) docs/interop/qemu-qmp-ref.7 "$(DESTDIR)$(mandir)/man7"
488 $(INSTALL_DATA) $(MANUAL_BUILDDIR)/system/qemu-block-drivers.7 "$(DESTDIR)$(mandir)/man7"
489 $(INSTALL_DATA) $(MANUAL_BUILDDIR)/system/qemu-cpu-models.7 "$(DESTDIR)$(mandir)/man7"
490 ifeq ($(CONFIG_TOOLS),y)
491 $(INSTALL_DATA) $(MANUAL_BUILDDIR)/tools/qemu-img.1 "$(DESTDIR)$(mandir)/man1"
492 $(INSTALL_DIR) "$(DESTDIR)$(mandir)/man8"
493 $(INSTALL_DATA) $(MANUAL_BUILDDIR)/tools/qemu-nbd.8 "$(DESTDIR)$(mandir)/man8"
494 endif
495 ifdef CONFIG_TRACE_SYSTEMTAP
496 $(INSTALL_DATA) $(MANUAL_BUILDDIR)/tools/qemu-trace-stap.1 "$(DESTDIR)$(mandir)/man1"
497 endif
498 ifeq ($(CONFIG_GUEST_AGENT),y)
499 $(INSTALL_DATA) $(MANUAL_BUILDDIR)/interop/qemu-ga.8 "$(DESTDIR)$(mandir)/man8"
500 $(INSTALL_DIR) "$(DESTDIR)$(qemu_docdir)/interop"
501 $(INSTALL_DATA) docs/interop/qemu-ga-ref.html "$(DESTDIR)$(qemu_docdir)/interop"
502 $(INSTALL_DATA) docs/interop/qemu-ga-ref.txt "$(DESTDIR)$(qemu_docdir)/interop"
503 $(INSTALL_DATA) docs/interop/qemu-ga-ref.7 "$(DESTDIR)$(mandir)/man7"
504 endif
505 endif
506 ifdef CONFIG_VIRTFS
507 $(INSTALL_DIR) "$(DESTDIR)$(mandir)/man1"
508 $(INSTALL_DATA) $(MANUAL_BUILDDIR)/tools/virtfs-proxy-helper.1 "$(DESTDIR)$(mandir)/man1"
509 endif
510 ifeq ($(CONFIG_LINUX)$(CONFIG_SECCOMP)$(CONFIG_LIBCAP_NG),yyy)
511 $(INSTALL_DATA) $(MANUAL_BUILDDIR)/tools/virtiofsd.1 "$(DESTDIR)$(mandir)/man1"
512 endif
513
514 install-datadir:
515 $(INSTALL_DIR) "$(DESTDIR)$(qemu_datadir)"
516
517 install-localstatedir:
518 ifdef CONFIG_POSIX
519 ifeq ($(CONFIG_GUEST_AGENT),y)
520 $(INSTALL_DIR) "$(DESTDIR)$(qemu_localstatedir)"/run
521 endif
522 endif
523
524 ICON_SIZES=16x16 24x24 32x32 48x48 64x64 128x128 256x256 512x512
525
526 install-includedir:
527 $(INSTALL_DIR) "$(DESTDIR)$(includedir)"
528
529 # Needed by "meson install"
530 export DESTDIR
531 install: all $(if $(BUILD_DOCS),install-doc) \
532 install-datadir install-localstatedir install-includedir \
533 recurse-install
534 ifneq ($(TOOLS),)
535 $(call install-prog,$(TOOLS),$(DESTDIR)$(bindir))
536 endif
537 ifneq ($(CONFIG_MODULES),)
538 $(INSTALL_DIR) "$(DESTDIR)$(qemu_moddir)"
539 for s in $(modules-m:.mo=$(DSOSUF)); do \
540 t="$(DESTDIR)$(qemu_moddir)/$$(echo $$s | tr / -)"; \
541 $(INSTALL_LIB) $$s "$$t"; \
542 test -z "$(STRIP)" || $(STRIP) "$$t"; \
543 done
544 endif
545 ifneq ($(HELPERS-y),)
546 $(call install-prog,$(HELPERS-y),$(DESTDIR)$(libexecdir))
547 endif
548 ifdef CONFIG_TRACE_SYSTEMTAP
549 $(INSTALL_PROG) "scripts/qemu-trace-stap" $(DESTDIR)$(bindir)
550 endif
551 ifneq ($(BLOBS),)
552 set -e; for x in $(BLOBS); do \
553 $(INSTALL_DATA) $(SRC_PATH)/pc-bios/$$x "$(DESTDIR)$(qemu_datadir)"; \
554 done
555 endif
556 for s in $(ICON_SIZES); do \
557 mkdir -p "$(DESTDIR)$(qemu_icondir)/hicolor/$${s}/apps"; \
558 $(INSTALL_DATA) $(SRC_PATH)/ui/icons/qemu_$${s}.png \
559 "$(DESTDIR)$(qemu_icondir)/hicolor/$${s}/apps/qemu.png"; \
560 done; \
561 mkdir -p "$(DESTDIR)$(qemu_icondir)/hicolor/32x32/apps"; \
562 $(INSTALL_DATA) $(SRC_PATH)/ui/icons/qemu_32x32.bmp \
563 "$(DESTDIR)$(qemu_icondir)/hicolor/32x32/apps/qemu.bmp"; \
564 mkdir -p "$(DESTDIR)$(qemu_icondir)/hicolor/scalable/apps"; \
565 $(INSTALL_DATA) $(SRC_PATH)/ui/icons/qemu.svg \
566 "$(DESTDIR)$(qemu_icondir)/hicolor/scalable/apps/qemu.svg"
567 mkdir -p "$(DESTDIR)$(qemu_desktopdir)"
568 $(INSTALL_DATA) $(SRC_PATH)/ui/qemu.desktop \
569 "$(DESTDIR)$(qemu_desktopdir)/qemu.desktop"
570 ifdef CONFIG_GTK
571 $(MAKE) -C po $@
572 endif
573 ifeq ($(CONFIG_PLUGIN),y)
574 $(INSTALL_DATA) $(SRC_PATH)/include/qemu/qemu-plugin.h "$(DESTDIR)$(includedir)/qemu-plugin.h"
575 endif
576 $(INSTALL_DIR) "$(DESTDIR)$(qemu_datadir)/keymaps"
577 set -e; for x in $(KEYMAPS); do \
578 $(INSTALL_DATA) $(SRC_PATH)/pc-bios/keymaps/$$x "$(DESTDIR)$(qemu_datadir)/keymaps"; \
579 done
580 for d in $(TARGET_DIRS); do \
581 $(MAKE) $(SUBDIR_MAKEFLAGS) TARGET_DIR=$$d/ -C $$d $@ || exit 1 ; \
582 done
583
584 # documentation
585 MAKEINFO=makeinfo
586 MAKEINFOINCLUDES= -I docs -I $(<D) -I $(@D)
587 MAKEINFOFLAGS=--no-split --number-sections $(MAKEINFOINCLUDES)
588 TEXI2PODFLAGS=$(MAKEINFOINCLUDES) -DVERSION="$(VERSION)" -DCONFDIR="$(qemu_confdir)"
589 TEXI2PDFFLAGS=$(if $(V),,--quiet) -I $(SRC_PATH) $(MAKEINFOINCLUDES)
590
591 docs/version.texi: $(SRC_PATH)/VERSION config-host.mak
592 $(call quiet-command,(\
593 echo "@set VERSION $(VERSION)" && \
594 echo "@set CONFDIR $(qemu_confdir)" \
595 )> $@,"GEN","$@")
596
597 %.html: %.texi docs/version.texi
598 $(call quiet-command,LC_ALL=C $(MAKEINFO) $(MAKEINFOFLAGS) --no-headers \
599 --html $< -o $@,"GEN","$@")
600
601 %.info: %.texi docs/version.texi
602 $(call quiet-command,$(MAKEINFO) $(MAKEINFOFLAGS) $< -o $@,"GEN","$@")
603
604 %.txt: %.texi docs/version.texi
605 $(call quiet-command,LC_ALL=C $(MAKEINFO) $(MAKEINFOFLAGS) --no-headers \
606 --plaintext $< -o $@,"GEN","$@")
607
608 %.pdf: %.texi docs/version.texi
609 $(call quiet-command,texi2pdf $(TEXI2PDFFLAGS) $< -o $@,"GEN","$@")
610
611 # Sphinx builds all its documentation at once in one invocation
612 # and handles "don't rebuild things unless necessary" itself.
613 # The '.doctrees' files are cached information to speed this up.
614 .PHONY: sphinxdocs
615 sphinxdocs: $(MANUAL_BUILDDIR)/devel/index.html \
616 $(MANUAL_BUILDDIR)/interop/index.html \
617 $(MANUAL_BUILDDIR)/specs/index.html \
618 $(MANUAL_BUILDDIR)/system/index.html \
619 $(MANUAL_BUILDDIR)/tools/index.html \
620 $(MANUAL_BUILDDIR)/user/index.html
621
622 # Canned command to build a single manual
623 # Arguments: $1 = manual name, $2 = Sphinx builder ('html' or 'man')
624 # Note the use of different doctree for each (manual, builder) tuple;
625 # this works around Sphinx not handling parallel invocation on
626 # a single doctree: https://github.com/sphinx-doc/sphinx/issues/2946
627 build-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")
628 # We assume all RST files in the manual's directory are used in it
629 manual-deps = $(wildcard $(SRC_PATH)/docs/$1/*.rst $(SRC_PATH)/docs/$1/*/*.rst) \
630 $(SRC_PATH)/docs/defs.rst.inc \
631 $(SRC_PATH)/docs/$1/conf.py $(SRC_PATH)/docs/conf.py \
632 $(SRC_PATH)/docs/sphinx/*.py
633 # Macro to write out the rule and dependencies for building manpages
634 # Usage: $(call define-manpage-rule,manualname,manpage1 manpage2...[,extradeps])
635 # 'extradeps' is optional, and specifies extra files (eg .hx files) that
636 # the manual page depends on.
637 define define-manpage-rule
638 $(call atomic,$(foreach manpage,$2,$(MANUAL_BUILDDIR)/$1/$(manpage)),$(call manual-deps,$1) $3)
639 $(call build-manual,$1,man)
640 endef
641
642 $(MANUAL_BUILDDIR)/devel/index.html: $(call manual-deps,devel)
643 $(call build-manual,devel,html)
644
645 $(MANUAL_BUILDDIR)/interop/index.html: $(call manual-deps,interop)
646 $(call build-manual,interop,html)
647
648 $(MANUAL_BUILDDIR)/specs/index.html: $(call manual-deps,specs)
649 $(call build-manual,specs,html)
650
651 $(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
652 $(call build-manual,system,html)
653
654 $(MANUAL_BUILDDIR)/tools/index.html: $(call manual-deps,tools) $(SRC_PATH)/qemu-img-cmds.hx $(SRC_PATH)/docs/qemu-option-trace.rst.inc
655 $(call build-manual,tools,html)
656
657 $(MANUAL_BUILDDIR)/user/index.html: $(call manual-deps,user)
658 $(call build-manual,user,html)
659
660 $(call define-manpage-rule,interop,qemu-ga.8)
661
662 $(call define-manpage-rule,system,qemu.1 qemu-block-drivers.7 qemu-cpu-models.7)
663
664 $(call define-manpage-rule,tools,\
665 qemu-img.1 qemu-nbd.8 qemu-trace-stap.1\
666 virtiofsd.1 virtfs-proxy-helper.1,\
667 $(SRC_PATH)/qemu-img-cmds.hx $(SRC_PATH)/docs/qemu-option-trace.rst.inc)
668
669 $(MANUAL_BUILDDIR)/index.html: $(SRC_PATH)/docs/index.html.in qemu-version.h
670 @mkdir -p "$(MANUAL_BUILDDIR)"
671 $(call quiet-command, sed "s|@@VERSION@@|${VERSION}|g" $< >$@, \
672 "GEN","$@")
673
674 docs/interop/qemu-qmp-qapi.texi: qapi/qapi-doc.texi
675 @cp -p $< $@
676
677 docs/interop/qemu-ga-qapi.texi: qga/qga-qapi-doc.texi
678 @cp -p $< $@
679
680 html: docs/interop/qemu-qmp-ref.html docs/interop/qemu-ga-ref.html sphinxdocs
681 info: docs/interop/qemu-qmp-ref.info docs/interop/qemu-ga-ref.info
682 pdf: docs/interop/qemu-qmp-ref.pdf docs/interop/qemu-ga-ref.pdf
683 txt: docs/interop/qemu-qmp-ref.txt docs/interop/qemu-ga-ref.txt
684
685 docs/interop/qemu-ga-ref.dvi docs/interop/qemu-ga-ref.html \
686 docs/interop/qemu-ga-ref.info docs/interop/qemu-ga-ref.pdf \
687 docs/interop/qemu-ga-ref.txt docs/interop/qemu-ga-ref.7: \
688 docs/interop/qemu-ga-ref.texi docs/interop/qemu-ga-qapi.texi
689
690 docs/interop/qemu-qmp-ref.dvi docs/interop/qemu-qmp-ref.html \
691 docs/interop/qemu-qmp-ref.info docs/interop/qemu-qmp-ref.pdf \
692 docs/interop/qemu-qmp-ref.txt docs/interop/qemu-qmp-ref.7: \
693 docs/interop/qemu-qmp-ref.texi docs/interop/qemu-qmp-qapi.texi
694
695 $(filter %.1 %.7 %.8,$(DOCS)): scripts/texi2pod.pl
696
697 # Reports/Analysis
698
699 %/coverage-report.html:
700 @mkdir -p $*
701 $(call quiet-command,\
702 gcovr -r $(SRC_PATH) \
703 $(foreach t, $(TARGET_DIRS), --object-directory $(BUILD_DIR)/$(t)) \
704 --object-directory $(BUILD_DIR) \
705 -p --html --html-details -o $@, \
706 "GEN", "coverage-report.html")
707
708 .PHONY: coverage-report
709 coverage-report: $(CURDIR)/reports/coverage/coverage-report.html
710
711 ifdef CONFIG_WIN32
712
713 INSTALLER = qemu-setup-$(VERSION)$(EXESUF)
714
715 nsisflags = -V2 -NOCD
716
717 ifneq ($(wildcard $(SRC_PATH)/dll),)
718 ifeq ($(ARCH),x86_64)
719 # 64 bit executables
720 DLL_PATH = $(SRC_PATH)/dll/w64
721 nsisflags += -DW64
722 else
723 # 32 bit executables
724 DLL_PATH = $(SRC_PATH)/dll/w32
725 endif
726 endif
727
728 .PHONY: installer
729 installer: $(INSTALLER)
730
731 INSTDIR=/tmp/qemu-nsis
732
733 $(INSTALLER): $(SRC_PATH)/qemu.nsi
734 $(MAKE) install DESTDIR=${INSTDIR}
735 ifdef SIGNCODE
736 (cd ${INSTDIR}/${bindir}; \
737 for i in *.exe; do \
738 $(SIGNCODE) $${i}; \
739 done \
740 )
741 endif # SIGNCODE
742 (cd ${INSTDIR}/${bindir}; \
743 for i in qemu-system-*.exe; do \
744 arch=$${i%.exe}; \
745 arch=$${arch#qemu-system-}; \
746 echo Section \"$$arch\" Section_$$arch; \
747 echo SetOutPath \"\$$INSTDIR\"; \
748 echo File \"\$${BINDIR}\\$$i\"; \
749 echo SectionEnd; \
750 done \
751 ) >${INSTDIR}/${bindir}/system-emulations.nsh
752 makensis $(nsisflags) \
753 $(if $(BUILD_DOCS),-DCONFIG_DOCUMENTATION="y") \
754 $(if $(CONFIG_GTK),-DCONFIG_GTK="y") \
755 -DBINDIR="${INSTDIR}/${bindir}" \
756 $(if $(DLL_PATH),-DDLLDIR="$(DLL_PATH)") \
757 -DSRCDIR="$(SRC_PATH)" \
758 -DOUTFILE="$(INSTALLER)" \
759 -DDISPLAYVERSION="$(VERSION)" \
760 $(SRC_PATH)/qemu.nsi
761 rm -r ${INSTDIR}
762 ifdef SIGNCODE
763 $(SIGNCODE) $(INSTALLER)
764 endif # SIGNCODE
765 endif # CONFIG_WIN
766
767 # Add a dependency on the generated files, so that they are always
768 # rebuilt before other object files
769 ifneq ($(wildcard config-host.mak),)
770 ifneq ($(filter-out $(UNCHECKED_GOALS),$(MAKECMDGOALS)),$(if $(MAKECMDGOALS),,fail))
771 Makefile: $(generated-files-y)
772 endif
773 endif
774
775 # Include automatically generated dependency files
776 # Dependencies in Makefile.objs files come from our recursive subdir rules
777 -include $(wildcard *.d tests/*.d)
778
779 include $(SRC_PATH)/tests/docker/Makefile.include
780 include $(SRC_PATH)/tests/vm/Makefile.include
781
782 print-help-run = printf " %-30s - %s\\n" "$1" "$2"
783 print-help = $(quiet-@)$(call print-help-run,$1,$2)
784
785 .PHONY: help
786 help:
787 @echo 'Generic targets:'
788 $(call print-help,all,Build all)
789 ifdef CONFIG_MODULES
790 $(call print-help,modules,Build all modules)
791 endif
792 $(call print-help,dir/file.o,Build specified target only)
793 $(call print-help,install,Install QEMU, documentation and tools)
794 $(call print-help,ctags/TAGS,Generate tags file for editors)
795 $(call print-help,cscope,Generate cscope index)
796 $(call print-help,sparse,Run sparse on the QEMU source)
797 @echo ''
798 @$(if $(TARGET_DIRS), \
799 echo 'Architecture specific targets:'; \
800 $(foreach t, $(TARGET_DIRS), \
801 $(call print-help-run,$(t)/all,Build for $(t)); \
802 $(if $(CONFIG_FUZZ), \
803 $(if $(findstring softmmu,$(t)), \
804 $(call print-help-run,$(t)/fuzz,Build fuzzer for $(t)); \
805 ))) \
806 echo '')
807 @$(if $(HELPERS-y), \
808 echo 'Helper targets:'; \
809 $(foreach t, $(HELPERS-y), \
810 $(call print-help-run,$(t),Build $(shell basename $(t)));) \
811 echo '')
812 @$(if $(TOOLS), \
813 echo 'Tools targets:'; \
814 $(foreach t, $(TOOLS), \
815 $(call print-help-run,$(t),Build $(shell basename $(t)) tool);) \
816 echo '')
817 @echo 'Cleaning targets:'
818 $(call print-help,clean,Remove most generated files but keep the config)
819 $(call print-help,distclean,Remove all generated files)
820 $(call print-help,dist,Build a distributable tarball)
821 @echo ''
822 @echo 'Test targets:'
823 $(call print-help,check,Run all tests (check-help for details))
824 $(call print-help,docker,Help about targets running tests inside containers)
825 $(call print-help,vm-help,Help about targets running tests inside VM)
826 @echo ''
827 @echo 'Documentation targets:'
828 $(call print-help,html info pdf txt,Build documentation in specified format)
829 @echo ''
830 ifdef CONFIG_WIN32
831 @echo 'Windows targets:'
832 $(call print-help,installer,Build NSIS-based installer for QEMU)
833 ifdef QEMU_GA_MSI_ENABLED
834 $(call print-help,msi,Build MSI-based installer for qemu-ga)
835 endif
836 @echo ''
837 endif
838 $(call print-help,$(MAKE) [targets],(quiet build, default))
839 $(call print-help,$(MAKE) V=1 [targets],(verbose build))