xref: /openbmc/qemu/Makefile (revision 81ed0a57)
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 =
339d52c454aSMarc-André LureauHELPERS-y =
340d52c454aSMarc-André Lureau
341206d1b9cSLaurent VivierHELPERS-$(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
3482405f3c0SDr. David Alan Gilbertifeq ($(CONFIG_LINUX)$(CONFIG_SECCOMP)$(CONFIG_LIBCAP_NG),yyy)
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
421ea763fd2SThomas HuthMINIKCONF_INPUTS = $(SRC_PATH)/Kconfig.host $(SRC_PATH)/hw/Kconfig
422ea763fd2SThomas HuthMINIKCONF_DEPS = $(MINIKCONF_INPUTS) $(wildcard $(SRC_PATH)/hw/*/Kconfig)
423e0e312f3SPaolo BonziniMINIKCONF = $(PYTHON) $(SRC_PATH)/scripts/minikconf.py \
424e0e312f3SPaolo Bonzini
425ea763fd2SThomas Huth$(SUBDIR_DEVICES_MAK): %/config-devices.mak: default-configs/%.mak $(MINIKCONF_DEPS) $(BUILD_DIR)/config-host.mak
426e0e312f3SPaolo Bonzini	$(call quiet-command, $(MINIKCONF) $(MINIKCONF_ARGS) > $@.tmp, "GEN", "$@.tmp")
42712ccfec9SMichael S. Tsirkin	$(call quiet-command, if test -f $@; then \
428904fe1fbSBlue Swirl	  if cmp -s $@.old $@; then \
429012f0879SStefan Weil	    mv $@.tmp $@; \
430012f0879SStefan Weil	    cp -p $@ $@.old; \
431012f0879SStefan Weil	  else \
432012f0879SStefan Weil	    if test -f $@.old; then \
433012f0879SStefan Weil	      echo "WARNING: $@ (user modified) out of date.";\
434012f0879SStefan Weil	    else \
435a992fe3dSPaul Brook	      echo "WARNING: $@ out of date.";\
436012f0879SStefan Weil	    fi; \
437b98a3baeSPhilippe Mathieu-Daudé	    echo "Run \"$(MAKE) defconfig\" to regenerate."; \
438a992fe3dSPaul Brook	    rm $@.tmp; \
439012f0879SStefan Weil	  fi; \
440a992fe3dSPaul Brook	 else \
441a992fe3dSPaul Brook	  mv $@.tmp $@; \
442012f0879SStefan Weil	  cp -p $@ $@.old; \
4430bdb12c7SPeter Maydell	 fi,"GEN","$@");
444a992fe3dSPaul Brook
445a992fe3dSPaul Brookdefconfig:
446a992fe3dSPaul Brook	rm -f config-all-devices.mak $(SUBDIR_DEVICES_MAK)
447a992fe3dSPaul Brook
448992aeb8eSPaolo Bonziniifneq ($(wildcard config-host.mak),)
449992aeb8eSPaolo Bonziniinclude $(SRC_PATH)/Makefile.objs
450ba1183daSFam Zhengendif
451ba1183daSFam Zheng
452ba1183daSFam Zhengdummy := $(call unnest-vars,, \
453ba1183daSFam Zheng                stub-obj-y \
4545b76dd13SDaniel P. Berrange                authz-obj-y \
45532d955a4SMarc-André Lureau                chardev-obj-y \
456ba1183daSFam Zheng                util-obj-y \
457ba1183daSFam Zheng                qga-obj-y \
4583fa2d384SViktor Prutyanov                elf2dmp-obj-y \
459a75eb03bSDavid Marchand                ivshmem-client-obj-y \
460a75eb03bSDavid Marchand                ivshmem-server-obj-y \
46181bfc42dSDr. David Alan Gilbert                virtiofsd-obj-y \
462a5d2f6f8SYuval Shaia                rdmacm-mux-obj-y \
4637b2e5c65SMarc-André Lureau                libvhost-user-obj-y \
46449cc0340SFelipe Franciosi                vhost-user-scsi-obj-y \
465406d2aa2SChangpeng Liu                vhost-user-blk-obj-y \
46606914c97SMarc-André Lureau                vhost-user-input-obj-y \
467d52c454aSMarc-André Lureau                vhost-user-gpu-obj-y \
468577a6723STomoki Sekiyama                qga-vss-dll-obj-y \
469ba1183daSFam Zheng                block-obj-y \
470cc475698SFam Zheng                block-obj-m \
47114837c64SKevin Wolf                storage-daemon-obj-y \
47214837c64SKevin Wolf                storage-daemon-obj-m \
473fb37726dSDaniel P. Berrange                crypto-obj-y \
4740c7012e0SDaniel P. Berrange                qom-obj-y \
475666a3af9SDaniel P. Berrange                io-obj-y \
476cc475698SFam Zheng                common-obj-y \
4770ab8ed18SDaniel P. Berrange                common-obj-m \
478675b9b53SMarc-André Lureau                trace-obj-y)
479ba1183daSFam Zheng
48046e7b706SFam Zhenginclude $(SRC_PATH)/tests/Makefile.include
481992aeb8eSPaolo Bonzini
482d52c454aSMarc-André Lureauall: $(DOCS) $(if $(BUILD_DOCS),sphinxdocs) $(TOOLS) $(HELPERS-y) recurse-all modules $(vhost-user-json-y)
483b9dea4fbSpbrook
48467a1de0dSFam Zhengqemu-version.h: FORCE
48567a1de0dSFam Zheng	$(call quiet-command, \
48657b49737SPeter Maydell                (printf '#define QEMU_PKGVERSION "$(QEMU_PKGVERSION)"\n'; \
48757b49737SPeter Maydell		printf '#define QEMU_FULL_VERSION "$(FULL_VERSION)"\n'; \
4887e563bfbSThomas Huth		) > $@.tmp)
489d9e73d32SLin Ma	$(call quiet-command, if ! cmp -s $@ $@.tmp; then \
490d9e73d32SLin Ma	  mv $@.tmp $@; \
491d9e73d32SLin Ma	 else \
492d9e73d32SLin Ma	  rm $@.tmp; \
493d9e73d32SLin Ma	 fi)
49467a1de0dSFam Zheng
4951215c6e7SJuan Quintelaconfig-host.h: config-host.h-timestamp
4961215c6e7SJuan Quintelaconfig-host.h-timestamp: config-host.mak
497077de81aSPaolo Bonziniqemu-options.def: $(SRC_PATH)/qemu-options.hx $(SRC_PATH)/scripts/hxtool
4980bdb12c7SPeter Maydell	$(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@,"GEN","$@")
4991215c6e7SJuan Quintela
500c621dc3eSAlexander BulekovTARGET_DIRS_RULES := $(foreach t, all fuzz clean install, $(addsuffix /$(t), $(TARGET_DIRS)))
501916359f6SAndreas Färber
5021338a4b7SMarkus ArmbrusterSOFTMMU_ALL_RULES=$(filter %-softmmu/all, $(TARGET_DIRS_RULES))
5031338a4b7SMarkus Armbruster$(SOFTMMU_ALL_RULES): $(authz-obj-y)
5041338a4b7SMarkus Armbruster$(SOFTMMU_ALL_RULES): $(block-obj-y)
50514837c64SKevin Wolf$(SOFTMMU_ALL_RULES): $(storage-daemon-obj-y)
5061338a4b7SMarkus Armbruster$(SOFTMMU_ALL_RULES): $(chardev-obj-y)
5071338a4b7SMarkus Armbruster$(SOFTMMU_ALL_RULES): $(crypto-obj-y)
5081338a4b7SMarkus Armbruster$(SOFTMMU_ALL_RULES): $(io-obj-y)
5091338a4b7SMarkus Armbruster$(SOFTMMU_ALL_RULES): config-all-devices.mak
51005dfa22bSPhilippe Mathieu-Daudéifdef DECOMPRESS_EDK2_BLOBS
5111338a4b7SMarkus Armbruster$(SOFTMMU_ALL_RULES): $(edk2-decompressed)
51205dfa22bSPhilippe Mathieu-Daudéendif
513cec7d0b6Spbrook
514c621dc3eSAlexander BulekovSOFTMMU_FUZZ_RULES=$(filter %-softmmu/fuzz, $(TARGET_DIRS_RULES))
515c621dc3eSAlexander Bulekov$(SOFTMMU_FUZZ_RULES): $(authz-obj-y)
516c621dc3eSAlexander Bulekov$(SOFTMMU_FUZZ_RULES): $(block-obj-y)
517c621dc3eSAlexander Bulekov$(SOFTMMU_FUZZ_RULES): $(chardev-obj-y)
518c621dc3eSAlexander Bulekov$(SOFTMMU_FUZZ_RULES): $(crypto-obj-y)
519c621dc3eSAlexander Bulekov$(SOFTMMU_FUZZ_RULES): $(io-obj-y)
520c621dc3eSAlexander Bulekov$(SOFTMMU_FUZZ_RULES): config-all-devices.mak
521c621dc3eSAlexander Bulekov$(SOFTMMU_FUZZ_RULES): $(edk2-decompressed)
522c621dc3eSAlexander Bulekov
5231338a4b7SMarkus Armbruster.PHONY: $(TARGET_DIRS_RULES)
5241338a4b7SMarkus Armbruster# The $(TARGET_DIRS_RULES) are of the form SUBDIR/GOAL, so that
5251338a4b7SMarkus Armbruster# $(dir $@) yields the sub-directory, and $(notdir $@) yields the sub-goal
5261338a4b7SMarkus Armbruster$(TARGET_DIRS_RULES):
5271338a4b7SMarkus Armbruster	$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C $(dir $@) V="$(V)" TARGET_DIR="$(dir $@)" $(notdir $@),)
5284aa42531Spbrook
529a540f158SPeter CrosthwaiteDTC_MAKE_ARGS=-I$(SRC_PATH)/dtc VPATH=$(SRC_PATH)/dtc -C dtc V="$(V)" LIBFDT_srcdir=$(SRC_PATH)/dtc/libfdt
530965f486cSPeter MaydellDTC_CFLAGS=$(CFLAGS) $(QEMU_CFLAGS)
531965f486cSPeter MaydellDTC_CPPFLAGS=-I$(BUILD_DIR)/dtc -I$(SRC_PATH)/dtc -I$(SRC_PATH)/dtc/libfdt
532a540f158SPeter Crosthwaite
5333b8593eeSMarkus Armbruster.PHONY: dtc/all
5343b8593eeSMarkus Armbrusterdtc/all: .git-submodule-status dtc/libfdt dtc/tests
535db5adeaaSPaolo Bonzini	$(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/libfdt.a,)
536a540f158SPeter Crosthwaite
53700525864SAaron Lindsaydtc/%: .git-submodule-status
538814e1110SJan Kiszka	@mkdir -p $@
539a540f158SPeter Crosthwaite
540e219c499SRichard Henderson# Overriding CFLAGS causes us to lose defines added in the sub-makefile.
541e219c499SRichard Henderson# Not overriding CFLAGS leads to mis-matches between compilation modes.
542e219c499SRichard Henderson# Therefore we replicate some of the logic in the sub-makefile.
543e219c499SRichard Henderson# Remove all the extra -Warning flags that QEMU uses that Capstone doesn't;
544e219c499SRichard Henderson# no need to annoy QEMU developers with such things.
545e219c499SRichard HendersonCAP_CFLAGS = $(patsubst -W%,,$(CFLAGS) $(QEMU_CFLAGS))
546e219c499SRichard HendersonCAP_CFLAGS += -DCAPSTONE_USE_SYS_DYN_MEM
547e219c499SRichard HendersonCAP_CFLAGS += -DCAPSTONE_HAS_ARM
548e219c499SRichard HendersonCAP_CFLAGS += -DCAPSTONE_HAS_ARM64
549e219c499SRichard HendersonCAP_CFLAGS += -DCAPSTONE_HAS_POWERPC
550e219c499SRichard HendersonCAP_CFLAGS += -DCAPSTONE_HAS_X86
551e219c499SRichard Henderson
5523b8593eeSMarkus Armbruster.PHONY: capstone/all
5533b8593eeSMarkus Armbrustercapstone/all: .git-submodule-status
5549f81aeb5SAlistair 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))
555e219c499SRichard Henderson
5563b8593eeSMarkus Armbruster.PHONY: slirp/all
5573b8593eeSMarkus Armbrusterslirp/all: .git-submodule-status
558daa79d9aSAlex Bennée	$(call quiet-command,$(MAKE) -C $(SRC_PATH)/slirp		\
559daa79d9aSAlex Bennée		BUILD_DIR="$(BUILD_DIR)/slirp" 			\
560daa79d9aSAlex Bennée		PKG_CONFIG="$(PKG_CONFIG)" 				\
561daa79d9aSAlex Bennée		CC="$(CC)" AR="$(AR)" 	LD="$(LD)" RANLIB="$(RANLIB)"	\
562db5adeaaSPaolo Bonzini		CFLAGS="$(QEMU_CFLAGS) $(CFLAGS)" LDFLAGS="$(QEMU_LDFLAGS)")
563675b9b53SMarc-André Lureau
5643b8593eeSMarkus Armbruster# Compatibility gunk to keep make working across the rename of targets
5653b8593eeSMarkus Armbruster# for recursion, to be removed some time after 4.1.
5663b8593eeSMarkus Armbrustersubdir-dtc: dtc/all
5673b8593eeSMarkus Armbrustersubdir-capstone: capstone/all
5683b8593eeSMarkus Armbrustersubdir-slirp: slirp/all
5693b8593eeSMarkus Armbruster
5701338a4b7SMarkus Armbruster$(filter %/all, $(TARGET_DIRS_RULES)): libqemuutil.a $(common-obj-y) \
571b8d89ba8SPaolo Bonzini	$(qom-obj-y)
572add16157SBlue Swirl
573c621dc3eSAlexander Bulekov$(filter %/fuzz, $(TARGET_DIRS_RULES)): libqemuutil.a $(common-obj-y) \
574c621dc3eSAlexander Bulekov	$(qom-obj-y) $(crypto-user-obj-$(CONFIG_USER_ONLY))
575c621dc3eSAlexander Bulekov
5763b8593eeSMarkus ArmbrusterROM_DIRS = $(addprefix pc-bios/, $(ROMS))
5771338a4b7SMarkus ArmbrusterROM_DIRS_RULES=$(foreach t, all clean, $(addsuffix /$(t), $(ROM_DIRS)))
578a9c87304SMarc-André Lureau# Only keep -O and -g cflags
5791338a4b7SMarkus Armbruster.PHONY: $(ROM_DIRS_RULES)
5801338a4b7SMarkus Armbruster$(ROM_DIRS_RULES):
5811338a4b7SMarkus Armbruster	$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C $(dir $@) V="$(V)" TARGET_DIR="$(dir $@)" CFLAGS="$(filter -O% -g%,$(CFLAGS))" $(notdir $@),)
582c05ac895SPaul Brook
5838d358a5eSMarkus Armbruster.PHONY: recurse-all recurse-clean recurse-install
5841338a4b7SMarkus Armbrusterrecurse-all: $(addsuffix /all, $(TARGET_DIRS) $(ROM_DIRS))
585c621dc3eSAlexander Bulekovrecurse-fuzz: $(addsuffix /fuzz, $(TARGET_DIRS) $(ROM_DIRS))
5861338a4b7SMarkus Armbrusterrecurse-clean: $(addsuffix /clean, $(TARGET_DIRS) $(ROM_DIRS))
5871338a4b7SMarkus Armbrusterrecurse-install: $(addsuffix /install, $(TARGET_DIRS))
58847ae060eSMarkus Armbruster$(addsuffix /install, $(TARGET_DIRS)): all
5894aa42531Spbrook
590c17a18efSMarc-André Lureau$(BUILD_DIR)/version.o: $(SRC_PATH)/version.rc config-host.h
5910bdb12c7SPeter Maydell	$(call quiet-command,$(WINDRES) -I$(BUILD_DIR) -o $@ $<,"RC","version.o")
5925354e4d2SMarc-André Lureau
593c17a18efSMarc-André LureauMakefile: $(version-obj-y)
5943bc2f570SPaolo Bonzini
5953bc2f570SPaolo Bonzini######################################################################
5968a090705SPaolo Bonzini# Build libraries
5973bc2f570SPaolo Bonzini
598ebedb37cSPaolo Bonzinilibqemuutil.a: $(util-obj-y) $(trace-obj-y) $(stub-obj-y)
5995f9ff1efSXie Yongjilibvhost-user.a: $(libvhost-user-obj-y) $(util-obj-y) $(stub-obj-y)
6003bc2f570SPaolo Bonzini
6014fb240a4Sbellard######################################################################
6024fb240a4Sbellard
603ebedb37cSPaolo BonziniCOMMON_LDADDS = libqemuutil.a
6040ab8ed18SDaniel P. Berrange
6053c089e15SJuan Quintelaqemu-img.o: qemu-img-cmds.h
606153859beSStuart Brady
6075b76dd13SDaniel P. Berrangeqemu-img$(EXESUF): qemu-img.o $(authz-obj-y) $(block-obj-y) $(crypto-obj-y) $(io-obj-y) $(qom-obj-y) $(COMMON_LDADDS)
6085b76dd13SDaniel P. Berrangeqemu-nbd$(EXESUF): qemu-nbd.o $(authz-obj-y) $(block-obj-y) $(crypto-obj-y) $(io-obj-y) $(qom-obj-y) $(COMMON_LDADDS)
6095b76dd13SDaniel P. Berrangeqemu-io$(EXESUF): qemu-io.o $(authz-obj-y) $(block-obj-y) $(crypto-obj-y) $(io-obj-y) $(qom-obj-y) $(COMMON_LDADDS)
6105e6911cfSKevin 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)
6110a8e1acdSaliguori
6120ab8ed18SDaniel P. Berrangeqemu-bridge-helper$(EXESUF): qemu-bridge-helper.o $(COMMON_LDADDS)
6137b93fadfSCorey Bryant
6146a021536SGerd Hoffmannqemu-keymap$(EXESUF): qemu-keymap.o ui/input-keymap.o $(COMMON_LDADDS)
6156a021536SGerd Hoffmann
61672d277a7SGerd Hoffmannqemu-edid$(EXESUF): qemu-edid.o hw/display/edid-generate.o $(COMMON_LDADDS)
61772d277a7SGerd Hoffmann
6180ab8ed18SDaniel P. Berrangefsdev/virtfs-proxy-helper$(EXESUF): fsdev/virtfs-proxy-helper.o fsdev/9p-marshal.o fsdev/9p-iov-marshal.o $(COMMON_LDADDS)
61917bff52bSM. Mohan Kumar
6205b76dd13SDaniel 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)
621fe8fc5aeSPaolo Bonziniifdef CONFIG_MPATH
622fe8fc5aeSPaolo Bonziniscsi/qemu-pr-helper$(EXESUF): LIBS += -ludev -lmultipath -lmpathpersist
623fe8fc5aeSPaolo Bonziniendif
624b855f8d1SPaolo Bonzini
625077de81aSPaolo Bonziniqemu-img-cmds.h: $(SRC_PATH)/qemu-img-cmds.hx $(SRC_PATH)/scripts/hxtool
6260bdb12c7SPeter Maydell	$(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@,"GEN","$@")
627153859beSStuart Brady
628957f1f99SMichael Rothqemu-ga$(EXESUF): LIBS = $(LIBS_QGA)
62954c2e502SDunrong Huangqemu-ga$(EXESUF): QEMU_CFLAGS += -I qga/qapi-generated
630640e5404SMichael Roth
6316a021536SGerd Hoffmannqemu-keymap$(EXESUF): LIBS += $(XKBCOMMON_LIBS)
6326a021536SGerd Hoffmannqemu-keymap$(EXESUF): QEMU_CFLAGS += $(XKBCOMMON_CFLAGS)
6336a021536SGerd Hoffmann
634e6c42b96SMarkus Armbrusterqapi-py = $(SRC_PATH)/scripts/qapi/__init__.py \
635e6c42b96SMarkus Armbruster$(SRC_PATH)/scripts/qapi/commands.py \
636fb0bc835SMarkus Armbruster$(SRC_PATH)/scripts/qapi/common.py \
637fb0bc835SMarkus Armbruster$(SRC_PATH)/scripts/qapi/doc.py \
638e6c42b96SMarkus Armbruster$(SRC_PATH)/scripts/qapi/error.py \
639e6c42b96SMarkus Armbruster$(SRC_PATH)/scripts/qapi/events.py \
640e6c42b96SMarkus Armbruster$(SRC_PATH)/scripts/qapi/expr.py \
641e6c42b96SMarkus Armbruster$(SRC_PATH)/scripts/qapi/gen.py \
642e6c42b96SMarkus Armbruster$(SRC_PATH)/scripts/qapi/introspect.py \
643e6c42b96SMarkus Armbruster$(SRC_PATH)/scripts/qapi/parser.py \
644e6c42b96SMarkus Armbruster$(SRC_PATH)/scripts/qapi/schema.py \
645e6c42b96SMarkus Armbruster$(SRC_PATH)/scripts/qapi/source.py \
646e6c42b96SMarkus Armbruster$(SRC_PATH)/scripts/qapi/types.py \
647e6c42b96SMarkus Armbruster$(SRC_PATH)/scripts/qapi/visit.py \
648fb0bc835SMarkus Armbruster$(SRC_PATH)/scripts/qapi-gen.py
6498d3bc517SAvi Kivity
650fb0bc835SMarkus Armbrusterqga/qapi-generated/qga-qapi-types.c qga/qapi-generated/qga-qapi-types.h \
651fb0bc835SMarkus Armbrusterqga/qapi-generated/qga-qapi-visit.c qga/qapi-generated/qga-qapi-visit.h \
652eb815e24SMarkus Armbrusterqga/qapi-generated/qga-qapi-commands.h qga/qapi-generated/qga-qapi-commands.c \
65300ca24ffSMarkus Armbrusterqga/qapi-generated/qga-qapi-init-commands.h qga/qapi-generated/qga-qapi-init-commands.c \
654fb0bc835SMarkus Armbrusterqga/qapi-generated/qga-qapi-doc.texi: \
655fb0bc835SMarkus Armbrusterqga/qapi-generated/qapi-gen-timestamp ;
656fb0bc835SMarkus Armbrusterqga/qapi-generated/qapi-gen-timestamp: $(SRC_PATH)/qga/qapi-schema.json $(qapi-py)
6570d6b93deSMatthias Maier	$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-gen.py \
658fb0bc835SMarkus Armbruster		-o qga/qapi-generated -p "qga-" $<, \
659fb0bc835SMarkus Armbruster		"GEN","$(@:%-timestamp=%)")
660fb0bc835SMarkus Armbruster	@>$@
661e3d4d252SMichael Roth
662bf582c34SEric Blakeqapi-modules = $(SRC_PATH)/qapi/qapi-schema.json \
663bf582c34SEric Blake               $(QAPI_MODULES:%=$(SRC_PATH)/qapi/%.json)
664be13d46dSMax Reitz
665bf582c34SEric Blake$(GENERATED_QAPI_FILES): qapi-gen-timestamp ;
666fb0bc835SMarkus Armbrusterqapi-gen-timestamp: $(qapi-modules) $(qapi-py)
6670d6b93deSMatthias Maier	$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-gen.py \
668eb815e24SMarkus Armbruster		-o "qapi" -b $<, \
669fb0bc835SMarkus Armbruster		"GEN","$(@:%-timestamp=%)")
670fb0bc835SMarkus Armbruster	@>$@
671e3193601SAnthony Liguori
6722af282ecSKevin Wolfqapi-modules-storage-daemon = \
6732af282ecSKevin Wolf	$(SRC_PATH)/storage-daemon/qapi/qapi-schema.json \
6742af282ecSKevin Wolf    $(QAPI_MODULES_STORAGE_DAEMON:%=$(SRC_PATH)/qapi/%.json)
6752af282ecSKevin Wolf
6762af282ecSKevin Wolf$(GENERATED_STORAGE_DAEMON_QAPI_FILES): storage-daemon/qapi/qapi-gen-timestamp ;
6772af282ecSKevin Wolfstorage-daemon/qapi/qapi-gen-timestamp: $(qapi-modules-storage-daemon) $(qapi-py)
6782af282ecSKevin Wolf	$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-gen.py \
6792af282ecSKevin Wolf		-o "storage-daemon/qapi" $<, \
6802af282ecSKevin Wolf		"GEN","$(@:%-timestamp=%)")
6812af282ecSKevin Wolf	@>$@
6822af282ecSKevin Wolf
68300ca24ffSMarkus ArmbrusterQGALIB_GEN=$(addprefix qga/qapi-generated/, qga-qapi-types.h qga-qapi-visit.h qga-qapi-commands.h qga-qapi-init-commands.h)
6847a0b7ebaSMarc-André Lureau$(qga-obj-y): $(QGALIB_GEN)
685957f1f99SMichael Roth
6860ab8ed18SDaniel P. Berrangeqemu-ga$(EXESUF): $(qga-obj-y) $(COMMON_LDADDS)
687fafcaf1dSMichael Roth	$(call LINK, $^)
68848ff7a62SMichael Roth
6899dacf32dSYossi Hindinifdef QEMU_GA_MSI_ENABLED
6909dacf32dSYossi HindinQEMU_GA_MSI=qemu-ga-$(ARCH).msi
6919dacf32dSYossi Hindin
6920a18750fSLeonid Blochmsi: $(QEMU_GA_MSI)
6939dacf32dSYossi Hindin
694fafcaf1dSMichael Roth$(QEMU_GA_MSI): qemu-ga.exe $(QGA_VSS_PROVIDER)
6959dacf32dSYossi Hindin
6969dacf32dSYossi Hindin$(QEMU_GA_MSI): config-host.mak
6979dacf32dSYossi Hindin
698decdfbd2SLeonid Bloch$(QEMU_GA_MSI):  $(SRC_PATH)/qga/installer/qemu-ga.wxs
699decdfbd2SLeonid 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)" \
7000bdb12c7SPeter Maydell	wixl -o $@ $(QEMU_GA_MSI_ARCH) $(QEMU_GA_MSI_WITH_VSS) $(QEMU_GA_MSI_MINGW_DLL_PATH) $<,"WIXL","$@")
7019dacf32dSYossi Hindinelse
7029dacf32dSYossi Hindinmsi:
70315b19ed8SMichael Roth	@echo "MSI build not configured or dependency resolution failed (reconfigure with --enable-guest-agent-msi option)"
7049dacf32dSYossi Hindinendif
7059dacf32dSYossi Hindin
706fafcaf1dSMichael Rothifneq ($(EXESUF),)
707fafcaf1dSMichael Roth.PHONY: qemu-ga
708fafcaf1dSMichael Rothqemu-ga: qemu-ga$(EXESUF) $(QGA_VSS_PROVIDER) $(QEMU_GA_MSI)
709fafcaf1dSMichael Rothendif
710fafcaf1dSMichael Roth
7111b9d35f3SViktor Prutyanovelf2dmp$(EXESUF): $(elf2dmp-obj-y)
7123fa2d384SViktor Prutyanov	$(call LINK, $^)
7133fa2d384SViktor Prutyanov
714b1449edbSKamil Rytarowskiifdef CONFIG_IVSHMEM
7150ab8ed18SDaniel P. Berrangeivshmem-client$(EXESUF): $(ivshmem-client-obj-y) $(COMMON_LDADDS)
716a75eb03bSDavid Marchand	$(call LINK, $^)
7170ab8ed18SDaniel P. Berrangeivshmem-server$(EXESUF): $(ivshmem-server-obj-y) $(COMMON_LDADDS)
718a75eb03bSDavid Marchand	$(call LINK, $^)
719b1449edbSKamil Rytarowskiendif
720d59a031cSMarc-André Lureauvhost-user-scsi$(EXESUF): $(vhost-user-scsi-obj-y) libvhost-user.a
72149cc0340SFelipe Franciosi	$(call LINK, $^)
722406d2aa2SChangpeng Liuvhost-user-blk$(EXESUF): $(vhost-user-blk-obj-y) libvhost-user.a
723406d2aa2SChangpeng Liu	$(call LINK, $^)
7240f645ba1SMarcel Apfelbaum
7250f645ba1SMarcel Apfelbaumrdmacm-mux$(EXESUF): LIBS += "-libumad"
726a5d2f6f8SYuval Shaiardmacm-mux$(EXESUF): $(rdmacm-mux-obj-y) $(COMMON_LDADDS)
727a5d2f6f8SYuval Shaia	$(call LINK, $^)
728a75eb03bSDavid Marchand
7294f8bde99SStefan Hajnoczi# relies on Linux-specific syscalls
7302405f3c0SDr. David Alan Gilbertifeq ($(CONFIG_LINUX)$(CONFIG_SECCOMP)$(CONFIG_LIBCAP_NG),yyy)
73181bfc42dSDr. David Alan Gilbertvirtiofsd$(EXESUF): $(virtiofsd-obj-y) libvhost-user.a $(COMMON_LDADDS)
73281bfc42dSDr. David Alan Gilbert	$(call LINK, $^)
73381bfc42dSDr. David Alan Gilbertendif
73481bfc42dSDr. David Alan Gilbert
735d52c454aSMarc-André Lureauvhost-user-gpu$(EXESUF): $(vhost-user-gpu-obj-y) $(libvhost-user-obj-y) libqemuutil.a libqemustub.a
736d52c454aSMarc-André Lureau	$(call LINK, $^)
737d52c454aSMarc-André Lureau
73806914c97SMarc-André Lureauifdef CONFIG_VHOST_USER_INPUT
73906914c97SMarc-André Lureauifdef CONFIG_LINUX
74006914c97SMarc-André Lureauvhost-user-input$(EXESUF): $(vhost-user-input-obj-y) libvhost-user.a libqemuutil.a
74106914c97SMarc-André Lureau	$(call LINK, $^)
74206914c97SMarc-André Lureau
74306914c97SMarc-André Lureau# build by default, do not install
74406914c97SMarc-André Lureauall: vhost-user-input$(EXESUF)
74506914c97SMarc-André Lureauendif
74606914c97SMarc-André Lureauendif
74706914c97SMarc-André Lureau
7480c0c1fd9SMarc Marimodule_block.h: $(SRC_PATH)/scripts/modules/module_block.py config-host.mak
7490c0c1fd9SMarc Mari	$(call quiet-command,$(PYTHON) $< $@ \
7500c0c1fd9SMarc Mari	$(addprefix $(SRC_PATH)/,$(patsubst %.mo,%.c,$(block-obj-m))), \
7510bdb12c7SPeter Maydell	"GEN","$@")
7520c0c1fd9SMarc Mari
753990e6a27SAlex Bennéeifdef CONFIG_GCOV
754990e6a27SAlex Bennée.PHONY: clean-coverage
755990e6a27SAlex Bennéeclean-coverage:
756990e6a27SAlex Bennée	$(call quiet-command, \
757990e6a27SAlex Bennée		find . \( -name '*.gcda' -o -name '*.gcov' \) -type f -exec rm {} +, \
758990e6a27SAlex Bennée		"CLEAN", "coverage files")
759990e6a27SAlex Bennéeendif
760990e6a27SAlex Bennée
7611338a4b7SMarkus Armbrusterclean: recurse-clean
7622d80ae89Sbellard# avoid old build problems by removing potentially incorrect old files
76325be210fSJuan 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
764df2943baSMichael S. Tsirkin	rm -f qemu-options.def
7659dacf32dSYossi Hindin	rm -f *.msi
76623858f40SLaszlo Ersek	find . \( -name '*.so' -o -name '*.dll' -o -name '*.mo' -o -name '*.[oda]' \) -type f \
76723858f40SLaszlo Ersek		! -path ./roms/edk2/ArmPkg/Library/GccLto/liblto-aarch64.a \
76823858f40SLaszlo Ersek		! -path ./roms/edk2/ArmPkg/Library/GccLto/liblto-arm.a \
76923858f40SLaszlo Ersek		! -path ./roms/edk2/BaseTools/Source/Python/UPT/Dll/sqlite3.dll \
77023858f40SLaszlo Ersek		-exec rm {} +
77126ce90fdSLaszlo Ersek	rm -f $(edk2-decompressed)
7720814465aSPaolo Bonzini	rm -f $(filter-out %.tlb,$(TOOLS)) $(HELPERS-y) TAGS cscope.* *.pod *~ */*~
773b855f8d1SPaolo Bonzini	rm -f fsdev/*.pod scsi/*.pod
77407b44ce9SBlue Swirl	rm -f qemu-img-cmds.h
775d98bc0b6SGerd Hoffmann	rm -f ui/shader/*-vert.h ui/shader/*-frag.h
7763dff199cSLaurent Vivier	@# May not be present in generated-files-y
777eac236eaSLluís Vilanova	rm -f trace/generated-tracers-dtrace.dtrace*
778eac236eaSLluís Vilanova	rm -f trace/generated-tracers-dtrace.h*
7793dff199cSLaurent Vivier	rm -f $(foreach f,$(generated-files-y),$(f) $(f)-timestamp)
780fb0bc835SMarkus Armbruster	rm -f qapi-gen-timestamp
7812af282ecSKevin Wolf	rm -f storage-daemon/qapi/qapi-gen-timestamp
78254c2e502SDunrong Huang	rm -rf qga/qapi-generated
783e92af6ecSJuan Quintela	rm -f config-all-devices.mak
78431e31b8aSbellard
78534bb443eSAnthony LiguoriVERSION ?= $(shell cat VERSION)
78634bb443eSAnthony Liguori
78734bb443eSAnthony Liguoridist: qemu-$(VERSION).tar.bz2
78834bb443eSAnthony Liguori
78934bb443eSAnthony Liguoriqemu-%.tar.bz2:
79034bb443eSAnthony Liguori	$(SRC_PATH)/scripts/make-release "$(SRC_PATH)" "$(patsubst qemu-%.tar.bz2,%,$@)"
79134bb443eSAnthony Liguori
7925f71eac0SPeter Maydelldefine clean-manual =
7931290e671SPeter Maydellrm -rf $(MANUAL_BUILDDIR)/$1/_static
7941290e671SPeter Maydellrm -f $(MANUAL_BUILDDIR)/$1/objects.inv $(MANUAL_BUILDDIR)/$1/searchindex.js $(MANUAL_BUILDDIR)/$1/*.html
7955f71eac0SPeter Maydellendef
7965f71eac0SPeter Maydell
7977d13299dSbellarddistclean: clean
798d1055e3aSPeter Maydell	rm -f config-host.mak config-host.h* config-host.ld $(DOCS)
7992038f8c8SPaolo Bonzini	rm -f tests/tcg/config-*.mak
800ae219359SThomas Huth	rm -f config-all-devices.mak config-all-disas.mak config.status
801e92af6ecSJuan Quintela	rm -f $(SUBDIR_DEVICES_MAK)
802ae219359SThomas Huth	rm -f po/*.mo tests/qemu-iotests/common.env
803fc8e320eSMagnus Damm	rm -f roms/seabios/config.mak roms/vgabios/config.mak
80426fffe29SEmilio G. Cota	rm -f qemu-plugins-ld.symbols qemu-plugins-ld64.symbols
805793553acSAlexandre Raymond	rm -f config.log
80667ed96f9SPeter Maydell	rm -f linux-headers/asm
807d59157eaSPaolo Bonzini	rm -f docs/version.texi
808d59157eaSPaolo Bonzini	rm -f docs/interop/qemu-ga-qapi.texi docs/interop/qemu-qmp-qapi.texi
809d59157eaSPaolo Bonzini	rm -f docs/interop/qemu-qmp-ref.7 docs/interop/qemu-ga-ref.7
810d59157eaSPaolo Bonzini	rm -f docs/interop/qemu-qmp-ref.txt docs/interop/qemu-ga-ref.txt
811d59157eaSPaolo Bonzini	rm -f docs/interop/qemu-qmp-ref.pdf docs/interop/qemu-ga-ref.pdf
812d59157eaSPaolo Bonzini	rm -f docs/interop/qemu-qmp-ref.html docs/interop/qemu-ga-ref.html
81381f33401SPeter Maydell	rm -rf .doctrees
8145f71eac0SPeter Maydell	$(call clean-manual,devel)
8155f71eac0SPeter Maydell	$(call clean-manual,interop)
8160783a732SPeter Maydell	$(call clean-manual,specs)
8170928523aSPeter Maydell	$(call clean-manual,system)
81865c3542bSPeter Maydell	$(call clean-manual,tools)
81909147930SPaolo Bonzini	$(call clean-manual,user)
8202b1f35b9SAlex Bennée	for d in $(TARGET_DIRS); do \
821bc1b050dSbellard	rm -rf $$d || exit 1 ; \
82276bc6838Sbellard        done
823d9840e25STomoki Sekiyama	rm -Rf .sdk
824fb8597bbSEd Maste	if test -f dtc/version_gen.h; then $(MAKE) $(DTC_MAKE_ARGS) clean; fi
8257d13299dSbellard
82606e7772fSGerd HoffmannKEYMAPS=da     en-gb  et  fr     fr-ch  is  lt  no  pt-br  sv \
827fed4a9adSbellardar      de     en-us  fi  fr-be  hr     it  lv  nl         pl  ru     th \
82826b1cbf8SGerd Hoffmannde-ch  es     fo  fr-ca  hu     ja  mk  pt  sl     tr \
8293751e722SJan Krupabepo    cz
830fed4a9adSbellard
83177755340Sthsifdef INSTALL_BLOBS
83232eb2da3SBruce RogersBLOBS=bios.bin bios-256k.bin bios-microvm.bin sgabios.bin vgabios.bin vgabios-cirrus.bin \
8337a4dfd1eSGerd Hoffmannvgabios-stdvga.bin vgabios-vmware.bin vgabios-qxl.bin vgabios-virtio.bin \
8340a87fd69SGerd Hoffmannvgabios-ramfb.bin vgabios-bochs-display.bin vgabios-ati.bin \
835b2ce76a0SThomas Huthopenbios-sparc32 openbios-sparc64 openbios-ppc QEMU,tcx.bin QEMU,cgthree.bin \
8365ee8ad71SAlex Williamsonpxe-e1000.rom pxe-eepro100.rom pxe-ne2k_pci.rom \
8375ee8ad71SAlex Williamsonpxe-pcnet.rom pxe-rtl8139.rom pxe-virtio.rom \
8389fd02979SSander Eikelenboomefi-e1000.rom efi-eepro100.rom efi-ne2k_pci.rom \
8399fd02979SSander Eikelenboomefi-pcnet.rom efi-rtl8139.rom efi-virtio.rom \
84045027808SGerd Hoffmannefi-e1000e.rom efi-vmxnet3.rom \
841b3ce38dcSPhilippe Mathieu-Daudéqemu-nsis.bmp \
8424b387f9eSBALATON Zoltanbamboo.dtb canyonlands.dtb petalogix-s3adsp1800.dtb petalogix-ml605.dtb \
8432785dc7bSStefano Garzarellamultiboot.bin linuxboot.bin linuxboot_dma.bin kvmvapic.bin pvh.bin \
8446c5359e1SChristian Borntraegers390-ccw.img s390-netboot.img \
845744a928cSAlexey Kardashevskiyslof.bin skiboot.lid \
8460c6ab8c9SCole Robinsonpalcode-clipper \
84782e65fe0SBALATON Zoltanu-boot.e500 u-boot-sam460-20100605.bin \
84843ad2564SRichard Hendersonqemu_vga.ndrv \
84926ce90fdSLaszlo Ersekedk2-licenses.txt \
85091f3a2f0SAlistair Francishppa-firmware.img \
85191f3a2f0SAlistair Francisopensbi-riscv32-virt-fw_jump.bin \
85291f3a2f0SAlistair Francisopensbi-riscv64-sifive_u-fw_jump.bin opensbi-riscv64-virt-fw_jump.bin
85391f3a2f0SAlistair Francis
85426ce90fdSLaszlo Ersek
85526ce90fdSLaszlo ErsekDESCS=50-edk2-i386-secure.json 50-edk2-x86_64-secure.json \
85626ce90fdSLaszlo Ersek60-edk2-aarch64.json 60-edk2-arm.json 60-edk2-i386.json 60-edk2-x86_64.json
85777755340Sthselse
85877755340SthsBLOBS=
85926ce90fdSLaszlo ErsekDESCS=
86077755340Sthsendif
86177755340Sths
862336cfef4SPeter Maydell# Note that we manually filter-out the non-Sphinx documentation which
86327a296fcSPeter Maydell# is currently built into the docs/interop directory in the build tree,
86427a296fcSPeter Maydell# and also any sphinx-built manpages.
8655f71eac0SPeter Maydelldefine install-manual =
8661290e671SPeter Maydellfor d in $$(cd $(MANUAL_BUILDDIR) && find $1 -type d); do $(INSTALL_DIR) "$(DESTDIR)$(qemu_docdir)/$$d"; done
86727a296fcSPeter 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
8685f71eac0SPeter Maydellendef
8695f71eac0SPeter Maydell
8705f71eac0SPeter Maydell# Note that we deliberately do not install the "devel" manual: it is
8715f71eac0SPeter Maydell# for QEMU developers, and not interesting to our users.
8725f71eac0SPeter Maydell.PHONY: install-sphinxdocs
8735f71eac0SPeter Maydellinstall-sphinxdocs: sphinxdocs
8745f71eac0SPeter Maydell	$(call install-manual,interop)
8750783a732SPeter Maydell	$(call install-manual,specs)
8760928523aSPeter Maydell	$(call install-manual,system)
87765c3542bSPeter Maydell	$(call install-manual,tools)
87809147930SPaolo Bonzini	$(call install-manual,user)
8795f71eac0SPeter Maydell
8805f71eac0SPeter Maydellinstall-doc: $(DOCS) install-sphinxdocs
881d7dd65baSEduardo Habkost	$(INSTALL_DIR) "$(DESTDIR)$(qemu_docdir)"
88222108f33SStefan Hajnoczi	$(INSTALL_DATA) $(MANUAL_BUILDDIR)/index.html "$(DESTDIR)$(qemu_docdir)"
883d59157eaSPaolo Bonzini	$(INSTALL_DATA) docs/interop/qemu-qmp-ref.html "$(DESTDIR)$(qemu_docdir)"
884d59157eaSPaolo Bonzini	$(INSTALL_DATA) docs/interop/qemu-qmp-ref.txt "$(DESTDIR)$(qemu_docdir)"
88596d409ebSJuan Quintelaifdef CONFIG_POSIX
88658f8aeadSaliguori	$(INSTALL_DIR) "$(DESTDIR)$(mandir)/man1"
887d06118bfSPeter Maydell	$(INSTALL_DATA) $(MANUAL_BUILDDIR)/system/qemu.1 "$(DESTDIR)$(mandir)/man1"
88856e8bdd4SMarc-André Lureau	$(INSTALL_DIR) "$(DESTDIR)$(mandir)/man7"
889d59157eaSPaolo Bonzini	$(INSTALL_DATA) docs/interop/qemu-qmp-ref.7 "$(DESTDIR)$(mandir)/man7"
890acab923dSPeter Maydell	$(INSTALL_DATA) $(MANUAL_BUILDDIR)/system/qemu-block-drivers.7 "$(DESTDIR)$(mandir)/man7"
8911bf84a1eSKashyap Chamarthy	$(INSTALL_DATA) $(MANUAL_BUILDDIR)/system/qemu-cpu-models.7 "$(DESTDIR)$(mandir)/man7"
892c932ce31SPaolo Bonziniifeq ($(CONFIG_TOOLS),y)
893a08b4a9fSPeter Maydell	$(INSTALL_DATA) $(MANUAL_BUILDDIR)/tools/qemu-img.1 "$(DESTDIR)$(mandir)/man1"
89458f8aeadSaliguori	$(INSTALL_DIR) "$(DESTDIR)$(mandir)/man8"
895a08b4a9fSPeter Maydell	$(INSTALL_DATA) $(MANUAL_BUILDDIR)/tools/qemu-nbd.8 "$(DESTDIR)$(mandir)/man8"
89638954dcaSpbrookendif
89762dd1048SDaniel P. Berrangéifdef CONFIG_TRACE_SYSTEMTAP
898a08b4a9fSPeter Maydell	$(INSTALL_DATA) $(MANUAL_BUILDDIR)/tools/qemu-trace-stap.1 "$(DESTDIR)$(mandir)/man1"
89962dd1048SDaniel P. Berrangéendif
900665b5d0dSMarc-André Lureauifneq (,$(findstring qemu-ga,$(TOOLS)))
901b53c54c6SPeter Maydell	$(INSTALL_DATA) $(MANUAL_BUILDDIR)/interop/qemu-ga.8 "$(DESTDIR)$(mandir)/man8"
902d59157eaSPaolo Bonzini	$(INSTALL_DATA) docs/interop/qemu-ga-ref.html "$(DESTDIR)$(qemu_docdir)"
903d59157eaSPaolo Bonzini	$(INSTALL_DATA) docs/interop/qemu-ga-ref.txt "$(DESTDIR)$(qemu_docdir)"
904d59157eaSPaolo Bonzini	$(INSTALL_DATA) docs/interop/qemu-ga-ref.7 "$(DESTDIR)$(mandir)/man7"
905665b5d0dSMarc-André Lureauendif
9068a3e8f7fSAndreas Färberendif
907a2d8f1beSM. Mohan Kumarifdef CONFIG_VIRTFS
908a2d8f1beSM. Mohan Kumar	$(INSTALL_DIR) "$(DESTDIR)$(mandir)/man1"
909a08b4a9fSPeter Maydell	$(INSTALL_DATA) $(MANUAL_BUILDDIR)/tools/virtfs-proxy-helper.1 "$(DESTDIR)$(mandir)/man1"
910a2d8f1beSM. Mohan Kumarendif
9116a7e2bbeSStefan Hajnocziifeq ($(CONFIG_LINUX)$(CONFIG_SECCOMP)$(CONFIG_LIBCAP_NG),yyy)
912a08b4a9fSPeter Maydell	$(INSTALL_DATA) $(MANUAL_BUILDDIR)/tools/virtiofsd.1 "$(DESTDIR)$(mandir)/man1"
9136a7e2bbeSStefan Hajnocziendif
914b5ec5ce0Sjohn cooper
915e2d87bffSEduardo Habkostinstall-datadir:
916e2d87bffSEduardo Habkost	$(INSTALL_DIR) "$(DESTDIR)$(qemu_datadir)"
917e2d87bffSEduardo Habkost
918f2e3978bSLaszlo Ersekinstall-localstatedir:
919f2e3978bSLaszlo Ersekifdef CONFIG_POSIX
920f2e3978bSLaszlo Ersekifneq (,$(findstring qemu-ga,$(TOOLS)))
921f2e3978bSLaszlo Ersek	$(INSTALL_DIR) "$(DESTDIR)$(qemu_localstatedir)"/run
922f2e3978bSLaszlo Ersekendif
923f2e3978bSLaszlo Ersekendif
924f2e3978bSLaszlo Ersek
925a8260d38SDaniel P. BerrangéICON_SIZES=16x16 24x24 32x32 48x48 64x64 128x128 256x256 512x512
926e2d87bffSEduardo Habkost
92754cb65d8SEmilio G. Cotainstall-includedir:
92854cb65d8SEmilio G. Cota	$(INSTALL_DIR) "$(DESTDIR)$(includedir)"
92954cb65d8SEmilio G. Cota
93054cb65d8SEmilio G. Cotainstall: all $(if $(BUILD_DOCS),install-doc) \
93154cb65d8SEmilio G. Cota	install-datadir install-localstatedir install-includedir \
9321338a4b7SMarkus Armbruster	$(if $(INSTALL_BLOBS),$(edk2-decompressed)) \
9331338a4b7SMarkus Armbruster	recurse-install
934932a79dfSthsifneq ($(TOOLS),)
9350814465aSPaolo Bonzini	$(call install-prog,$(TOOLS),$(DESTDIR)$(bindir))
936932a79dfSthsendif
937e3be6f0eSFam Zhengifneq ($(CONFIG_MODULES),)
938e3be6f0eSFam Zheng	$(INSTALL_DIR) "$(DESTDIR)$(qemu_moddir)"
9392115182fSMichael Tokarev	for s in $(modules-m:.mo=$(DSOSUF)); do \
9402115182fSMichael Tokarev		t="$(DESTDIR)$(qemu_moddir)/$$(echo $$s | tr / -)"; \
941264f8b4fSMichael Tokarev		$(INSTALL_LIB) $$s "$$t"; \
9422115182fSMichael Tokarev		test -z "$(STRIP)" || $(STRIP) "$$t"; \
943e3be6f0eSFam Zheng	done
944e3be6f0eSFam Zhengendif
9457b93fadfSCorey Bryantifneq ($(HELPERS-y),)
9460d659426SMichael Tokarev	$(call install-prog,$(HELPERS-y),$(DESTDIR)$(libexecdir))
9477b93fadfSCorey Bryantendif
948d52c454aSMarc-André Lureauifneq ($(vhost-user-json-y),)
949d52c454aSMarc-André Lureau	$(INSTALL_DIR) "$(DESTDIR)$(qemu_datadir)/vhost-user/"
950d52c454aSMarc-André Lureau	for x in $(vhost-user-json-y); do \
951d52c454aSMarc-André Lureau		$(INSTALL_DATA) $$x "$(DESTDIR)$(qemu_datadir)/vhost-user/"; \
952d52c454aSMarc-André Lureau	done
953d52c454aSMarc-André Lureauendif
95462dd1048SDaniel P. Berrangéifdef CONFIG_TRACE_SYSTEMTAP
95562dd1048SDaniel P. Berrangé	$(INSTALL_PROG) "scripts/qemu-trace-stap" $(DESTDIR)$(bindir)
95662dd1048SDaniel P. Berrangéendif
95777755340Sthsifneq ($(BLOBS),)
95877755340Sths	set -e; for x in $(BLOBS); do \
9596aae2a2eSEduardo Habkost		$(INSTALL_DATA) $(SRC_PATH)/pc-bios/$$x "$(DESTDIR)$(qemu_datadir)"; \
960ad064840Spbrook	done
96177755340Sthsendif
96226ce90fdSLaszlo Ersekifdef INSTALL_BLOBS
96326ce90fdSLaszlo Ersek	set -e; for x in $(edk2-decompressed); do \
96426ce90fdSLaszlo Ersek		$(INSTALL_DATA) $$x "$(DESTDIR)$(qemu_datadir)"; \
96526ce90fdSLaszlo Ersek	done
96626ce90fdSLaszlo Ersekendif
96726ce90fdSLaszlo Ersekifneq ($(DESCS),)
96826ce90fdSLaszlo Ersek	$(INSTALL_DIR) "$(DESTDIR)$(qemu_datadir)/firmware"
96926ce90fdSLaszlo Ersek	set -e; tmpf=$$(mktemp); trap 'rm -f -- "$$tmpf"' EXIT; \
97026ce90fdSLaszlo Ersek	for x in $(DESCS); do \
971177cd674SOlaf Hering		sed -e 's,@DATADIR@,$(qemu_datadir),' \
97226ce90fdSLaszlo Ersek			"$(SRC_PATH)/pc-bios/descriptors/$$x" > "$$tmpf"; \
97326ce90fdSLaszlo Ersek		$(INSTALL_DATA) "$$tmpf" \
97426ce90fdSLaszlo Ersek			"$(DESTDIR)$(qemu_datadir)/firmware/$$x"; \
97526ce90fdSLaszlo Ersek	done
97626ce90fdSLaszlo Ersekendif
977a8260d38SDaniel P. Berrangé	for s in $(ICON_SIZES); do \
9786c11dda9SStefan Hajnoczi		mkdir -p "$(DESTDIR)$(qemu_icondir)/hicolor/$${s}/apps"; \
979a8260d38SDaniel P. Berrangé		$(INSTALL_DATA) $(SRC_PATH)/ui/icons/qemu_$${s}.png \
9806c11dda9SStefan Hajnoczi			"$(DESTDIR)$(qemu_icondir)/hicolor/$${s}/apps/qemu.png"; \
981a8260d38SDaniel P. Berrangé	done; \
9826c11dda9SStefan Hajnoczi	mkdir -p "$(DESTDIR)$(qemu_icondir)/hicolor/32x32/apps"; \
983a8260d38SDaniel P. Berrangé	$(INSTALL_DATA) $(SRC_PATH)/ui/icons/qemu_32x32.bmp \
9846c11dda9SStefan Hajnoczi		"$(DESTDIR)$(qemu_icondir)/hicolor/32x32/apps/qemu.bmp"; \
9856c11dda9SStefan Hajnoczi	mkdir -p "$(DESTDIR)$(qemu_icondir)/hicolor/scalable/apps"; \
986a8260d38SDaniel P. Berrangé	$(INSTALL_DATA) $(SRC_PATH)/ui/icons/qemu.svg \
9876c11dda9SStefan Hajnoczi		"$(DESTDIR)$(qemu_icondir)/hicolor/scalable/apps/qemu.svg"
9886c11dda9SStefan Hajnoczi	mkdir -p "$(DESTDIR)$(qemu_desktopdir)"
98967ea9546SDaniel P. Berrangé	$(INSTALL_DATA) $(SRC_PATH)/ui/qemu.desktop \
9906c11dda9SStefan Hajnoczi		"$(DESTDIR)$(qemu_desktopdir)/qemu.desktop"
9912a6b5372SMichael Tokarevifdef CONFIG_GTK
992834574eaSAnthony Liguori	$(MAKE) -C po $@
993834574eaSAnthony Liguoriendif
99454cb65d8SEmilio G. Cotaifeq ($(CONFIG_PLUGIN),y)
99554cb65d8SEmilio G. Cota	$(INSTALL_DATA) $(SRC_PATH)/include/qemu/qemu-plugin.h "$(DESTDIR)$(includedir)/qemu-plugin.h"
99654cb65d8SEmilio G. Cotaendif
9976aae2a2eSEduardo Habkost	$(INSTALL_DIR) "$(DESTDIR)$(qemu_datadir)/keymaps"
99818be8d77Sblueswir1	set -e; for x in $(KEYMAPS); do \
9996aae2a2eSEduardo Habkost		$(INSTALL_DATA) $(SRC_PATH)/pc-bios/keymaps/$$x "$(DESTDIR)$(qemu_datadir)/keymaps"; \
1000ad064840Spbrook	done
10011412cf58SDaniel P. Berrange	$(INSTALL_DATA) $(BUILD_DIR)/trace-events-all "$(DESTDIR)$(qemu_datadir)/trace-events-all"
1002612384d7Sbellard
1003ae5fdc81SFam Zheng.PHONY: ctags
1004ae5fdc81SFam Zhengctags:
1005ac99c624SSergey Fedorov	rm -f tags
1006ae5fdc81SFam Zheng	find "$(SRC_PATH)" -name '*.[hc]' -exec ctags --append {} +
1007ae5fdc81SFam Zheng
100821d4e8e3SAlexandre Bique.PHONY: TAGS
1009367e86e8SbellardTAGS:
1010ac99c624SSergey Fedorov	rm -f TAGS
1011b1999e87SDavid Gibson	find "$(SRC_PATH)" -name '*.[hc]' -exec etags --append {} +
101231e31b8aSbellard
10136688bc6dSbellardcscope:
1014eaa2ddbbSFam Zheng	rm -f "$(SRC_PATH)"/cscope.*
1015eaa2ddbbSFam Zheng	find "$(SRC_PATH)/" -name "*.[chsS]" -print | sed 's,^\./,,' > "$(SRC_PATH)/cscope.files"
1016eaa2ddbbSFam Zheng	cscope -b -i"$(SRC_PATH)/cscope.files"
10176688bc6dSbellard
1018d98bc0b6SGerd Hoffmann# opengl shader programs
1019d98bc0b6SGerd Hoffmannui/shader/%-vert.h: $(SRC_PATH)/ui/shader/%.vert $(SRC_PATH)/scripts/shaderinclude.pl
1020d98bc0b6SGerd Hoffmann	@mkdir -p $(dir $@)
1021d98bc0b6SGerd Hoffmann	$(call quiet-command,\
1022d98bc0b6SGerd Hoffmann		perl $(SRC_PATH)/scripts/shaderinclude.pl $< > $@,\
10230bdb12c7SPeter Maydell		"VERT","$@")
1024d98bc0b6SGerd Hoffmann
1025d98bc0b6SGerd Hoffmannui/shader/%-frag.h: $(SRC_PATH)/ui/shader/%.frag $(SRC_PATH)/scripts/shaderinclude.pl
1026d98bc0b6SGerd Hoffmann	@mkdir -p $(dir $@)
1027d98bc0b6SGerd Hoffmann	$(call quiet-command,\
1028d98bc0b6SGerd Hoffmann		perl $(SRC_PATH)/scripts/shaderinclude.pl $< > $@,\
10290bdb12c7SPeter Maydell		"FRAG","$@")
1030d98bc0b6SGerd Hoffmann
103146e19e14SGerd Hoffmannui/shader.o: $(SRC_PATH)/ui/shader.c \
10322e1d70b9SGerd Hoffmann	ui/shader/texture-blit-vert.h \
10332e1d70b9SGerd Hoffmann	ui/shader/texture-blit-flip-vert.h \
10342e1d70b9SGerd Hoffmann	ui/shader/texture-blit-frag.h
1035cd2bc889SGerd Hoffmann
10363ef693a0Sbellard# documentation
1037e8518c92SMarkus ArmbrusterMAKEINFO=makeinfo
1038d59157eaSPaolo BonziniMAKEINFOINCLUDES= -I docs -I $(<D) -I $(@D)
1039d59157eaSPaolo BonziniMAKEINFOFLAGS=--no-split --number-sections $(MAKEINFOINCLUDES)
1040e8338fdbSMarc-André LureauTEXI2PODFLAGS=$(MAKEINFOINCLUDES) -DVERSION="$(VERSION)" -DCONFDIR="$(qemu_confdir)"
1041d59157eaSPaolo BonziniTEXI2PDFFLAGS=$(if $(V),,--quiet) -I $(SRC_PATH) $(MAKEINFOINCLUDES)
104256e8bdd4SMarc-André Lureau
1043e8338fdbSMarc-André Lureaudocs/version.texi: $(SRC_PATH)/VERSION config-host.mak
1044e8338fdbSMarc-André Lureau	$(call quiet-command,(\
1045e8338fdbSMarc-André Lureau		echo "@set VERSION $(VERSION)" && \
1046e8338fdbSMarc-André Lureau		echo "@set CONFDIR $(qemu_confdir)" \
1047e8338fdbSMarc-André Lureau	)> $@,"GEN","$@")
1048fea346f5SPeter Maydell
104944cb280dSPaolo Bonzini%.html: %.texi docs/version.texi
1050e9ee06bdSMarc-André Lureau	$(call quiet-command,LC_ALL=C $(MAKEINFO) $(MAKEINFOFLAGS) --no-headers \
1051e9ee06bdSMarc-André Lureau	--html $< -o $@,"GEN","$@")
10523ef693a0Sbellard
105344cb280dSPaolo Bonzini%.info: %.texi docs/version.texi
1054e9ee06bdSMarc-André Lureau	$(call quiet-command,$(MAKEINFO) $(MAKEINFOFLAGS) $< -o $@,"GEN","$@")
1055f3548328Sbellard
105644cb280dSPaolo Bonzini%.txt: %.texi docs/version.texi
1057f8bab10bSMarc-André Lureau	$(call quiet-command,LC_ALL=C $(MAKEINFO) $(MAKEINFOFLAGS) --no-headers \
1058f8bab10bSMarc-André Lureau	--plaintext $< -o $@,"GEN","$@")
1059f8bab10bSMarc-André Lureau
106044cb280dSPaolo Bonzini%.pdf: %.texi docs/version.texi
1061d59157eaSPaolo Bonzini	$(call quiet-command,texi2pdf $(TEXI2PDFFLAGS) $< -o $@,"GEN","$@")
1062bd7f9747SMarkus Armbruster
10635f71eac0SPeter Maydell# Sphinx builds all its documentation at once in one invocation
10645f71eac0SPeter Maydell# and handles "don't rebuild things unless necessary" itself.
10655f71eac0SPeter Maydell# The '.doctrees' files are cached information to speed this up.
10665f71eac0SPeter Maydell.PHONY: sphinxdocs
10670928523aSPeter Maydellsphinxdocs: $(MANUAL_BUILDDIR)/devel/index.html \
10680928523aSPeter Maydell            $(MANUAL_BUILDDIR)/interop/index.html \
10690928523aSPeter Maydell            $(MANUAL_BUILDDIR)/specs/index.html \
107065c3542bSPeter Maydell            $(MANUAL_BUILDDIR)/system/index.html \
107109147930SPaolo Bonzini            $(MANUAL_BUILDDIR)/tools/index.html \
107209147930SPaolo Bonzini            $(MANUAL_BUILDDIR)/user/index.html
10735f71eac0SPeter Maydell
10745f71eac0SPeter Maydell# Canned command to build a single manual
107527a296fcSPeter Maydell# Arguments: $1 = manual name, $2 = Sphinx builder ('html' or 'man')
10766bda415cSEduardo Habkost# Note the use of different doctree for each (manual, builder) tuple;
10776bda415cSEduardo Habkost# this works around Sphinx not handling parallel invocation on
10786bda415cSEduardo Habkost# a single doctree: https://github.com/sphinx-doc/sphinx/issues/2946
10792eb054c2SPeter Maydellbuild-manual = $(call quiet-command,CONFDIR="$(qemu_confdir)" $(SPHINX_BUILD) $(if $(V),,-q) -W -b $2 -D version=$(VERSION) -D release="$(FULL_VERSION)" -d .doctrees/$1-$2 $(SRC_PATH)/docs/$1 $(MANUAL_BUILDDIR)/$1 ,"SPHINX","$(MANUAL_BUILDDIR)/$1")
10805f71eac0SPeter Maydell# We assume all RST files in the manual's directory are used in it
1081814e068fSPeter Maydellmanual-deps = $(wildcard $(SRC_PATH)/docs/$1/*.rst $(SRC_PATH)/docs/$1/*/*.rst) \
1082de1572caSPeter Maydell              $(SRC_PATH)/docs/defs.rst.inc \
10839165d323SPeter Maydell              $(SRC_PATH)/docs/$1/conf.py $(SRC_PATH)/docs/conf.py \
10849165d323SPeter Maydell              $(SRC_PATH)/docs/sphinx/*.py
1085e0f3728dSPeter Maydell# Macro to write out the rule and dependencies for building manpages
1086e0f3728dSPeter Maydell# Usage: $(call define-manpage-rule,manualname,manpage1 manpage2...[,extradeps])
1087e0f3728dSPeter Maydell# 'extradeps' is optional, and specifies extra files (eg .hx files) that
1088e0f3728dSPeter Maydell# the manual page depends on.
1089e0f3728dSPeter Maydelldefine define-manpage-rule
1090e0f3728dSPeter Maydell$(call atomic,$(foreach manpage,$2,$(MANUAL_BUILDDIR)/$1/$(manpage)),$(call manual-deps,$1) $3)
1091e0f3728dSPeter Maydell	$(call build-manual,$1,man)
1092e0f3728dSPeter Maydellendef
10935f71eac0SPeter Maydell
10941290e671SPeter Maydell$(MANUAL_BUILDDIR)/devel/index.html: $(call manual-deps,devel)
109527a296fcSPeter Maydell	$(call build-manual,devel,html)
10965f71eac0SPeter Maydell
1097a08b4a9fSPeter Maydell$(MANUAL_BUILDDIR)/interop/index.html: $(call manual-deps,interop)
109827a296fcSPeter Maydell	$(call build-manual,interop,html)
10995f71eac0SPeter Maydell
11000783a732SPeter Maydell$(MANUAL_BUILDDIR)/specs/index.html: $(call manual-deps,specs)
110127a296fcSPeter Maydell	$(call build-manual,specs,html)
110227a296fcSPeter Maydell
110309ce5f2dSPeter 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
11040928523aSPeter Maydell	$(call build-manual,system,html)
11050928523aSPeter Maydell
1106a08b4a9fSPeter Maydell$(MANUAL_BUILDDIR)/tools/index.html: $(call manual-deps,tools) $(SRC_PATH)/qemu-img-cmds.hx $(SRC_PATH)/docs/qemu-option-trace.rst.inc
110765c3542bSPeter Maydell	$(call build-manual,tools,html)
110865c3542bSPeter Maydell
110909147930SPaolo Bonzini$(MANUAL_BUILDDIR)/user/index.html: $(call manual-deps,user)
111009147930SPaolo Bonzini	$(call build-manual,user,html)
111109147930SPaolo Bonzini
1112a08b4a9fSPeter Maydell$(call define-manpage-rule,interop,qemu-ga.8)
11130783a732SPeter Maydell
1114d06118bfSPeter Maydell$(call define-manpage-rule,system,qemu.1 qemu-block-drivers.7 qemu-cpu-models.7)
1115acab923dSPeter Maydell
1116a08b4a9fSPeter Maydell$(call define-manpage-rule,tools,\
1117a08b4a9fSPeter Maydell       qemu-img.1 qemu-nbd.8 qemu-trace-stap.1\
1118a08b4a9fSPeter Maydell       virtiofsd.1 virtfs-proxy-helper.1,\
1119a08b4a9fSPeter Maydell       $(SRC_PATH)/qemu-img-cmds.hx $(SRC_PATH)/docs/qemu-option-trace.rst.inc)
1120a08b4a9fSPeter Maydell
112122108f33SStefan Hajnoczi$(MANUAL_BUILDDIR)/index.html: $(SRC_PATH)/docs/index.html.in qemu-version.h
1122d83bbedaSStefan Hajnoczi	@mkdir -p "$(MANUAL_BUILDDIR)"
112322108f33SStefan Hajnoczi	$(call quiet-command, sed "s|@@VERSION@@|${VERSION}|g" $< >$@, \
112422108f33SStefan Hajnoczi             "GEN","$@")
112522108f33SStefan Hajnoczi
1126eb815e24SMarkus Armbrusterdocs/interop/qemu-qmp-qapi.texi: qapi/qapi-doc.texi
1127fb0bc835SMarkus Armbruster	@cp -p $< $@
11284afeeb57SMarkus Armbruster
1129fb0bc835SMarkus Armbrusterdocs/interop/qemu-ga-qapi.texi: qga/qapi-generated/qga-qapi-doc.texi
1130fb0bc835SMarkus Armbruster	@cp -p $< $@
113156e8bdd4SMarc-André Lureau
11325b1d0e92SPeter Maydellhtml: docs/interop/qemu-qmp-ref.html docs/interop/qemu-ga-ref.html sphinxdocs
11335b1d0e92SPeter Maydellinfo: docs/interop/qemu-qmp-ref.info docs/interop/qemu-ga-ref.info
11345b1d0e92SPeter Maydellpdf: docs/interop/qemu-qmp-ref.pdf docs/interop/qemu-ga-ref.pdf
11355b1d0e92SPeter Maydelltxt: docs/interop/qemu-qmp-ref.txt docs/interop/qemu-ga-ref.txt
1136818220f5Saliguori
1137d59157eaSPaolo Bonzinidocs/interop/qemu-ga-ref.dvi docs/interop/qemu-ga-ref.html \
1138d59157eaSPaolo Bonzini    docs/interop/qemu-ga-ref.info docs/interop/qemu-ga-ref.pdf \
1139d59157eaSPaolo Bonzini    docs/interop/qemu-ga-ref.txt docs/interop/qemu-ga-ref.7: \
1140d59157eaSPaolo Bonzini	docs/interop/qemu-ga-ref.texi docs/interop/qemu-ga-qapi.texi
114156e8bdd4SMarc-André Lureau
1142d59157eaSPaolo Bonzinidocs/interop/qemu-qmp-ref.dvi docs/interop/qemu-qmp-ref.html \
1143d59157eaSPaolo Bonzini    docs/interop/qemu-qmp-ref.info docs/interop/qemu-qmp-ref.pdf \
1144d59157eaSPaolo Bonzini    docs/interop/qemu-qmp-ref.txt docs/interop/qemu-qmp-ref.7: \
1145d59157eaSPaolo Bonzini	docs/interop/qemu-qmp-ref.texi docs/interop/qemu-qmp-qapi.texi
114656e8bdd4SMarc-André Lureau
1147ae560cc3SEric Blake$(filter %.1 %.7 %.8,$(DOCS)): scripts/texi2pod.pl
1148ae560cc3SEric Blake
1149fe8bf5f6SAlex Bennée# Reports/Analysis
1150fe8bf5f6SAlex Bennée
1151fe8bf5f6SAlex Bennée%/coverage-report.html:
1152fe8bf5f6SAlex Bennée	@mkdir -p $*
1153fe8bf5f6SAlex Bennée	$(call quiet-command,\
11545eda6e42SAlex Bennée		gcovr -r $(SRC_PATH) \
11555eda6e42SAlex Bennée		$(foreach t, $(TARGET_DIRS), --object-directory $(BUILD_DIR)/$(t)) \
11565eda6e42SAlex Bennée		 --object-directory $(BUILD_DIR) \
1157337f2311SAlex Bennée		-p --html --html-details -o $@, \
1158fe8bf5f6SAlex Bennée		"GEN", "coverage-report.html")
1159fe8bf5f6SAlex Bennée
1160fe8bf5f6SAlex Bennée.PHONY: coverage-report
1161fe8bf5f6SAlex Bennéecoverage-report: $(CURDIR)/reports/coverage/coverage-report.html
116256e8bdd4SMarc-André Lureau
1163f53ec699SStefan Weilifdef CONFIG_WIN32
1164f53ec699SStefan Weil
1165f53ec699SStefan WeilINSTALLER = qemu-setup-$(VERSION)$(EXESUF)
1166f53ec699SStefan Weil
1167f53ec699SStefan Weilnsisflags = -V2 -NOCD
1168f53ec699SStefan Weil
1169f53ec699SStefan Weilifneq ($(wildcard $(SRC_PATH)/dll),)
1170f53ec699SStefan Weilifeq ($(ARCH),x86_64)
1171f53ec699SStefan Weil# 64 bit executables
1172f53ec699SStefan WeilDLL_PATH = $(SRC_PATH)/dll/w64
1173f53ec699SStefan Weilnsisflags += -DW64
1174f53ec699SStefan Weilelse
1175f53ec699SStefan Weil# 32 bit executables
1176f53ec699SStefan WeilDLL_PATH = $(SRC_PATH)/dll/w32
1177f53ec699SStefan Weilendif
1178f53ec699SStefan Weilendif
1179f53ec699SStefan Weil
1180f53ec699SStefan Weil.PHONY: installer
1181f53ec699SStefan Weilinstaller: $(INSTALLER)
1182f53ec699SStefan Weil
1183f53ec699SStefan WeilINSTDIR=/tmp/qemu-nsis
1184f53ec699SStefan Weil
1185f84f9f75SPhilippe Mathieu-Daudé$(INSTALLER): install-doc $(SRC_PATH)/qemu.nsi
1186fb8597bbSEd Maste	$(MAKE) install prefix=${INSTDIR}
1187f53ec699SStefan Weilifdef SIGNCODE
1188f53ec699SStefan Weil	(cd ${INSTDIR}; \
1189f53ec699SStefan Weil         for i in *.exe; do \
1190f53ec699SStefan Weil           $(SIGNCODE) $${i}; \
1191f53ec699SStefan Weil         done \
1192f53ec699SStefan Weil        )
1193f53ec699SStefan Weilendif # SIGNCODE
1194f53ec699SStefan Weil	(cd ${INSTDIR}; \
1195f53ec699SStefan Weil         for i in qemu-system-*.exe; do \
1196f53ec699SStefan Weil           arch=$${i%.exe}; \
1197f53ec699SStefan Weil           arch=$${arch#qemu-system-}; \
1198f53ec699SStefan Weil           echo Section \"$$arch\" Section_$$arch; \
1199f53ec699SStefan Weil           echo SetOutPath \"\$$INSTDIR\"; \
1200f53ec699SStefan Weil           echo File \"\$${BINDIR}\\$$i\"; \
1201f53ec699SStefan Weil           echo SectionEnd; \
1202f53ec699SStefan Weil         done \
1203f53ec699SStefan Weil        ) >${INSTDIR}/system-emulations.nsh
1204f53ec699SStefan Weil	makensis $(nsisflags) \
1205f53ec699SStefan Weil                $(if $(BUILD_DOCS),-DCONFIG_DOCUMENTATION="y") \
1206f53ec699SStefan Weil                $(if $(CONFIG_GTK),-DCONFIG_GTK="y") \
1207f53ec699SStefan Weil                -DBINDIR="${INSTDIR}" \
1208f53ec699SStefan Weil                $(if $(DLL_PATH),-DDLLDIR="$(DLL_PATH)") \
1209f53ec699SStefan Weil                -DSRCDIR="$(SRC_PATH)" \
1210f53ec699SStefan Weil                -DOUTFILE="$(INSTALLER)" \
1211805d8a67SStefan Weil                -DDISPLAYVERSION="$(VERSION)" \
1212f53ec699SStefan Weil                $(SRC_PATH)/qemu.nsi
1213f53ec699SStefan Weil	rm -r ${INSTDIR}
1214f53ec699SStefan Weilifdef SIGNCODE
1215f53ec699SStefan Weil	$(SIGNCODE) $(INSTALLER)
1216f53ec699SStefan Weilendif # SIGNCODE
1217f53ec699SStefan Weilendif # CONFIG_WIN
1218f53ec699SStefan Weil
1219cb5fc67dSAnthony Liguori# Add a dependency on the generated files, so that they are always
1220cb5fc67dSAnthony Liguori# rebuilt before other object files
1221428952cfSThomas Huthifneq ($(wildcard config-host.mak),)
1222eaa2ddbbSFam Zhengifneq ($(filter-out $(UNCHECKED_GOALS),$(MAKECMDGOALS)),$(if $(MAKECMDGOALS),,fail))
12233dff199cSLaurent VivierMakefile: $(generated-files-y)
12247748b8cbSMike Frysingerendif
1225428952cfSThomas Huthendif
1226cb5fc67dSAnthony Liguori
12270ab8ed18SDaniel P. Berrange.SECONDARY: $(TRACE_HEADERS) $(TRACE_HEADERS:%=%-timestamp) \
12280ab8ed18SDaniel P. Berrange	$(TRACE_SOURCES) $(TRACE_SOURCES:%=%-timestamp) \
12290ab8ed18SDaniel P. Berrange	$(TRACE_DTRACE) $(TRACE_DTRACE:%=%-timestamp)
12300ab8ed18SDaniel P. Berrange
12314fb240a4Sbellard# Include automatically generated dependency files
12321435ddb8SPaolo Bonzini# Dependencies in Makefile.objs files come from our recursive subdir rules
12331435ddb8SPaolo Bonzini-include $(wildcard *.d tests/*.d)
1234324027c2SFam Zheng
1235324027c2SFam Zhenginclude $(SRC_PATH)/tests/docker/Makefile.include
1236b1fb9a63SFam Zhenginclude $(SRC_PATH)/tests/vm/Makefile.include
12370d8e065fSMarc-André Lureau
1238c355de59SPhilippe Mathieu-Daudéprint-help-run = printf "  %-30s - %s\\n" "$1" "$2"
1239c355de59SPhilippe Mathieu-Daudéprint-help = $(quiet-@)$(call print-help-run,$1,$2)
1240c355de59SPhilippe Mathieu-Daudé
12410d8e065fSMarc-André Lureau.PHONY: help
12420d8e065fSMarc-André Lureauhelp:
12430d8e065fSMarc-André Lureau	@echo  'Generic targets:'
1244c355de59SPhilippe Mathieu-Daudé	$(call print-help,all,Build all)
12450decdfe2SMarc-André Lureauifdef CONFIG_MODULES
1246c355de59SPhilippe Mathieu-Daudé	$(call print-help,modules,Build all modules)
12470decdfe2SMarc-André Lureauendif
1248c355de59SPhilippe Mathieu-Daudé	$(call print-help,dir/file.o,Build specified target only)
1249c355de59SPhilippe Mathieu-Daudé	$(call print-help,install,Install QEMU, documentation and tools)
1250c355de59SPhilippe Mathieu-Daudé	$(call print-help,ctags/TAGS,Generate tags file for editors)
1251c355de59SPhilippe Mathieu-Daudé	$(call print-help,cscope,Generate cscope index)
12520d8e065fSMarc-André Lureau	@echo  ''
12532b1f35b9SAlex Bennée	@$(if $(TARGET_DIRS), \
12540d8e065fSMarc-André Lureau		echo 'Architecture specific targets:'; \
12552b1f35b9SAlex Bennée		$(foreach t, $(TARGET_DIRS), \
1256c355de59SPhilippe Mathieu-Daudé		$(call print-help-run,$(t)/all,Build for $(t));) \
12570d8e065fSMarc-André Lureau		echo '')
1258*81ed0a57SPhilippe Mathieu-Daudé	@$(if $(TOOLS), \
1259*81ed0a57SPhilippe Mathieu-Daudé		echo 'Tools targets:'; \
1260*81ed0a57SPhilippe Mathieu-Daudé		$(foreach t, $(TOOLS), \
1261*81ed0a57SPhilippe Mathieu-Daudé		$(call print-help-run,$(t),Build $(shell basename $(t)) tool);) \
1262*81ed0a57SPhilippe Mathieu-Daudé		echo '')
12630d8e065fSMarc-André Lureau	@echo  'Cleaning targets:'
1264c355de59SPhilippe Mathieu-Daudé	$(call print-help,clean,Remove most generated files but keep the config)
1265990e6a27SAlex Bennéeifdef CONFIG_GCOV
1266c355de59SPhilippe Mathieu-Daudé	$(call print-help,clean-coverage,Remove coverage files)
1267990e6a27SAlex Bennéeendif
1268c355de59SPhilippe Mathieu-Daudé	$(call print-help,distclean,Remove all generated files)
1269c355de59SPhilippe Mathieu-Daudé	$(call print-help,dist,Build a distributable tarball)
12700d8e065fSMarc-André Lureau	@echo  ''
12710d8e065fSMarc-André Lureau	@echo  'Test targets:'
1272c355de59SPhilippe Mathieu-Daudé	$(call print-help,check,Run all tests (check-help for details))
1273c355de59SPhilippe Mathieu-Daudé	$(call print-help,docker,Help about targets running tests inside containers)
1274c355de59SPhilippe Mathieu-Daudé	$(call print-help,vm-help,Help about targets running tests inside VM)
12750d8e065fSMarc-André Lureau	@echo  ''
12760d8e065fSMarc-André Lureau	@echo  'Documentation targets:'
1277c355de59SPhilippe Mathieu-Daudé	$(call print-help,html info pdf txt,Build documentation in specified format)
1278fe8bf5f6SAlex Bennéeifdef CONFIG_GCOV
1279c355de59SPhilippe Mathieu-Daudé	$(call print-help,coverage-report,Create code coverage report)
1280fe8bf5f6SAlex Bennéeendif
12810d8e065fSMarc-André Lureau	@echo  ''
12820d8e065fSMarc-André Lureauifdef CONFIG_WIN32
12830d8e065fSMarc-André Lureau	@echo  'Windows targets:'
1284c355de59SPhilippe Mathieu-Daudé	$(call print-help,installer,Build NSIS-based installer for QEMU)
12850d8e065fSMarc-André Lureauifdef QEMU_GA_MSI_ENABLED
1286c355de59SPhilippe Mathieu-Daudé	$(call print-help,msi,Build MSI-based installer for qemu-ga)
12870d8e065fSMarc-André Lureauendif
12880d8e065fSMarc-André Lureau	@echo  ''
12890d8e065fSMarc-André Lureauendif
1290c355de59SPhilippe Mathieu-Daudé	$(call print-help,$(MAKE) [targets],(quiet build, default))
1291c355de59SPhilippe Mathieu-Daudé	$(call print-help,$(MAKE) V=1 [targets],(verbose build))
1292