]> git.proxmox.com Git - mirror_qemu.git/blame - Makefile
rules.mak: remove version.o
[mirror_qemu.git] / Makefile
CommitLineData
0cb3fb1e
PB
1# Makefile for QEMU.
2
4ace32e2
AO
3ifneq ($(words $(subst :, ,$(CURDIR))), 1)
4 $(error main directory cannot contain spaces nor colons)
5endif
6
519e1693
SW
7# Always point to the root of the build tree (needs GNU make).
8BUILD_DIR=$(CURDIR)
388d4758 9
eaa2ddbb
FZ
10# Before including a proper config-host.mak, assume we are in the source tree
11SRC_PATH=.
12
28fa2927
PMD
13UNCHECKED_GOALS := %clean TAGS cscope ctags dist \
14 html info pdf txt \
de1da442 15 help check-help print-% \
4f2f6276 16 docker docker-% vm-help vm-test vm-build-%
eaa2ddbb 17
250b086e 18# All following code might depend on configuration variables
55d7e8f6 19ifneq ($(wildcard config-host.mak),)
1ad2134f 20# Put the all: rule here so that config-host.mak can contain dependencies.
8f67aa82 21all:
ad064840 22include config-host.mak
d1bd2423 23
aef45d51
DB
24git-submodule-update:
25
26.PHONY: git-submodule-update
27
c4b01c7c
DB
28git_module_status := $(shell \
29 cd '$(SRC_PATH)' && \
30 GIT="$(GIT)" ./scripts/git-submodule.sh status $(GIT_SUBMODULES); \
31 echo $$?; \
32)
aef45d51
DB
33
34ifeq (1,$(git_module_status))
f62bbee5
DB
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
aef45d51
DB
45git-submodule-update:
46 $(call quiet-command, \
cc84d63a 47 (cd $(SRC_PATH) && GIT="$(GIT)" ./scripts/git-submodule.sh update $(GIT_SUBMODULES)), \
aef45d51
DB
48 "GIT","$(GIT_SUBMODULES)")
49endif
50endif
51
a5665051
PB
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
245dac4a
PB
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
92712822 79.git-submodule-status: git-submodule-update config-host.mak
aef45d51 80
d1bd2423
PM
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 \
b98a3bae 87"$(MAKE) distclean && rm -rf *-linux-user *-softmmu" in your source tree)
d1bd2423
PM
88endif
89endif
90
2b1f35b9
AB
91CONFIG_SOFTMMU := $(if $(filter %-softmmu,$(TARGET_DIRS)),y)
92CONFIG_USER_ONLY := $(if $(filter %-user,$(TARGET_DIRS)),y)
6b827cca 93CONFIG_XEN := $(CONFIG_XEN_BACKEND)
f3aa844b
PB
94CONFIG_ALL=y
95-include config-all-devices.mak
96-include config-all-disas.mak
97
3a6b016d 98config-host.mak: $(SRC_PATH)/configure $(SRC_PATH)/pc-bios $(SRC_PATH)/VERSION
e5efe7f5 99 @echo $@ is out-of-date, running configure
a5665051
PB
100 @if test -f meson-private/coredata.dat; then \
101 ./config.status --skip-meson; \
102 else \
103 ./config.status; \
104 fi
26fffe29
EC
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
55d7e8f6
AJ
111else
112config-host.mak:
eaa2ddbb 113ifneq ($(filter-out $(UNCHECKED_GOALS),$(MAKECMDGOALS)),$(if $(MAKECMDGOALS),,fail))
55d7e8f6
AJ
114 @echo "Please call configure before running make!"
115 @exit 1
116endif
7748b8cb 117endif
766a487a 118
fb57c881
FZ
119include $(SRC_PATH)/rules.mak
120
c932ce31 121# lor is defined in rules.mak
29de2804
LV
122CONFIG_BLOCK := $(call lor,$(CONFIG_SOFTMMU),$(CONFIG_TOOLS))
123
3dff199c 124generated-files-y += .git-submodule-status
0ab8ed18 125
d9ace8b3
JQ
126# Don't try to regenerate Makefile or configure
127# We don't generate any of them
128Makefile: ;
129configure: ;
130
bd3f5706 131.PHONY: all clean cscope distclean html info install install-doc \
7c3d1917 132 pdf txt recurse-all dist msi FORCE
0cb3fb1e 133
fec90ff0 134$(call set-vpath, $(SRC_PATH))
8c462f8f 135
3e2e0e6b 136LIBS+=-lz $(LIBS_TOOLS)
67c0f08d 137
b53c54c6
PM
138# Sphinx does not allow building manuals into the same directory as
139# the source files, so if we're doing an in-tree QEMU build we must
140# build the manuals into a subdirectory (and then install them from
141# there for 'make install'). For an out-of-tree build we can just
142# use the docs/ subdirectory in the build tree as normal.
143ifeq ($(realpath $(SRC_PATH)),$(realpath .))
144MANUAL_BUILDDIR := docs/built
145else
146MANUAL_BUILDDIR := docs
147endif
148
cc8ae6de 149ifdef BUILD_DOCS
d06118bf 150DOCS+=$(MANUAL_BUILDDIR)/system/qemu.1
a08b4a9f
PM
151DOCS+=$(MANUAL_BUILDDIR)/tools/qemu-img.1
152DOCS+=$(MANUAL_BUILDDIR)/tools/qemu-nbd.8
87c0868f 153DOCS+=$(MANUAL_BUILDDIR)/interop/qemu-ga.8
6a7e2bbe 154ifeq ($(CONFIG_LINUX)$(CONFIG_SECCOMP)$(CONFIG_LIBCAP_NG),yyy)
a08b4a9f 155DOCS+=$(MANUAL_BUILDDIR)/tools/virtiofsd.1
6a7e2bbe 156endif
acab923d 157DOCS+=$(MANUAL_BUILDDIR)/system/qemu-block-drivers.7
d59157ea
PB
158DOCS+=docs/interop/qemu-qmp-ref.html docs/interop/qemu-qmp-ref.txt docs/interop/qemu-qmp-ref.7
159DOCS+=docs/interop/qemu-ga-ref.html docs/interop/qemu-ga-ref.txt docs/interop/qemu-ga-ref.7
1bf84a1e 160DOCS+=$(MANUAL_BUILDDIR)/system/qemu-cpu-models.7
22108f33 161DOCS+=$(MANUAL_BUILDDIR)/index.html
983eef5a 162ifdef CONFIG_VIRTFS
a08b4a9f 163DOCS+=$(MANUAL_BUILDDIR)/tools/virtfs-proxy-helper.1
983eef5a 164endif
62dd1048 165ifdef CONFIG_TRACE_SYSTEMTAP
a08b4a9f 166DOCS+=$(MANUAL_BUILDDIR)/tools/qemu-trace-stap.1
62dd1048 167endif
cc8ae6de
PB
168else
169DOCS=
170endif
aa05ae6f 171
8cc357b5 172SUBDIR_MAKEFLAGS=$(if $(V),,--no-print-directory --quiet) BUILD_DIR=$(BUILD_DIR)
a992fe3d 173
992aeb8e
PB
174ifneq ($(wildcard config-host.mak),)
175include $(SRC_PATH)/Makefile.objs
ba1183da
FZ
176endif
177
46e7b706 178include $(SRC_PATH)/tests/Makefile.include
992aeb8e 179
c3a0ee84 180all: $(DOCS) $(if $(BUILD_DOCS),sphinxdocs) recurse-all modules
b9dea4fb 181
1215c6e7
JQ
182config-host.h: config-host.h-timestamp
183config-host.h-timestamp: config-host.mak
184
c621dc3e 185TARGET_DIRS_RULES := $(foreach t, all fuzz clean install, $(addsuffix /$(t), $(TARGET_DIRS)))
916359f6 186
1338a4b7
MA
187.PHONY: $(TARGET_DIRS_RULES)
188# The $(TARGET_DIRS_RULES) are of the form SUBDIR/GOAL, so that
189# $(dir $@) yields the sub-directory, and $(notdir $@) yields the sub-goal
2becc36a 190$(TARGET_DIRS_RULES): $(TARGET_DEPS)
1338a4b7 191 $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C $(dir $@) V="$(V)" TARGET_DIR="$(dir $@)" $(notdir $@),)
4aa42531 192
67953a37
CF
193# LIBFDT_lib="": avoid breaking existing trees with objects requiring -fPIC
194DTC_MAKE_ARGS=-I$(SRC_PATH)/dtc VPATH=$(SRC_PATH)/dtc -C dtc V="$(V)" LIBFDT_lib=""
965f486c 195DTC_CFLAGS=$(CFLAGS) $(QEMU_CFLAGS)
67953a37 196DTC_CPPFLAGS=-I$(SRC_PATH)/dtc/libfdt
a540f158 197
3b8593ee 198.PHONY: dtc/all
67953a37
CF
199dtc/all: .git-submodule-status dtc/libfdt
200 $(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,)
a540f158 201
00525864 202dtc/%: .git-submodule-status
814e1110 203 @mkdir -p $@
a540f158 204
e219c499
RH
205# Overriding CFLAGS causes us to lose defines added in the sub-makefile.
206# Not overriding CFLAGS leads to mis-matches between compilation modes.
207# Therefore we replicate some of the logic in the sub-makefile.
208# Remove all the extra -Warning flags that QEMU uses that Capstone doesn't;
209# no need to annoy QEMU developers with such things.
210CAP_CFLAGS = $(patsubst -W%,,$(CFLAGS) $(QEMU_CFLAGS))
211CAP_CFLAGS += -DCAPSTONE_USE_SYS_DYN_MEM
212CAP_CFLAGS += -DCAPSTONE_HAS_ARM
213CAP_CFLAGS += -DCAPSTONE_HAS_ARM64
214CAP_CFLAGS += -DCAPSTONE_HAS_POWERPC
215CAP_CFLAGS += -DCAPSTONE_HAS_X86
216
3b8593ee
MA
217.PHONY: capstone/all
218capstone/all: .git-submodule-status
9f81aeb5 219 $(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))
e219c499 220
3b8593ee
MA
221.PHONY: slirp/all
222slirp/all: .git-submodule-status
daa79d9a
AB
223 $(call quiet-command,$(MAKE) -C $(SRC_PATH)/slirp \
224 BUILD_DIR="$(BUILD_DIR)/slirp" \
225 PKG_CONFIG="$(PKG_CONFIG)" \
226 CC="$(CC)" AR="$(AR)" LD="$(LD)" RANLIB="$(RANLIB)" \
db5adeaa 227 CFLAGS="$(QEMU_CFLAGS) $(CFLAGS)" LDFLAGS="$(QEMU_LDFLAGS)")
675b9b53 228
64ed6f92 229$(filter %/all, $(TARGET_DIRS_RULES)):
c621dc3e 230
3b8593ee 231ROM_DIRS = $(addprefix pc-bios/, $(ROMS))
1338a4b7 232ROM_DIRS_RULES=$(foreach t, all clean, $(addsuffix /$(t), $(ROM_DIRS)))
a9c87304 233# Only keep -O and -g cflags
1338a4b7
MA
234.PHONY: $(ROM_DIRS_RULES)
235$(ROM_DIRS_RULES):
236 $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C $(dir $@) V="$(V)" TARGET_DIR="$(dir $@)" CFLAGS="$(filter -O% -g%,$(CFLAGS))" $(notdir $@),)
c05ac895 237
8d358a5e 238.PHONY: recurse-all recurse-clean recurse-install
1338a4b7
MA
239recurse-all: $(addsuffix /all, $(TARGET_DIRS) $(ROM_DIRS))
240recurse-clean: $(addsuffix /clean, $(TARGET_DIRS) $(ROM_DIRS))
241recurse-install: $(addsuffix /install, $(TARGET_DIRS))
47ae060e 242$(addsuffix /install, $(TARGET_DIRS)): all
83f64091 243
44dc0ca3 244######################################################################
4fb240a4 245
a5665051
PB
246clean: recurse-clean ninja-clean clean-ctlist
247 -test -f ninjatool && ./ninjatool $(if $(V),-v,) -t clean
2d80ae89 248# avoid old build problems by removing potentially incorrect old files
25be210f 249 rm -f config.mak op-i386.h opc-i386.h gen-op-i386.h op-arm.h opc-arm.h gen-op-arm.h
23858f40
LE
250 find . \( -name '*.so' -o -name '*.dll' -o -name '*.mo' -o -name '*.[oda]' \) -type f \
251 ! -path ./roms/edk2/ArmPkg/Library/GccLto/liblto-aarch64.a \
252 ! -path ./roms/edk2/ArmPkg/Library/GccLto/liblto-arm.a \
253 ! -path ./roms/edk2/BaseTools/Source/Python/UPT/Dll/sqlite3.dll \
254 -exec rm {} +
c3a0ee84 255 rm -f TAGS cscope.* *.pod *~ */*~
b855f8d1 256 rm -f fsdev/*.pod scsi/*.pod
3dff199c 257 rm -f $(foreach f,$(generated-files-y),$(f) $(f)-timestamp)
31e31b8a 258
34bb443e
AL
259VERSION ?= $(shell cat VERSION)
260
261dist: qemu-$(VERSION).tar.bz2
262
34bb443e
AL
263qemu-%.tar.bz2:
264 $(SRC_PATH)/scripts/make-release "$(SRC_PATH)" "$(patsubst qemu-%.tar.bz2,%,$@)"
265
5f71eac0 266define clean-manual =
1290e671
PM
267rm -rf $(MANUAL_BUILDDIR)/$1/_static
268rm -f $(MANUAL_BUILDDIR)/$1/objects.inv $(MANUAL_BUILDDIR)/$1/searchindex.js $(MANUAL_BUILDDIR)/$1/*.html
5f71eac0
PM
269endef
270
a5665051
PB
271distclean: clean ninja-distclean
272 -test -f ninjatool && ./ninjatool $(if $(V),-v,) -t clean -g
ee5195ee 273 rm -f config-host.mak config-host.h* $(DOCS)
2038f8c8 274 rm -f tests/tcg/config-*.mak
2becc36a 275 rm -f config-all-disas.mak config.status
ae219359 276 rm -f po/*.mo tests/qemu-iotests/common.env
fc8e320e 277 rm -f roms/seabios/config.mak roms/vgabios/config.mak
26fffe29 278 rm -f qemu-plugins-ld.symbols qemu-plugins-ld64.symbols
64ed6f92 279 rm -f *-config-target.h *-config-devices.mak *-config-devices.h
a5665051 280 rm -rf meson-private meson-logs meson-info compile_commands.json
245dac4a 281 rm -f Makefile.ninja ninjatool ninjatool.stamp Makefile.mtest
793553ac 282 rm -f config.log
67ed96f9 283 rm -f linux-headers/asm
d59157ea
PB
284 rm -f docs/version.texi
285 rm -f docs/interop/qemu-ga-qapi.texi docs/interop/qemu-qmp-qapi.texi
286 rm -f docs/interop/qemu-qmp-ref.7 docs/interop/qemu-ga-ref.7
287 rm -f docs/interop/qemu-qmp-ref.txt docs/interop/qemu-ga-ref.txt
288 rm -f docs/interop/qemu-qmp-ref.pdf docs/interop/qemu-ga-ref.pdf
289 rm -f docs/interop/qemu-qmp-ref.html docs/interop/qemu-ga-ref.html
81f33401 290 rm -rf .doctrees
5f71eac0
PM
291 $(call clean-manual,devel)
292 $(call clean-manual,interop)
0783a732 293 $(call clean-manual,specs)
0928523a 294 $(call clean-manual,system)
65c3542b 295 $(call clean-manual,tools)
09147930 296 $(call clean-manual,user)
2b1f35b9 297 for d in $(TARGET_DIRS); do \
bc1b050d 298 rm -rf $$d || exit 1 ; \
76bc6838 299 done
d9840e25 300 rm -Rf .sdk
7d13299d 301
06e7772f 302KEYMAPS=da en-gb et fr fr-ch is lt no pt-br sv \
fed4a9ad 303ar de en-us fi fr-be hr it lv nl pl ru th \
26b1cbf8 304de-ch es fo fr-ca hu ja mk pt sl tr \
3751e722 305bepo cz
fed4a9ad 306
77755340 307ifdef INSTALL_BLOBS
32eb2da3 308BLOBS=bios.bin bios-256k.bin bios-microvm.bin sgabios.bin vgabios.bin vgabios-cirrus.bin \
7a4dfd1e 309vgabios-stdvga.bin vgabios-vmware.bin vgabios-qxl.bin vgabios-virtio.bin \
0a87fd69 310vgabios-ramfb.bin vgabios-bochs-display.bin vgabios-ati.bin \
b2ce76a0 311openbios-sparc32 openbios-sparc64 openbios-ppc QEMU,tcx.bin QEMU,cgthree.bin \
5ee8ad71
AW
312pxe-e1000.rom pxe-eepro100.rom pxe-ne2k_pci.rom \
313pxe-pcnet.rom pxe-rtl8139.rom pxe-virtio.rom \
9fd02979
SE
314efi-e1000.rom efi-eepro100.rom efi-ne2k_pci.rom \
315efi-pcnet.rom efi-rtl8139.rom efi-virtio.rom \
45027808 316efi-e1000e.rom efi-vmxnet3.rom \
b3ce38dc 317qemu-nsis.bmp \
4b387f9e 318bamboo.dtb canyonlands.dtb petalogix-s3adsp1800.dtb petalogix-ml605.dtb \
2785dc7b 319multiboot.bin linuxboot.bin linuxboot_dma.bin kvmvapic.bin pvh.bin \
6c5359e1 320s390-ccw.img s390-netboot.img \
744a928c 321slof.bin skiboot.lid \
0c6ab8c9 322palcode-clipper \
82e65fe0 323u-boot.e500 u-boot-sam460-20100605.bin \
43ad2564 324qemu_vga.ndrv \
26ce90fd 325edk2-licenses.txt \
91f3a2f0 326hppa-firmware.img \
a6fcc80b 327opensbi-riscv32-sifive_u-fw_jump.bin opensbi-riscv32-virt-fw_jump.bin \
91f3a2f0 328opensbi-riscv64-sifive_u-fw_jump.bin opensbi-riscv64-virt-fw_jump.bin
77755340
TS
329else
330BLOBS=
331endif
332
336cfef4 333# Note that we manually filter-out the non-Sphinx documentation which
27a296fc
PM
334# is currently built into the docs/interop directory in the build tree,
335# and also any sphinx-built manpages.
5f71eac0 336define install-manual =
1290e671 337for d in $$(cd $(MANUAL_BUILDDIR) && find $1 -type d); do $(INSTALL_DIR) "$(DESTDIR)$(qemu_docdir)/$$d"; done
27a296fc 338for 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
5f71eac0
PM
339endef
340
341# Note that we deliberately do not install the "devel" manual: it is
342# for QEMU developers, and not interesting to our users.
343.PHONY: install-sphinxdocs
344install-sphinxdocs: sphinxdocs
345 $(call install-manual,interop)
0783a732 346 $(call install-manual,specs)
0928523a 347 $(call install-manual,system)
65c3542b 348 $(call install-manual,tools)
09147930 349 $(call install-manual,user)
5f71eac0
PM
350
351install-doc: $(DOCS) install-sphinxdocs
d7dd65ba 352 $(INSTALL_DIR) "$(DESTDIR)$(qemu_docdir)"
22108f33 353 $(INSTALL_DATA) $(MANUAL_BUILDDIR)/index.html "$(DESTDIR)$(qemu_docdir)"
c13dba2c
LP
354 $(INSTALL_DIR) "$(DESTDIR)$(qemu_docdir)/interop"
355 $(INSTALL_DATA) docs/interop/qemu-qmp-ref.html "$(DESTDIR)$(qemu_docdir)/interop"
356 $(INSTALL_DATA) docs/interop/qemu-qmp-ref.txt "$(DESTDIR)$(qemu_docdir)/interop"
96d409eb 357ifdef CONFIG_POSIX
58f8aead 358 $(INSTALL_DIR) "$(DESTDIR)$(mandir)/man1"
d06118bf 359 $(INSTALL_DATA) $(MANUAL_BUILDDIR)/system/qemu.1 "$(DESTDIR)$(mandir)/man1"
56e8bdd4 360 $(INSTALL_DIR) "$(DESTDIR)$(mandir)/man7"
d59157ea 361 $(INSTALL_DATA) docs/interop/qemu-qmp-ref.7 "$(DESTDIR)$(mandir)/man7"
acab923d 362 $(INSTALL_DATA) $(MANUAL_BUILDDIR)/system/qemu-block-drivers.7 "$(DESTDIR)$(mandir)/man7"
1bf84a1e 363 $(INSTALL_DATA) $(MANUAL_BUILDDIR)/system/qemu-cpu-models.7 "$(DESTDIR)$(mandir)/man7"
c932ce31 364ifeq ($(CONFIG_TOOLS),y)
a08b4a9f 365 $(INSTALL_DATA) $(MANUAL_BUILDDIR)/tools/qemu-img.1 "$(DESTDIR)$(mandir)/man1"
58f8aead 366 $(INSTALL_DIR) "$(DESTDIR)$(mandir)/man8"
a08b4a9f 367 $(INSTALL_DATA) $(MANUAL_BUILDDIR)/tools/qemu-nbd.8 "$(DESTDIR)$(mandir)/man8"
38954dca 368endif
62dd1048 369ifdef CONFIG_TRACE_SYSTEMTAP
a08b4a9f 370 $(INSTALL_DATA) $(MANUAL_BUILDDIR)/tools/qemu-trace-stap.1 "$(DESTDIR)$(mandir)/man1"
62dd1048 371endif
f15bff25 372ifeq ($(CONFIG_GUEST_AGENT),y)
b53c54c6 373 $(INSTALL_DATA) $(MANUAL_BUILDDIR)/interop/qemu-ga.8 "$(DESTDIR)$(mandir)/man8"
c13dba2c
LP
374 $(INSTALL_DIR) "$(DESTDIR)$(qemu_docdir)/interop"
375 $(INSTALL_DATA) docs/interop/qemu-ga-ref.html "$(DESTDIR)$(qemu_docdir)/interop"
376 $(INSTALL_DATA) docs/interop/qemu-ga-ref.txt "$(DESTDIR)$(qemu_docdir)/interop"
d59157ea 377 $(INSTALL_DATA) docs/interop/qemu-ga-ref.7 "$(DESTDIR)$(mandir)/man7"
665b5d0d 378endif
8a3e8f7f 379endif
a2d8f1be
MK
380ifdef CONFIG_VIRTFS
381 $(INSTALL_DIR) "$(DESTDIR)$(mandir)/man1"
a08b4a9f 382 $(INSTALL_DATA) $(MANUAL_BUILDDIR)/tools/virtfs-proxy-helper.1 "$(DESTDIR)$(mandir)/man1"
a2d8f1be 383endif
6a7e2bbe 384ifeq ($(CONFIG_LINUX)$(CONFIG_SECCOMP)$(CONFIG_LIBCAP_NG),yyy)
a08b4a9f 385 $(INSTALL_DATA) $(MANUAL_BUILDDIR)/tools/virtiofsd.1 "$(DESTDIR)$(mandir)/man1"
6a7e2bbe 386endif
e2d87bff
EH
387
388install-datadir:
389 $(INSTALL_DIR) "$(DESTDIR)$(qemu_datadir)"
390
f2e3978b
LE
391install-localstatedir:
392ifdef CONFIG_POSIX
f15bff25 393ifeq ($(CONFIG_GUEST_AGENT),y)
f2e3978b
LE
394 $(INSTALL_DIR) "$(DESTDIR)$(qemu_localstatedir)"/run
395endif
396endif
397
a8260d38 398ICON_SIZES=16x16 24x24 32x32 48x48 64x64 128x128 256x256 512x512
e2d87bff 399
a5665051
PB
400# Needed by "meson install"
401export DESTDIR
54cb65d8 402install: all $(if $(BUILD_DOCS),install-doc) \
f556b4a1 403 install-datadir install-localstatedir \
1338a4b7 404 recurse-install
62dd1048
DB
405ifdef CONFIG_TRACE_SYSTEMTAP
406 $(INSTALL_PROG) "scripts/qemu-trace-stap" $(DESTDIR)$(bindir)
407endif
77755340 408ifneq ($(BLOBS),)
77755340 409 set -e; for x in $(BLOBS); do \
6aae2a2e 410 $(INSTALL_DATA) $(SRC_PATH)/pc-bios/$$x "$(DESTDIR)$(qemu_datadir)"; \
ad064840 411 done
834574ea 412endif
a8260d38 413 for s in $(ICON_SIZES); do \
6c11dda9 414 mkdir -p "$(DESTDIR)$(qemu_icondir)/hicolor/$${s}/apps"; \
a8260d38 415 $(INSTALL_DATA) $(SRC_PATH)/ui/icons/qemu_$${s}.png \
6c11dda9 416 "$(DESTDIR)$(qemu_icondir)/hicolor/$${s}/apps/qemu.png"; \
a8260d38 417 done; \
6c11dda9 418 mkdir -p "$(DESTDIR)$(qemu_icondir)/hicolor/32x32/apps"; \
a8260d38 419 $(INSTALL_DATA) $(SRC_PATH)/ui/icons/qemu_32x32.bmp \
6c11dda9
SH
420 "$(DESTDIR)$(qemu_icondir)/hicolor/32x32/apps/qemu.bmp"; \
421 mkdir -p "$(DESTDIR)$(qemu_icondir)/hicolor/scalable/apps"; \
a8260d38 422 $(INSTALL_DATA) $(SRC_PATH)/ui/icons/qemu.svg \
6c11dda9
SH
423 "$(DESTDIR)$(qemu_icondir)/hicolor/scalable/apps/qemu.svg"
424 mkdir -p "$(DESTDIR)$(qemu_desktopdir)"
67ea9546 425 $(INSTALL_DATA) $(SRC_PATH)/ui/qemu.desktop \
6c11dda9 426 "$(DESTDIR)$(qemu_desktopdir)/qemu.desktop"
2a6b5372 427ifdef CONFIG_GTK
834574ea 428 $(MAKE) -C po $@
77755340 429endif
6aae2a2e 430 $(INSTALL_DIR) "$(DESTDIR)$(qemu_datadir)/keymaps"
18be8d77 431 set -e; for x in $(KEYMAPS); do \
6aae2a2e 432 $(INSTALL_DATA) $(SRC_PATH)/pc-bios/keymaps/$$x "$(DESTDIR)$(qemu_datadir)/keymaps"; \
ad064840 433 done
a81df1b6
PB
434 for d in $(TARGET_DIRS); do \
435 $(MAKE) $(SUBDIR_MAKEFLAGS) TARGET_DIR=$$d/ -C $$d $@ || exit 1 ; \
436 done
612384d7 437
3ef693a0 438# documentation
e8518c92 439MAKEINFO=makeinfo
d59157ea
PB
440MAKEINFOINCLUDES= -I docs -I $(<D) -I $(@D)
441MAKEINFOFLAGS=--no-split --number-sections $(MAKEINFOINCLUDES)
e8338fdb 442TEXI2PODFLAGS=$(MAKEINFOINCLUDES) -DVERSION="$(VERSION)" -DCONFDIR="$(qemu_confdir)"
d59157ea 443TEXI2PDFFLAGS=$(if $(V),,--quiet) -I $(SRC_PATH) $(MAKEINFOINCLUDES)
56e8bdd4 444
e8338fdb
MAL
445docs/version.texi: $(SRC_PATH)/VERSION config-host.mak
446 $(call quiet-command,(\
447 echo "@set VERSION $(VERSION)" && \
448 echo "@set CONFDIR $(qemu_confdir)" \
449 )> $@,"GEN","$@")
fea346f5 450
44cb280d 451%.html: %.texi docs/version.texi
e9ee06bd
MAL
452 $(call quiet-command,LC_ALL=C $(MAKEINFO) $(MAKEINFOFLAGS) --no-headers \
453 --html $< -o $@,"GEN","$@")
3ef693a0 454
44cb280d 455%.info: %.texi docs/version.texi
e9ee06bd 456 $(call quiet-command,$(MAKEINFO) $(MAKEINFOFLAGS) $< -o $@,"GEN","$@")
f3548328 457
44cb280d 458%.txt: %.texi docs/version.texi
f8bab10b
MAL
459 $(call quiet-command,LC_ALL=C $(MAKEINFO) $(MAKEINFOFLAGS) --no-headers \
460 --plaintext $< -o $@,"GEN","$@")
461
44cb280d 462%.pdf: %.texi docs/version.texi
d59157ea 463 $(call quiet-command,texi2pdf $(TEXI2PDFFLAGS) $< -o $@,"GEN","$@")
bd7f9747 464
5f71eac0
PM
465# Sphinx builds all its documentation at once in one invocation
466# and handles "don't rebuild things unless necessary" itself.
467# The '.doctrees' files are cached information to speed this up.
468.PHONY: sphinxdocs
0928523a
PM
469sphinxdocs: $(MANUAL_BUILDDIR)/devel/index.html \
470 $(MANUAL_BUILDDIR)/interop/index.html \
471 $(MANUAL_BUILDDIR)/specs/index.html \
65c3542b 472 $(MANUAL_BUILDDIR)/system/index.html \
09147930
PB
473 $(MANUAL_BUILDDIR)/tools/index.html \
474 $(MANUAL_BUILDDIR)/user/index.html
5f71eac0
PM
475
476# Canned command to build a single manual
27a296fc 477# Arguments: $1 = manual name, $2 = Sphinx builder ('html' or 'man')
6bda415c
EH
478# Note the use of different doctree for each (manual, builder) tuple;
479# this works around Sphinx not handling parallel invocation on
480# a single doctree: https://github.com/sphinx-doc/sphinx/issues/2946
516e8b7d 481build-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")
5f71eac0 482# We assume all RST files in the manual's directory are used in it
814e068f 483manual-deps = $(wildcard $(SRC_PATH)/docs/$1/*.rst $(SRC_PATH)/docs/$1/*/*.rst) \
de1572ca 484 $(SRC_PATH)/docs/defs.rst.inc \
9165d323
PM
485 $(SRC_PATH)/docs/$1/conf.py $(SRC_PATH)/docs/conf.py \
486 $(SRC_PATH)/docs/sphinx/*.py
e0f3728d
PM
487# Macro to write out the rule and dependencies for building manpages
488# Usage: $(call define-manpage-rule,manualname,manpage1 manpage2...[,extradeps])
489# 'extradeps' is optional, and specifies extra files (eg .hx files) that
490# the manual page depends on.
491define define-manpage-rule
492$(call atomic,$(foreach manpage,$2,$(MANUAL_BUILDDIR)/$1/$(manpage)),$(call manual-deps,$1) $3)
493 $(call build-manual,$1,man)
494endef
5f71eac0 495
1290e671 496$(MANUAL_BUILDDIR)/devel/index.html: $(call manual-deps,devel)
27a296fc 497 $(call build-manual,devel,html)
5f71eac0 498
a08b4a9f 499$(MANUAL_BUILDDIR)/interop/index.html: $(call manual-deps,interop)
27a296fc 500 $(call build-manual,interop,html)
5f71eac0 501
0783a732 502$(MANUAL_BUILDDIR)/specs/index.html: $(call manual-deps,specs)
27a296fc
PM
503 $(call build-manual,specs,html)
504
09ce5f2d 505$(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
0928523a
PM
506 $(call build-manual,system,html)
507
a08b4a9f 508$(MANUAL_BUILDDIR)/tools/index.html: $(call manual-deps,tools) $(SRC_PATH)/qemu-img-cmds.hx $(SRC_PATH)/docs/qemu-option-trace.rst.inc
65c3542b
PM
509 $(call build-manual,tools,html)
510
09147930
PB
511$(MANUAL_BUILDDIR)/user/index.html: $(call manual-deps,user)
512 $(call build-manual,user,html)
513
a08b4a9f 514$(call define-manpage-rule,interop,qemu-ga.8)
87c0868f 515
d06118bf 516$(call define-manpage-rule,system,qemu.1 qemu-block-drivers.7 qemu-cpu-models.7)
acab923d 517
a08b4a9f
PM
518$(call define-manpage-rule,tools,\
519 qemu-img.1 qemu-nbd.8 qemu-trace-stap.1\
520 virtiofsd.1 virtfs-proxy-helper.1,\
521 $(SRC_PATH)/qemu-img-cmds.hx $(SRC_PATH)/docs/qemu-option-trace.rst.inc)
522
22108f33 523$(MANUAL_BUILDDIR)/index.html: $(SRC_PATH)/docs/index.html.in qemu-version.h
d83bbeda 524 @mkdir -p "$(MANUAL_BUILDDIR)"
22108f33
SH
525 $(call quiet-command, sed "s|@@VERSION@@|${VERSION}|g" $< >$@, \
526 "GEN","$@")
527
eb815e24 528docs/interop/qemu-qmp-qapi.texi: qapi/qapi-doc.texi
fb0bc835 529 @cp -p $< $@
4afeeb57 530
f15bff25 531docs/interop/qemu-ga-qapi.texi: qga/qga-qapi-doc.texi
fb0bc835 532 @cp -p $< $@
56e8bdd4 533
5b1d0e92
PM
534html: docs/interop/qemu-qmp-ref.html docs/interop/qemu-ga-ref.html sphinxdocs
535info: docs/interop/qemu-qmp-ref.info docs/interop/qemu-ga-ref.info
536pdf: docs/interop/qemu-qmp-ref.pdf docs/interop/qemu-ga-ref.pdf
537txt: docs/interop/qemu-qmp-ref.txt docs/interop/qemu-ga-ref.txt
818220f5 538
d59157ea
PB
539docs/interop/qemu-ga-ref.dvi docs/interop/qemu-ga-ref.html \
540 docs/interop/qemu-ga-ref.info docs/interop/qemu-ga-ref.pdf \
541 docs/interop/qemu-ga-ref.txt docs/interop/qemu-ga-ref.7: \
542 docs/interop/qemu-ga-ref.texi docs/interop/qemu-ga-qapi.texi
56e8bdd4 543
d59157ea
PB
544docs/interop/qemu-qmp-ref.dvi docs/interop/qemu-qmp-ref.html \
545 docs/interop/qemu-qmp-ref.info docs/interop/qemu-qmp-ref.pdf \
546 docs/interop/qemu-qmp-ref.txt docs/interop/qemu-qmp-ref.7: \
547 docs/interop/qemu-qmp-ref.texi docs/interop/qemu-qmp-qapi.texi
56e8bdd4 548
ae560cc3
EB
549$(filter %.1 %.7 %.8,$(DOCS)): scripts/texi2pod.pl
550
fe8bf5f6
AB
551# Reports/Analysis
552
553%/coverage-report.html:
554 @mkdir -p $*
555 $(call quiet-command,\
5eda6e42
AB
556 gcovr -r $(SRC_PATH) \
557 $(foreach t, $(TARGET_DIRS), --object-directory $(BUILD_DIR)/$(t)) \
558 --object-directory $(BUILD_DIR) \
337f2311 559 -p --html --html-details -o $@, \
fe8bf5f6
AB
560 "GEN", "coverage-report.html")
561
562.PHONY: coverage-report
563coverage-report: $(CURDIR)/reports/coverage/coverage-report.html
56e8bdd4 564
f53ec699
SW
565ifdef CONFIG_WIN32
566
567INSTALLER = qemu-setup-$(VERSION)$(EXESUF)
568
569nsisflags = -V2 -NOCD
570
571ifneq ($(wildcard $(SRC_PATH)/dll),)
572ifeq ($(ARCH),x86_64)
573# 64 bit executables
574DLL_PATH = $(SRC_PATH)/dll/w64
575nsisflags += -DW64
576else
577# 32 bit executables
578DLL_PATH = $(SRC_PATH)/dll/w32
579endif
580endif
581
582.PHONY: installer
583installer: $(INSTALLER)
584
585INSTDIR=/tmp/qemu-nsis
586
1b00a4c4
PB
587$(INSTALLER): $(SRC_PATH)/qemu.nsi
588 $(MAKE) install DESTDIR=${INSTDIR}
f53ec699 589ifdef SIGNCODE
1b00a4c4 590 (cd ${INSTDIR}/${bindir}; \
f53ec699
SW
591 for i in *.exe; do \
592 $(SIGNCODE) $${i}; \
593 done \
594 )
595endif # SIGNCODE
1b00a4c4 596 (cd ${INSTDIR}/${bindir}; \
f53ec699
SW
597 for i in qemu-system-*.exe; do \
598 arch=$${i%.exe}; \
599 arch=$${arch#qemu-system-}; \
600 echo Section \"$$arch\" Section_$$arch; \
601 echo SetOutPath \"\$$INSTDIR\"; \
602 echo File \"\$${BINDIR}\\$$i\"; \
603 echo SectionEnd; \
604 done \
1b00a4c4 605 ) >${INSTDIR}/${bindir}/system-emulations.nsh
f53ec699
SW
606 makensis $(nsisflags) \
607 $(if $(BUILD_DOCS),-DCONFIG_DOCUMENTATION="y") \
608 $(if $(CONFIG_GTK),-DCONFIG_GTK="y") \
1b00a4c4 609 -DBINDIR="${INSTDIR}/${bindir}" \
f53ec699
SW
610 $(if $(DLL_PATH),-DDLLDIR="$(DLL_PATH)") \
611 -DSRCDIR="$(SRC_PATH)" \
612 -DOUTFILE="$(INSTALLER)" \
805d8a67 613 -DDISPLAYVERSION="$(VERSION)" \
f53ec699
SW
614 $(SRC_PATH)/qemu.nsi
615 rm -r ${INSTDIR}
616ifdef SIGNCODE
617 $(SIGNCODE) $(INSTALLER)
618endif # SIGNCODE
619endif # CONFIG_WIN
620
cb5fc67d
AL
621# Add a dependency on the generated files, so that they are always
622# rebuilt before other object files
428952cf 623ifneq ($(wildcard config-host.mak),)
eaa2ddbb 624ifneq ($(filter-out $(UNCHECKED_GOALS),$(MAKECMDGOALS)),$(if $(MAKECMDGOALS),,fail))
3dff199c 625Makefile: $(generated-files-y)
7748b8cb 626endif
428952cf 627endif
cb5fc67d 628
4fb240a4 629# Include automatically generated dependency files
1435ddb8
PB
630# Dependencies in Makefile.objs files come from our recursive subdir rules
631-include $(wildcard *.d tests/*.d)
324027c2
FZ
632
633include $(SRC_PATH)/tests/docker/Makefile.include
b1fb9a63 634include $(SRC_PATH)/tests/vm/Makefile.include
0d8e065f 635
c355de59
PMD
636print-help-run = printf " %-30s - %s\\n" "$1" "$2"
637print-help = $(quiet-@)$(call print-help-run,$1,$2)
638
0d8e065f
MAL
639.PHONY: help
640help:
641 @echo 'Generic targets:'
c355de59 642 $(call print-help,all,Build all)
0decdfe2 643ifdef CONFIG_MODULES
c355de59 644 $(call print-help,modules,Build all modules)
0decdfe2 645endif
c355de59
PMD
646 $(call print-help,dir/file.o,Build specified target only)
647 $(call print-help,install,Install QEMU, documentation and tools)
648 $(call print-help,ctags/TAGS,Generate tags file for editors)
649 $(call print-help,cscope,Generate cscope index)
968b4db3 650 $(call print-help,sparse,Run sparse on the QEMU source)
0d8e065f 651 @echo ''
2b1f35b9 652 @$(if $(TARGET_DIRS), \
0d8e065f 653 echo 'Architecture specific targets:'; \
2b1f35b9 654 $(foreach t, $(TARGET_DIRS), \
763815a8
PMD
655 $(call print-help-run,$(t)/all,Build for $(t)); \
656 $(if $(CONFIG_FUZZ), \
657 $(if $(findstring softmmu,$(t)), \
658 $(call print-help-run,$(t)/fuzz,Build fuzzer for $(t)); \
659 ))) \
0d8e065f
MAL
660 echo '')
661 @echo 'Cleaning targets:'
c355de59 662 $(call print-help,clean,Remove most generated files but keep the config)
c355de59
PMD
663 $(call print-help,distclean,Remove all generated files)
664 $(call print-help,dist,Build a distributable tarball)
0d8e065f
MAL
665 @echo ''
666 @echo 'Test targets:'
c355de59
PMD
667 $(call print-help,check,Run all tests (check-help for details))
668 $(call print-help,docker,Help about targets running tests inside containers)
669 $(call print-help,vm-help,Help about targets running tests inside VM)
0d8e065f
MAL
670 @echo ''
671 @echo 'Documentation targets:'
c355de59 672 $(call print-help,html info pdf txt,Build documentation in specified format)
0d8e065f
MAL
673 @echo ''
674ifdef CONFIG_WIN32
675 @echo 'Windows targets:'
c355de59 676 $(call print-help,installer,Build NSIS-based installer for QEMU)
0d8e065f 677ifdef QEMU_GA_MSI_ENABLED
c355de59 678 $(call print-help,msi,Build MSI-based installer for qemu-ga)
0d8e065f
MAL
679endif
680 @echo ''
681endif
c355de59
PMD
682 $(call print-help,$(MAKE) [targets],(quiet build, default))
683 $(call print-help,$(MAKE) V=1 [targets],(verbose build))