meson: link emulators without Makefile.target
[qemu/ar7.git] / Makefile
blobfe8c63acad27f9704e31bdcca097d0b4fc71f2d6
1 # Makefile for QEMU.
3 ifneq ($(words $(subst :, ,$(CURDIR))), 1)
4 $(error main directory cannot contain spaces nor colons)
5 endif
7 # Always point to the root of the build tree (needs GNU make).
8 BUILD_DIR=$(CURDIR)
10 # Before including a proper config-host.mak, assume we are in the source tree
11 SRC_PATH=.
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-%
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
24 git-submodule-update:
26 .PHONY: git-submodule-update
28 git_module_status := $(shell \
29 cd '$(SRC_PATH)' && \
30 GIT="$(GIT)" ./scripts/git-submodule.sh status $(GIT_SUBMODULES); \
31 echo $$?; \
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
52 export NINJA=./ninjatool
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
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
65 Makefile.ninja: build.ninja ninjatool
66 ./ninjatool -t ninja2make --omit clean dist uninstall < $< > $@
67 -include Makefile.ninja
69 ${ninja-targets-c_COMPILER} ${ninja-targets-cpp_COMPILER}: .var.command += -MP
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
79 .git-submodule-status: git-submodule-update config-host.mak
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
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
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; \
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
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
119 include $(SRC_PATH)/rules.mak
121 # lor is defined in rules.mak
122 CONFIG_BLOCK := $(call lor,$(CONFIG_SOFTMMU),$(CONFIG_TOOLS))
124 generated-files-y += .git-submodule-status
126 # Don't try to regenerate Makefile or configure
127 # We don't generate any of them
128 Makefile: ;
129 configure: ;
131 .PHONY: all clean cscope distclean html info install install-doc \
132 pdf txt recurse-all dist msi FORCE
134 $(call set-vpath, $(SRC_PATH))
136 LIBS+=-lz $(LIBS_TOOLS)
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.
143 ifeq ($(realpath $(SRC_PATH)),$(realpath .))
144 MANUAL_BUILDDIR := docs/built
145 else
146 MANUAL_BUILDDIR := docs
147 endif
149 ifdef BUILD_DOCS
150 DOCS+=$(MANUAL_BUILDDIR)/system/qemu.1
151 DOCS+=$(MANUAL_BUILDDIR)/tools/qemu-img.1
152 DOCS+=$(MANUAL_BUILDDIR)/tools/qemu-nbd.8
153 DOCS+=$(MANUAL_BUILDDIR)/interop/qemu-ga.8
154 ifeq ($(CONFIG_LINUX)$(CONFIG_SECCOMP)$(CONFIG_LIBCAP_NG),yyy)
155 DOCS+=$(MANUAL_BUILDDIR)/tools/virtiofsd.1
156 endif
157 DOCS+=$(MANUAL_BUILDDIR)/system/qemu-block-drivers.7
158 DOCS+=docs/interop/qemu-qmp-ref.html docs/interop/qemu-qmp-ref.txt docs/interop/qemu-qmp-ref.7
159 DOCS+=docs/interop/qemu-ga-ref.html docs/interop/qemu-ga-ref.txt docs/interop/qemu-ga-ref.7
160 DOCS+=$(MANUAL_BUILDDIR)/system/qemu-cpu-models.7
161 DOCS+=$(MANUAL_BUILDDIR)/index.html
162 ifdef CONFIG_VIRTFS
163 DOCS+=$(MANUAL_BUILDDIR)/tools/virtfs-proxy-helper.1
164 endif
165 ifdef CONFIG_TRACE_SYSTEMTAP
166 DOCS+=$(MANUAL_BUILDDIR)/tools/qemu-trace-stap.1
167 endif
168 else
169 DOCS=
170 endif
172 SUBDIR_MAKEFLAGS=$(if $(V),,--no-print-directory --quiet) BUILD_DIR=$(BUILD_DIR)
174 ifneq ($(wildcard config-host.mak),)
175 include $(SRC_PATH)/Makefile.objs
176 endif
178 include $(SRC_PATH)/tests/Makefile.include
180 all: $(DOCS) $(if $(BUILD_DOCS),sphinxdocs) recurse-all modules
182 config-host.h: config-host.h-timestamp
183 config-host.h-timestamp: config-host.mak
185 TARGET_DIRS_RULES := $(foreach t, all fuzz clean install, $(addsuffix /$(t), $(TARGET_DIRS)))
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
190 $(TARGET_DIRS_RULES): $(TARGET_DEPS)
191 $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C $(dir $@) V="$(V)" TARGET_DIR="$(dir $@)" $(notdir $@),)
193 # LIBFDT_lib="": avoid breaking existing trees with objects requiring -fPIC
194 DTC_MAKE_ARGS=-I$(SRC_PATH)/dtc VPATH=$(SRC_PATH)/dtc -C dtc V="$(V)" LIBFDT_lib=""
195 DTC_CFLAGS=$(CFLAGS) $(QEMU_CFLAGS)
196 DTC_CPPFLAGS=-I$(SRC_PATH)/dtc/libfdt
198 .PHONY: dtc/all
199 dtc/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,)
202 dtc/%: .git-submodule-status
203 @mkdir -p $@
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.
210 CAP_CFLAGS = $(patsubst -W%,,$(CFLAGS) $(QEMU_CFLAGS))
211 CAP_CFLAGS += -DCAPSTONE_USE_SYS_DYN_MEM
212 CAP_CFLAGS += -DCAPSTONE_HAS_ARM
213 CAP_CFLAGS += -DCAPSTONE_HAS_ARM64
214 CAP_CFLAGS += -DCAPSTONE_HAS_POWERPC
215 CAP_CFLAGS += -DCAPSTONE_HAS_X86
217 .PHONY: capstone/all
218 capstone/all: .git-submodule-status
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))
221 .PHONY: slirp/all
222 slirp/all: .git-submodule-status
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)" \
227 CFLAGS="$(QEMU_CFLAGS) $(CFLAGS)" LDFLAGS="$(QEMU_LDFLAGS)")
229 $(filter %/all, $(TARGET_DIRS_RULES)):
231 ROM_DIRS = $(addprefix pc-bios/, $(ROMS))
232 ROM_DIRS_RULES=$(foreach t, all clean, $(addsuffix /$(t), $(ROM_DIRS)))
233 # Only keep -O and -g cflags
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 $@),)
238 .PHONY: recurse-all recurse-clean recurse-install
239 recurse-all: $(addsuffix /all, $(TARGET_DIRS) $(ROM_DIRS))
240 recurse-clean: $(addsuffix /clean, $(TARGET_DIRS) $(ROM_DIRS))
241 recurse-install: $(addsuffix /install, $(TARGET_DIRS))
242 $(addsuffix /install, $(TARGET_DIRS)): all
244 $(BUILD_DIR)/version.o: $(SRC_PATH)/version.rc config-host.h
245 $(call quiet-command,$(WINDRES) -I$(BUILD_DIR) -o $@ $<,"RC","version.o")
247 Makefile: $(version-obj-y)
249 ######################################################################
251 clean: recurse-clean ninja-clean clean-ctlist
252 -test -f ninjatool && ./ninjatool $(if $(V),-v,) -t clean
253 # avoid old build problems by removing potentially incorrect old files
254 rm -f config.mak op-i386.h opc-i386.h gen-op-i386.h op-arm.h opc-arm.h gen-op-arm.h
255 find . \( -name '*.so' -o -name '*.dll' -o -name '*.mo' -o -name '*.[oda]' \) -type f \
256 ! -path ./roms/edk2/ArmPkg/Library/GccLto/liblto-aarch64.a \
257 ! -path ./roms/edk2/ArmPkg/Library/GccLto/liblto-arm.a \
258 ! -path ./roms/edk2/BaseTools/Source/Python/UPT/Dll/sqlite3.dll \
259 -exec rm {} +
260 rm -f TAGS cscope.* *.pod *~ */*~
261 rm -f fsdev/*.pod scsi/*.pod
262 rm -f $(foreach f,$(generated-files-y),$(f) $(f)-timestamp)
264 VERSION ?= $(shell cat VERSION)
266 dist: qemu-$(VERSION).tar.bz2
268 qemu-%.tar.bz2:
269 $(SRC_PATH)/scripts/make-release "$(SRC_PATH)" "$(patsubst qemu-%.tar.bz2,%,$@)"
271 define clean-manual =
272 rm -rf $(MANUAL_BUILDDIR)/$1/_static
273 rm -f $(MANUAL_BUILDDIR)/$1/objects.inv $(MANUAL_BUILDDIR)/$1/searchindex.js $(MANUAL_BUILDDIR)/$1/*.html
274 endef
276 distclean: clean ninja-distclean
277 -test -f ninjatool && ./ninjatool $(if $(V),-v,) -t clean -g
278 rm -f config-host.mak config-host.h* $(DOCS)
279 rm -f tests/tcg/config-*.mak
280 rm -f config-all-disas.mak config.status
281 rm -f po/*.mo tests/qemu-iotests/common.env
282 rm -f roms/seabios/config.mak roms/vgabios/config.mak
283 rm -f qemu-plugins-ld.symbols qemu-plugins-ld64.symbols
284 rm -f *-config-target.h *-config-devices.mak *-config-devices.h
285 rm -rf meson-private meson-logs meson-info compile_commands.json
286 rm -f Makefile.ninja ninjatool ninjatool.stamp Makefile.mtest
287 rm -f config.log
288 rm -f linux-headers/asm
289 rm -f docs/version.texi
290 rm -f docs/interop/qemu-ga-qapi.texi docs/interop/qemu-qmp-qapi.texi
291 rm -f docs/interop/qemu-qmp-ref.7 docs/interop/qemu-ga-ref.7
292 rm -f docs/interop/qemu-qmp-ref.txt docs/interop/qemu-ga-ref.txt
293 rm -f docs/interop/qemu-qmp-ref.pdf docs/interop/qemu-ga-ref.pdf
294 rm -f docs/interop/qemu-qmp-ref.html docs/interop/qemu-ga-ref.html
295 rm -rf .doctrees
296 $(call clean-manual,devel)
297 $(call clean-manual,interop)
298 $(call clean-manual,specs)
299 $(call clean-manual,system)
300 $(call clean-manual,tools)
301 $(call clean-manual,user)
302 for d in $(TARGET_DIRS); do \
303 rm -rf $$d || exit 1 ; \
304 done
305 rm -Rf .sdk
307 KEYMAPS=da en-gb et fr fr-ch is lt no pt-br sv \
308 ar de en-us fi fr-be hr it lv nl pl ru th \
309 de-ch es fo fr-ca hu ja mk pt sl tr \
310 bepo cz
312 ifdef INSTALL_BLOBS
313 BLOBS=bios.bin bios-256k.bin bios-microvm.bin sgabios.bin vgabios.bin vgabios-cirrus.bin \
314 vgabios-stdvga.bin vgabios-vmware.bin vgabios-qxl.bin vgabios-virtio.bin \
315 vgabios-ramfb.bin vgabios-bochs-display.bin vgabios-ati.bin \
316 openbios-sparc32 openbios-sparc64 openbios-ppc QEMU,tcx.bin QEMU,cgthree.bin \
317 pxe-e1000.rom pxe-eepro100.rom pxe-ne2k_pci.rom \
318 pxe-pcnet.rom pxe-rtl8139.rom pxe-virtio.rom \
319 efi-e1000.rom efi-eepro100.rom efi-ne2k_pci.rom \
320 efi-pcnet.rom efi-rtl8139.rom efi-virtio.rom \
321 efi-e1000e.rom efi-vmxnet3.rom \
322 qemu-nsis.bmp \
323 bamboo.dtb canyonlands.dtb petalogix-s3adsp1800.dtb petalogix-ml605.dtb \
324 multiboot.bin linuxboot.bin linuxboot_dma.bin kvmvapic.bin pvh.bin \
325 s390-ccw.img s390-netboot.img \
326 slof.bin skiboot.lid \
327 palcode-clipper \
328 u-boot.e500 u-boot-sam460-20100605.bin \
329 qemu_vga.ndrv \
330 edk2-licenses.txt \
331 hppa-firmware.img \
332 opensbi-riscv32-sifive_u-fw_jump.bin opensbi-riscv32-virt-fw_jump.bin \
333 opensbi-riscv64-sifive_u-fw_jump.bin opensbi-riscv64-virt-fw_jump.bin
334 else
335 BLOBS=
336 endif
338 # Note that we manually filter-out the non-Sphinx documentation which
339 # is currently built into the docs/interop directory in the build tree,
340 # and also any sphinx-built manpages.
341 define install-manual =
342 for d in $$(cd $(MANUAL_BUILDDIR) && find $1 -type d); do $(INSTALL_DIR) "$(DESTDIR)$(qemu_docdir)/$$d"; done
343 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
344 endef
346 # Note that we deliberately do not install the "devel" manual: it is
347 # for QEMU developers, and not interesting to our users.
348 .PHONY: install-sphinxdocs
349 install-sphinxdocs: sphinxdocs
350 $(call install-manual,interop)
351 $(call install-manual,specs)
352 $(call install-manual,system)
353 $(call install-manual,tools)
354 $(call install-manual,user)
356 install-doc: $(DOCS) install-sphinxdocs
357 $(INSTALL_DIR) "$(DESTDIR)$(qemu_docdir)"
358 $(INSTALL_DATA) $(MANUAL_BUILDDIR)/index.html "$(DESTDIR)$(qemu_docdir)"
359 $(INSTALL_DIR) "$(DESTDIR)$(qemu_docdir)/interop"
360 $(INSTALL_DATA) docs/interop/qemu-qmp-ref.html "$(DESTDIR)$(qemu_docdir)/interop"
361 $(INSTALL_DATA) docs/interop/qemu-qmp-ref.txt "$(DESTDIR)$(qemu_docdir)/interop"
362 ifdef CONFIG_POSIX
363 $(INSTALL_DIR) "$(DESTDIR)$(mandir)/man1"
364 $(INSTALL_DATA) $(MANUAL_BUILDDIR)/system/qemu.1 "$(DESTDIR)$(mandir)/man1"
365 $(INSTALL_DIR) "$(DESTDIR)$(mandir)/man7"
366 $(INSTALL_DATA) docs/interop/qemu-qmp-ref.7 "$(DESTDIR)$(mandir)/man7"
367 $(INSTALL_DATA) $(MANUAL_BUILDDIR)/system/qemu-block-drivers.7 "$(DESTDIR)$(mandir)/man7"
368 $(INSTALL_DATA) $(MANUAL_BUILDDIR)/system/qemu-cpu-models.7 "$(DESTDIR)$(mandir)/man7"
369 ifeq ($(CONFIG_TOOLS),y)
370 $(INSTALL_DATA) $(MANUAL_BUILDDIR)/tools/qemu-img.1 "$(DESTDIR)$(mandir)/man1"
371 $(INSTALL_DIR) "$(DESTDIR)$(mandir)/man8"
372 $(INSTALL_DATA) $(MANUAL_BUILDDIR)/tools/qemu-nbd.8 "$(DESTDIR)$(mandir)/man8"
373 endif
374 ifdef CONFIG_TRACE_SYSTEMTAP
375 $(INSTALL_DATA) $(MANUAL_BUILDDIR)/tools/qemu-trace-stap.1 "$(DESTDIR)$(mandir)/man1"
376 endif
377 ifeq ($(CONFIG_GUEST_AGENT),y)
378 $(INSTALL_DATA) $(MANUAL_BUILDDIR)/interop/qemu-ga.8 "$(DESTDIR)$(mandir)/man8"
379 $(INSTALL_DIR) "$(DESTDIR)$(qemu_docdir)/interop"
380 $(INSTALL_DATA) docs/interop/qemu-ga-ref.html "$(DESTDIR)$(qemu_docdir)/interop"
381 $(INSTALL_DATA) docs/interop/qemu-ga-ref.txt "$(DESTDIR)$(qemu_docdir)/interop"
382 $(INSTALL_DATA) docs/interop/qemu-ga-ref.7 "$(DESTDIR)$(mandir)/man7"
383 endif
384 endif
385 ifdef CONFIG_VIRTFS
386 $(INSTALL_DIR) "$(DESTDIR)$(mandir)/man1"
387 $(INSTALL_DATA) $(MANUAL_BUILDDIR)/tools/virtfs-proxy-helper.1 "$(DESTDIR)$(mandir)/man1"
388 endif
389 ifeq ($(CONFIG_LINUX)$(CONFIG_SECCOMP)$(CONFIG_LIBCAP_NG),yyy)
390 $(INSTALL_DATA) $(MANUAL_BUILDDIR)/tools/virtiofsd.1 "$(DESTDIR)$(mandir)/man1"
391 endif
393 install-datadir:
394 $(INSTALL_DIR) "$(DESTDIR)$(qemu_datadir)"
396 install-localstatedir:
397 ifdef CONFIG_POSIX
398 ifeq ($(CONFIG_GUEST_AGENT),y)
399 $(INSTALL_DIR) "$(DESTDIR)$(qemu_localstatedir)"/run
400 endif
401 endif
403 ICON_SIZES=16x16 24x24 32x32 48x48 64x64 128x128 256x256 512x512
405 # Needed by "meson install"
406 export DESTDIR
407 install: all $(if $(BUILD_DOCS),install-doc) \
408 install-datadir install-localstatedir \
409 recurse-install
410 ifdef CONFIG_TRACE_SYSTEMTAP
411 $(INSTALL_PROG) "scripts/qemu-trace-stap" $(DESTDIR)$(bindir)
412 endif
413 ifneq ($(BLOBS),)
414 set -e; for x in $(BLOBS); do \
415 $(INSTALL_DATA) $(SRC_PATH)/pc-bios/$$x "$(DESTDIR)$(qemu_datadir)"; \
416 done
417 endif
418 for s in $(ICON_SIZES); do \
419 mkdir -p "$(DESTDIR)$(qemu_icondir)/hicolor/$${s}/apps"; \
420 $(INSTALL_DATA) $(SRC_PATH)/ui/icons/qemu_$${s}.png \
421 "$(DESTDIR)$(qemu_icondir)/hicolor/$${s}/apps/qemu.png"; \
422 done; \
423 mkdir -p "$(DESTDIR)$(qemu_icondir)/hicolor/32x32/apps"; \
424 $(INSTALL_DATA) $(SRC_PATH)/ui/icons/qemu_32x32.bmp \
425 "$(DESTDIR)$(qemu_icondir)/hicolor/32x32/apps/qemu.bmp"; \
426 mkdir -p "$(DESTDIR)$(qemu_icondir)/hicolor/scalable/apps"; \
427 $(INSTALL_DATA) $(SRC_PATH)/ui/icons/qemu.svg \
428 "$(DESTDIR)$(qemu_icondir)/hicolor/scalable/apps/qemu.svg"
429 mkdir -p "$(DESTDIR)$(qemu_desktopdir)"
430 $(INSTALL_DATA) $(SRC_PATH)/ui/qemu.desktop \
431 "$(DESTDIR)$(qemu_desktopdir)/qemu.desktop"
432 ifdef CONFIG_GTK
433 $(MAKE) -C po $@
434 endif
435 $(INSTALL_DIR) "$(DESTDIR)$(qemu_datadir)/keymaps"
436 set -e; for x in $(KEYMAPS); do \
437 $(INSTALL_DATA) $(SRC_PATH)/pc-bios/keymaps/$$x "$(DESTDIR)$(qemu_datadir)/keymaps"; \
438 done
439 for d in $(TARGET_DIRS); do \
440 $(MAKE) $(SUBDIR_MAKEFLAGS) TARGET_DIR=$$d/ -C $$d $@ || exit 1 ; \
441 done
443 # documentation
444 MAKEINFO=makeinfo
445 MAKEINFOINCLUDES= -I docs -I $(<D) -I $(@D)
446 MAKEINFOFLAGS=--no-split --number-sections $(MAKEINFOINCLUDES)
447 TEXI2PODFLAGS=$(MAKEINFOINCLUDES) -DVERSION="$(VERSION)" -DCONFDIR="$(qemu_confdir)"
448 TEXI2PDFFLAGS=$(if $(V),,--quiet) -I $(SRC_PATH) $(MAKEINFOINCLUDES)
450 docs/version.texi: $(SRC_PATH)/VERSION config-host.mak
451 $(call quiet-command,(\
452 echo "@set VERSION $(VERSION)" && \
453 echo "@set CONFDIR $(qemu_confdir)" \
454 )> $@,"GEN","$@")
456 %.html: %.texi docs/version.texi
457 $(call quiet-command,LC_ALL=C $(MAKEINFO) $(MAKEINFOFLAGS) --no-headers \
458 --html $< -o $@,"GEN","$@")
460 %.info: %.texi docs/version.texi
461 $(call quiet-command,$(MAKEINFO) $(MAKEINFOFLAGS) $< -o $@,"GEN","$@")
463 %.txt: %.texi docs/version.texi
464 $(call quiet-command,LC_ALL=C $(MAKEINFO) $(MAKEINFOFLAGS) --no-headers \
465 --plaintext $< -o $@,"GEN","$@")
467 %.pdf: %.texi docs/version.texi
468 $(call quiet-command,texi2pdf $(TEXI2PDFFLAGS) $< -o $@,"GEN","$@")
470 # Sphinx builds all its documentation at once in one invocation
471 # and handles "don't rebuild things unless necessary" itself.
472 # The '.doctrees' files are cached information to speed this up.
473 .PHONY: sphinxdocs
474 sphinxdocs: $(MANUAL_BUILDDIR)/devel/index.html \
475 $(MANUAL_BUILDDIR)/interop/index.html \
476 $(MANUAL_BUILDDIR)/specs/index.html \
477 $(MANUAL_BUILDDIR)/system/index.html \
478 $(MANUAL_BUILDDIR)/tools/index.html \
479 $(MANUAL_BUILDDIR)/user/index.html
481 # Canned command to build a single manual
482 # Arguments: $1 = manual name, $2 = Sphinx builder ('html' or 'man')
483 # Note the use of different doctree for each (manual, builder) tuple;
484 # this works around Sphinx not handling parallel invocation on
485 # a single doctree: https://github.com/sphinx-doc/sphinx/issues/2946
486 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")
487 # We assume all RST files in the manual's directory are used in it
488 manual-deps = $(wildcard $(SRC_PATH)/docs/$1/*.rst $(SRC_PATH)/docs/$1/*/*.rst) \
489 $(SRC_PATH)/docs/defs.rst.inc \
490 $(SRC_PATH)/docs/$1/conf.py $(SRC_PATH)/docs/conf.py \
491 $(SRC_PATH)/docs/sphinx/*.py
492 # Macro to write out the rule and dependencies for building manpages
493 # Usage: $(call define-manpage-rule,manualname,manpage1 manpage2...[,extradeps])
494 # 'extradeps' is optional, and specifies extra files (eg .hx files) that
495 # the manual page depends on.
496 define define-manpage-rule
497 $(call atomic,$(foreach manpage,$2,$(MANUAL_BUILDDIR)/$1/$(manpage)),$(call manual-deps,$1) $3)
498 $(call build-manual,$1,man)
499 endef
501 $(MANUAL_BUILDDIR)/devel/index.html: $(call manual-deps,devel)
502 $(call build-manual,devel,html)
504 $(MANUAL_BUILDDIR)/interop/index.html: $(call manual-deps,interop)
505 $(call build-manual,interop,html)
507 $(MANUAL_BUILDDIR)/specs/index.html: $(call manual-deps,specs)
508 $(call build-manual,specs,html)
510 $(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
511 $(call build-manual,system,html)
513 $(MANUAL_BUILDDIR)/tools/index.html: $(call manual-deps,tools) $(SRC_PATH)/qemu-img-cmds.hx $(SRC_PATH)/docs/qemu-option-trace.rst.inc
514 $(call build-manual,tools,html)
516 $(MANUAL_BUILDDIR)/user/index.html: $(call manual-deps,user)
517 $(call build-manual,user,html)
519 $(call define-manpage-rule,interop,qemu-ga.8)
521 $(call define-manpage-rule,system,qemu.1 qemu-block-drivers.7 qemu-cpu-models.7)
523 $(call define-manpage-rule,tools,\
524 qemu-img.1 qemu-nbd.8 qemu-trace-stap.1\
525 virtiofsd.1 virtfs-proxy-helper.1,\
526 $(SRC_PATH)/qemu-img-cmds.hx $(SRC_PATH)/docs/qemu-option-trace.rst.inc)
528 $(MANUAL_BUILDDIR)/index.html: $(SRC_PATH)/docs/index.html.in qemu-version.h
529 @mkdir -p "$(MANUAL_BUILDDIR)"
530 $(call quiet-command, sed "s|@@VERSION@@|${VERSION}|g" $< >$@, \
531 "GEN","$@")
533 docs/interop/qemu-qmp-qapi.texi: qapi/qapi-doc.texi
534 @cp -p $< $@
536 docs/interop/qemu-ga-qapi.texi: qga/qga-qapi-doc.texi
537 @cp -p $< $@
539 html: docs/interop/qemu-qmp-ref.html docs/interop/qemu-ga-ref.html sphinxdocs
540 info: docs/interop/qemu-qmp-ref.info docs/interop/qemu-ga-ref.info
541 pdf: docs/interop/qemu-qmp-ref.pdf docs/interop/qemu-ga-ref.pdf
542 txt: docs/interop/qemu-qmp-ref.txt docs/interop/qemu-ga-ref.txt
544 docs/interop/qemu-ga-ref.dvi docs/interop/qemu-ga-ref.html \
545 docs/interop/qemu-ga-ref.info docs/interop/qemu-ga-ref.pdf \
546 docs/interop/qemu-ga-ref.txt docs/interop/qemu-ga-ref.7: \
547 docs/interop/qemu-ga-ref.texi docs/interop/qemu-ga-qapi.texi
549 docs/interop/qemu-qmp-ref.dvi docs/interop/qemu-qmp-ref.html \
550 docs/interop/qemu-qmp-ref.info docs/interop/qemu-qmp-ref.pdf \
551 docs/interop/qemu-qmp-ref.txt docs/interop/qemu-qmp-ref.7: \
552 docs/interop/qemu-qmp-ref.texi docs/interop/qemu-qmp-qapi.texi
554 $(filter %.1 %.7 %.8,$(DOCS)): scripts/texi2pod.pl
556 # Reports/Analysis
558 %/coverage-report.html:
559 @mkdir -p $*
560 $(call quiet-command,\
561 gcovr -r $(SRC_PATH) \
562 $(foreach t, $(TARGET_DIRS), --object-directory $(BUILD_DIR)/$(t)) \
563 --object-directory $(BUILD_DIR) \
564 -p --html --html-details -o $@, \
565 "GEN", "coverage-report.html")
567 .PHONY: coverage-report
568 coverage-report: $(CURDIR)/reports/coverage/coverage-report.html
570 ifdef CONFIG_WIN32
572 INSTALLER = qemu-setup-$(VERSION)$(EXESUF)
574 nsisflags = -V2 -NOCD
576 ifneq ($(wildcard $(SRC_PATH)/dll),)
577 ifeq ($(ARCH),x86_64)
578 # 64 bit executables
579 DLL_PATH = $(SRC_PATH)/dll/w64
580 nsisflags += -DW64
581 else
582 # 32 bit executables
583 DLL_PATH = $(SRC_PATH)/dll/w32
584 endif
585 endif
587 .PHONY: installer
588 installer: $(INSTALLER)
590 INSTDIR=/tmp/qemu-nsis
592 $(INSTALLER): $(SRC_PATH)/qemu.nsi
593 $(MAKE) install DESTDIR=${INSTDIR}
594 ifdef SIGNCODE
595 (cd ${INSTDIR}/${bindir}; \
596 for i in *.exe; do \
597 $(SIGNCODE) $${i}; \
598 done \
600 endif # SIGNCODE
601 (cd ${INSTDIR}/${bindir}; \
602 for i in qemu-system-*.exe; do \
603 arch=$${i%.exe}; \
604 arch=$${arch#qemu-system-}; \
605 echo Section \"$$arch\" Section_$$arch; \
606 echo SetOutPath \"\$$INSTDIR\"; \
607 echo File \"\$${BINDIR}\\$$i\"; \
608 echo SectionEnd; \
609 done \
610 ) >${INSTDIR}/${bindir}/system-emulations.nsh
611 makensis $(nsisflags) \
612 $(if $(BUILD_DOCS),-DCONFIG_DOCUMENTATION="y") \
613 $(if $(CONFIG_GTK),-DCONFIG_GTK="y") \
614 -DBINDIR="${INSTDIR}/${bindir}" \
615 $(if $(DLL_PATH),-DDLLDIR="$(DLL_PATH)") \
616 -DSRCDIR="$(SRC_PATH)" \
617 -DOUTFILE="$(INSTALLER)" \
618 -DDISPLAYVERSION="$(VERSION)" \
619 $(SRC_PATH)/qemu.nsi
620 rm -r ${INSTDIR}
621 ifdef SIGNCODE
622 $(SIGNCODE) $(INSTALLER)
623 endif # SIGNCODE
624 endif # CONFIG_WIN
626 # Add a dependency on the generated files, so that they are always
627 # rebuilt before other object files
628 ifneq ($(wildcard config-host.mak),)
629 ifneq ($(filter-out $(UNCHECKED_GOALS),$(MAKECMDGOALS)),$(if $(MAKECMDGOALS),,fail))
630 Makefile: $(generated-files-y)
631 endif
632 endif
634 # Include automatically generated dependency files
635 # Dependencies in Makefile.objs files come from our recursive subdir rules
636 -include $(wildcard *.d tests/*.d)
638 include $(SRC_PATH)/tests/docker/Makefile.include
639 include $(SRC_PATH)/tests/vm/Makefile.include
641 print-help-run = printf " %-30s - %s\\n" "$1" "$2"
642 print-help = $(quiet-@)$(call print-help-run,$1,$2)
644 .PHONY: help
645 help:
646 @echo 'Generic targets:'
647 $(call print-help,all,Build all)
648 ifdef CONFIG_MODULES
649 $(call print-help,modules,Build all modules)
650 endif
651 $(call print-help,dir/file.o,Build specified target only)
652 $(call print-help,install,Install QEMU, documentation and tools)
653 $(call print-help,ctags/TAGS,Generate tags file for editors)
654 $(call print-help,cscope,Generate cscope index)
655 $(call print-help,sparse,Run sparse on the QEMU source)
656 @echo ''
657 @$(if $(TARGET_DIRS), \
658 echo 'Architecture specific targets:'; \
659 $(foreach t, $(TARGET_DIRS), \
660 $(call print-help-run,$(t)/all,Build for $(t)); \
661 $(if $(CONFIG_FUZZ), \
662 $(if $(findstring softmmu,$(t)), \
663 $(call print-help-run,$(t)/fuzz,Build fuzzer for $(t)); \
664 ))) \
665 echo '')
666 @echo 'Cleaning targets:'
667 $(call print-help,clean,Remove most generated files but keep the config)
668 $(call print-help,distclean,Remove all generated files)
669 $(call print-help,dist,Build a distributable tarball)
670 @echo ''
671 @echo 'Test targets:'
672 $(call print-help,check,Run all tests (check-help for details))
673 $(call print-help,docker,Help about targets running tests inside containers)
674 $(call print-help,vm-help,Help about targets running tests inside VM)
675 @echo ''
676 @echo 'Documentation targets:'
677 $(call print-help,html info pdf txt,Build documentation in specified format)
678 @echo ''
679 ifdef CONFIG_WIN32
680 @echo 'Windows targets:'
681 $(call print-help,installer,Build NSIS-based installer for QEMU)
682 ifdef QEMU_GA_MSI_ENABLED
683 $(call print-help,msi,Build MSI-based installer for qemu-ga)
684 endif
685 @echo ''
686 endif
687 $(call print-help,$(MAKE) [targets],(quiet build, default))
688 $(call print-help,$(MAKE) V=1 [targets],(verbose build))