xref: /openbmc/qemu/Makefile (revision 1e0ef873)
10cb3fb1eSpbrook# Makefile for QEMU.
20cb3fb1eSpbrook
34ace32e2SAntonio Ospiteifneq ($(words $(subst :, ,$(CURDIR))), 1)
44ace32e2SAntonio Ospite  $(error main directory cannot contain spaces nor colons)
54ace32e2SAntonio Ospiteendif
64ace32e2SAntonio Ospite
7519e1693SStefan Weil# Always point to the root of the build tree (needs GNU make).
8519e1693SStefan WeilBUILD_DIR=$(CURDIR)
9388d4758SLluís Vilanova
10eaa2ddbbSFam Zheng# Before including a proper config-host.mak, assume we are in the source tree
11eaa2ddbbSFam ZhengSRC_PATH=.
12eaa2ddbbSFam Zheng
1328fa2927SPhilippe Mathieu-DaudéUNCHECKED_GOALS := %clean TAGS cscope ctags dist \
1428fa2927SPhilippe Mathieu-Daudé    html info pdf txt \
15de1da442SMarc-André Lureau    help check-help print-% \
164f2f6276SPhilippe Mathieu-Daudé    docker docker-% vm-help vm-test vm-build-%
17eaa2ddbbSFam Zheng
18250b086eSLluís Vilanova# All following code might depend on configuration variables
1955d7e8f6Saurel32ifneq ($(wildcard config-host.mak),)
201ad2134fSPaul Brook# Put the all: rule here so that config-host.mak can contain dependencies.
218f67aa82SStefan Weilall:
22ad064840Spbrookinclude config-host.mak
23d1bd2423SPeter Maydell
24aef45d51SDaniel P. Berrangegit-submodule-update:
25aef45d51SDaniel P. Berrange
26aef45d51SDaniel P. Berrange.PHONY: git-submodule-update
27aef45d51SDaniel P. Berrange
28aef45d51SDaniel P. Berrangegit_module_status := $(shell \
29aef45d51SDaniel P. Berrange  cd '$(SRC_PATH)' && \
30cc84d63aSDaniel P. Berrange  GIT="$(GIT)" ./scripts/git-submodule.sh status $(GIT_SUBMODULES); \
31aef45d51SDaniel P. Berrange  echo $$?; \
32aef45d51SDaniel P. Berrange)
33aef45d51SDaniel P. Berrange
34aef45d51SDaniel P. Berrangeifeq (1,$(git_module_status))
35f62bbee5SDaniel P. Berrangeifeq (no,$(GIT_UPDATE))
36f62bbee5SDaniel P. Berrangegit-submodule-update:
37f62bbee5SDaniel P. Berrange	$(call quiet-command, \
38f62bbee5SDaniel P. Berrange            echo && \
39f62bbee5SDaniel P. Berrange            echo "GIT submodule checkout is out of date. Please run" && \
40f62bbee5SDaniel P. Berrange            echo "  scripts/git-submodule.sh update $(GIT_SUBMODULES)" && \
41f62bbee5SDaniel P. Berrange            echo "from the source directory checkout $(SRC_PATH)" && \
42f62bbee5SDaniel P. Berrange            echo && \
43f62bbee5SDaniel P. Berrange            exit 1)
44f62bbee5SDaniel P. Berrangeelse
45aef45d51SDaniel P. Berrangegit-submodule-update:
46aef45d51SDaniel P. Berrange	$(call quiet-command, \
47cc84d63aSDaniel P. Berrange          (cd $(SRC_PATH) && GIT="$(GIT)" ./scripts/git-submodule.sh update $(GIT_SUBMODULES)), \
48aef45d51SDaniel P. Berrange          "GIT","$(GIT_SUBMODULES)")
49aef45d51SDaniel P. Berrangeendif
50aef45d51SDaniel P. Berrangeendif
51aef45d51SDaniel P. Berrange
5292712822SDaniel P. Berrange.git-submodule-status: git-submodule-update config-host.mak
53aef45d51SDaniel P. Berrange
54d1bd2423SPeter Maydell# Check that we're not trying to do an out-of-tree build from
55d1bd2423SPeter Maydell# a tree that's been used for an in-tree build.
56d1bd2423SPeter Maydellifneq ($(realpath $(SRC_PATH)),$(realpath .))
57d1bd2423SPeter Maydellifneq ($(wildcard $(SRC_PATH)/config-host.mak),)
58d1bd2423SPeter Maydell$(error This is an out of tree build but your source tree ($(SRC_PATH)) \
59d1bd2423SPeter Maydellseems to have been used for an in-tree build. You can fix this by running \
60b98a3baeSPhilippe Mathieu-Daudé"$(MAKE) distclean && rm -rf *-linux-user *-softmmu" in your source tree)
61d1bd2423SPeter Maydellendif
62d1bd2423SPeter Maydellendif
63d1bd2423SPeter Maydell
642b1f35b9SAlex BennéeCONFIG_SOFTMMU := $(if $(filter %-softmmu,$(TARGET_DIRS)),y)
652b1f35b9SAlex BennéeCONFIG_USER_ONLY := $(if $(filter %-user,$(TARGET_DIRS)),y)
666b827ccaSStefano StabelliniCONFIG_XEN := $(CONFIG_XEN_BACKEND)
67f3aa844bSPaolo BonziniCONFIG_ALL=y
68f3aa844bSPaolo Bonzini-include config-all-devices.mak
69f3aa844bSPaolo Bonzini-include config-all-disas.mak
70f3aa844bSPaolo Bonzini
713a6b016dSMarkus Armbrusterconfig-host.mak: $(SRC_PATH)/configure $(SRC_PATH)/pc-bios $(SRC_PATH)/VERSION
72e5efe7f5SJuan Quintela	@echo $@ is out-of-date, running configure
73cdb69b08SMarkus Armbruster	@./config.status
7426fffe29SEmilio G. Cota
7526fffe29SEmilio G. Cota# Force configure to re-run if the API symbols are updated
7626fffe29SEmilio G. Cotaifeq ($(CONFIG_PLUGIN),y)
7726fffe29SEmilio G. Cotaconfig-host.mak: $(SRC_PATH)/plugins/qemu-plugins.symbols
7826fffe29SEmilio G. Cotaendif
7926fffe29SEmilio G. Cota
8055d7e8f6Saurel32else
8155d7e8f6Saurel32config-host.mak:
82eaa2ddbbSFam Zhengifneq ($(filter-out $(UNCHECKED_GOALS),$(MAKECMDGOALS)),$(if $(MAKECMDGOALS),,fail))
8355d7e8f6Saurel32	@echo "Please call configure before running make!"
8455d7e8f6Saurel32	@exit 1
8555d7e8f6Saurel32endif
867748b8cbSMike Frysingerendif
87766a487aSbellard
88fb57c881SFam Zhenginclude $(SRC_PATH)/rules.mak
89fb57c881SFam Zheng
90c932ce31SPaolo Bonzini# lor is defined in rules.mak
9129de2804SLaurent VivierCONFIG_BLOCK := $(call lor,$(CONFIG_SOFTMMU),$(CONFIG_TOOLS))
9229de2804SLaurent Vivier
9357b49737SPeter Maydell# Create QEMU_PKGVERSION and FULL_VERSION strings
9457b49737SPeter Maydell# If PKGVERSION is set, use that; otherwise get version and -dirty status from git
9557b49737SPeter MaydellQEMU_PKGVERSION := $(if $(PKGVERSION),$(PKGVERSION),$(shell \
9657b49737SPeter Maydell  cd $(SRC_PATH); \
9757b49737SPeter Maydell  if test -e .git; then \
9857b49737SPeter Maydell    git describe --match 'v*' 2>/dev/null | tr -d '\n'; \
9957b49737SPeter Maydell    if ! git diff-index --quiet HEAD &>/dev/null; then \
10057b49737SPeter Maydell      echo "-dirty"; \
10157b49737SPeter Maydell    fi; \
10257b49737SPeter Maydell  fi))
10357b49737SPeter Maydell
10457b49737SPeter Maydell# Either "version (pkgversion)", or just "version" if pkgversion not set
10557b49737SPeter MaydellFULL_VERSION := $(if $(QEMU_PKGVERSION),$(VERSION) ($(QEMU_PKGVERSION)),$(VERSION))
10657b49737SPeter Maydell
1073dff199cSLaurent Viviergenerated-files-y = qemu-version.h config-host.h qemu-options.def
108bf582c34SEric Blake
109bf582c34SEric BlakeGENERATED_QAPI_FILES = qapi/qapi-builtin-types.h qapi/qapi-builtin-types.c
110bf582c34SEric BlakeGENERATED_QAPI_FILES += qapi/qapi-types.h qapi/qapi-types.c
111bf582c34SEric BlakeGENERATED_QAPI_FILES += $(QAPI_MODULES:%=qapi/qapi-types-%.h)
112bf582c34SEric BlakeGENERATED_QAPI_FILES += $(QAPI_MODULES:%=qapi/qapi-types-%.c)
113bf582c34SEric BlakeGENERATED_QAPI_FILES += qapi/qapi-builtin-visit.h qapi/qapi-builtin-visit.c
114bf582c34SEric BlakeGENERATED_QAPI_FILES += qapi/qapi-visit.h qapi/qapi-visit.c
115bf582c34SEric BlakeGENERATED_QAPI_FILES += $(QAPI_MODULES:%=qapi/qapi-visit-%.h)
116bf582c34SEric BlakeGENERATED_QAPI_FILES += $(QAPI_MODULES:%=qapi/qapi-visit-%.c)
11700ca24ffSMarkus ArmbrusterGENERATED_QAPI_FILES += qapi/qapi-init-commands.h qapi/qapi-init-commands.c
118bf582c34SEric BlakeGENERATED_QAPI_FILES += qapi/qapi-commands.h qapi/qapi-commands.c
119bf582c34SEric BlakeGENERATED_QAPI_FILES += $(QAPI_MODULES:%=qapi/qapi-commands-%.h)
120bf582c34SEric BlakeGENERATED_QAPI_FILES += $(QAPI_MODULES:%=qapi/qapi-commands-%.c)
1215d75648bSMarkus ArmbrusterGENERATED_QAPI_FILES += qapi/qapi-emit-events.h qapi/qapi-emit-events.c
122bf582c34SEric BlakeGENERATED_QAPI_FILES += qapi/qapi-events.h qapi/qapi-events.c
123bf582c34SEric BlakeGENERATED_QAPI_FILES += $(QAPI_MODULES:%=qapi/qapi-events-%.h)
124bf582c34SEric BlakeGENERATED_QAPI_FILES += $(QAPI_MODULES:%=qapi/qapi-events-%.c)
125bf582c34SEric BlakeGENERATED_QAPI_FILES += qapi/qapi-introspect.c qapi/qapi-introspect.h
126bf582c34SEric BlakeGENERATED_QAPI_FILES += qapi/qapi-doc.texi
127bf582c34SEric Blake
1282af282ecSKevin Wolf# The following list considers only the storage daemon main module. All other
1292af282ecSKevin Wolf# modules are currently shared with the main schema, so we don't actually
1302af282ecSKevin Wolf# generate additional files.
1312af282ecSKevin Wolf
1322af282ecSKevin WolfGENERATED_STORAGE_DAEMON_QAPI_FILES = storage-daemon/qapi/qapi-commands.h
1332af282ecSKevin WolfGENERATED_STORAGE_DAEMON_QAPI_FILES += storage-daemon/qapi/qapi-commands.c
1342af282ecSKevin WolfGENERATED_STORAGE_DAEMON_QAPI_FILES += storage-daemon/qapi/qapi-emit-events.h
1352af282ecSKevin WolfGENERATED_STORAGE_DAEMON_QAPI_FILES += storage-daemon/qapi/qapi-emit-events.c
1362af282ecSKevin WolfGENERATED_STORAGE_DAEMON_QAPI_FILES += storage-daemon/qapi/qapi-events.h
1372af282ecSKevin WolfGENERATED_STORAGE_DAEMON_QAPI_FILES += storage-daemon/qapi/qapi-events.c
1382af282ecSKevin WolfGENERATED_STORAGE_DAEMON_QAPI_FILES += storage-daemon/qapi/qapi-init-commands.h
1392af282ecSKevin WolfGENERATED_STORAGE_DAEMON_QAPI_FILES += storage-daemon/qapi/qapi-init-commands.c
1402af282ecSKevin WolfGENERATED_STORAGE_DAEMON_QAPI_FILES += storage-daemon/qapi/qapi-introspect.h
1412af282ecSKevin WolfGENERATED_STORAGE_DAEMON_QAPI_FILES += storage-daemon/qapi/qapi-introspect.c
1422af282ecSKevin WolfGENERATED_STORAGE_DAEMON_QAPI_FILES += storage-daemon/qapi/qapi-types.h
1432af282ecSKevin WolfGENERATED_STORAGE_DAEMON_QAPI_FILES += storage-daemon/qapi/qapi-types.c
1442af282ecSKevin WolfGENERATED_STORAGE_DAEMON_QAPI_FILES += storage-daemon/qapi/qapi-visit.h
1452af282ecSKevin WolfGENERATED_STORAGE_DAEMON_QAPI_FILES += storage-daemon/qapi/qapi-visit.c
1462af282ecSKevin WolfGENERATED_STORAGE_DAEMON_QAPI_FILES += storage-daemon/qapi/qapi-doc.texi
1472af282ecSKevin Wolf
1483dff199cSLaurent Viviergenerated-files-y += $(GENERATED_QAPI_FILES)
1492af282ecSKevin Wolfgenerated-files-y += $(GENERATED_STORAGE_DAEMON_QAPI_FILES)
150eac236eaSLluís Vilanova
1513dff199cSLaurent Viviergenerated-files-y += trace/generated-tcg-tracers.h
152465830fbSLluís Vilanova
1533dff199cSLaurent Viviergenerated-files-y += trace/generated-helpers-wrappers.h
1543dff199cSLaurent Viviergenerated-files-y += trace/generated-helpers.h
1553dff199cSLaurent Viviergenerated-files-y += trace/generated-helpers.c
156707c8a98SLluís Vilanova
1573dff199cSLaurent Viviergenerated-files-$(CONFIG_TRACE_UST) += trace-ust-all.h
1583dff199cSLaurent Viviergenerated-files-$(CONFIG_TRACE_UST) += trace-ust-all.c
159e6bf23f8SMohamad Gebai
1603dff199cSLaurent Viviergenerated-files-y += module_block.h
1610c0c1fd9SMarc Mari
1620ab8ed18SDaniel P. BerrangeTRACE_HEADERS = trace-root.h $(trace-events-subdirs:%=%/trace.h)
1630ab8ed18SDaniel P. BerrangeTRACE_SOURCES = trace-root.c $(trace-events-subdirs:%=%/trace.c)
1640ab8ed18SDaniel P. BerrangeTRACE_DTRACE =
1650ab8ed18SDaniel P. Berrangeifdef CONFIG_TRACE_DTRACE
1660ab8ed18SDaniel P. BerrangeTRACE_HEADERS += trace-dtrace-root.h $(trace-events-subdirs:%=%/trace-dtrace.h)
1670ab8ed18SDaniel P. BerrangeTRACE_DTRACE += trace-dtrace-root.dtrace $(trace-events-subdirs:%=%/trace-dtrace.dtrace)
1680ab8ed18SDaniel P. Berrangeendif
1690ab8ed18SDaniel P. Berrangeifdef CONFIG_TRACE_UST
1700ab8ed18SDaniel P. BerrangeTRACE_HEADERS += trace-ust-root.h $(trace-events-subdirs:%=%/trace-ust.h)
1710ab8ed18SDaniel P. Berrangeendif
1720ab8ed18SDaniel P. Berrange
1733dff199cSLaurent Viviergenerated-files-y += $(TRACE_HEADERS)
1743dff199cSLaurent Viviergenerated-files-y += $(TRACE_SOURCES)
1753dff199cSLaurent Viviergenerated-files-y += $(BUILD_DIR)/trace-events-all
1763dff199cSLaurent Viviergenerated-files-y += .git-submodule-status
1770ab8ed18SDaniel P. Berrange
1780ab8ed18SDaniel P. Berrangetrace-group-name = $(shell dirname $1 | sed -e 's/[^a-zA-Z0-9]/_/g')
1790ab8ed18SDaniel P. Berrange
1808755b4afSDaniel P. Berrangetracetool-y = $(SRC_PATH)/scripts/tracetool.py
1818755b4afSDaniel P. Berrangetracetool-y += $(shell find $(SRC_PATH)/scripts/tracetool -name "*.py")
1828755b4afSDaniel P. Berrange
1830ab8ed18SDaniel P. Berrange%/trace.h: %/trace.h-timestamp
1840ab8ed18SDaniel P. Berrange	@cmp $< $@ >/dev/null 2>&1 || cp $< $@
18557b7bdf4SStefan Hajnoczi%/trace.h-timestamp: $(SRC_PATH)/%/trace-events $(tracetool-y) $(BUILD_DIR)/config-host.mak
1860ab8ed18SDaniel P. Berrange	$(call quiet-command,$(TRACETOOL) \
1870ab8ed18SDaniel P. Berrange		--group=$(call trace-group-name,$@) \
1880ab8ed18SDaniel P. Berrange		--format=h \
1890ab8ed18SDaniel P. Berrange		--backends=$(TRACE_BACKENDS) \
1900ab8ed18SDaniel P. Berrange		$< > $@,"GEN","$(@:%-timestamp=%)")
1910ab8ed18SDaniel P. Berrange
1920ab8ed18SDaniel P. Berrange%/trace.c: %/trace.c-timestamp
1930ab8ed18SDaniel P. Berrange	@cmp $< $@ >/dev/null 2>&1 || cp $< $@
19457b7bdf4SStefan Hajnoczi%/trace.c-timestamp: $(SRC_PATH)/%/trace-events $(tracetool-y) $(BUILD_DIR)/config-host.mak
1950ab8ed18SDaniel P. Berrange	$(call quiet-command,$(TRACETOOL) \
1960ab8ed18SDaniel P. Berrange		--group=$(call trace-group-name,$@) \
1970ab8ed18SDaniel P. Berrange		--format=c \
1980ab8ed18SDaniel P. Berrange		--backends=$(TRACE_BACKENDS) \
1990ab8ed18SDaniel P. Berrange		$< > $@,"GEN","$(@:%-timestamp=%)")
2000ab8ed18SDaniel P. Berrange
2010ab8ed18SDaniel P. Berrange%/trace-ust.h: %/trace-ust.h-timestamp
2020ab8ed18SDaniel P. Berrange	@cmp $< $@ >/dev/null 2>&1 || cp $< $@
20357b7bdf4SStefan Hajnoczi%/trace-ust.h-timestamp: $(SRC_PATH)/%/trace-events $(tracetool-y) $(BUILD_DIR)/config-host.mak
2040ab8ed18SDaniel P. Berrange	$(call quiet-command,$(TRACETOOL) \
2050ab8ed18SDaniel P. Berrange		--group=$(call trace-group-name,$@) \
2060ab8ed18SDaniel P. Berrange		--format=ust-events-h \
2070ab8ed18SDaniel P. Berrange		--backends=$(TRACE_BACKENDS) \
2080ab8ed18SDaniel P. Berrange		$< > $@,"GEN","$(@:%-timestamp=%)")
2090ab8ed18SDaniel P. Berrange
2100ab8ed18SDaniel P. Berrange%/trace-dtrace.dtrace: %/trace-dtrace.dtrace-timestamp
2110ab8ed18SDaniel P. Berrange	@cmp $< $@ >/dev/null 2>&1 || cp $< $@
2120ab8ed18SDaniel P. Berrange%/trace-dtrace.dtrace-timestamp: $(SRC_PATH)/%/trace-events $(BUILD_DIR)/config-host.mak $(tracetool-y)
2130ab8ed18SDaniel P. Berrange	$(call quiet-command,$(TRACETOOL) \
2140ab8ed18SDaniel P. Berrange		--group=$(call trace-group-name,$@) \
2150ab8ed18SDaniel P. Berrange		--format=d \
2160ab8ed18SDaniel P. Berrange		--backends=$(TRACE_BACKENDS) \
2170ab8ed18SDaniel P. Berrange		$< > $@,"GEN","$(@:%-timestamp=%)")
2180ab8ed18SDaniel P. Berrange
2190ab8ed18SDaniel P. Berrange%/trace-dtrace.h: %/trace-dtrace.dtrace $(tracetool-y)
2200ab8ed18SDaniel P. Berrange	$(call quiet-command,dtrace -o $@ -h -s $<, "GEN","$@")
2210ab8ed18SDaniel P. Berrange
2220ab8ed18SDaniel P. Berrange%/trace-dtrace.o: %/trace-dtrace.dtrace $(tracetool-y)
2230ab8ed18SDaniel P. Berrange
2240ab8ed18SDaniel P. Berrange
2250ab8ed18SDaniel P. Berrangetrace-root.h: trace-root.h-timestamp
2260ab8ed18SDaniel P. Berrange	@cmp $< $@ >/dev/null 2>&1 || cp $< $@
22757b7bdf4SStefan Hajnoczitrace-root.h-timestamp: $(SRC_PATH)/trace-events $(tracetool-y) $(BUILD_DIR)/config-host.mak
2280ab8ed18SDaniel P. Berrange	$(call quiet-command,$(TRACETOOL) \
2290ab8ed18SDaniel P. Berrange		--group=root \
2300ab8ed18SDaniel P. Berrange		--format=h \
2310ab8ed18SDaniel P. Berrange		--backends=$(TRACE_BACKENDS) \
2320ab8ed18SDaniel P. Berrange		$< > $@,"GEN","$(@:%-timestamp=%)")
2330ab8ed18SDaniel P. Berrange
2340ab8ed18SDaniel P. Berrangetrace-root.c: trace-root.c-timestamp
2350ab8ed18SDaniel P. Berrange	@cmp $< $@ >/dev/null 2>&1 || cp $< $@
23657b7bdf4SStefan Hajnoczitrace-root.c-timestamp: $(SRC_PATH)/trace-events $(tracetool-y) $(BUILD_DIR)/config-host.mak
2370ab8ed18SDaniel P. Berrange	$(call quiet-command,$(TRACETOOL) \
2380ab8ed18SDaniel P. Berrange		--group=root \
2390ab8ed18SDaniel P. Berrange		--format=c \
2400ab8ed18SDaniel P. Berrange		--backends=$(TRACE_BACKENDS) \
2410ab8ed18SDaniel P. Berrange		$< > $@,"GEN","$(@:%-timestamp=%)")
2420ab8ed18SDaniel P. Berrange
2430ab8ed18SDaniel P. Berrangetrace-ust-root.h: trace-ust-root.h-timestamp
2440ab8ed18SDaniel P. Berrange	@cmp $< $@ >/dev/null 2>&1 || cp $< $@
24557b7bdf4SStefan Hajnoczitrace-ust-root.h-timestamp: $(SRC_PATH)/trace-events $(tracetool-y) $(BUILD_DIR)/config-host.mak
2460ab8ed18SDaniel P. Berrange	$(call quiet-command,$(TRACETOOL) \
2470ab8ed18SDaniel P. Berrange		--group=root \
2480ab8ed18SDaniel P. Berrange		--format=ust-events-h \
2490ab8ed18SDaniel P. Berrange		--backends=$(TRACE_BACKENDS) \
2500ab8ed18SDaniel P. Berrange		$< > $@,"GEN","$(@:%-timestamp=%)")
2510ab8ed18SDaniel P. Berrange
2520ab8ed18SDaniel P. Berrangetrace-ust-all.h: trace-ust-all.h-timestamp
2530ab8ed18SDaniel P. Berrange	@cmp $< $@ >/dev/null 2>&1 || cp $< $@
25457b7bdf4SStefan Hajnoczitrace-ust-all.h-timestamp: $(trace-events-files) $(tracetool-y) $(BUILD_DIR)/config-host.mak
2550ab8ed18SDaniel P. Berrange	$(call quiet-command,$(TRACETOOL) \
2560ab8ed18SDaniel P. Berrange		--group=all \
2570ab8ed18SDaniel P. Berrange		--format=ust-events-h \
2580ab8ed18SDaniel P. Berrange		--backends=$(TRACE_BACKENDS) \
2590ab8ed18SDaniel P. Berrange		$(trace-events-files) > $@,"GEN","$(@:%-timestamp=%)")
2600ab8ed18SDaniel P. Berrange
2610ab8ed18SDaniel P. Berrangetrace-ust-all.c: trace-ust-all.c-timestamp
2620ab8ed18SDaniel P. Berrange	@cmp $< $@ >/dev/null 2>&1 || cp $< $@
26357b7bdf4SStefan Hajnoczitrace-ust-all.c-timestamp: $(trace-events-files) $(tracetool-y) $(BUILD_DIR)/config-host.mak
2640ab8ed18SDaniel P. Berrange	$(call quiet-command,$(TRACETOOL) \
2650ab8ed18SDaniel P. Berrange		--group=all \
2660ab8ed18SDaniel P. Berrange		--format=ust-events-c \
2670ab8ed18SDaniel P. Berrange		--backends=$(TRACE_BACKENDS) \
2680ab8ed18SDaniel P. Berrange		$(trace-events-files) > $@,"GEN","$(@:%-timestamp=%)")
2690ab8ed18SDaniel P. Berrange
2700ab8ed18SDaniel P. Berrangetrace-dtrace-root.dtrace: trace-dtrace-root.dtrace-timestamp
2710ab8ed18SDaniel P. Berrange	@cmp $< $@ >/dev/null 2>&1 || cp $< $@
2720ab8ed18SDaniel P. Berrangetrace-dtrace-root.dtrace-timestamp: $(SRC_PATH)/trace-events $(BUILD_DIR)/config-host.mak $(tracetool-y)
2730ab8ed18SDaniel P. Berrange	$(call quiet-command,$(TRACETOOL) \
2740ab8ed18SDaniel P. Berrange		--group=root \
2750ab8ed18SDaniel P. Berrange		--format=d \
2760ab8ed18SDaniel P. Berrange		--backends=$(TRACE_BACKENDS) \
2770ab8ed18SDaniel P. Berrange		$< > $@,"GEN","$(@:%-timestamp=%)")
2780ab8ed18SDaniel P. Berrange
2790ab8ed18SDaniel P. Berrangetrace-dtrace-root.h: trace-dtrace-root.dtrace
2800ab8ed18SDaniel P. Berrange	$(call quiet-command,dtrace -o $@ -h -s $<, "GEN","$@")
2810ab8ed18SDaniel P. Berrange
2820ab8ed18SDaniel P. Berrangetrace-dtrace-root.o: trace-dtrace-root.dtrace
2830ab8ed18SDaniel P. Berrange
28492712822SDaniel P. BerrangeKEYCODEMAP_GEN = $(SRC_PATH)/ui/keycodemapdb/tools/keymap-gen
28592712822SDaniel P. BerrangeKEYCODEMAP_CSV = $(SRC_PATH)/ui/keycodemapdb/data/keymaps.csv
28692712822SDaniel P. Berrange
28792712822SDaniel P. BerrangeKEYCODEMAP_FILES = \
2882ec78706SDaniel P. Berrange		 ui/input-keymap-atset1-to-qcode.c \
289bcd5ac9bSDaniel P. Berrange		 ui/input-keymap-linux-to-qcode.c \
290ab8f9d49SDaniel P. Berrange		 ui/input-keymap-qcode-to-atset1.c \
291ab8f9d49SDaniel P. Berrange		 ui/input-keymap-qcode-to-atset2.c \
292ab8f9d49SDaniel P. Berrange		 ui/input-keymap-qcode-to-atset3.c \
2935a15e6b1SDaniel P. Berrange		 ui/input-keymap-qcode-to-linux.c \
294bcd5ac9bSDaniel P. Berrange		 ui/input-keymap-qcode-to-qnum.c \
295e709a61aSDaniel P. Berrange		 ui/input-keymap-qcode-to-sun.c \
296bcd5ac9bSDaniel P. Berrange		 ui/input-keymap-qnum-to-qcode.c \
297ed7b2624SDaniel P. Berrange		 ui/input-keymap-usb-to-qcode.c \
2982ec78706SDaniel P. Berrange		 ui/input-keymap-win32-to-qcode.c \
2992ec78706SDaniel P. Berrange		 ui/input-keymap-x11-to-qcode.c \
3002ec78706SDaniel P. Berrange		 ui/input-keymap-xorgevdev-to-qcode.c \
3012ec78706SDaniel P. Berrange		 ui/input-keymap-xorgkbd-to-qcode.c \
3022ec78706SDaniel P. Berrange		 ui/input-keymap-xorgxquartz-to-qcode.c \
3032ec78706SDaniel P. Berrange		 ui/input-keymap-xorgxwin-to-qcode.c \
304656282d2SKeno Fischer		 ui/input-keymap-osx-to-qcode.c \
30592712822SDaniel P. Berrange		 $(NULL)
30692712822SDaniel P. Berrange
3073dff199cSLaurent Viviergenerated-files-$(CONFIG_SOFTMMU) += $(KEYCODEMAP_FILES)
30892712822SDaniel P. Berrange
30992712822SDaniel P. Berrangeui/input-keymap-%.c: $(KEYCODEMAP_GEN) $(KEYCODEMAP_CSV) $(SRC_PATH)/ui/Makefile.objs
31092712822SDaniel P. Berrange	$(call quiet-command,\
3116809df1dSJan Beulich	    stem=$* && src=$${stem%-to-*} dst=$${stem#*-to-} && \
31292712822SDaniel P. Berrange	    test -e $(KEYCODEMAP_GEN) && \
31392712822SDaniel P. Berrange	    $(PYTHON) $(KEYCODEMAP_GEN) \
31492712822SDaniel P. Berrange	          --lang glib2 \
31592712822SDaniel P. Berrange	          --varname qemu_input_map_$${src}_to_$${dst} \
31692712822SDaniel P. Berrange	          code-map $(KEYCODEMAP_CSV) $${src} $${dst} \
31792712822SDaniel P. Berrange	        > $@ || rm -f $@, "GEN", "$@")
31892712822SDaniel P. Berrange
31992712822SDaniel P. Berrange$(KEYCODEMAP_GEN): .git-submodule-status
32092712822SDaniel P. Berrange$(KEYCODEMAP_CSV): .git-submodule-status
32192712822SDaniel P. Berrange
32226ce90fdSLaszlo Ersekedk2-decompressed = $(basename $(wildcard pc-bios/edk2-*.fd.bz2))
32326ce90fdSLaszlo Ersekpc-bios/edk2-%.fd: pc-bios/edk2-%.fd.bz2
32426ce90fdSLaszlo Ersek	$(call quiet-command,bzip2 -d -c $< > $@,"BUNZIP2",$<)
32526ce90fdSLaszlo Ersek
326d9ace8b3SJuan Quintela# Don't try to regenerate Makefile or configure
327d9ace8b3SJuan Quintela# We don't generate any of them
328d9ace8b3SJuan QuintelaMakefile: ;
329d9ace8b3SJuan Quintelaconfigure: ;
330d9ace8b3SJuan Quintela
331bd3f5706SMarc-André Lureau.PHONY: all clean cscope distclean html info install install-doc \
3327c3d1917SDaniel P. Berrange	pdf txt recurse-all dist msi FORCE
3330cb3fb1eSpbrook
334fec90ff0SPaolo Bonzini$(call set-vpath, $(SRC_PATH))
3358c462f8fSpbrook
3363e2e0e6bSJuan QuintelaLIBS+=-lz $(LIBS_TOOLS)
33767c0f08dSJuan Quintela
338d52c454aSMarc-André Lureauvhost-user-json-y =
339fdbff6bdSPhilippe Mathieu-DaudéHELPERS-y = $(HELPERS)
340d52c454aSMarc-André Lureau
341fdbff6bdSPhilippe Mathieu-DaudéHELPERS-$(call land,$(CONFIG_SOFTMMU),$(CONFIG_LINUX)) += qemu-bridge-helper$(EXESUF)
3427b93fadfSCorey Bryant
34357589bc4SMarc-André Lureauifeq ($(CONFIG_LINUX)$(CONFIG_VIRGL)$(CONFIG_GBM)$(CONFIG_TOOLS),yyyy)
344d52c454aSMarc-André LureauHELPERS-y += vhost-user-gpu$(EXESUF)
345d52c454aSMarc-André Lureauvhost-user-json-y += contrib/vhost-user-gpu/50-qemu-gpu.json
346d52c454aSMarc-André Lureauendif
347d52c454aSMarc-André Lureau
34857159bb2SPhilippe Mathieu-Daudéifeq ($(CONFIG_SOFTMMU)$(CONFIG_LINUX)$(CONFIG_SECCOMP)$(CONFIG_LIBCAP_NG),yyyy)
34981bfc42dSDr. David Alan GilbertHELPERS-y += virtiofsd$(EXESUF)
350315616edSStefan Hajnoczivhost-user-json-y += tools/virtiofsd/50-qemu-virtiofsd.json
35181bfc42dSDr. David Alan Gilbertendif
35281bfc42dSDr. David Alan Gilbert
353b53c54c6SPeter Maydell# Sphinx does not allow building manuals into the same directory as
354b53c54c6SPeter Maydell# the source files, so if we're doing an in-tree QEMU build we must
355b53c54c6SPeter Maydell# build the manuals into a subdirectory (and then install them from
356b53c54c6SPeter Maydell# there for 'make install'). For an out-of-tree build we can just
357b53c54c6SPeter Maydell# use the docs/ subdirectory in the build tree as normal.
358b53c54c6SPeter Maydellifeq ($(realpath $(SRC_PATH)),$(realpath .))
359b53c54c6SPeter MaydellMANUAL_BUILDDIR := docs/built
360b53c54c6SPeter Maydellelse
361b53c54c6SPeter MaydellMANUAL_BUILDDIR := docs
362b53c54c6SPeter Maydellendif
363b53c54c6SPeter Maydell
364cc8ae6deSpbrookifdef BUILD_DOCS
365d06118bfSPeter MaydellDOCS+=$(MANUAL_BUILDDIR)/system/qemu.1
366a08b4a9fSPeter MaydellDOCS+=$(MANUAL_BUILDDIR)/tools/qemu-img.1
367a08b4a9fSPeter MaydellDOCS+=$(MANUAL_BUILDDIR)/tools/qemu-nbd.8
36887c0868fSPeter MaydellDOCS+=$(MANUAL_BUILDDIR)/interop/qemu-ga.8
3696a7e2bbeSStefan Hajnocziifeq ($(CONFIG_LINUX)$(CONFIG_SECCOMP)$(CONFIG_LIBCAP_NG),yyy)
370a08b4a9fSPeter MaydellDOCS+=$(MANUAL_BUILDDIR)/tools/virtiofsd.1
3716a7e2bbeSStefan Hajnocziendif
372acab923dSPeter MaydellDOCS+=$(MANUAL_BUILDDIR)/system/qemu-block-drivers.7
373d59157eaSPaolo BonziniDOCS+=docs/interop/qemu-qmp-ref.html docs/interop/qemu-qmp-ref.txt docs/interop/qemu-qmp-ref.7
374d59157eaSPaolo BonziniDOCS+=docs/interop/qemu-ga-ref.html docs/interop/qemu-ga-ref.txt docs/interop/qemu-ga-ref.7
3751bf84a1eSKashyap ChamarthyDOCS+=$(MANUAL_BUILDDIR)/system/qemu-cpu-models.7
37622108f33SStefan HajnocziDOCS+=$(MANUAL_BUILDDIR)/index.html
377983eef5aSMeador Ingeifdef CONFIG_VIRTFS
378a08b4a9fSPeter MaydellDOCS+=$(MANUAL_BUILDDIR)/tools/virtfs-proxy-helper.1
379983eef5aSMeador Ingeendif
38062dd1048SDaniel P. Berrangéifdef CONFIG_TRACE_SYSTEMTAP
381a08b4a9fSPeter MaydellDOCS+=$(MANUAL_BUILDDIR)/tools/qemu-trace-stap.1
38262dd1048SDaniel P. Berrangéendif
383cc8ae6deSpbrookelse
384cc8ae6deSpbrookDOCS=
385cc8ae6deSpbrookendif
3867d13299dSbellard
3878cc357b5SDaniel P. BerrangeSUBDIR_MAKEFLAGS=$(if $(V),,--no-print-directory --quiet) BUILD_DIR=$(BUILD_DIR)
388e0e312f3SPaolo BonziniSUBDIR_DEVICES_MAK=$(patsubst %, %/config-devices.mak, $(filter %-softmmu, $(TARGET_DIRS)))
389e0e312f3SPaolo BonziniSUBDIR_DEVICES_MAK_DEP=$(patsubst %, %.d, $(SUBDIR_DEVICES_MAK))
3901f3d3c8fSJuan Quintela
3918bdd3d49SStefan Weilifeq ($(SUBDIR_DEVICES_MAK),)
392b7c11e57SPaolo Bonziniconfig-all-devices.mak: config-host.mak
3930bdb12c7SPeter Maydell	$(call quiet-command,echo '# no devices' > $@,"GEN","$@")
3948bdd3d49SStefan Weilelse
395b7c11e57SPaolo Bonziniconfig-all-devices.mak: $(SUBDIR_DEVICES_MAK) config-host.mak
396bb585a78SPaolo Bonzini	$(call quiet-command, sed -n \
397bb585a78SPaolo Bonzini             's|^\([^=]*\)=\(.*\)$$|\1:=$$(findstring y,$$(\1)\2)|p' \
398bb585a78SPaolo Bonzini             $(SUBDIR_DEVICES_MAK) | sort -u > $@, \
3990bdb12c7SPeter Maydell             "GEN","$@")
4008bdd3d49SStefan Weilendif
4011f3d3c8fSJuan Quintela
402bd9141bbSPaul Brook-include $(SUBDIR_DEVICES_MAK_DEP)
403bd9141bbSPaul Brook
404e0e312f3SPaolo Bonzini# This has to be kept in sync with Kconfig.host.
405e0e312f3SPaolo BonziniMINIKCONF_ARGS = \
406f3494749SPaolo Bonzini    $(CONFIG_MINIKCONF_MODE) \
407bb768f71SThomas Huth    $@ $*/config-devices.mak.d $< $(MINIKCONF_INPUTS) \
408e0e312f3SPaolo Bonzini    CONFIG_KVM=$(CONFIG_KVM) \
409e0e312f3SPaolo Bonzini    CONFIG_SPICE=$(CONFIG_SPICE) \
410e0e312f3SPaolo Bonzini    CONFIG_IVSHMEM=$(CONFIG_IVSHMEM) \
411e0e312f3SPaolo Bonzini    CONFIG_TPM=$(CONFIG_TPM) \
412e0e312f3SPaolo Bonzini    CONFIG_XEN=$(CONFIG_XEN) \
413e0e312f3SPaolo Bonzini    CONFIG_OPENGL=$(CONFIG_OPENGL) \
414e0e312f3SPaolo Bonzini    CONFIG_X11=$(CONFIG_X11) \
415e0e312f3SPaolo Bonzini    CONFIG_VHOST_USER=$(CONFIG_VHOST_USER) \
41621c6b0c8SMarc-André Lureau    CONFIG_VHOST_KERNEL=$(CONFIG_VHOST_KERNEL) \
417e0e312f3SPaolo Bonzini    CONFIG_VIRTFS=$(CONFIG_VIRTFS) \
418d6c1bd4aSPaolo Bonzini    CONFIG_LINUX=$(CONFIG_LINUX) \
419d6c1bd4aSPaolo Bonzini    CONFIG_PVRDMA=$(CONFIG_PVRDMA)
420e0e312f3SPaolo Bonzini
421*1e0ef873SPhilippe Mathieu-DaudéMINIKCONF_INPUTS = $(SRC_PATH)/Kconfig.host \
422*1e0ef873SPhilippe Mathieu-Daudé                   $(SRC_PATH)/backends/Kconfig \
423*1e0ef873SPhilippe Mathieu-Daudé                   $(SRC_PATH)/hw/Kconfig
424*1e0ef873SPhilippe Mathieu-DaudéMINIKCONF_DEPS = $(MINIKCONF_INPUTS) \
425*1e0ef873SPhilippe Mathieu-Daudé                 $(wildcard $(SRC_PATH)/hw/*/Kconfig)
426f4bda37dSPhilippe Mathieu-DaudéMINIKCONF = $(PYTHON) $(SRC_PATH)/scripts/minikconf.py
427e0e312f3SPaolo Bonzini
428ea763fd2SThomas Huth$(SUBDIR_DEVICES_MAK): %/config-devices.mak: default-configs/%.mak $(MINIKCONF_DEPS) $(BUILD_DIR)/config-host.mak
429*1e0ef873SPhilippe Mathieu-Daudé	$(call quiet-command, $(MINIKCONF) $(MINIKCONF_ARGS) \
430*1e0ef873SPhilippe Mathieu-Daudé		> $@.tmp, "GEN", "$@.tmp")
43112ccfec9SMichael S. Tsirkin	$(call quiet-command, if test -f $@; then \
432904fe1fbSBlue Swirl	  if cmp -s $@.old $@; then \
433012f0879SStefan Weil	    mv $@.tmp $@; \
434012f0879SStefan Weil	    cp -p $@ $@.old; \
435012f0879SStefan Weil	  else \
436012f0879SStefan Weil	    if test -f $@.old; then \
437012f0879SStefan Weil	      echo "WARNING: $@ (user modified) out of date.";\
438012f0879SStefan Weil	    else \
439a992fe3dSPaul Brook	      echo "WARNING: $@ out of date.";\
440012f0879SStefan Weil	    fi; \
441b98a3baeSPhilippe Mathieu-Daudé	    echo "Run \"$(MAKE) defconfig\" to regenerate."; \
442a992fe3dSPaul Brook	    rm $@.tmp; \
443012f0879SStefan Weil	  fi; \
444a992fe3dSPaul Brook	 else \
445a992fe3dSPaul Brook	  mv $@.tmp $@; \
446012f0879SStefan Weil	  cp -p $@ $@.old; \
4470bdb12c7SPeter Maydell	 fi,"GEN","$@");
448a992fe3dSPaul Brook
449a992fe3dSPaul Brookdefconfig:
450a992fe3dSPaul Brook	rm -f config-all-devices.mak $(SUBDIR_DEVICES_MAK)
451a992fe3dSPaul Brook
452992aeb8eSPaolo Bonziniifneq ($(wildcard config-host.mak),)
453992aeb8eSPaolo Bonziniinclude $(SRC_PATH)/Makefile.objs
454ba1183daSFam Zhengendif
455ba1183daSFam Zheng
456ba1183daSFam Zhengdummy := $(call unnest-vars,, \
457ba1183daSFam Zheng                stub-obj-y \
4585b76dd13SDaniel P. Berrange                authz-obj-y \
45932d955a4SMarc-André Lureau                chardev-obj-y \
460ba1183daSFam Zheng                util-obj-y \
461ba1183daSFam Zheng                qga-obj-y \
4623fa2d384SViktor Prutyanov                elf2dmp-obj-y \
463a75eb03bSDavid Marchand                ivshmem-client-obj-y \
464a75eb03bSDavid Marchand                ivshmem-server-obj-y \
46581bfc42dSDr. David Alan Gilbert                virtiofsd-obj-y \
466a5d2f6f8SYuval Shaia                rdmacm-mux-obj-y \
4677b2e5c65SMarc-André Lureau                libvhost-user-obj-y \
46849cc0340SFelipe Franciosi                vhost-user-scsi-obj-y \
469406d2aa2SChangpeng Liu                vhost-user-blk-obj-y \
47006914c97SMarc-André Lureau                vhost-user-input-obj-y \
471d52c454aSMarc-André Lureau                vhost-user-gpu-obj-y \
472577a6723STomoki Sekiyama                qga-vss-dll-obj-y \
473ba1183daSFam Zheng                block-obj-y \
474cc475698SFam Zheng                block-obj-m \
47514837c64SKevin Wolf                storage-daemon-obj-y \
47614837c64SKevin Wolf                storage-daemon-obj-m \
477fb37726dSDaniel P. Berrange                crypto-obj-y \
4780c7012e0SDaniel P. Berrange                qom-obj-y \
479666a3af9SDaniel P. Berrange                io-obj-y \
480cc475698SFam Zheng                common-obj-y \
4810ab8ed18SDaniel P. Berrange                common-obj-m \
482675b9b53SMarc-André Lureau                trace-obj-y)
483ba1183daSFam Zheng
48446e7b706SFam Zhenginclude $(SRC_PATH)/tests/Makefile.include
485992aeb8eSPaolo Bonzini
486d52c454aSMarc-André Lureauall: $(DOCS) $(if $(BUILD_DOCS),sphinxdocs) $(TOOLS) $(HELPERS-y) recurse-all modules $(vhost-user-json-y)
487b9dea4fbSpbrook
48867a1de0dSFam Zhengqemu-version.h: FORCE
48967a1de0dSFam Zheng	$(call quiet-command, \
49057b49737SPeter Maydell                (printf '#define QEMU_PKGVERSION "$(QEMU_PKGVERSION)"\n'; \
49157b49737SPeter Maydell		printf '#define QEMU_FULL_VERSION "$(FULL_VERSION)"\n'; \
4927e563bfbSThomas Huth		) > $@.tmp)
493d9e73d32SLin Ma	$(call quiet-command, if ! cmp -s $@ $@.tmp; then \
494d9e73d32SLin Ma	  mv $@.tmp $@; \
495d9e73d32SLin Ma	 else \
496d9e73d32SLin Ma	  rm $@.tmp; \
497d9e73d32SLin Ma	 fi)
49867a1de0dSFam Zheng
4991215c6e7SJuan Quintelaconfig-host.h: config-host.h-timestamp
5001215c6e7SJuan Quintelaconfig-host.h-timestamp: config-host.mak
501077de81aSPaolo Bonziniqemu-options.def: $(SRC_PATH)/qemu-options.hx $(SRC_PATH)/scripts/hxtool
5020bdb12c7SPeter Maydell	$(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@,"GEN","$@")
5031215c6e7SJuan Quintela
504c621dc3eSAlexander BulekovTARGET_DIRS_RULES := $(foreach t, all fuzz clean install, $(addsuffix /$(t), $(TARGET_DIRS)))
505916359f6SAndreas Färber
5061338a4b7SMarkus ArmbrusterSOFTMMU_ALL_RULES=$(filter %-softmmu/all, $(TARGET_DIRS_RULES))
5071338a4b7SMarkus Armbruster$(SOFTMMU_ALL_RULES): $(authz-obj-y)
5081338a4b7SMarkus Armbruster$(SOFTMMU_ALL_RULES): $(block-obj-y)
50914837c64SKevin Wolf$(SOFTMMU_ALL_RULES): $(storage-daemon-obj-y)
5101338a4b7SMarkus Armbruster$(SOFTMMU_ALL_RULES): $(chardev-obj-y)
5111338a4b7SMarkus Armbruster$(SOFTMMU_ALL_RULES): $(crypto-obj-y)
5121338a4b7SMarkus Armbruster$(SOFTMMU_ALL_RULES): $(io-obj-y)
5131338a4b7SMarkus Armbruster$(SOFTMMU_ALL_RULES): config-all-devices.mak
51405dfa22bSPhilippe Mathieu-Daudéifdef DECOMPRESS_EDK2_BLOBS
5151338a4b7SMarkus Armbruster$(SOFTMMU_ALL_RULES): $(edk2-decompressed)
51605dfa22bSPhilippe Mathieu-Daudéendif
517cec7d0b6Spbrook
518c621dc3eSAlexander BulekovSOFTMMU_FUZZ_RULES=$(filter %-softmmu/fuzz, $(TARGET_DIRS_RULES))
519c621dc3eSAlexander Bulekov$(SOFTMMU_FUZZ_RULES): $(authz-obj-y)
520c621dc3eSAlexander Bulekov$(SOFTMMU_FUZZ_RULES): $(block-obj-y)
521c621dc3eSAlexander Bulekov$(SOFTMMU_FUZZ_RULES): $(chardev-obj-y)
522c621dc3eSAlexander Bulekov$(SOFTMMU_FUZZ_RULES): $(crypto-obj-y)
523c621dc3eSAlexander Bulekov$(SOFTMMU_FUZZ_RULES): $(io-obj-y)
524c621dc3eSAlexander Bulekov$(SOFTMMU_FUZZ_RULES): config-all-devices.mak
525c621dc3eSAlexander Bulekov$(SOFTMMU_FUZZ_RULES): $(edk2-decompressed)
526c621dc3eSAlexander Bulekov
5271338a4b7SMarkus Armbruster.PHONY: $(TARGET_DIRS_RULES)
5281338a4b7SMarkus Armbruster# The $(TARGET_DIRS_RULES) are of the form SUBDIR/GOAL, so that
5291338a4b7SMarkus Armbruster# $(dir $@) yields the sub-directory, and $(notdir $@) yields the sub-goal
5301338a4b7SMarkus Armbruster$(TARGET_DIRS_RULES):
5311338a4b7SMarkus Armbruster	$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C $(dir $@) V="$(V)" TARGET_DIR="$(dir $@)" $(notdir $@),)
5324aa42531Spbrook
53367953a37SClaudio Fontana# LIBFDT_lib="": avoid breaking existing trees with objects requiring -fPIC
53467953a37SClaudio FontanaDTC_MAKE_ARGS=-I$(SRC_PATH)/dtc VPATH=$(SRC_PATH)/dtc -C dtc V="$(V)" LIBFDT_lib=""
535965f486cSPeter MaydellDTC_CFLAGS=$(CFLAGS) $(QEMU_CFLAGS)
53667953a37SClaudio FontanaDTC_CPPFLAGS=-I$(SRC_PATH)/dtc/libfdt
537a540f158SPeter Crosthwaite
5383b8593eeSMarkus Armbruster.PHONY: dtc/all
53967953a37SClaudio Fontanadtc/all: .git-submodule-status dtc/libfdt
54067953a37SClaudio Fontana	$(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,)
541a540f158SPeter Crosthwaite
54200525864SAaron Lindsaydtc/%: .git-submodule-status
543814e1110SJan Kiszka	@mkdir -p $@
544a540f158SPeter Crosthwaite
545e219c499SRichard Henderson# Overriding CFLAGS causes us to lose defines added in the sub-makefile.
546e219c499SRichard Henderson# Not overriding CFLAGS leads to mis-matches between compilation modes.
547e219c499SRichard Henderson# Therefore we replicate some of the logic in the sub-makefile.
548e219c499SRichard Henderson# Remove all the extra -Warning flags that QEMU uses that Capstone doesn't;
549e219c499SRichard Henderson# no need to annoy QEMU developers with such things.
550e219c499SRichard HendersonCAP_CFLAGS = $(patsubst -W%,,$(CFLAGS) $(QEMU_CFLAGS))
551e219c499SRichard HendersonCAP_CFLAGS += -DCAPSTONE_USE_SYS_DYN_MEM
552e219c499SRichard HendersonCAP_CFLAGS += -DCAPSTONE_HAS_ARM
553e219c499SRichard HendersonCAP_CFLAGS += -DCAPSTONE_HAS_ARM64
554e219c499SRichard HendersonCAP_CFLAGS += -DCAPSTONE_HAS_POWERPC
555e219c499SRichard HendersonCAP_CFLAGS += -DCAPSTONE_HAS_X86
556e219c499SRichard Henderson
5573b8593eeSMarkus Armbruster.PHONY: capstone/all
5583b8593eeSMarkus Armbrustercapstone/all: .git-submodule-status
5599f81aeb5SAlistair Francis	$(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))
560e219c499SRichard Henderson
5613b8593eeSMarkus Armbruster.PHONY: slirp/all
5623b8593eeSMarkus Armbrusterslirp/all: .git-submodule-status
563daa79d9aSAlex Bennée	$(call quiet-command,$(MAKE) -C $(SRC_PATH)/slirp		\
564daa79d9aSAlex Bennée		BUILD_DIR="$(BUILD_DIR)/slirp" 			\
565daa79d9aSAlex Bennée		PKG_CONFIG="$(PKG_CONFIG)" 				\
566daa79d9aSAlex Bennée		CC="$(CC)" AR="$(AR)" 	LD="$(LD)" RANLIB="$(RANLIB)"	\
567db5adeaaSPaolo Bonzini		CFLAGS="$(QEMU_CFLAGS) $(CFLAGS)" LDFLAGS="$(QEMU_LDFLAGS)")
568675b9b53SMarc-André Lureau
5691338a4b7SMarkus Armbruster$(filter %/all, $(TARGET_DIRS_RULES)): libqemuutil.a $(common-obj-y) \
570b8d89ba8SPaolo Bonzini	$(qom-obj-y)
571add16157SBlue Swirl
572c621dc3eSAlexander Bulekov$(filter %/fuzz, $(TARGET_DIRS_RULES)): libqemuutil.a $(common-obj-y) \
573c621dc3eSAlexander Bulekov	$(qom-obj-y) $(crypto-user-obj-$(CONFIG_USER_ONLY))
574c621dc3eSAlexander Bulekov
5753b8593eeSMarkus ArmbrusterROM_DIRS = $(addprefix pc-bios/, $(ROMS))
5761338a4b7SMarkus ArmbrusterROM_DIRS_RULES=$(foreach t, all clean, $(addsuffix /$(t), $(ROM_DIRS)))
577a9c87304SMarc-André Lureau# Only keep -O and -g cflags
5781338a4b7SMarkus Armbruster.PHONY: $(ROM_DIRS_RULES)
5791338a4b7SMarkus Armbruster$(ROM_DIRS_RULES):
5801338a4b7SMarkus Armbruster	$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C $(dir $@) V="$(V)" TARGET_DIR="$(dir $@)" CFLAGS="$(filter -O% -g%,$(CFLAGS))" $(notdir $@),)
581c05ac895SPaul Brook
5828d358a5eSMarkus Armbruster.PHONY: recurse-all recurse-clean recurse-install
5831338a4b7SMarkus Armbrusterrecurse-all: $(addsuffix /all, $(TARGET_DIRS) $(ROM_DIRS))
5841338a4b7SMarkus Armbrusterrecurse-clean: $(addsuffix /clean, $(TARGET_DIRS) $(ROM_DIRS))
5851338a4b7SMarkus Armbrusterrecurse-install: $(addsuffix /install, $(TARGET_DIRS))
58647ae060eSMarkus Armbruster$(addsuffix /install, $(TARGET_DIRS)): all
5874aa42531Spbrook
588c17a18efSMarc-André Lureau$(BUILD_DIR)/version.o: $(SRC_PATH)/version.rc config-host.h
5890bdb12c7SPeter Maydell	$(call quiet-command,$(WINDRES) -I$(BUILD_DIR) -o $@ $<,"RC","version.o")
5905354e4d2SMarc-André Lureau
591c17a18efSMarc-André LureauMakefile: $(version-obj-y)
5923bc2f570SPaolo Bonzini
5933bc2f570SPaolo Bonzini######################################################################
5948a090705SPaolo Bonzini# Build libraries
5953bc2f570SPaolo Bonzini
596ebedb37cSPaolo Bonzinilibqemuutil.a: $(util-obj-y) $(trace-obj-y) $(stub-obj-y)
5975f9ff1efSXie Yongjilibvhost-user.a: $(libvhost-user-obj-y) $(util-obj-y) $(stub-obj-y)
5983bc2f570SPaolo Bonzini
5994fb240a4Sbellard######################################################################
6004fb240a4Sbellard
601ebedb37cSPaolo BonziniCOMMON_LDADDS = libqemuutil.a
6020ab8ed18SDaniel P. Berrange
6033c089e15SJuan Quintelaqemu-img.o: qemu-img-cmds.h
604153859beSStuart Brady
6055b76dd13SDaniel P. Berrangeqemu-img$(EXESUF): qemu-img.o $(authz-obj-y) $(block-obj-y) $(crypto-obj-y) $(io-obj-y) $(qom-obj-y) $(COMMON_LDADDS)
6065b76dd13SDaniel P. Berrangeqemu-nbd$(EXESUF): qemu-nbd.o $(authz-obj-y) $(block-obj-y) $(crypto-obj-y) $(io-obj-y) $(qom-obj-y) $(COMMON_LDADDS)
6075b76dd13SDaniel P. Berrangeqemu-io$(EXESUF): qemu-io.o $(authz-obj-y) $(block-obj-y) $(crypto-obj-y) $(io-obj-y) $(qom-obj-y) $(COMMON_LDADDS)
6085e6911cfSKevin Wolfqemu-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)
6090a8e1acdSaliguori
6100ab8ed18SDaniel P. Berrangeqemu-bridge-helper$(EXESUF): qemu-bridge-helper.o $(COMMON_LDADDS)
6117b93fadfSCorey Bryant
6126a021536SGerd Hoffmannqemu-keymap$(EXESUF): qemu-keymap.o ui/input-keymap.o $(COMMON_LDADDS)
6136a021536SGerd Hoffmann
61472d277a7SGerd Hoffmannqemu-edid$(EXESUF): qemu-edid.o hw/display/edid-generate.o $(COMMON_LDADDS)
61572d277a7SGerd Hoffmann
6160ab8ed18SDaniel P. Berrangefsdev/virtfs-proxy-helper$(EXESUF): fsdev/virtfs-proxy-helper.o fsdev/9p-marshal.o fsdev/9p-iov-marshal.o $(COMMON_LDADDS)
61717bff52bSM. Mohan Kumar
6185b76dd13SDaniel P. Berrangescsi/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)
619fe8fc5aeSPaolo Bonziniifdef CONFIG_MPATH
620fe8fc5aeSPaolo Bonziniscsi/qemu-pr-helper$(EXESUF): LIBS += -ludev -lmultipath -lmpathpersist
621fe8fc5aeSPaolo Bonziniendif
622b855f8d1SPaolo Bonzini
623077de81aSPaolo Bonziniqemu-img-cmds.h: $(SRC_PATH)/qemu-img-cmds.hx $(SRC_PATH)/scripts/hxtool
6240bdb12c7SPeter Maydell	$(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@,"GEN","$@")
625153859beSStuart Brady
626957f1f99SMichael Rothqemu-ga$(EXESUF): LIBS = $(LIBS_QGA)
62754c2e502SDunrong Huangqemu-ga$(EXESUF): QEMU_CFLAGS += -I qga/qapi-generated
628640e5404SMichael Roth
6296a021536SGerd Hoffmannqemu-keymap$(EXESUF): LIBS += $(XKBCOMMON_LIBS)
6306a021536SGerd Hoffmannqemu-keymap$(EXESUF): QEMU_CFLAGS += $(XKBCOMMON_CFLAGS)
6316a021536SGerd Hoffmann
632e6c42b96SMarkus Armbrusterqapi-py = $(SRC_PATH)/scripts/qapi/__init__.py \
633e6c42b96SMarkus Armbruster$(SRC_PATH)/scripts/qapi/commands.py \
634fb0bc835SMarkus Armbruster$(SRC_PATH)/scripts/qapi/common.py \
635fb0bc835SMarkus Armbruster$(SRC_PATH)/scripts/qapi/doc.py \
636e6c42b96SMarkus Armbruster$(SRC_PATH)/scripts/qapi/error.py \
637e6c42b96SMarkus Armbruster$(SRC_PATH)/scripts/qapi/events.py \
638e6c42b96SMarkus Armbruster$(SRC_PATH)/scripts/qapi/expr.py \
639e6c42b96SMarkus Armbruster$(SRC_PATH)/scripts/qapi/gen.py \
640e6c42b96SMarkus Armbruster$(SRC_PATH)/scripts/qapi/introspect.py \
641e6c42b96SMarkus Armbruster$(SRC_PATH)/scripts/qapi/parser.py \
642e6c42b96SMarkus Armbruster$(SRC_PATH)/scripts/qapi/schema.py \
643e6c42b96SMarkus Armbruster$(SRC_PATH)/scripts/qapi/source.py \
644e6c42b96SMarkus Armbruster$(SRC_PATH)/scripts/qapi/types.py \
645e6c42b96SMarkus Armbruster$(SRC_PATH)/scripts/qapi/visit.py \
646fb0bc835SMarkus Armbruster$(SRC_PATH)/scripts/qapi-gen.py
6478d3bc517SAvi Kivity
648fb0bc835SMarkus Armbrusterqga/qapi-generated/qga-qapi-types.c qga/qapi-generated/qga-qapi-types.h \
649fb0bc835SMarkus Armbrusterqga/qapi-generated/qga-qapi-visit.c qga/qapi-generated/qga-qapi-visit.h \
650eb815e24SMarkus Armbrusterqga/qapi-generated/qga-qapi-commands.h qga/qapi-generated/qga-qapi-commands.c \
65100ca24ffSMarkus Armbrusterqga/qapi-generated/qga-qapi-init-commands.h qga/qapi-generated/qga-qapi-init-commands.c \
652fb0bc835SMarkus Armbrusterqga/qapi-generated/qga-qapi-doc.texi: \
653fb0bc835SMarkus Armbrusterqga/qapi-generated/qapi-gen-timestamp ;
654fb0bc835SMarkus Armbrusterqga/qapi-generated/qapi-gen-timestamp: $(SRC_PATH)/qga/qapi-schema.json $(qapi-py)
6550d6b93deSMatthias Maier	$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-gen.py \
656fb0bc835SMarkus Armbruster		-o qga/qapi-generated -p "qga-" $<, \
657fb0bc835SMarkus Armbruster		"GEN","$(@:%-timestamp=%)")
658fb0bc835SMarkus Armbruster	@>$@
659e3d4d252SMichael Roth
660bf582c34SEric Blakeqapi-modules = $(SRC_PATH)/qapi/qapi-schema.json \
661bf582c34SEric Blake               $(QAPI_MODULES:%=$(SRC_PATH)/qapi/%.json)
662be13d46dSMax Reitz
663bf582c34SEric Blake$(GENERATED_QAPI_FILES): qapi-gen-timestamp ;
664fb0bc835SMarkus Armbrusterqapi-gen-timestamp: $(qapi-modules) $(qapi-py)
6650d6b93deSMatthias Maier	$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-gen.py \
666eb815e24SMarkus Armbruster		-o "qapi" -b $<, \
667fb0bc835SMarkus Armbruster		"GEN","$(@:%-timestamp=%)")
668fb0bc835SMarkus Armbruster	@>$@
669e3193601SAnthony Liguori
6702af282ecSKevin Wolfqapi-modules-storage-daemon = \
6712af282ecSKevin Wolf	$(SRC_PATH)/storage-daemon/qapi/qapi-schema.json \
6722af282ecSKevin Wolf    $(QAPI_MODULES_STORAGE_DAEMON:%=$(SRC_PATH)/qapi/%.json)
6732af282ecSKevin Wolf
6742af282ecSKevin Wolf$(GENERATED_STORAGE_DAEMON_QAPI_FILES): storage-daemon/qapi/qapi-gen-timestamp ;
6752af282ecSKevin Wolfstorage-daemon/qapi/qapi-gen-timestamp: $(qapi-modules-storage-daemon) $(qapi-py)
6762af282ecSKevin Wolf	$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-gen.py \
6772af282ecSKevin Wolf		-o "storage-daemon/qapi" $<, \
6782af282ecSKevin Wolf		"GEN","$(@:%-timestamp=%)")
6792af282ecSKevin Wolf	@>$@
6802af282ecSKevin Wolf
68100ca24ffSMarkus ArmbrusterQGALIB_GEN=$(addprefix qga/qapi-generated/, qga-qapi-types.h qga-qapi-visit.h qga-qapi-commands.h qga-qapi-init-commands.h)
6827a0b7ebaSMarc-André Lureau$(qga-obj-y): $(QGALIB_GEN)
683957f1f99SMichael Roth
6840ab8ed18SDaniel P. Berrangeqemu-ga$(EXESUF): $(qga-obj-y) $(COMMON_LDADDS)
685fafcaf1dSMichael Roth	$(call LINK, $^)
68648ff7a62SMichael Roth
6879dacf32dSYossi Hindinifdef QEMU_GA_MSI_ENABLED
6889dacf32dSYossi HindinQEMU_GA_MSI=qemu-ga-$(ARCH).msi
6899dacf32dSYossi Hindin
6900a18750fSLeonid Blochmsi: $(QEMU_GA_MSI)
6919dacf32dSYossi Hindin
692fafcaf1dSMichael Roth$(QEMU_GA_MSI): qemu-ga.exe $(QGA_VSS_PROVIDER)
6939dacf32dSYossi Hindin
6949dacf32dSYossi Hindin$(QEMU_GA_MSI): config-host.mak
6959dacf32dSYossi Hindin
696decdfbd2SLeonid Bloch$(QEMU_GA_MSI):  $(SRC_PATH)/qga/installer/qemu-ga.wxs
697decdfbd2SLeonid Bloch	$(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)" \
6980bdb12c7SPeter Maydell	wixl -o $@ $(QEMU_GA_MSI_ARCH) $(QEMU_GA_MSI_WITH_VSS) $(QEMU_GA_MSI_MINGW_DLL_PATH) $<,"WIXL","$@")
6999dacf32dSYossi Hindinelse
7009dacf32dSYossi Hindinmsi:
70115b19ed8SMichael Roth	@echo "MSI build not configured or dependency resolution failed (reconfigure with --enable-guest-agent-msi option)"
7029dacf32dSYossi Hindinendif
7039dacf32dSYossi Hindin
704fafcaf1dSMichael Rothifneq ($(EXESUF),)
705fafcaf1dSMichael Roth.PHONY: qemu-ga
706fafcaf1dSMichael Rothqemu-ga: qemu-ga$(EXESUF) $(QGA_VSS_PROVIDER) $(QEMU_GA_MSI)
707fafcaf1dSMichael Rothendif
708fafcaf1dSMichael Roth
7091b9d35f3SViktor Prutyanovelf2dmp$(EXESUF): $(elf2dmp-obj-y)
7103fa2d384SViktor Prutyanov	$(call LINK, $^)
7113fa2d384SViktor Prutyanov
712b1449edbSKamil Rytarowskiifdef CONFIG_IVSHMEM
7130ab8ed18SDaniel P. Berrangeivshmem-client$(EXESUF): $(ivshmem-client-obj-y) $(COMMON_LDADDS)
714a75eb03bSDavid Marchand	$(call LINK, $^)
7150ab8ed18SDaniel P. Berrangeivshmem-server$(EXESUF): $(ivshmem-server-obj-y) $(COMMON_LDADDS)
716a75eb03bSDavid Marchand	$(call LINK, $^)
717b1449edbSKamil Rytarowskiendif
718d59a031cSMarc-André Lureauvhost-user-scsi$(EXESUF): $(vhost-user-scsi-obj-y) libvhost-user.a
71949cc0340SFelipe Franciosi	$(call LINK, $^)
720406d2aa2SChangpeng Liuvhost-user-blk$(EXESUF): $(vhost-user-blk-obj-y) libvhost-user.a
721406d2aa2SChangpeng Liu	$(call LINK, $^)
7220f645ba1SMarcel Apfelbaum
7230f645ba1SMarcel Apfelbaumrdmacm-mux$(EXESUF): LIBS += "-libumad"
724a5d2f6f8SYuval Shaiardmacm-mux$(EXESUF): $(rdmacm-mux-obj-y) $(COMMON_LDADDS)
725a5d2f6f8SYuval Shaia	$(call LINK, $^)
726a75eb03bSDavid Marchand
7274f8bde99SStefan Hajnoczi# relies on Linux-specific syscalls
7282405f3c0SDr. David Alan Gilbertifeq ($(CONFIG_LINUX)$(CONFIG_SECCOMP)$(CONFIG_LIBCAP_NG),yyy)
72981bfc42dSDr. David Alan Gilbertvirtiofsd$(EXESUF): $(virtiofsd-obj-y) libvhost-user.a $(COMMON_LDADDS)
73081bfc42dSDr. David Alan Gilbert	$(call LINK, $^)
73181bfc42dSDr. David Alan Gilbertendif
73281bfc42dSDr. David Alan Gilbert
733d52c454aSMarc-André Lureauvhost-user-gpu$(EXESUF): $(vhost-user-gpu-obj-y) $(libvhost-user-obj-y) libqemuutil.a libqemustub.a
734d52c454aSMarc-André Lureau	$(call LINK, $^)
735d52c454aSMarc-André Lureau
73606914c97SMarc-André Lureauifdef CONFIG_VHOST_USER_INPUT
73706914c97SMarc-André Lureauifdef CONFIG_LINUX
73806914c97SMarc-André Lureauvhost-user-input$(EXESUF): $(vhost-user-input-obj-y) libvhost-user.a libqemuutil.a
73906914c97SMarc-André Lureau	$(call LINK, $^)
74006914c97SMarc-André Lureau
74106914c97SMarc-André Lureau# build by default, do not install
74206914c97SMarc-André Lureauall: vhost-user-input$(EXESUF)
74306914c97SMarc-André Lureauendif
74406914c97SMarc-André Lureauendif
74506914c97SMarc-André Lureau
7460c0c1fd9SMarc Marimodule_block.h: $(SRC_PATH)/scripts/modules/module_block.py config-host.mak
7470c0c1fd9SMarc Mari	$(call quiet-command,$(PYTHON) $< $@ \
7480c0c1fd9SMarc Mari	$(addprefix $(SRC_PATH)/,$(patsubst %.mo,%.c,$(block-obj-m))), \
7490bdb12c7SPeter Maydell	"GEN","$@")
7500c0c1fd9SMarc Mari
751990e6a27SAlex Bennéeifdef CONFIG_GCOV
752990e6a27SAlex Bennée.PHONY: clean-coverage
753990e6a27SAlex Bennéeclean-coverage:
754990e6a27SAlex Bennée	$(call quiet-command, \
755990e6a27SAlex Bennée		find . \( -name '*.gcda' -o -name '*.gcov' \) -type f -exec rm {} +, \
756990e6a27SAlex Bennée		"CLEAN", "coverage files")
757990e6a27SAlex Bennéeendif
758990e6a27SAlex Bennée
7591338a4b7SMarkus Armbrusterclean: recurse-clean
7602d80ae89Sbellard# avoid old build problems by removing potentially incorrect old files
76125be210fSJuan Quintela	rm -f config.mak op-i386.h opc-i386.h gen-op-i386.h op-arm.h opc-arm.h gen-op-arm.h
762df2943baSMichael S. Tsirkin	rm -f qemu-options.def
7639dacf32dSYossi Hindin	rm -f *.msi
76423858f40SLaszlo Ersek	find . \( -name '*.so' -o -name '*.dll' -o -name '*.mo' -o -name '*.[oda]' \) -type f \
76523858f40SLaszlo Ersek		! -path ./roms/edk2/ArmPkg/Library/GccLto/liblto-aarch64.a \
76623858f40SLaszlo Ersek		! -path ./roms/edk2/ArmPkg/Library/GccLto/liblto-arm.a \
76723858f40SLaszlo Ersek		! -path ./roms/edk2/BaseTools/Source/Python/UPT/Dll/sqlite3.dll \
76823858f40SLaszlo Ersek		-exec rm {} +
76926ce90fdSLaszlo Ersek	rm -f $(edk2-decompressed)
7700814465aSPaolo Bonzini	rm -f $(filter-out %.tlb,$(TOOLS)) $(HELPERS-y) TAGS cscope.* *.pod *~ */*~
771b855f8d1SPaolo Bonzini	rm -f fsdev/*.pod scsi/*.pod
77207b44ce9SBlue Swirl	rm -f qemu-img-cmds.h
773d98bc0b6SGerd Hoffmann	rm -f ui/shader/*-vert.h ui/shader/*-frag.h
7743dff199cSLaurent Vivier	@# May not be present in generated-files-y
775eac236eaSLluís Vilanova	rm -f trace/generated-tracers-dtrace.dtrace*
776eac236eaSLluís Vilanova	rm -f trace/generated-tracers-dtrace.h*
7773dff199cSLaurent Vivier	rm -f $(foreach f,$(generated-files-y),$(f) $(f)-timestamp)
778fb0bc835SMarkus Armbruster	rm -f qapi-gen-timestamp
7792af282ecSKevin Wolf	rm -f storage-daemon/qapi/qapi-gen-timestamp
78054c2e502SDunrong Huang	rm -rf qga/qapi-generated
781e92af6ecSJuan Quintela	rm -f config-all-devices.mak
78231e31b8aSbellard
78334bb443eSAnthony LiguoriVERSION ?= $(shell cat VERSION)
78434bb443eSAnthony Liguori
78534bb443eSAnthony Liguoridist: qemu-$(VERSION).tar.bz2
78634bb443eSAnthony Liguori
78734bb443eSAnthony Liguoriqemu-%.tar.bz2:
78834bb443eSAnthony Liguori	$(SRC_PATH)/scripts/make-release "$(SRC_PATH)" "$(patsubst qemu-%.tar.bz2,%,$@)"
78934bb443eSAnthony Liguori
7905f71eac0SPeter Maydelldefine clean-manual =
7911290e671SPeter Maydellrm -rf $(MANUAL_BUILDDIR)/$1/_static
7921290e671SPeter Maydellrm -f $(MANUAL_BUILDDIR)/$1/objects.inv $(MANUAL_BUILDDIR)/$1/searchindex.js $(MANUAL_BUILDDIR)/$1/*.html
7935f71eac0SPeter Maydellendef
7945f71eac0SPeter Maydell
7957d13299dSbellarddistclean: clean
796ee5195eeSRichard Henderson	rm -f config-host.mak config-host.h* $(DOCS)
7972038f8c8SPaolo Bonzini	rm -f tests/tcg/config-*.mak
798ae219359SThomas Huth	rm -f config-all-devices.mak config-all-disas.mak config.status
799e92af6ecSJuan Quintela	rm -f $(SUBDIR_DEVICES_MAK)
800ae219359SThomas Huth	rm -f po/*.mo tests/qemu-iotests/common.env
801fc8e320eSMagnus Damm	rm -f roms/seabios/config.mak roms/vgabios/config.mak
80226fffe29SEmilio G. Cota	rm -f qemu-plugins-ld.symbols qemu-plugins-ld64.symbols
803793553acSAlexandre Raymond	rm -f config.log
80467ed96f9SPeter Maydell	rm -f linux-headers/asm
805d59157eaSPaolo Bonzini	rm -f docs/version.texi
806d59157eaSPaolo Bonzini	rm -f docs/interop/qemu-ga-qapi.texi docs/interop/qemu-qmp-qapi.texi
807d59157eaSPaolo Bonzini	rm -f docs/interop/qemu-qmp-ref.7 docs/interop/qemu-ga-ref.7
808d59157eaSPaolo Bonzini	rm -f docs/interop/qemu-qmp-ref.txt docs/interop/qemu-ga-ref.txt
809d59157eaSPaolo Bonzini	rm -f docs/interop/qemu-qmp-ref.pdf docs/interop/qemu-ga-ref.pdf
810d59157eaSPaolo Bonzini	rm -f docs/interop/qemu-qmp-ref.html docs/interop/qemu-ga-ref.html
81181f33401SPeter Maydell	rm -rf .doctrees
8125f71eac0SPeter Maydell	$(call clean-manual,devel)
8135f71eac0SPeter Maydell	$(call clean-manual,interop)
8140783a732SPeter Maydell	$(call clean-manual,specs)
8150928523aSPeter Maydell	$(call clean-manual,system)
81665c3542bSPeter Maydell	$(call clean-manual,tools)
81709147930SPaolo Bonzini	$(call clean-manual,user)
8182b1f35b9SAlex Bennée	for d in $(TARGET_DIRS); do \
819bc1b050dSbellard	rm -rf $$d || exit 1 ; \
82076bc6838Sbellard        done
821d9840e25STomoki Sekiyama	rm -Rf .sdk
8227d13299dSbellard
82306e7772fSGerd HoffmannKEYMAPS=da     en-gb  et  fr     fr-ch  is  lt  no  pt-br  sv \
824fed4a9adSbellardar      de     en-us  fi  fr-be  hr     it  lv  nl         pl  ru     th \
82526b1cbf8SGerd Hoffmannde-ch  es     fo  fr-ca  hu     ja  mk  pt  sl     tr \
8263751e722SJan Krupabepo    cz
827fed4a9adSbellard
82877755340Sthsifdef INSTALL_BLOBS
82932eb2da3SBruce RogersBLOBS=bios.bin bios-256k.bin bios-microvm.bin sgabios.bin vgabios.bin vgabios-cirrus.bin \
8307a4dfd1eSGerd Hoffmannvgabios-stdvga.bin vgabios-vmware.bin vgabios-qxl.bin vgabios-virtio.bin \
8310a87fd69SGerd Hoffmannvgabios-ramfb.bin vgabios-bochs-display.bin vgabios-ati.bin \
832b2ce76a0SThomas Huthopenbios-sparc32 openbios-sparc64 openbios-ppc QEMU,tcx.bin QEMU,cgthree.bin \
8335ee8ad71SAlex Williamsonpxe-e1000.rom pxe-eepro100.rom pxe-ne2k_pci.rom \
8345ee8ad71SAlex Williamsonpxe-pcnet.rom pxe-rtl8139.rom pxe-virtio.rom \
8359fd02979SSander Eikelenboomefi-e1000.rom efi-eepro100.rom efi-ne2k_pci.rom \
8369fd02979SSander Eikelenboomefi-pcnet.rom efi-rtl8139.rom efi-virtio.rom \
83745027808SGerd Hoffmannefi-e1000e.rom efi-vmxnet3.rom \
838b3ce38dcSPhilippe Mathieu-Daudéqemu-nsis.bmp \
8394b387f9eSBALATON Zoltanbamboo.dtb canyonlands.dtb petalogix-s3adsp1800.dtb petalogix-ml605.dtb \
8402785dc7bSStefano Garzarellamultiboot.bin linuxboot.bin linuxboot_dma.bin kvmvapic.bin pvh.bin \
8416c5359e1SChristian Borntraegers390-ccw.img s390-netboot.img \
842744a928cSAlexey Kardashevskiyslof.bin skiboot.lid \
8430c6ab8c9SCole Robinsonpalcode-clipper \
84482e65fe0SBALATON Zoltanu-boot.e500 u-boot-sam460-20100605.bin \
84543ad2564SRichard Hendersonqemu_vga.ndrv \
84626ce90fdSLaszlo Ersekedk2-licenses.txt \
84791f3a2f0SAlistair Francishppa-firmware.img \
848a6fcc80bSBin Mengopensbi-riscv32-sifive_u-fw_jump.bin opensbi-riscv32-virt-fw_jump.bin \
84991f3a2f0SAlistair Francisopensbi-riscv64-sifive_u-fw_jump.bin opensbi-riscv64-virt-fw_jump.bin
85091f3a2f0SAlistair Francis
85126ce90fdSLaszlo Ersek
85226ce90fdSLaszlo ErsekDESCS=50-edk2-i386-secure.json 50-edk2-x86_64-secure.json \
85326ce90fdSLaszlo Ersek60-edk2-aarch64.json 60-edk2-arm.json 60-edk2-i386.json 60-edk2-x86_64.json
85477755340Sthselse
85577755340SthsBLOBS=
85626ce90fdSLaszlo ErsekDESCS=
85777755340Sthsendif
85877755340Sths
859336cfef4SPeter Maydell# Note that we manually filter-out the non-Sphinx documentation which
86027a296fcSPeter Maydell# is currently built into the docs/interop directory in the build tree,
86127a296fcSPeter Maydell# and also any sphinx-built manpages.
8625f71eac0SPeter Maydelldefine install-manual =
8631290e671SPeter Maydellfor d in $$(cd $(MANUAL_BUILDDIR) && find $1 -type d); do $(INSTALL_DIR) "$(DESTDIR)$(qemu_docdir)/$$d"; done
86427a296fcSPeter Maydellfor 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
8655f71eac0SPeter Maydellendef
8665f71eac0SPeter Maydell
8675f71eac0SPeter Maydell# Note that we deliberately do not install the "devel" manual: it is
8685f71eac0SPeter Maydell# for QEMU developers, and not interesting to our users.
8695f71eac0SPeter Maydell.PHONY: install-sphinxdocs
8705f71eac0SPeter Maydellinstall-sphinxdocs: sphinxdocs
8715f71eac0SPeter Maydell	$(call install-manual,interop)
8720783a732SPeter Maydell	$(call install-manual,specs)
8730928523aSPeter Maydell	$(call install-manual,system)
87465c3542bSPeter Maydell	$(call install-manual,tools)
87509147930SPaolo Bonzini	$(call install-manual,user)
8765f71eac0SPeter Maydell
8775f71eac0SPeter Maydellinstall-doc: $(DOCS) install-sphinxdocs
878d7dd65baSEduardo Habkost	$(INSTALL_DIR) "$(DESTDIR)$(qemu_docdir)"
87922108f33SStefan Hajnoczi	$(INSTALL_DATA) $(MANUAL_BUILDDIR)/index.html "$(DESTDIR)$(qemu_docdir)"
880c13dba2cSLiao Pingfang	$(INSTALL_DIR) "$(DESTDIR)$(qemu_docdir)/interop"
881c13dba2cSLiao Pingfang	$(INSTALL_DATA) docs/interop/qemu-qmp-ref.html "$(DESTDIR)$(qemu_docdir)/interop"
882c13dba2cSLiao Pingfang	$(INSTALL_DATA) docs/interop/qemu-qmp-ref.txt "$(DESTDIR)$(qemu_docdir)/interop"
88396d409ebSJuan Quintelaifdef CONFIG_POSIX
88458f8aeadSaliguori	$(INSTALL_DIR) "$(DESTDIR)$(mandir)/man1"
885d06118bfSPeter Maydell	$(INSTALL_DATA) $(MANUAL_BUILDDIR)/system/qemu.1 "$(DESTDIR)$(mandir)/man1"
88656e8bdd4SMarc-André Lureau	$(INSTALL_DIR) "$(DESTDIR)$(mandir)/man7"
887d59157eaSPaolo Bonzini	$(INSTALL_DATA) docs/interop/qemu-qmp-ref.7 "$(DESTDIR)$(mandir)/man7"
888acab923dSPeter Maydell	$(INSTALL_DATA) $(MANUAL_BUILDDIR)/system/qemu-block-drivers.7 "$(DESTDIR)$(mandir)/man7"
8891bf84a1eSKashyap Chamarthy	$(INSTALL_DATA) $(MANUAL_BUILDDIR)/system/qemu-cpu-models.7 "$(DESTDIR)$(mandir)/man7"
890c932ce31SPaolo Bonziniifeq ($(CONFIG_TOOLS),y)
891a08b4a9fSPeter Maydell	$(INSTALL_DATA) $(MANUAL_BUILDDIR)/tools/qemu-img.1 "$(DESTDIR)$(mandir)/man1"
89258f8aeadSaliguori	$(INSTALL_DIR) "$(DESTDIR)$(mandir)/man8"
893a08b4a9fSPeter Maydell	$(INSTALL_DATA) $(MANUAL_BUILDDIR)/tools/qemu-nbd.8 "$(DESTDIR)$(mandir)/man8"
89438954dcaSpbrookendif
89562dd1048SDaniel P. Berrangéifdef CONFIG_TRACE_SYSTEMTAP
896a08b4a9fSPeter Maydell	$(INSTALL_DATA) $(MANUAL_BUILDDIR)/tools/qemu-trace-stap.1 "$(DESTDIR)$(mandir)/man1"
89762dd1048SDaniel P. Berrangéendif
898665b5d0dSMarc-André Lureauifneq (,$(findstring qemu-ga,$(TOOLS)))
899b53c54c6SPeter Maydell	$(INSTALL_DATA) $(MANUAL_BUILDDIR)/interop/qemu-ga.8 "$(DESTDIR)$(mandir)/man8"
900c13dba2cSLiao Pingfang	$(INSTALL_DIR) "$(DESTDIR)$(qemu_docdir)/interop"
901c13dba2cSLiao Pingfang	$(INSTALL_DATA) docs/interop/qemu-ga-ref.html "$(DESTDIR)$(qemu_docdir)/interop"
902c13dba2cSLiao Pingfang	$(INSTALL_DATA) docs/interop/qemu-ga-ref.txt "$(DESTDIR)$(qemu_docdir)/interop"
903d59157eaSPaolo Bonzini	$(INSTALL_DATA) docs/interop/qemu-ga-ref.7 "$(DESTDIR)$(mandir)/man7"
904665b5d0dSMarc-André Lureauendif
9058a3e8f7fSAndreas Färberendif
906a2d8f1beSM. Mohan Kumarifdef CONFIG_VIRTFS
907a2d8f1beSM. Mohan Kumar	$(INSTALL_DIR) "$(DESTDIR)$(mandir)/man1"
908a08b4a9fSPeter Maydell	$(INSTALL_DATA) $(MANUAL_BUILDDIR)/tools/virtfs-proxy-helper.1 "$(DESTDIR)$(mandir)/man1"
909a2d8f1beSM. Mohan Kumarendif
9106a7e2bbeSStefan Hajnocziifeq ($(CONFIG_LINUX)$(CONFIG_SECCOMP)$(CONFIG_LIBCAP_NG),yyy)
911a08b4a9fSPeter Maydell	$(INSTALL_DATA) $(MANUAL_BUILDDIR)/tools/virtiofsd.1 "$(DESTDIR)$(mandir)/man1"
9126a7e2bbeSStefan Hajnocziendif
913b5ec5ce0Sjohn cooper
914e2d87bffSEduardo Habkostinstall-datadir:
915e2d87bffSEduardo Habkost	$(INSTALL_DIR) "$(DESTDIR)$(qemu_datadir)"
916e2d87bffSEduardo Habkost
917f2e3978bSLaszlo Ersekinstall-localstatedir:
918f2e3978bSLaszlo Ersekifdef CONFIG_POSIX
919f2e3978bSLaszlo Ersekifneq (,$(findstring qemu-ga,$(TOOLS)))
920f2e3978bSLaszlo Ersek	$(INSTALL_DIR) "$(DESTDIR)$(qemu_localstatedir)"/run
921f2e3978bSLaszlo Ersekendif
922f2e3978bSLaszlo Ersekendif
923f2e3978bSLaszlo Ersek
924a8260d38SDaniel P. BerrangéICON_SIZES=16x16 24x24 32x32 48x48 64x64 128x128 256x256 512x512
925e2d87bffSEduardo Habkost
92654cb65d8SEmilio G. Cotainstall-includedir:
92754cb65d8SEmilio G. Cota	$(INSTALL_DIR) "$(DESTDIR)$(includedir)"
92854cb65d8SEmilio G. Cota
92954cb65d8SEmilio G. Cotainstall: all $(if $(BUILD_DOCS),install-doc) \
93054cb65d8SEmilio G. Cota	install-datadir install-localstatedir install-includedir \
9311338a4b7SMarkus Armbruster	$(if $(INSTALL_BLOBS),$(edk2-decompressed)) \
9321338a4b7SMarkus Armbruster	recurse-install
933932a79dfSthsifneq ($(TOOLS),)
9340814465aSPaolo Bonzini	$(call install-prog,$(TOOLS),$(DESTDIR)$(bindir))
935932a79dfSthsendif
936e3be6f0eSFam Zhengifneq ($(CONFIG_MODULES),)
937e3be6f0eSFam Zheng	$(INSTALL_DIR) "$(DESTDIR)$(qemu_moddir)"
9382115182fSMichael Tokarev	for s in $(modules-m:.mo=$(DSOSUF)); do \
9392115182fSMichael Tokarev		t="$(DESTDIR)$(qemu_moddir)/$$(echo $$s | tr / -)"; \
940264f8b4fSMichael Tokarev		$(INSTALL_LIB) $$s "$$t"; \
9412115182fSMichael Tokarev		test -z "$(STRIP)" || $(STRIP) "$$t"; \
942e3be6f0eSFam Zheng	done
943e3be6f0eSFam Zhengendif
9447b93fadfSCorey Bryantifneq ($(HELPERS-y),)
9450d659426SMichael Tokarev	$(call install-prog,$(HELPERS-y),$(DESTDIR)$(libexecdir))
9467b93fadfSCorey Bryantendif
947d52c454aSMarc-André Lureauifneq ($(vhost-user-json-y),)
948d52c454aSMarc-André Lureau	$(INSTALL_DIR) "$(DESTDIR)$(qemu_datadir)/vhost-user/"
949d52c454aSMarc-André Lureau	for x in $(vhost-user-json-y); do \
950d52c454aSMarc-André Lureau		$(INSTALL_DATA) $$x "$(DESTDIR)$(qemu_datadir)/vhost-user/"; \
951d52c454aSMarc-André Lureau	done
952d52c454aSMarc-André Lureauendif
95362dd1048SDaniel P. Berrangéifdef CONFIG_TRACE_SYSTEMTAP
95462dd1048SDaniel P. Berrangé	$(INSTALL_PROG) "scripts/qemu-trace-stap" $(DESTDIR)$(bindir)
95562dd1048SDaniel P. Berrangéendif
95677755340Sthsifneq ($(BLOBS),)
95777755340Sths	set -e; for x in $(BLOBS); do \
9586aae2a2eSEduardo Habkost		$(INSTALL_DATA) $(SRC_PATH)/pc-bios/$$x "$(DESTDIR)$(qemu_datadir)"; \
959ad064840Spbrook	done
96077755340Sthsendif
96126ce90fdSLaszlo Ersekifdef INSTALL_BLOBS
96226ce90fdSLaszlo Ersek	set -e; for x in $(edk2-decompressed); do \
96326ce90fdSLaszlo Ersek		$(INSTALL_DATA) $$x "$(DESTDIR)$(qemu_datadir)"; \
96426ce90fdSLaszlo Ersek	done
96526ce90fdSLaszlo Ersekendif
96626ce90fdSLaszlo Ersekifneq ($(DESCS),)
96726ce90fdSLaszlo Ersek	$(INSTALL_DIR) "$(DESTDIR)$(qemu_datadir)/firmware"
96826ce90fdSLaszlo Ersek	set -e; tmpf=$$(mktemp); trap 'rm -f -- "$$tmpf"' EXIT; \
96926ce90fdSLaszlo Ersek	for x in $(DESCS); do \
970177cd674SOlaf Hering		sed -e 's,@DATADIR@,$(qemu_datadir),' \
97126ce90fdSLaszlo Ersek			"$(SRC_PATH)/pc-bios/descriptors/$$x" > "$$tmpf"; \
97226ce90fdSLaszlo Ersek		$(INSTALL_DATA) "$$tmpf" \
97326ce90fdSLaszlo Ersek			"$(DESTDIR)$(qemu_datadir)/firmware/$$x"; \
97426ce90fdSLaszlo Ersek	done
97526ce90fdSLaszlo Ersekendif
976a8260d38SDaniel P. Berrangé	for s in $(ICON_SIZES); do \
9776c11dda9SStefan Hajnoczi		mkdir -p "$(DESTDIR)$(qemu_icondir)/hicolor/$${s}/apps"; \
978a8260d38SDaniel P. Berrangé		$(INSTALL_DATA) $(SRC_PATH)/ui/icons/qemu_$${s}.png \
9796c11dda9SStefan Hajnoczi			"$(DESTDIR)$(qemu_icondir)/hicolor/$${s}/apps/qemu.png"; \
980a8260d38SDaniel P. Berrangé	done; \
9816c11dda9SStefan Hajnoczi	mkdir -p "$(DESTDIR)$(qemu_icondir)/hicolor/32x32/apps"; \
982a8260d38SDaniel P. Berrangé	$(INSTALL_DATA) $(SRC_PATH)/ui/icons/qemu_32x32.bmp \
9836c11dda9SStefan Hajnoczi		"$(DESTDIR)$(qemu_icondir)/hicolor/32x32/apps/qemu.bmp"; \
9846c11dda9SStefan Hajnoczi	mkdir -p "$(DESTDIR)$(qemu_icondir)/hicolor/scalable/apps"; \
985a8260d38SDaniel P. Berrangé	$(INSTALL_DATA) $(SRC_PATH)/ui/icons/qemu.svg \
9866c11dda9SStefan Hajnoczi		"$(DESTDIR)$(qemu_icondir)/hicolor/scalable/apps/qemu.svg"
9876c11dda9SStefan Hajnoczi	mkdir -p "$(DESTDIR)$(qemu_desktopdir)"
98867ea9546SDaniel P. Berrangé	$(INSTALL_DATA) $(SRC_PATH)/ui/qemu.desktop \
9896c11dda9SStefan Hajnoczi		"$(DESTDIR)$(qemu_desktopdir)/qemu.desktop"
9902a6b5372SMichael Tokarevifdef CONFIG_GTK
991834574eaSAnthony Liguori	$(MAKE) -C po $@
992834574eaSAnthony Liguoriendif
99354cb65d8SEmilio G. Cotaifeq ($(CONFIG_PLUGIN),y)
99454cb65d8SEmilio G. Cota	$(INSTALL_DATA) $(SRC_PATH)/include/qemu/qemu-plugin.h "$(DESTDIR)$(includedir)/qemu-plugin.h"
99554cb65d8SEmilio G. Cotaendif
9966aae2a2eSEduardo Habkost	$(INSTALL_DIR) "$(DESTDIR)$(qemu_datadir)/keymaps"
99718be8d77Sblueswir1	set -e; for x in $(KEYMAPS); do \
9986aae2a2eSEduardo Habkost		$(INSTALL_DATA) $(SRC_PATH)/pc-bios/keymaps/$$x "$(DESTDIR)$(qemu_datadir)/keymaps"; \
999ad064840Spbrook	done
10001412cf58SDaniel P. Berrange	$(INSTALL_DATA) $(BUILD_DIR)/trace-events-all "$(DESTDIR)$(qemu_datadir)/trace-events-all"
1001612384d7Sbellard
1002ae5fdc81SFam Zheng.PHONY: ctags
1003ae5fdc81SFam Zhengctags:
1004ac99c624SSergey Fedorov	rm -f tags
1005ae5fdc81SFam Zheng	find "$(SRC_PATH)" -name '*.[hc]' -exec ctags --append {} +
1006ae5fdc81SFam Zheng
100721d4e8e3SAlexandre Bique.PHONY: TAGS
1008367e86e8SbellardTAGS:
1009ac99c624SSergey Fedorov	rm -f TAGS
1010b1999e87SDavid Gibson	find "$(SRC_PATH)" -name '*.[hc]' -exec etags --append {} +
101131e31b8aSbellard
10126688bc6dSbellardcscope:
1013eaa2ddbbSFam Zheng	rm -f "$(SRC_PATH)"/cscope.*
1014eaa2ddbbSFam Zheng	find "$(SRC_PATH)/" -name "*.[chsS]" -print | sed 's,^\./,,' > "$(SRC_PATH)/cscope.files"
1015eaa2ddbbSFam Zheng	cscope -b -i"$(SRC_PATH)/cscope.files"
10166688bc6dSbellard
1017d98bc0b6SGerd Hoffmann# opengl shader programs
1018d98bc0b6SGerd Hoffmannui/shader/%-vert.h: $(SRC_PATH)/ui/shader/%.vert $(SRC_PATH)/scripts/shaderinclude.pl
1019d98bc0b6SGerd Hoffmann	@mkdir -p $(dir $@)
1020d98bc0b6SGerd Hoffmann	$(call quiet-command,\
1021d98bc0b6SGerd Hoffmann		perl $(SRC_PATH)/scripts/shaderinclude.pl $< > $@,\
10220bdb12c7SPeter Maydell		"VERT","$@")
1023d98bc0b6SGerd Hoffmann
1024d98bc0b6SGerd Hoffmannui/shader/%-frag.h: $(SRC_PATH)/ui/shader/%.frag $(SRC_PATH)/scripts/shaderinclude.pl
1025d98bc0b6SGerd Hoffmann	@mkdir -p $(dir $@)
1026d98bc0b6SGerd Hoffmann	$(call quiet-command,\
1027d98bc0b6SGerd Hoffmann		perl $(SRC_PATH)/scripts/shaderinclude.pl $< > $@,\
10280bdb12c7SPeter Maydell		"FRAG","$@")
1029d98bc0b6SGerd Hoffmann
103046e19e14SGerd Hoffmannui/shader.o: $(SRC_PATH)/ui/shader.c \
10312e1d70b9SGerd Hoffmann	ui/shader/texture-blit-vert.h \
10322e1d70b9SGerd Hoffmann	ui/shader/texture-blit-flip-vert.h \
10332e1d70b9SGerd Hoffmann	ui/shader/texture-blit-frag.h
1034cd2bc889SGerd Hoffmann
10353ef693a0Sbellard# documentation
1036e8518c92SMarkus ArmbrusterMAKEINFO=makeinfo
1037d59157eaSPaolo BonziniMAKEINFOINCLUDES= -I docs -I $(<D) -I $(@D)
1038d59157eaSPaolo BonziniMAKEINFOFLAGS=--no-split --number-sections $(MAKEINFOINCLUDES)
1039e8338fdbSMarc-André LureauTEXI2PODFLAGS=$(MAKEINFOINCLUDES) -DVERSION="$(VERSION)" -DCONFDIR="$(qemu_confdir)"
1040d59157eaSPaolo BonziniTEXI2PDFFLAGS=$(if $(V),,--quiet) -I $(SRC_PATH) $(MAKEINFOINCLUDES)
104156e8bdd4SMarc-André Lureau
1042e8338fdbSMarc-André Lureaudocs/version.texi: $(SRC_PATH)/VERSION config-host.mak
1043e8338fdbSMarc-André Lureau	$(call quiet-command,(\
1044e8338fdbSMarc-André Lureau		echo "@set VERSION $(VERSION)" && \
1045e8338fdbSMarc-André Lureau		echo "@set CONFDIR $(qemu_confdir)" \
1046e8338fdbSMarc-André Lureau	)> $@,"GEN","$@")
1047fea346f5SPeter Maydell
104844cb280dSPaolo Bonzini%.html: %.texi docs/version.texi
1049e9ee06bdSMarc-André Lureau	$(call quiet-command,LC_ALL=C $(MAKEINFO) $(MAKEINFOFLAGS) --no-headers \
1050e9ee06bdSMarc-André Lureau	--html $< -o $@,"GEN","$@")
10513ef693a0Sbellard
105244cb280dSPaolo Bonzini%.info: %.texi docs/version.texi
1053e9ee06bdSMarc-André Lureau	$(call quiet-command,$(MAKEINFO) $(MAKEINFOFLAGS) $< -o $@,"GEN","$@")
1054f3548328Sbellard
105544cb280dSPaolo Bonzini%.txt: %.texi docs/version.texi
1056f8bab10bSMarc-André Lureau	$(call quiet-command,LC_ALL=C $(MAKEINFO) $(MAKEINFOFLAGS) --no-headers \
1057f8bab10bSMarc-André Lureau	--plaintext $< -o $@,"GEN","$@")
1058f8bab10bSMarc-André Lureau
105944cb280dSPaolo Bonzini%.pdf: %.texi docs/version.texi
1060d59157eaSPaolo Bonzini	$(call quiet-command,texi2pdf $(TEXI2PDFFLAGS) $< -o $@,"GEN","$@")
1061bd7f9747SMarkus Armbruster
10625f71eac0SPeter Maydell# Sphinx builds all its documentation at once in one invocation
10635f71eac0SPeter Maydell# and handles "don't rebuild things unless necessary" itself.
10645f71eac0SPeter Maydell# The '.doctrees' files are cached information to speed this up.
10655f71eac0SPeter Maydell.PHONY: sphinxdocs
10660928523aSPeter Maydellsphinxdocs: $(MANUAL_BUILDDIR)/devel/index.html \
10670928523aSPeter Maydell            $(MANUAL_BUILDDIR)/interop/index.html \
10680928523aSPeter Maydell            $(MANUAL_BUILDDIR)/specs/index.html \
106965c3542bSPeter Maydell            $(MANUAL_BUILDDIR)/system/index.html \
107009147930SPaolo Bonzini            $(MANUAL_BUILDDIR)/tools/index.html \
107109147930SPaolo Bonzini            $(MANUAL_BUILDDIR)/user/index.html
10725f71eac0SPeter Maydell
10735f71eac0SPeter Maydell# Canned command to build a single manual
107427a296fcSPeter Maydell# Arguments: $1 = manual name, $2 = Sphinx builder ('html' or 'man')
10756bda415cSEduardo Habkost# Note the use of different doctree for each (manual, builder) tuple;
10766bda415cSEduardo Habkost# this works around Sphinx not handling parallel invocation on
10776bda415cSEduardo Habkost# a single doctree: https://github.com/sphinx-doc/sphinx/issues/2946
1078516e8b7dSPeter Maydellbuild-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")
10795f71eac0SPeter Maydell# We assume all RST files in the manual's directory are used in it
1080814e068fSPeter Maydellmanual-deps = $(wildcard $(SRC_PATH)/docs/$1/*.rst $(SRC_PATH)/docs/$1/*/*.rst) \
1081de1572caSPeter Maydell              $(SRC_PATH)/docs/defs.rst.inc \
10829165d323SPeter Maydell              $(SRC_PATH)/docs/$1/conf.py $(SRC_PATH)/docs/conf.py \
10839165d323SPeter Maydell              $(SRC_PATH)/docs/sphinx/*.py
1084e0f3728dSPeter Maydell# Macro to write out the rule and dependencies for building manpages
1085e0f3728dSPeter Maydell# Usage: $(call define-manpage-rule,manualname,manpage1 manpage2...[,extradeps])
1086e0f3728dSPeter Maydell# 'extradeps' is optional, and specifies extra files (eg .hx files) that
1087e0f3728dSPeter Maydell# the manual page depends on.
1088e0f3728dSPeter Maydelldefine define-manpage-rule
1089e0f3728dSPeter Maydell$(call atomic,$(foreach manpage,$2,$(MANUAL_BUILDDIR)/$1/$(manpage)),$(call manual-deps,$1) $3)
1090e0f3728dSPeter Maydell	$(call build-manual,$1,man)
1091e0f3728dSPeter Maydellendef
10925f71eac0SPeter Maydell
10931290e671SPeter Maydell$(MANUAL_BUILDDIR)/devel/index.html: $(call manual-deps,devel)
109427a296fcSPeter Maydell	$(call build-manual,devel,html)
10955f71eac0SPeter Maydell
1096a08b4a9fSPeter Maydell$(MANUAL_BUILDDIR)/interop/index.html: $(call manual-deps,interop)
109727a296fcSPeter Maydell	$(call build-manual,interop,html)
10985f71eac0SPeter Maydell
10990783a732SPeter Maydell$(MANUAL_BUILDDIR)/specs/index.html: $(call manual-deps,specs)
110027a296fcSPeter Maydell	$(call build-manual,specs,html)
110127a296fcSPeter Maydell
110209ce5f2dSPeter Maydell$(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
11030928523aSPeter Maydell	$(call build-manual,system,html)
11040928523aSPeter Maydell
1105a08b4a9fSPeter Maydell$(MANUAL_BUILDDIR)/tools/index.html: $(call manual-deps,tools) $(SRC_PATH)/qemu-img-cmds.hx $(SRC_PATH)/docs/qemu-option-trace.rst.inc
110665c3542bSPeter Maydell	$(call build-manual,tools,html)
110765c3542bSPeter Maydell
110809147930SPaolo Bonzini$(MANUAL_BUILDDIR)/user/index.html: $(call manual-deps,user)
110909147930SPaolo Bonzini	$(call build-manual,user,html)
111009147930SPaolo Bonzini
1111a08b4a9fSPeter Maydell$(call define-manpage-rule,interop,qemu-ga.8)
11120783a732SPeter Maydell
1113d06118bfSPeter Maydell$(call define-manpage-rule,system,qemu.1 qemu-block-drivers.7 qemu-cpu-models.7)
1114acab923dSPeter Maydell
1115a08b4a9fSPeter Maydell$(call define-manpage-rule,tools,\
1116a08b4a9fSPeter Maydell       qemu-img.1 qemu-nbd.8 qemu-trace-stap.1\
1117a08b4a9fSPeter Maydell       virtiofsd.1 virtfs-proxy-helper.1,\
1118a08b4a9fSPeter Maydell       $(SRC_PATH)/qemu-img-cmds.hx $(SRC_PATH)/docs/qemu-option-trace.rst.inc)
1119a08b4a9fSPeter Maydell
112022108f33SStefan Hajnoczi$(MANUAL_BUILDDIR)/index.html: $(SRC_PATH)/docs/index.html.in qemu-version.h
1121d83bbedaSStefan Hajnoczi	@mkdir -p "$(MANUAL_BUILDDIR)"
112222108f33SStefan Hajnoczi	$(call quiet-command, sed "s|@@VERSION@@|${VERSION}|g" $< >$@, \
112322108f33SStefan Hajnoczi             "GEN","$@")
112422108f33SStefan Hajnoczi
1125eb815e24SMarkus Armbrusterdocs/interop/qemu-qmp-qapi.texi: qapi/qapi-doc.texi
1126fb0bc835SMarkus Armbruster	@cp -p $< $@
11274afeeb57SMarkus Armbruster
1128fb0bc835SMarkus Armbrusterdocs/interop/qemu-ga-qapi.texi: qga/qapi-generated/qga-qapi-doc.texi
1129fb0bc835SMarkus Armbruster	@cp -p $< $@
113056e8bdd4SMarc-André Lureau
11315b1d0e92SPeter Maydellhtml: docs/interop/qemu-qmp-ref.html docs/interop/qemu-ga-ref.html sphinxdocs
11325b1d0e92SPeter Maydellinfo: docs/interop/qemu-qmp-ref.info docs/interop/qemu-ga-ref.info
11335b1d0e92SPeter Maydellpdf: docs/interop/qemu-qmp-ref.pdf docs/interop/qemu-ga-ref.pdf
11345b1d0e92SPeter Maydelltxt: docs/interop/qemu-qmp-ref.txt docs/interop/qemu-ga-ref.txt
1135818220f5Saliguori
1136d59157eaSPaolo Bonzinidocs/interop/qemu-ga-ref.dvi docs/interop/qemu-ga-ref.html \
1137d59157eaSPaolo Bonzini    docs/interop/qemu-ga-ref.info docs/interop/qemu-ga-ref.pdf \
1138d59157eaSPaolo Bonzini    docs/interop/qemu-ga-ref.txt docs/interop/qemu-ga-ref.7: \
1139d59157eaSPaolo Bonzini	docs/interop/qemu-ga-ref.texi docs/interop/qemu-ga-qapi.texi
114056e8bdd4SMarc-André Lureau
1141d59157eaSPaolo Bonzinidocs/interop/qemu-qmp-ref.dvi docs/interop/qemu-qmp-ref.html \
1142d59157eaSPaolo Bonzini    docs/interop/qemu-qmp-ref.info docs/interop/qemu-qmp-ref.pdf \
1143d59157eaSPaolo Bonzini    docs/interop/qemu-qmp-ref.txt docs/interop/qemu-qmp-ref.7: \
1144d59157eaSPaolo Bonzini	docs/interop/qemu-qmp-ref.texi docs/interop/qemu-qmp-qapi.texi
114556e8bdd4SMarc-André Lureau
1146ae560cc3SEric Blake$(filter %.1 %.7 %.8,$(DOCS)): scripts/texi2pod.pl
1147ae560cc3SEric Blake
1148fe8bf5f6SAlex Bennée# Reports/Analysis
1149fe8bf5f6SAlex Bennée
1150fe8bf5f6SAlex Bennée%/coverage-report.html:
1151fe8bf5f6SAlex Bennée	@mkdir -p $*
1152fe8bf5f6SAlex Bennée	$(call quiet-command,\
11535eda6e42SAlex Bennée		gcovr -r $(SRC_PATH) \
11545eda6e42SAlex Bennée		$(foreach t, $(TARGET_DIRS), --object-directory $(BUILD_DIR)/$(t)) \
11555eda6e42SAlex Bennée		 --object-directory $(BUILD_DIR) \
1156337f2311SAlex Bennée		-p --html --html-details -o $@, \
1157fe8bf5f6SAlex Bennée		"GEN", "coverage-report.html")
1158fe8bf5f6SAlex Bennée
1159fe8bf5f6SAlex Bennée.PHONY: coverage-report
1160fe8bf5f6SAlex Bennéecoverage-report: $(CURDIR)/reports/coverage/coverage-report.html
116156e8bdd4SMarc-André Lureau
1162f53ec699SStefan Weilifdef CONFIG_WIN32
1163f53ec699SStefan Weil
1164f53ec699SStefan WeilINSTALLER = qemu-setup-$(VERSION)$(EXESUF)
1165f53ec699SStefan Weil
1166f53ec699SStefan Weilnsisflags = -V2 -NOCD
1167f53ec699SStefan Weil
1168f53ec699SStefan Weilifneq ($(wildcard $(SRC_PATH)/dll),)
1169f53ec699SStefan Weilifeq ($(ARCH),x86_64)
1170f53ec699SStefan Weil# 64 bit executables
1171f53ec699SStefan WeilDLL_PATH = $(SRC_PATH)/dll/w64
1172f53ec699SStefan Weilnsisflags += -DW64
1173f53ec699SStefan Weilelse
1174f53ec699SStefan Weil# 32 bit executables
1175f53ec699SStefan WeilDLL_PATH = $(SRC_PATH)/dll/w32
1176f53ec699SStefan Weilendif
1177f53ec699SStefan Weilendif
1178f53ec699SStefan Weil
1179f53ec699SStefan Weil.PHONY: installer
1180f53ec699SStefan Weilinstaller: $(INSTALLER)
1181f53ec699SStefan Weil
1182f53ec699SStefan WeilINSTDIR=/tmp/qemu-nsis
1183f53ec699SStefan Weil
1184f84f9f75SPhilippe Mathieu-Daudé$(INSTALLER): install-doc $(SRC_PATH)/qemu.nsi
1185fb8597bbSEd Maste	$(MAKE) install prefix=${INSTDIR}
1186f53ec699SStefan Weilifdef SIGNCODE
1187f53ec699SStefan Weil	(cd ${INSTDIR}; \
1188f53ec699SStefan Weil         for i in *.exe; do \
1189f53ec699SStefan Weil           $(SIGNCODE) $${i}; \
1190f53ec699SStefan Weil         done \
1191f53ec699SStefan Weil        )
1192f53ec699SStefan Weilendif # SIGNCODE
1193f53ec699SStefan Weil	(cd ${INSTDIR}; \
1194f53ec699SStefan Weil         for i in qemu-system-*.exe; do \
1195f53ec699SStefan Weil           arch=$${i%.exe}; \
1196f53ec699SStefan Weil           arch=$${arch#qemu-system-}; \
1197f53ec699SStefan Weil           echo Section \"$$arch\" Section_$$arch; \
1198f53ec699SStefan Weil           echo SetOutPath \"\$$INSTDIR\"; \
1199f53ec699SStefan Weil           echo File \"\$${BINDIR}\\$$i\"; \
1200f53ec699SStefan Weil           echo SectionEnd; \
1201f53ec699SStefan Weil         done \
1202f53ec699SStefan Weil        ) >${INSTDIR}/system-emulations.nsh
1203f53ec699SStefan Weil	makensis $(nsisflags) \
1204f53ec699SStefan Weil                $(if $(BUILD_DOCS),-DCONFIG_DOCUMENTATION="y") \
1205f53ec699SStefan Weil                $(if $(CONFIG_GTK),-DCONFIG_GTK="y") \
1206f53ec699SStefan Weil                -DBINDIR="${INSTDIR}" \
1207f53ec699SStefan Weil                $(if $(DLL_PATH),-DDLLDIR="$(DLL_PATH)") \
1208f53ec699SStefan Weil                -DSRCDIR="$(SRC_PATH)" \
1209f53ec699SStefan Weil                -DOUTFILE="$(INSTALLER)" \
1210805d8a67SStefan Weil                -DDISPLAYVERSION="$(VERSION)" \
1211f53ec699SStefan Weil                $(SRC_PATH)/qemu.nsi
1212f53ec699SStefan Weil	rm -r ${INSTDIR}
1213f53ec699SStefan Weilifdef SIGNCODE
1214f53ec699SStefan Weil	$(SIGNCODE) $(INSTALLER)
1215f53ec699SStefan Weilendif # SIGNCODE
1216f53ec699SStefan Weilendif # CONFIG_WIN
1217f53ec699SStefan Weil
1218cb5fc67dSAnthony Liguori# Add a dependency on the generated files, so that they are always
1219cb5fc67dSAnthony Liguori# rebuilt before other object files
1220428952cfSThomas Huthifneq ($(wildcard config-host.mak),)
1221eaa2ddbbSFam Zhengifneq ($(filter-out $(UNCHECKED_GOALS),$(MAKECMDGOALS)),$(if $(MAKECMDGOALS),,fail))
12223dff199cSLaurent VivierMakefile: $(generated-files-y)
12237748b8cbSMike Frysingerendif
1224428952cfSThomas Huthendif
1225cb5fc67dSAnthony Liguori
12260ab8ed18SDaniel P. Berrange.SECONDARY: $(TRACE_HEADERS) $(TRACE_HEADERS:%=%-timestamp) \
12270ab8ed18SDaniel P. Berrange	$(TRACE_SOURCES) $(TRACE_SOURCES:%=%-timestamp) \
12280ab8ed18SDaniel P. Berrange	$(TRACE_DTRACE) $(TRACE_DTRACE:%=%-timestamp)
12290ab8ed18SDaniel P. Berrange
12304fb240a4Sbellard# Include automatically generated dependency files
12311435ddb8SPaolo Bonzini# Dependencies in Makefile.objs files come from our recursive subdir rules
12321435ddb8SPaolo Bonzini-include $(wildcard *.d tests/*.d)
1233324027c2SFam Zheng
1234324027c2SFam Zhenginclude $(SRC_PATH)/tests/docker/Makefile.include
1235b1fb9a63SFam Zhenginclude $(SRC_PATH)/tests/vm/Makefile.include
12360d8e065fSMarc-André Lureau
1237c355de59SPhilippe Mathieu-Daudéprint-help-run = printf "  %-30s - %s\\n" "$1" "$2"
1238c355de59SPhilippe Mathieu-Daudéprint-help = $(quiet-@)$(call print-help-run,$1,$2)
1239c355de59SPhilippe Mathieu-Daudé
12400d8e065fSMarc-André Lureau.PHONY: help
12410d8e065fSMarc-André Lureauhelp:
12420d8e065fSMarc-André Lureau	@echo  'Generic targets:'
1243c355de59SPhilippe Mathieu-Daudé	$(call print-help,all,Build all)
12440decdfe2SMarc-André Lureauifdef CONFIG_MODULES
1245c355de59SPhilippe Mathieu-Daudé	$(call print-help,modules,Build all modules)
12460decdfe2SMarc-André Lureauendif
1247c355de59SPhilippe Mathieu-Daudé	$(call print-help,dir/file.o,Build specified target only)
1248c355de59SPhilippe Mathieu-Daudé	$(call print-help,install,Install QEMU, documentation and tools)
1249c355de59SPhilippe Mathieu-Daudé	$(call print-help,ctags/TAGS,Generate tags file for editors)
1250c355de59SPhilippe Mathieu-Daudé	$(call print-help,cscope,Generate cscope index)
12510d8e065fSMarc-André Lureau	@echo  ''
12522b1f35b9SAlex Bennée	@$(if $(TARGET_DIRS), \
12530d8e065fSMarc-André Lureau		echo 'Architecture specific targets:'; \
12542b1f35b9SAlex Bennée		$(foreach t, $(TARGET_DIRS), \
1255763815a8SPhilippe Mathieu-Daudé		$(call print-help-run,$(t)/all,Build for $(t)); \
1256763815a8SPhilippe Mathieu-Daudé		$(if $(CONFIG_FUZZ), \
1257763815a8SPhilippe Mathieu-Daudé			$(if $(findstring softmmu,$(t)), \
1258763815a8SPhilippe Mathieu-Daudé				$(call print-help-run,$(t)/fuzz,Build fuzzer for $(t)); \
1259763815a8SPhilippe Mathieu-Daudé		))) \
12600d8e065fSMarc-André Lureau		echo '')
1261fdbff6bdSPhilippe Mathieu-Daudé	@$(if $(HELPERS-y), \
1262fdbff6bdSPhilippe Mathieu-Daudé		echo 'Helper targets:'; \
1263fdbff6bdSPhilippe Mathieu-Daudé		$(foreach t, $(HELPERS-y), \
1264fdbff6bdSPhilippe Mathieu-Daudé		$(call print-help-run,$(t),Build $(shell basename $(t)));) \
1265fdbff6bdSPhilippe Mathieu-Daudé		echo '')
126681ed0a57SPhilippe Mathieu-Daudé	@$(if $(TOOLS), \
126781ed0a57SPhilippe Mathieu-Daudé		echo 'Tools targets:'; \
126881ed0a57SPhilippe Mathieu-Daudé		$(foreach t, $(TOOLS), \
126981ed0a57SPhilippe Mathieu-Daudé		$(call print-help-run,$(t),Build $(shell basename $(t)) tool);) \
12700d8e065fSMarc-André Lureau		echo '')
12710d8e065fSMarc-André Lureau	@echo  'Cleaning targets:'
1272c355de59SPhilippe Mathieu-Daudé	$(call print-help,clean,Remove most generated files but keep the config)
1273990e6a27SAlex Bennéeifdef CONFIG_GCOV
1274c355de59SPhilippe Mathieu-Daudé	$(call print-help,clean-coverage,Remove coverage files)
1275990e6a27SAlex Bennéeendif
1276c355de59SPhilippe Mathieu-Daudé	$(call print-help,distclean,Remove all generated files)
1277c355de59SPhilippe Mathieu-Daudé	$(call print-help,dist,Build a distributable tarball)
12780d8e065fSMarc-André Lureau	@echo  ''
12790d8e065fSMarc-André Lureau	@echo  'Test targets:'
1280c355de59SPhilippe Mathieu-Daudé	$(call print-help,check,Run all tests (check-help for details))
1281c355de59SPhilippe Mathieu-Daudé	$(call print-help,docker,Help about targets running tests inside containers)
1282c355de59SPhilippe Mathieu-Daudé	$(call print-help,vm-help,Help about targets running tests inside VM)
12830d8e065fSMarc-André Lureau	@echo  ''
12840d8e065fSMarc-André Lureau	@echo  'Documentation targets:'
1285c355de59SPhilippe Mathieu-Daudé	$(call print-help,html info pdf txt,Build documentation in specified format)
1286fe8bf5f6SAlex Bennéeifdef CONFIG_GCOV
1287c355de59SPhilippe Mathieu-Daudé	$(call print-help,coverage-report,Create code coverage report)
1288fe8bf5f6SAlex Bennéeendif
12890d8e065fSMarc-André Lureau	@echo  ''
12900d8e065fSMarc-André Lureauifdef CONFIG_WIN32
12910d8e065fSMarc-André Lureau	@echo  'Windows targets:'
1292c355de59SPhilippe Mathieu-Daudé	$(call print-help,installer,Build NSIS-based installer for QEMU)
12930d8e065fSMarc-André Lureauifdef QEMU_GA_MSI_ENABLED
1294c355de59SPhilippe Mathieu-Daudé	$(call print-help,msi,Build MSI-based installer for qemu-ga)
12950d8e065fSMarc-André Lureauendif
12960d8e065fSMarc-André Lureau	@echo  ''
12970d8e065fSMarc-André Lureauendif
1298c355de59SPhilippe Mathieu-Daudé	$(call print-help,$(MAKE) [targets],(quiet build, default))
1299c355de59SPhilippe Mathieu-Daudé	$(call print-help,$(MAKE) V=1 [targets],(verbose build))
1300