xref: /openbmc/qemu/Makefile (revision 14837c64)
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
18de1da442SMarc-André Lureauprint-%:
19de1da442SMarc-André Lureau	@echo '$*=$($*)'
20de1da442SMarc-André Lureau
21250b086eSLluís Vilanova# All following code might depend on configuration variables
2255d7e8f6Saurel32ifneq ($(wildcard config-host.mak),)
231ad2134fSPaul Brook# Put the all: rule here so that config-host.mak can contain dependencies.
248f67aa82SStefan Weilall:
25ad064840Spbrookinclude config-host.mak
26d1bd2423SPeter Maydell
27aef45d51SDaniel P. Berrangegit-submodule-update:
28aef45d51SDaniel P. Berrange
29aef45d51SDaniel P. Berrange.PHONY: git-submodule-update
30aef45d51SDaniel P. Berrange
31aef45d51SDaniel P. Berrangegit_module_status := $(shell \
32aef45d51SDaniel P. Berrange  cd '$(SRC_PATH)' && \
33cc84d63aSDaniel P. Berrange  GIT="$(GIT)" ./scripts/git-submodule.sh status $(GIT_SUBMODULES); \
34aef45d51SDaniel P. Berrange  echo $$?; \
35aef45d51SDaniel P. Berrange)
36aef45d51SDaniel P. Berrange
37aef45d51SDaniel P. Berrangeifeq (1,$(git_module_status))
38f62bbee5SDaniel P. Berrangeifeq (no,$(GIT_UPDATE))
39f62bbee5SDaniel P. Berrangegit-submodule-update:
40f62bbee5SDaniel P. Berrange	$(call quiet-command, \
41f62bbee5SDaniel P. Berrange            echo && \
42f62bbee5SDaniel P. Berrange            echo "GIT submodule checkout is out of date. Please run" && \
43f62bbee5SDaniel P. Berrange            echo "  scripts/git-submodule.sh update $(GIT_SUBMODULES)" && \
44f62bbee5SDaniel P. Berrange            echo "from the source directory checkout $(SRC_PATH)" && \
45f62bbee5SDaniel P. Berrange            echo && \
46f62bbee5SDaniel P. Berrange            exit 1)
47f62bbee5SDaniel P. Berrangeelse
48aef45d51SDaniel P. Berrangegit-submodule-update:
49aef45d51SDaniel P. Berrange	$(call quiet-command, \
50cc84d63aSDaniel P. Berrange          (cd $(SRC_PATH) && GIT="$(GIT)" ./scripts/git-submodule.sh update $(GIT_SUBMODULES)), \
51aef45d51SDaniel P. Berrange          "GIT","$(GIT_SUBMODULES)")
52aef45d51SDaniel P. Berrangeendif
53aef45d51SDaniel P. Berrangeendif
54aef45d51SDaniel P. Berrange
5592712822SDaniel P. Berrange.git-submodule-status: git-submodule-update config-host.mak
56aef45d51SDaniel P. Berrange
57d1bd2423SPeter Maydell# Check that we're not trying to do an out-of-tree build from
58d1bd2423SPeter Maydell# a tree that's been used for an in-tree build.
59d1bd2423SPeter Maydellifneq ($(realpath $(SRC_PATH)),$(realpath .))
60d1bd2423SPeter Maydellifneq ($(wildcard $(SRC_PATH)/config-host.mak),)
61d1bd2423SPeter Maydell$(error This is an out of tree build but your source tree ($(SRC_PATH)) \
62d1bd2423SPeter Maydellseems to have been used for an in-tree build. You can fix this by running \
63b98a3baeSPhilippe Mathieu-Daudé"$(MAKE) distclean && rm -rf *-linux-user *-softmmu" in your source tree)
64d1bd2423SPeter Maydellendif
65d1bd2423SPeter Maydellendif
66d1bd2423SPeter Maydell
672b1f35b9SAlex BennéeCONFIG_SOFTMMU := $(if $(filter %-softmmu,$(TARGET_DIRS)),y)
682b1f35b9SAlex BennéeCONFIG_USER_ONLY := $(if $(filter %-user,$(TARGET_DIRS)),y)
696b827ccaSStefano StabelliniCONFIG_XEN := $(CONFIG_XEN_BACKEND)
70f3aa844bSPaolo BonziniCONFIG_ALL=y
71f3aa844bSPaolo Bonzini-include config-all-devices.mak
72f3aa844bSPaolo Bonzini-include config-all-disas.mak
73f3aa844bSPaolo Bonzini
743a6b016dSMarkus Armbrusterconfig-host.mak: $(SRC_PATH)/configure $(SRC_PATH)/pc-bios $(SRC_PATH)/VERSION
75e5efe7f5SJuan Quintela	@echo $@ is out-of-date, running configure
76cdb69b08SMarkus Armbruster	@./config.status
7726fffe29SEmilio G. Cota
7826fffe29SEmilio G. Cota# Force configure to re-run if the API symbols are updated
7926fffe29SEmilio G. Cotaifeq ($(CONFIG_PLUGIN),y)
8026fffe29SEmilio G. Cotaconfig-host.mak: $(SRC_PATH)/plugins/qemu-plugins.symbols
8126fffe29SEmilio G. Cotaendif
8226fffe29SEmilio G. Cota
8355d7e8f6Saurel32else
8455d7e8f6Saurel32config-host.mak:
85eaa2ddbbSFam Zhengifneq ($(filter-out $(UNCHECKED_GOALS),$(MAKECMDGOALS)),$(if $(MAKECMDGOALS),,fail))
8655d7e8f6Saurel32	@echo "Please call configure before running make!"
8755d7e8f6Saurel32	@exit 1
8855d7e8f6Saurel32endif
897748b8cbSMike Frysingerendif
90766a487aSbellard
91fb57c881SFam Zhenginclude $(SRC_PATH)/rules.mak
92fb57c881SFam Zheng
93c932ce31SPaolo Bonzini# lor is defined in rules.mak
9429de2804SLaurent VivierCONFIG_BLOCK := $(call lor,$(CONFIG_SOFTMMU),$(CONFIG_TOOLS))
9529de2804SLaurent Vivier
9657b49737SPeter Maydell# Create QEMU_PKGVERSION and FULL_VERSION strings
9757b49737SPeter Maydell# If PKGVERSION is set, use that; otherwise get version and -dirty status from git
9857b49737SPeter MaydellQEMU_PKGVERSION := $(if $(PKGVERSION),$(PKGVERSION),$(shell \
9957b49737SPeter Maydell  cd $(SRC_PATH); \
10057b49737SPeter Maydell  if test -e .git; then \
10157b49737SPeter Maydell    git describe --match 'v*' 2>/dev/null | tr -d '\n'; \
10257b49737SPeter Maydell    if ! git diff-index --quiet HEAD &>/dev/null; then \
10357b49737SPeter Maydell      echo "-dirty"; \
10457b49737SPeter Maydell    fi; \
10557b49737SPeter Maydell  fi))
10657b49737SPeter Maydell
10757b49737SPeter Maydell# Either "version (pkgversion)", or just "version" if pkgversion not set
10857b49737SPeter MaydellFULL_VERSION := $(if $(QEMU_PKGVERSION),$(VERSION) ($(QEMU_PKGVERSION)),$(VERSION))
10957b49737SPeter Maydell
1103dff199cSLaurent Viviergenerated-files-y = qemu-version.h config-host.h qemu-options.def
111bf582c34SEric Blake
112bf582c34SEric BlakeGENERATED_QAPI_FILES = qapi/qapi-builtin-types.h qapi/qapi-builtin-types.c
113bf582c34SEric BlakeGENERATED_QAPI_FILES += qapi/qapi-types.h qapi/qapi-types.c
114bf582c34SEric BlakeGENERATED_QAPI_FILES += $(QAPI_MODULES:%=qapi/qapi-types-%.h)
115bf582c34SEric BlakeGENERATED_QAPI_FILES += $(QAPI_MODULES:%=qapi/qapi-types-%.c)
116bf582c34SEric BlakeGENERATED_QAPI_FILES += qapi/qapi-builtin-visit.h qapi/qapi-builtin-visit.c
117bf582c34SEric BlakeGENERATED_QAPI_FILES += qapi/qapi-visit.h qapi/qapi-visit.c
118bf582c34SEric BlakeGENERATED_QAPI_FILES += $(QAPI_MODULES:%=qapi/qapi-visit-%.h)
119bf582c34SEric BlakeGENERATED_QAPI_FILES += $(QAPI_MODULES:%=qapi/qapi-visit-%.c)
12000ca24ffSMarkus ArmbrusterGENERATED_QAPI_FILES += qapi/qapi-init-commands.h qapi/qapi-init-commands.c
121bf582c34SEric BlakeGENERATED_QAPI_FILES += qapi/qapi-commands.h qapi/qapi-commands.c
122bf582c34SEric BlakeGENERATED_QAPI_FILES += $(QAPI_MODULES:%=qapi/qapi-commands-%.h)
123bf582c34SEric BlakeGENERATED_QAPI_FILES += $(QAPI_MODULES:%=qapi/qapi-commands-%.c)
1245d75648bSMarkus ArmbrusterGENERATED_QAPI_FILES += qapi/qapi-emit-events.h qapi/qapi-emit-events.c
125bf582c34SEric BlakeGENERATED_QAPI_FILES += qapi/qapi-events.h qapi/qapi-events.c
126bf582c34SEric BlakeGENERATED_QAPI_FILES += $(QAPI_MODULES:%=qapi/qapi-events-%.h)
127bf582c34SEric BlakeGENERATED_QAPI_FILES += $(QAPI_MODULES:%=qapi/qapi-events-%.c)
128bf582c34SEric BlakeGENERATED_QAPI_FILES += qapi/qapi-introspect.c qapi/qapi-introspect.h
129bf582c34SEric BlakeGENERATED_QAPI_FILES += qapi/qapi-doc.texi
130bf582c34SEric Blake
1313dff199cSLaurent Viviergenerated-files-y += $(GENERATED_QAPI_FILES)
132eac236eaSLluís Vilanova
1333dff199cSLaurent Viviergenerated-files-y += trace/generated-tcg-tracers.h
134465830fbSLluís Vilanova
1353dff199cSLaurent Viviergenerated-files-y += trace/generated-helpers-wrappers.h
1363dff199cSLaurent Viviergenerated-files-y += trace/generated-helpers.h
1373dff199cSLaurent Viviergenerated-files-y += trace/generated-helpers.c
138707c8a98SLluís Vilanova
1393dff199cSLaurent Viviergenerated-files-$(CONFIG_TRACE_UST) += trace-ust-all.h
1403dff199cSLaurent Viviergenerated-files-$(CONFIG_TRACE_UST) += trace-ust-all.c
141e6bf23f8SMohamad Gebai
1423dff199cSLaurent Viviergenerated-files-y += module_block.h
1430c0c1fd9SMarc Mari
1440ab8ed18SDaniel P. BerrangeTRACE_HEADERS = trace-root.h $(trace-events-subdirs:%=%/trace.h)
1450ab8ed18SDaniel P. BerrangeTRACE_SOURCES = trace-root.c $(trace-events-subdirs:%=%/trace.c)
1460ab8ed18SDaniel P. BerrangeTRACE_DTRACE =
1470ab8ed18SDaniel P. Berrangeifdef CONFIG_TRACE_DTRACE
1480ab8ed18SDaniel P. BerrangeTRACE_HEADERS += trace-dtrace-root.h $(trace-events-subdirs:%=%/trace-dtrace.h)
1490ab8ed18SDaniel P. BerrangeTRACE_DTRACE += trace-dtrace-root.dtrace $(trace-events-subdirs:%=%/trace-dtrace.dtrace)
1500ab8ed18SDaniel P. Berrangeendif
1510ab8ed18SDaniel P. Berrangeifdef CONFIG_TRACE_UST
1520ab8ed18SDaniel P. BerrangeTRACE_HEADERS += trace-ust-root.h $(trace-events-subdirs:%=%/trace-ust.h)
1530ab8ed18SDaniel P. Berrangeendif
1540ab8ed18SDaniel P. Berrange
1553dff199cSLaurent Viviergenerated-files-y += $(TRACE_HEADERS)
1563dff199cSLaurent Viviergenerated-files-y += $(TRACE_SOURCES)
1573dff199cSLaurent Viviergenerated-files-y += $(BUILD_DIR)/trace-events-all
1583dff199cSLaurent Viviergenerated-files-y += .git-submodule-status
1590ab8ed18SDaniel P. Berrange
1600ab8ed18SDaniel P. Berrangetrace-group-name = $(shell dirname $1 | sed -e 's/[^a-zA-Z0-9]/_/g')
1610ab8ed18SDaniel P. Berrange
1628755b4afSDaniel P. Berrangetracetool-y = $(SRC_PATH)/scripts/tracetool.py
1638755b4afSDaniel P. Berrangetracetool-y += $(shell find $(SRC_PATH)/scripts/tracetool -name "*.py")
1648755b4afSDaniel P. Berrange
1650ab8ed18SDaniel P. Berrange%/trace.h: %/trace.h-timestamp
1660ab8ed18SDaniel P. Berrange	@cmp $< $@ >/dev/null 2>&1 || cp $< $@
16757b7bdf4SStefan Hajnoczi%/trace.h-timestamp: $(SRC_PATH)/%/trace-events $(tracetool-y) $(BUILD_DIR)/config-host.mak
1680ab8ed18SDaniel P. Berrange	$(call quiet-command,$(TRACETOOL) \
1690ab8ed18SDaniel P. Berrange		--group=$(call trace-group-name,$@) \
1700ab8ed18SDaniel P. Berrange		--format=h \
1710ab8ed18SDaniel P. Berrange		--backends=$(TRACE_BACKENDS) \
1720ab8ed18SDaniel P. Berrange		$< > $@,"GEN","$(@:%-timestamp=%)")
1730ab8ed18SDaniel P. Berrange
1740ab8ed18SDaniel P. Berrange%/trace.c: %/trace.c-timestamp
1750ab8ed18SDaniel P. Berrange	@cmp $< $@ >/dev/null 2>&1 || cp $< $@
17657b7bdf4SStefan Hajnoczi%/trace.c-timestamp: $(SRC_PATH)/%/trace-events $(tracetool-y) $(BUILD_DIR)/config-host.mak
1770ab8ed18SDaniel P. Berrange	$(call quiet-command,$(TRACETOOL) \
1780ab8ed18SDaniel P. Berrange		--group=$(call trace-group-name,$@) \
1790ab8ed18SDaniel P. Berrange		--format=c \
1800ab8ed18SDaniel P. Berrange		--backends=$(TRACE_BACKENDS) \
1810ab8ed18SDaniel P. Berrange		$< > $@,"GEN","$(@:%-timestamp=%)")
1820ab8ed18SDaniel P. Berrange
1830ab8ed18SDaniel P. Berrange%/trace-ust.h: %/trace-ust.h-timestamp
1840ab8ed18SDaniel P. Berrange	@cmp $< $@ >/dev/null 2>&1 || cp $< $@
18557b7bdf4SStefan Hajnoczi%/trace-ust.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=ust-events-h \
1890ab8ed18SDaniel P. Berrange		--backends=$(TRACE_BACKENDS) \
1900ab8ed18SDaniel P. Berrange		$< > $@,"GEN","$(@:%-timestamp=%)")
1910ab8ed18SDaniel P. Berrange
1920ab8ed18SDaniel P. Berrange%/trace-dtrace.dtrace: %/trace-dtrace.dtrace-timestamp
1930ab8ed18SDaniel P. Berrange	@cmp $< $@ >/dev/null 2>&1 || cp $< $@
1940ab8ed18SDaniel P. Berrange%/trace-dtrace.dtrace-timestamp: $(SRC_PATH)/%/trace-events $(BUILD_DIR)/config-host.mak $(tracetool-y)
1950ab8ed18SDaniel P. Berrange	$(call quiet-command,$(TRACETOOL) \
1960ab8ed18SDaniel P. Berrange		--group=$(call trace-group-name,$@) \
1970ab8ed18SDaniel P. Berrange		--format=d \
1980ab8ed18SDaniel P. Berrange		--backends=$(TRACE_BACKENDS) \
1990ab8ed18SDaniel P. Berrange		$< > $@,"GEN","$(@:%-timestamp=%)")
2000ab8ed18SDaniel P. Berrange
2010ab8ed18SDaniel P. Berrange%/trace-dtrace.h: %/trace-dtrace.dtrace $(tracetool-y)
2020ab8ed18SDaniel P. Berrange	$(call quiet-command,dtrace -o $@ -h -s $<, "GEN","$@")
2030ab8ed18SDaniel P. Berrange
2040ab8ed18SDaniel P. Berrange%/trace-dtrace.o: %/trace-dtrace.dtrace $(tracetool-y)
2050ab8ed18SDaniel P. Berrange
2060ab8ed18SDaniel P. Berrange
2070ab8ed18SDaniel P. Berrangetrace-root.h: trace-root.h-timestamp
2080ab8ed18SDaniel P. Berrange	@cmp $< $@ >/dev/null 2>&1 || cp $< $@
20957b7bdf4SStefan Hajnoczitrace-root.h-timestamp: $(SRC_PATH)/trace-events $(tracetool-y) $(BUILD_DIR)/config-host.mak
2100ab8ed18SDaniel P. Berrange	$(call quiet-command,$(TRACETOOL) \
2110ab8ed18SDaniel P. Berrange		--group=root \
2120ab8ed18SDaniel P. Berrange		--format=h \
2130ab8ed18SDaniel P. Berrange		--backends=$(TRACE_BACKENDS) \
2140ab8ed18SDaniel P. Berrange		$< > $@,"GEN","$(@:%-timestamp=%)")
2150ab8ed18SDaniel P. Berrange
2160ab8ed18SDaniel P. Berrangetrace-root.c: trace-root.c-timestamp
2170ab8ed18SDaniel P. Berrange	@cmp $< $@ >/dev/null 2>&1 || cp $< $@
21857b7bdf4SStefan Hajnoczitrace-root.c-timestamp: $(SRC_PATH)/trace-events $(tracetool-y) $(BUILD_DIR)/config-host.mak
2190ab8ed18SDaniel P. Berrange	$(call quiet-command,$(TRACETOOL) \
2200ab8ed18SDaniel P. Berrange		--group=root \
2210ab8ed18SDaniel P. Berrange		--format=c \
2220ab8ed18SDaniel P. Berrange		--backends=$(TRACE_BACKENDS) \
2230ab8ed18SDaniel P. Berrange		$< > $@,"GEN","$(@:%-timestamp=%)")
2240ab8ed18SDaniel P. Berrange
2250ab8ed18SDaniel P. Berrangetrace-ust-root.h: trace-ust-root.h-timestamp
2260ab8ed18SDaniel P. Berrange	@cmp $< $@ >/dev/null 2>&1 || cp $< $@
22757b7bdf4SStefan Hajnoczitrace-ust-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=ust-events-h \
2310ab8ed18SDaniel P. Berrange		--backends=$(TRACE_BACKENDS) \
2320ab8ed18SDaniel P. Berrange		$< > $@,"GEN","$(@:%-timestamp=%)")
2330ab8ed18SDaniel P. Berrange
2340ab8ed18SDaniel P. Berrangetrace-ust-all.h: trace-ust-all.h-timestamp
2350ab8ed18SDaniel P. Berrange	@cmp $< $@ >/dev/null 2>&1 || cp $< $@
23657b7bdf4SStefan Hajnoczitrace-ust-all.h-timestamp: $(trace-events-files) $(tracetool-y) $(BUILD_DIR)/config-host.mak
2370ab8ed18SDaniel P. Berrange	$(call quiet-command,$(TRACETOOL) \
2380ab8ed18SDaniel P. Berrange		--group=all \
2390ab8ed18SDaniel P. Berrange		--format=ust-events-h \
2400ab8ed18SDaniel P. Berrange		--backends=$(TRACE_BACKENDS) \
2410ab8ed18SDaniel P. Berrange		$(trace-events-files) > $@,"GEN","$(@:%-timestamp=%)")
2420ab8ed18SDaniel P. Berrange
2430ab8ed18SDaniel P. Berrangetrace-ust-all.c: trace-ust-all.c-timestamp
2440ab8ed18SDaniel P. Berrange	@cmp $< $@ >/dev/null 2>&1 || cp $< $@
24557b7bdf4SStefan Hajnoczitrace-ust-all.c-timestamp: $(trace-events-files) $(tracetool-y) $(BUILD_DIR)/config-host.mak
2460ab8ed18SDaniel P. Berrange	$(call quiet-command,$(TRACETOOL) \
2470ab8ed18SDaniel P. Berrange		--group=all \
2480ab8ed18SDaniel P. Berrange		--format=ust-events-c \
2490ab8ed18SDaniel P. Berrange		--backends=$(TRACE_BACKENDS) \
2500ab8ed18SDaniel P. Berrange		$(trace-events-files) > $@,"GEN","$(@:%-timestamp=%)")
2510ab8ed18SDaniel P. Berrange
2520ab8ed18SDaniel P. Berrangetrace-dtrace-root.dtrace: trace-dtrace-root.dtrace-timestamp
2530ab8ed18SDaniel P. Berrange	@cmp $< $@ >/dev/null 2>&1 || cp $< $@
2540ab8ed18SDaniel P. Berrangetrace-dtrace-root.dtrace-timestamp: $(SRC_PATH)/trace-events $(BUILD_DIR)/config-host.mak $(tracetool-y)
2550ab8ed18SDaniel P. Berrange	$(call quiet-command,$(TRACETOOL) \
2560ab8ed18SDaniel P. Berrange		--group=root \
2570ab8ed18SDaniel P. Berrange		--format=d \
2580ab8ed18SDaniel P. Berrange		--backends=$(TRACE_BACKENDS) \
2590ab8ed18SDaniel P. Berrange		$< > $@,"GEN","$(@:%-timestamp=%)")
2600ab8ed18SDaniel P. Berrange
2610ab8ed18SDaniel P. Berrangetrace-dtrace-root.h: trace-dtrace-root.dtrace
2620ab8ed18SDaniel P. Berrange	$(call quiet-command,dtrace -o $@ -h -s $<, "GEN","$@")
2630ab8ed18SDaniel P. Berrange
2640ab8ed18SDaniel P. Berrangetrace-dtrace-root.o: trace-dtrace-root.dtrace
2650ab8ed18SDaniel P. Berrange
26692712822SDaniel P. BerrangeKEYCODEMAP_GEN = $(SRC_PATH)/ui/keycodemapdb/tools/keymap-gen
26792712822SDaniel P. BerrangeKEYCODEMAP_CSV = $(SRC_PATH)/ui/keycodemapdb/data/keymaps.csv
26892712822SDaniel P. Berrange
26992712822SDaniel P. BerrangeKEYCODEMAP_FILES = \
2702ec78706SDaniel P. Berrange		 ui/input-keymap-atset1-to-qcode.c \
271bcd5ac9bSDaniel P. Berrange		 ui/input-keymap-linux-to-qcode.c \
272ab8f9d49SDaniel P. Berrange		 ui/input-keymap-qcode-to-atset1.c \
273ab8f9d49SDaniel P. Berrange		 ui/input-keymap-qcode-to-atset2.c \
274ab8f9d49SDaniel P. Berrange		 ui/input-keymap-qcode-to-atset3.c \
2755a15e6b1SDaniel P. Berrange		 ui/input-keymap-qcode-to-linux.c \
276bcd5ac9bSDaniel P. Berrange		 ui/input-keymap-qcode-to-qnum.c \
277e709a61aSDaniel P. Berrange		 ui/input-keymap-qcode-to-sun.c \
278bcd5ac9bSDaniel P. Berrange		 ui/input-keymap-qnum-to-qcode.c \
279ed7b2624SDaniel P. Berrange		 ui/input-keymap-usb-to-qcode.c \
2802ec78706SDaniel P. Berrange		 ui/input-keymap-win32-to-qcode.c \
2812ec78706SDaniel P. Berrange		 ui/input-keymap-x11-to-qcode.c \
2822ec78706SDaniel P. Berrange		 ui/input-keymap-xorgevdev-to-qcode.c \
2832ec78706SDaniel P. Berrange		 ui/input-keymap-xorgkbd-to-qcode.c \
2842ec78706SDaniel P. Berrange		 ui/input-keymap-xorgxquartz-to-qcode.c \
2852ec78706SDaniel P. Berrange		 ui/input-keymap-xorgxwin-to-qcode.c \
286656282d2SKeno Fischer		 ui/input-keymap-osx-to-qcode.c \
28792712822SDaniel P. Berrange		 $(NULL)
28892712822SDaniel P. Berrange
2893dff199cSLaurent Viviergenerated-files-$(CONFIG_SOFTMMU) += $(KEYCODEMAP_FILES)
29092712822SDaniel P. Berrange
29192712822SDaniel P. Berrangeui/input-keymap-%.c: $(KEYCODEMAP_GEN) $(KEYCODEMAP_CSV) $(SRC_PATH)/ui/Makefile.objs
29292712822SDaniel P. Berrange	$(call quiet-command,\
2936809df1dSJan Beulich	    stem=$* && src=$${stem%-to-*} dst=$${stem#*-to-} && \
29492712822SDaniel P. Berrange	    test -e $(KEYCODEMAP_GEN) && \
29592712822SDaniel P. Berrange	    $(PYTHON) $(KEYCODEMAP_GEN) \
29692712822SDaniel P. Berrange	          --lang glib2 \
29792712822SDaniel P. Berrange	          --varname qemu_input_map_$${src}_to_$${dst} \
29892712822SDaniel P. Berrange	          code-map $(KEYCODEMAP_CSV) $${src} $${dst} \
29992712822SDaniel P. Berrange	        > $@ || rm -f $@, "GEN", "$@")
30092712822SDaniel P. Berrange
30192712822SDaniel P. Berrange$(KEYCODEMAP_GEN): .git-submodule-status
30292712822SDaniel P. Berrange$(KEYCODEMAP_CSV): .git-submodule-status
30392712822SDaniel P. Berrange
30426ce90fdSLaszlo Ersekedk2-decompressed = $(basename $(wildcard pc-bios/edk2-*.fd.bz2))
30526ce90fdSLaszlo Ersekpc-bios/edk2-%.fd: pc-bios/edk2-%.fd.bz2
30626ce90fdSLaszlo Ersek	$(call quiet-command,bzip2 -d -c $< > $@,"BUNZIP2",$<)
30726ce90fdSLaszlo Ersek
308d9ace8b3SJuan Quintela# Don't try to regenerate Makefile or configure
309d9ace8b3SJuan Quintela# We don't generate any of them
310d9ace8b3SJuan QuintelaMakefile: ;
311d9ace8b3SJuan Quintelaconfigure: ;
312d9ace8b3SJuan Quintela
313bd3f5706SMarc-André Lureau.PHONY: all clean cscope distclean html info install install-doc \
3147c3d1917SDaniel P. Berrange	pdf txt recurse-all dist msi FORCE
3150cb3fb1eSpbrook
316fec90ff0SPaolo Bonzini$(call set-vpath, $(SRC_PATH))
3178c462f8fSpbrook
3183e2e0e6bSJuan QuintelaLIBS+=-lz $(LIBS_TOOLS)
31967c0f08dSJuan Quintela
320d52c454aSMarc-André Lureauvhost-user-json-y =
321d52c454aSMarc-André LureauHELPERS-y =
322d52c454aSMarc-André Lureau
323206d1b9cSLaurent VivierHELPERS-$(call land,$(CONFIG_SOFTMMU),$(CONFIG_LINUX)) = qemu-bridge-helper$(EXESUF)
3247b93fadfSCorey Bryant
32557589bc4SMarc-André Lureauifeq ($(CONFIG_LINUX)$(CONFIG_VIRGL)$(CONFIG_GBM)$(CONFIG_TOOLS),yyyy)
326d52c454aSMarc-André LureauHELPERS-y += vhost-user-gpu$(EXESUF)
327d52c454aSMarc-André Lureauvhost-user-json-y += contrib/vhost-user-gpu/50-qemu-gpu.json
328d52c454aSMarc-André Lureauendif
329d52c454aSMarc-André Lureau
3302405f3c0SDr. David Alan Gilbertifeq ($(CONFIG_LINUX)$(CONFIG_SECCOMP)$(CONFIG_LIBCAP_NG),yyy)
33181bfc42dSDr. David Alan GilbertHELPERS-y += virtiofsd$(EXESUF)
332315616edSStefan Hajnoczivhost-user-json-y += tools/virtiofsd/50-qemu-virtiofsd.json
33381bfc42dSDr. David Alan Gilbertendif
33481bfc42dSDr. David Alan Gilbert
335b53c54c6SPeter Maydell# Sphinx does not allow building manuals into the same directory as
336b53c54c6SPeter Maydell# the source files, so if we're doing an in-tree QEMU build we must
337b53c54c6SPeter Maydell# build the manuals into a subdirectory (and then install them from
338b53c54c6SPeter Maydell# there for 'make install'). For an out-of-tree build we can just
339b53c54c6SPeter Maydell# use the docs/ subdirectory in the build tree as normal.
340b53c54c6SPeter Maydellifeq ($(realpath $(SRC_PATH)),$(realpath .))
341b53c54c6SPeter MaydellMANUAL_BUILDDIR := docs/built
342b53c54c6SPeter Maydellelse
343b53c54c6SPeter MaydellMANUAL_BUILDDIR := docs
344b53c54c6SPeter Maydellendif
345b53c54c6SPeter Maydell
346cc8ae6deSpbrookifdef BUILD_DOCS
347d06118bfSPeter MaydellDOCS+=$(MANUAL_BUILDDIR)/system/qemu.1
348a08b4a9fSPeter MaydellDOCS+=$(MANUAL_BUILDDIR)/tools/qemu-img.1
349a08b4a9fSPeter MaydellDOCS+=$(MANUAL_BUILDDIR)/tools/qemu-nbd.8
35087c0868fSPeter MaydellDOCS+=$(MANUAL_BUILDDIR)/interop/qemu-ga.8
3516a7e2bbeSStefan Hajnocziifeq ($(CONFIG_LINUX)$(CONFIG_SECCOMP)$(CONFIG_LIBCAP_NG),yyy)
352a08b4a9fSPeter MaydellDOCS+=$(MANUAL_BUILDDIR)/tools/virtiofsd.1
3536a7e2bbeSStefan Hajnocziendif
354acab923dSPeter MaydellDOCS+=$(MANUAL_BUILDDIR)/system/qemu-block-drivers.7
355d59157eaSPaolo BonziniDOCS+=docs/interop/qemu-qmp-ref.html docs/interop/qemu-qmp-ref.txt docs/interop/qemu-qmp-ref.7
356d59157eaSPaolo BonziniDOCS+=docs/interop/qemu-ga-ref.html docs/interop/qemu-ga-ref.txt docs/interop/qemu-ga-ref.7
3571bf84a1eSKashyap ChamarthyDOCS+=$(MANUAL_BUILDDIR)/system/qemu-cpu-models.7
35822108f33SStefan HajnocziDOCS+=$(MANUAL_BUILDDIR)/index.html
359983eef5aSMeador Ingeifdef CONFIG_VIRTFS
360a08b4a9fSPeter MaydellDOCS+=$(MANUAL_BUILDDIR)/tools/virtfs-proxy-helper.1
361983eef5aSMeador Ingeendif
36262dd1048SDaniel P. Berrangéifdef CONFIG_TRACE_SYSTEMTAP
363a08b4a9fSPeter MaydellDOCS+=$(MANUAL_BUILDDIR)/tools/qemu-trace-stap.1
36462dd1048SDaniel P. Berrangéendif
365cc8ae6deSpbrookelse
366cc8ae6deSpbrookDOCS=
367cc8ae6deSpbrookendif
3687d13299dSbellard
3698cc357b5SDaniel P. BerrangeSUBDIR_MAKEFLAGS=$(if $(V),,--no-print-directory --quiet) BUILD_DIR=$(BUILD_DIR)
370e0e312f3SPaolo BonziniSUBDIR_DEVICES_MAK=$(patsubst %, %/config-devices.mak, $(filter %-softmmu, $(TARGET_DIRS)))
371e0e312f3SPaolo BonziniSUBDIR_DEVICES_MAK_DEP=$(patsubst %, %.d, $(SUBDIR_DEVICES_MAK))
3721f3d3c8fSJuan Quintela
3738bdd3d49SStefan Weilifeq ($(SUBDIR_DEVICES_MAK),)
374b7c11e57SPaolo Bonziniconfig-all-devices.mak: config-host.mak
3750bdb12c7SPeter Maydell	$(call quiet-command,echo '# no devices' > $@,"GEN","$@")
3768bdd3d49SStefan Weilelse
377b7c11e57SPaolo Bonziniconfig-all-devices.mak: $(SUBDIR_DEVICES_MAK) config-host.mak
378bb585a78SPaolo Bonzini	$(call quiet-command, sed -n \
379bb585a78SPaolo Bonzini             's|^\([^=]*\)=\(.*\)$$|\1:=$$(findstring y,$$(\1)\2)|p' \
380bb585a78SPaolo Bonzini             $(SUBDIR_DEVICES_MAK) | sort -u > $@, \
3810bdb12c7SPeter Maydell             "GEN","$@")
3828bdd3d49SStefan Weilendif
3831f3d3c8fSJuan Quintela
384bd9141bbSPaul Brook-include $(SUBDIR_DEVICES_MAK_DEP)
385bd9141bbSPaul Brook
386e0e312f3SPaolo Bonzini# This has to be kept in sync with Kconfig.host.
387e0e312f3SPaolo BonziniMINIKCONF_ARGS = \
388f3494749SPaolo Bonzini    $(CONFIG_MINIKCONF_MODE) \
389bb768f71SThomas Huth    $@ $*/config-devices.mak.d $< $(MINIKCONF_INPUTS) \
390e0e312f3SPaolo Bonzini    CONFIG_KVM=$(CONFIG_KVM) \
391e0e312f3SPaolo Bonzini    CONFIG_SPICE=$(CONFIG_SPICE) \
392e0e312f3SPaolo Bonzini    CONFIG_IVSHMEM=$(CONFIG_IVSHMEM) \
393e0e312f3SPaolo Bonzini    CONFIG_TPM=$(CONFIG_TPM) \
394e0e312f3SPaolo Bonzini    CONFIG_XEN=$(CONFIG_XEN) \
395e0e312f3SPaolo Bonzini    CONFIG_OPENGL=$(CONFIG_OPENGL) \
396e0e312f3SPaolo Bonzini    CONFIG_X11=$(CONFIG_X11) \
397e0e312f3SPaolo Bonzini    CONFIG_VHOST_USER=$(CONFIG_VHOST_USER) \
39821c6b0c8SMarc-André Lureau    CONFIG_VHOST_KERNEL=$(CONFIG_VHOST_KERNEL) \
399e0e312f3SPaolo Bonzini    CONFIG_VIRTFS=$(CONFIG_VIRTFS) \
400d6c1bd4aSPaolo Bonzini    CONFIG_LINUX=$(CONFIG_LINUX) \
401d6c1bd4aSPaolo Bonzini    CONFIG_PVRDMA=$(CONFIG_PVRDMA)
402e0e312f3SPaolo Bonzini
403ea763fd2SThomas HuthMINIKCONF_INPUTS = $(SRC_PATH)/Kconfig.host $(SRC_PATH)/hw/Kconfig
404ea763fd2SThomas HuthMINIKCONF_DEPS = $(MINIKCONF_INPUTS) $(wildcard $(SRC_PATH)/hw/*/Kconfig)
405e0e312f3SPaolo BonziniMINIKCONF = $(PYTHON) $(SRC_PATH)/scripts/minikconf.py \
406e0e312f3SPaolo Bonzini
407ea763fd2SThomas Huth$(SUBDIR_DEVICES_MAK): %/config-devices.mak: default-configs/%.mak $(MINIKCONF_DEPS) $(BUILD_DIR)/config-host.mak
408e0e312f3SPaolo Bonzini	$(call quiet-command, $(MINIKCONF) $(MINIKCONF_ARGS) > $@.tmp, "GEN", "$@.tmp")
40912ccfec9SMichael S. Tsirkin	$(call quiet-command, if test -f $@; then \
410904fe1fbSBlue Swirl	  if cmp -s $@.old $@; then \
411012f0879SStefan Weil	    mv $@.tmp $@; \
412012f0879SStefan Weil	    cp -p $@ $@.old; \
413012f0879SStefan Weil	  else \
414012f0879SStefan Weil	    if test -f $@.old; then \
415012f0879SStefan Weil	      echo "WARNING: $@ (user modified) out of date.";\
416012f0879SStefan Weil	    else \
417a992fe3dSPaul Brook	      echo "WARNING: $@ out of date.";\
418012f0879SStefan Weil	    fi; \
419b98a3baeSPhilippe Mathieu-Daudé	    echo "Run \"$(MAKE) defconfig\" to regenerate."; \
420a992fe3dSPaul Brook	    rm $@.tmp; \
421012f0879SStefan Weil	  fi; \
422a992fe3dSPaul Brook	 else \
423a992fe3dSPaul Brook	  mv $@.tmp $@; \
424012f0879SStefan Weil	  cp -p $@ $@.old; \
4250bdb12c7SPeter Maydell	 fi,"GEN","$@");
426a992fe3dSPaul Brook
427a992fe3dSPaul Brookdefconfig:
428a992fe3dSPaul Brook	rm -f config-all-devices.mak $(SUBDIR_DEVICES_MAK)
429a992fe3dSPaul Brook
430992aeb8eSPaolo Bonziniifneq ($(wildcard config-host.mak),)
431992aeb8eSPaolo Bonziniinclude $(SRC_PATH)/Makefile.objs
432ba1183daSFam Zhengendif
433ba1183daSFam Zheng
434ba1183daSFam Zhengdummy := $(call unnest-vars,, \
435ba1183daSFam Zheng                stub-obj-y \
4365b76dd13SDaniel P. Berrange                authz-obj-y \
43732d955a4SMarc-André Lureau                chardev-obj-y \
438ba1183daSFam Zheng                util-obj-y \
439ba1183daSFam Zheng                qga-obj-y \
4403fa2d384SViktor Prutyanov                elf2dmp-obj-y \
441a75eb03bSDavid Marchand                ivshmem-client-obj-y \
442a75eb03bSDavid Marchand                ivshmem-server-obj-y \
44381bfc42dSDr. David Alan Gilbert                virtiofsd-obj-y \
444a5d2f6f8SYuval Shaia                rdmacm-mux-obj-y \
4457b2e5c65SMarc-André Lureau                libvhost-user-obj-y \
44649cc0340SFelipe Franciosi                vhost-user-scsi-obj-y \
447406d2aa2SChangpeng Liu                vhost-user-blk-obj-y \
44806914c97SMarc-André Lureau                vhost-user-input-obj-y \
449d52c454aSMarc-André Lureau                vhost-user-gpu-obj-y \
450577a6723STomoki Sekiyama                qga-vss-dll-obj-y \
451ba1183daSFam Zheng                block-obj-y \
452cc475698SFam Zheng                block-obj-m \
453*14837c64SKevin Wolf                storage-daemon-obj-y \
454*14837c64SKevin Wolf                storage-daemon-obj-m \
455fb37726dSDaniel P. Berrange                crypto-obj-y \
4560c7012e0SDaniel P. Berrange                qom-obj-y \
457666a3af9SDaniel P. Berrange                io-obj-y \
458cc475698SFam Zheng                common-obj-y \
4590ab8ed18SDaniel P. Berrange                common-obj-m \
460675b9b53SMarc-André Lureau                trace-obj-y)
461ba1183daSFam Zheng
46246e7b706SFam Zhenginclude $(SRC_PATH)/tests/Makefile.include
463992aeb8eSPaolo Bonzini
464d52c454aSMarc-André Lureauall: $(DOCS) $(if $(BUILD_DOCS),sphinxdocs) $(TOOLS) $(HELPERS-y) recurse-all modules $(vhost-user-json-y)
465b9dea4fbSpbrook
46667a1de0dSFam Zhengqemu-version.h: FORCE
46767a1de0dSFam Zheng	$(call quiet-command, \
46857b49737SPeter Maydell                (printf '#define QEMU_PKGVERSION "$(QEMU_PKGVERSION)"\n'; \
46957b49737SPeter Maydell		printf '#define QEMU_FULL_VERSION "$(FULL_VERSION)"\n'; \
4707e563bfbSThomas Huth		) > $@.tmp)
471d9e73d32SLin Ma	$(call quiet-command, if ! cmp -s $@ $@.tmp; then \
472d9e73d32SLin Ma	  mv $@.tmp $@; \
473d9e73d32SLin Ma	 else \
474d9e73d32SLin Ma	  rm $@.tmp; \
475d9e73d32SLin Ma	 fi)
47667a1de0dSFam Zheng
4771215c6e7SJuan Quintelaconfig-host.h: config-host.h-timestamp
4781215c6e7SJuan Quintelaconfig-host.h-timestamp: config-host.mak
479077de81aSPaolo Bonziniqemu-options.def: $(SRC_PATH)/qemu-options.hx $(SRC_PATH)/scripts/hxtool
4800bdb12c7SPeter Maydell	$(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@,"GEN","$@")
4811215c6e7SJuan Quintela
482c621dc3eSAlexander BulekovTARGET_DIRS_RULES := $(foreach t, all fuzz clean install, $(addsuffix /$(t), $(TARGET_DIRS)))
483916359f6SAndreas Färber
4841338a4b7SMarkus ArmbrusterSOFTMMU_ALL_RULES=$(filter %-softmmu/all, $(TARGET_DIRS_RULES))
4851338a4b7SMarkus Armbruster$(SOFTMMU_ALL_RULES): $(authz-obj-y)
4861338a4b7SMarkus Armbruster$(SOFTMMU_ALL_RULES): $(block-obj-y)
487*14837c64SKevin Wolf$(SOFTMMU_ALL_RULES): $(storage-daemon-obj-y)
4881338a4b7SMarkus Armbruster$(SOFTMMU_ALL_RULES): $(chardev-obj-y)
4891338a4b7SMarkus Armbruster$(SOFTMMU_ALL_RULES): $(crypto-obj-y)
4901338a4b7SMarkus Armbruster$(SOFTMMU_ALL_RULES): $(io-obj-y)
4911338a4b7SMarkus Armbruster$(SOFTMMU_ALL_RULES): config-all-devices.mak
49205dfa22bSPhilippe Mathieu-Daudéifdef DECOMPRESS_EDK2_BLOBS
4931338a4b7SMarkus Armbruster$(SOFTMMU_ALL_RULES): $(edk2-decompressed)
49405dfa22bSPhilippe Mathieu-Daudéendif
495cec7d0b6Spbrook
496c621dc3eSAlexander BulekovSOFTMMU_FUZZ_RULES=$(filter %-softmmu/fuzz, $(TARGET_DIRS_RULES))
497c621dc3eSAlexander Bulekov$(SOFTMMU_FUZZ_RULES): $(authz-obj-y)
498c621dc3eSAlexander Bulekov$(SOFTMMU_FUZZ_RULES): $(block-obj-y)
499c621dc3eSAlexander Bulekov$(SOFTMMU_FUZZ_RULES): $(chardev-obj-y)
500c621dc3eSAlexander Bulekov$(SOFTMMU_FUZZ_RULES): $(crypto-obj-y)
501c621dc3eSAlexander Bulekov$(SOFTMMU_FUZZ_RULES): $(io-obj-y)
502c621dc3eSAlexander Bulekov$(SOFTMMU_FUZZ_RULES): config-all-devices.mak
503c621dc3eSAlexander Bulekov$(SOFTMMU_FUZZ_RULES): $(edk2-decompressed)
504c621dc3eSAlexander Bulekov
5051338a4b7SMarkus Armbruster.PHONY: $(TARGET_DIRS_RULES)
5061338a4b7SMarkus Armbruster# The $(TARGET_DIRS_RULES) are of the form SUBDIR/GOAL, so that
5071338a4b7SMarkus Armbruster# $(dir $@) yields the sub-directory, and $(notdir $@) yields the sub-goal
5081338a4b7SMarkus Armbruster$(TARGET_DIRS_RULES):
5091338a4b7SMarkus Armbruster	$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C $(dir $@) V="$(V)" TARGET_DIR="$(dir $@)" $(notdir $@),)
5104aa42531Spbrook
511a540f158SPeter CrosthwaiteDTC_MAKE_ARGS=-I$(SRC_PATH)/dtc VPATH=$(SRC_PATH)/dtc -C dtc V="$(V)" LIBFDT_srcdir=$(SRC_PATH)/dtc/libfdt
512965f486cSPeter MaydellDTC_CFLAGS=$(CFLAGS) $(QEMU_CFLAGS)
513965f486cSPeter MaydellDTC_CPPFLAGS=-I$(BUILD_DIR)/dtc -I$(SRC_PATH)/dtc -I$(SRC_PATH)/dtc/libfdt
514a540f158SPeter Crosthwaite
5153b8593eeSMarkus Armbruster.PHONY: dtc/all
5163b8593eeSMarkus Armbrusterdtc/all: .git-submodule-status dtc/libfdt dtc/tests
517db5adeaaSPaolo 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,)
518a540f158SPeter Crosthwaite
51900525864SAaron Lindsaydtc/%: .git-submodule-status
520814e1110SJan Kiszka	@mkdir -p $@
521a540f158SPeter Crosthwaite
522e219c499SRichard Henderson# Overriding CFLAGS causes us to lose defines added in the sub-makefile.
523e219c499SRichard Henderson# Not overriding CFLAGS leads to mis-matches between compilation modes.
524e219c499SRichard Henderson# Therefore we replicate some of the logic in the sub-makefile.
525e219c499SRichard Henderson# Remove all the extra -Warning flags that QEMU uses that Capstone doesn't;
526e219c499SRichard Henderson# no need to annoy QEMU developers with such things.
527e219c499SRichard HendersonCAP_CFLAGS = $(patsubst -W%,,$(CFLAGS) $(QEMU_CFLAGS))
528e219c499SRichard HendersonCAP_CFLAGS += -DCAPSTONE_USE_SYS_DYN_MEM
529e219c499SRichard HendersonCAP_CFLAGS += -DCAPSTONE_HAS_ARM
530e219c499SRichard HendersonCAP_CFLAGS += -DCAPSTONE_HAS_ARM64
531e219c499SRichard HendersonCAP_CFLAGS += -DCAPSTONE_HAS_POWERPC
532e219c499SRichard HendersonCAP_CFLAGS += -DCAPSTONE_HAS_X86
533e219c499SRichard Henderson
5343b8593eeSMarkus Armbruster.PHONY: capstone/all
5353b8593eeSMarkus Armbrustercapstone/all: .git-submodule-status
5369f81aeb5SAlistair 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))
537e219c499SRichard Henderson
5383b8593eeSMarkus Armbruster.PHONY: slirp/all
5393b8593eeSMarkus Armbrusterslirp/all: .git-submodule-status
540daa79d9aSAlex Bennée	$(call quiet-command,$(MAKE) -C $(SRC_PATH)/slirp		\
541daa79d9aSAlex Bennée		BUILD_DIR="$(BUILD_DIR)/slirp" 			\
542daa79d9aSAlex Bennée		PKG_CONFIG="$(PKG_CONFIG)" 				\
543daa79d9aSAlex Bennée		CC="$(CC)" AR="$(AR)" 	LD="$(LD)" RANLIB="$(RANLIB)"	\
544db5adeaaSPaolo Bonzini		CFLAGS="$(QEMU_CFLAGS) $(CFLAGS)" LDFLAGS="$(QEMU_LDFLAGS)")
545675b9b53SMarc-André Lureau
5463b8593eeSMarkus Armbruster# Compatibility gunk to keep make working across the rename of targets
5473b8593eeSMarkus Armbruster# for recursion, to be removed some time after 4.1.
5483b8593eeSMarkus Armbrustersubdir-dtc: dtc/all
5493b8593eeSMarkus Armbrustersubdir-capstone: capstone/all
5503b8593eeSMarkus Armbrustersubdir-slirp: slirp/all
5513b8593eeSMarkus Armbruster
5521338a4b7SMarkus Armbruster$(filter %/all, $(TARGET_DIRS_RULES)): libqemuutil.a $(common-obj-y) \
553b8d89ba8SPaolo Bonzini	$(qom-obj-y)
554add16157SBlue Swirl
555c621dc3eSAlexander Bulekov$(filter %/fuzz, $(TARGET_DIRS_RULES)): libqemuutil.a $(common-obj-y) \
556c621dc3eSAlexander Bulekov	$(qom-obj-y) $(crypto-user-obj-$(CONFIG_USER_ONLY))
557c621dc3eSAlexander Bulekov
5583b8593eeSMarkus ArmbrusterROM_DIRS = $(addprefix pc-bios/, $(ROMS))
5591338a4b7SMarkus ArmbrusterROM_DIRS_RULES=$(foreach t, all clean, $(addsuffix /$(t), $(ROM_DIRS)))
560a9c87304SMarc-André Lureau# Only keep -O and -g cflags
5611338a4b7SMarkus Armbruster.PHONY: $(ROM_DIRS_RULES)
5621338a4b7SMarkus Armbruster$(ROM_DIRS_RULES):
5631338a4b7SMarkus Armbruster	$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C $(dir $@) V="$(V)" TARGET_DIR="$(dir $@)" CFLAGS="$(filter -O% -g%,$(CFLAGS))" $(notdir $@),)
564c05ac895SPaul Brook
5658d358a5eSMarkus Armbruster.PHONY: recurse-all recurse-clean recurse-install
5661338a4b7SMarkus Armbrusterrecurse-all: $(addsuffix /all, $(TARGET_DIRS) $(ROM_DIRS))
567c621dc3eSAlexander Bulekovrecurse-fuzz: $(addsuffix /fuzz, $(TARGET_DIRS) $(ROM_DIRS))
5681338a4b7SMarkus Armbrusterrecurse-clean: $(addsuffix /clean, $(TARGET_DIRS) $(ROM_DIRS))
5691338a4b7SMarkus Armbrusterrecurse-install: $(addsuffix /install, $(TARGET_DIRS))
57047ae060eSMarkus Armbruster$(addsuffix /install, $(TARGET_DIRS)): all
5714aa42531Spbrook
572c17a18efSMarc-André Lureau$(BUILD_DIR)/version.o: $(SRC_PATH)/version.rc config-host.h
5730bdb12c7SPeter Maydell	$(call quiet-command,$(WINDRES) -I$(BUILD_DIR) -o $@ $<,"RC","version.o")
5745354e4d2SMarc-André Lureau
575c17a18efSMarc-André LureauMakefile: $(version-obj-y)
5763bc2f570SPaolo Bonzini
5773bc2f570SPaolo Bonzini######################################################################
5788a090705SPaolo Bonzini# Build libraries
5793bc2f570SPaolo Bonzini
580ebedb37cSPaolo Bonzinilibqemuutil.a: $(util-obj-y) $(trace-obj-y) $(stub-obj-y)
5815f9ff1efSXie Yongjilibvhost-user.a: $(libvhost-user-obj-y) $(util-obj-y) $(stub-obj-y)
5823bc2f570SPaolo Bonzini
5834fb240a4Sbellard######################################################################
5844fb240a4Sbellard
585ebedb37cSPaolo BonziniCOMMON_LDADDS = libqemuutil.a
5860ab8ed18SDaniel P. Berrange
5873c089e15SJuan Quintelaqemu-img.o: qemu-img-cmds.h
588153859beSStuart Brady
5895b76dd13SDaniel P. Berrangeqemu-img$(EXESUF): qemu-img.o $(authz-obj-y) $(block-obj-y) $(crypto-obj-y) $(io-obj-y) $(qom-obj-y) $(COMMON_LDADDS)
5905b76dd13SDaniel P. Berrangeqemu-nbd$(EXESUF): qemu-nbd.o $(authz-obj-y) $(block-obj-y) $(crypto-obj-y) $(io-obj-y) $(qom-obj-y) $(COMMON_LDADDS)
5915b76dd13SDaniel P. Berrangeqemu-io$(EXESUF): qemu-io.o $(authz-obj-y) $(block-obj-y) $(crypto-obj-y) $(io-obj-y) $(qom-obj-y) $(COMMON_LDADDS)
592*14837c64SKevin Wolfqemu-storage-daemon$(EXESUF): qemu-storage-daemon.o $(authz-obj-y) $(block-obj-y) $(crypto-obj-y) $(io-obj-y) $(qom-obj-y) $(storage-daemon-obj-y) $(COMMON_LDADDS)
5930a8e1acdSaliguori
5940ab8ed18SDaniel P. Berrangeqemu-bridge-helper$(EXESUF): qemu-bridge-helper.o $(COMMON_LDADDS)
5957b93fadfSCorey Bryant
5966a021536SGerd Hoffmannqemu-keymap$(EXESUF): qemu-keymap.o ui/input-keymap.o $(COMMON_LDADDS)
5976a021536SGerd Hoffmann
59872d277a7SGerd Hoffmannqemu-edid$(EXESUF): qemu-edid.o hw/display/edid-generate.o $(COMMON_LDADDS)
59972d277a7SGerd Hoffmann
6000ab8ed18SDaniel P. Berrangefsdev/virtfs-proxy-helper$(EXESUF): fsdev/virtfs-proxy-helper.o fsdev/9p-marshal.o fsdev/9p-iov-marshal.o $(COMMON_LDADDS)
60117bff52bSM. Mohan Kumar
6025b76dd13SDaniel 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)
603fe8fc5aeSPaolo Bonziniifdef CONFIG_MPATH
604fe8fc5aeSPaolo Bonziniscsi/qemu-pr-helper$(EXESUF): LIBS += -ludev -lmultipath -lmpathpersist
605fe8fc5aeSPaolo Bonziniendif
606b855f8d1SPaolo Bonzini
607077de81aSPaolo Bonziniqemu-img-cmds.h: $(SRC_PATH)/qemu-img-cmds.hx $(SRC_PATH)/scripts/hxtool
6080bdb12c7SPeter Maydell	$(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@,"GEN","$@")
609153859beSStuart Brady
610957f1f99SMichael Rothqemu-ga$(EXESUF): LIBS = $(LIBS_QGA)
61154c2e502SDunrong Huangqemu-ga$(EXESUF): QEMU_CFLAGS += -I qga/qapi-generated
612640e5404SMichael Roth
6136a021536SGerd Hoffmannqemu-keymap$(EXESUF): LIBS += $(XKBCOMMON_LIBS)
6146a021536SGerd Hoffmannqemu-keymap$(EXESUF): QEMU_CFLAGS += $(XKBCOMMON_CFLAGS)
6156a021536SGerd Hoffmann
616e6c42b96SMarkus Armbrusterqapi-py = $(SRC_PATH)/scripts/qapi/__init__.py \
617e6c42b96SMarkus Armbruster$(SRC_PATH)/scripts/qapi/commands.py \
618fb0bc835SMarkus Armbruster$(SRC_PATH)/scripts/qapi/common.py \
619fb0bc835SMarkus Armbruster$(SRC_PATH)/scripts/qapi/doc.py \
620e6c42b96SMarkus Armbruster$(SRC_PATH)/scripts/qapi/error.py \
621e6c42b96SMarkus Armbruster$(SRC_PATH)/scripts/qapi/events.py \
622e6c42b96SMarkus Armbruster$(SRC_PATH)/scripts/qapi/expr.py \
623e6c42b96SMarkus Armbruster$(SRC_PATH)/scripts/qapi/gen.py \
624e6c42b96SMarkus Armbruster$(SRC_PATH)/scripts/qapi/introspect.py \
625e6c42b96SMarkus Armbruster$(SRC_PATH)/scripts/qapi/parser.py \
626e6c42b96SMarkus Armbruster$(SRC_PATH)/scripts/qapi/schema.py \
627e6c42b96SMarkus Armbruster$(SRC_PATH)/scripts/qapi/source.py \
628e6c42b96SMarkus Armbruster$(SRC_PATH)/scripts/qapi/types.py \
629e6c42b96SMarkus Armbruster$(SRC_PATH)/scripts/qapi/visit.py \
630fb0bc835SMarkus Armbruster$(SRC_PATH)/scripts/qapi-gen.py
6318d3bc517SAvi Kivity
632fb0bc835SMarkus Armbrusterqga/qapi-generated/qga-qapi-types.c qga/qapi-generated/qga-qapi-types.h \
633fb0bc835SMarkus Armbrusterqga/qapi-generated/qga-qapi-visit.c qga/qapi-generated/qga-qapi-visit.h \
634eb815e24SMarkus Armbrusterqga/qapi-generated/qga-qapi-commands.h qga/qapi-generated/qga-qapi-commands.c \
63500ca24ffSMarkus Armbrusterqga/qapi-generated/qga-qapi-init-commands.h qga/qapi-generated/qga-qapi-init-commands.c \
636fb0bc835SMarkus Armbrusterqga/qapi-generated/qga-qapi-doc.texi: \
637fb0bc835SMarkus Armbrusterqga/qapi-generated/qapi-gen-timestamp ;
638fb0bc835SMarkus Armbrusterqga/qapi-generated/qapi-gen-timestamp: $(SRC_PATH)/qga/qapi-schema.json $(qapi-py)
6390d6b93deSMatthias Maier	$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-gen.py \
640fb0bc835SMarkus Armbruster		-o qga/qapi-generated -p "qga-" $<, \
641fb0bc835SMarkus Armbruster		"GEN","$(@:%-timestamp=%)")
642fb0bc835SMarkus Armbruster	@>$@
643e3d4d252SMichael Roth
644bf582c34SEric Blakeqapi-modules = $(SRC_PATH)/qapi/qapi-schema.json \
645bf582c34SEric Blake               $(QAPI_MODULES:%=$(SRC_PATH)/qapi/%.json)
646be13d46dSMax Reitz
647bf582c34SEric Blake$(GENERATED_QAPI_FILES): qapi-gen-timestamp ;
648fb0bc835SMarkus Armbrusterqapi-gen-timestamp: $(qapi-modules) $(qapi-py)
6490d6b93deSMatthias Maier	$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-gen.py \
650eb815e24SMarkus Armbruster		-o "qapi" -b $<, \
651fb0bc835SMarkus Armbruster		"GEN","$(@:%-timestamp=%)")
652fb0bc835SMarkus Armbruster	@>$@
653e3193601SAnthony Liguori
65400ca24ffSMarkus ArmbrusterQGALIB_GEN=$(addprefix qga/qapi-generated/, qga-qapi-types.h qga-qapi-visit.h qga-qapi-commands.h qga-qapi-init-commands.h)
6557a0b7ebaSMarc-André Lureau$(qga-obj-y): $(QGALIB_GEN)
656957f1f99SMichael Roth
6570ab8ed18SDaniel P. Berrangeqemu-ga$(EXESUF): $(qga-obj-y) $(COMMON_LDADDS)
658fafcaf1dSMichael Roth	$(call LINK, $^)
65948ff7a62SMichael Roth
6609dacf32dSYossi Hindinifdef QEMU_GA_MSI_ENABLED
6619dacf32dSYossi HindinQEMU_GA_MSI=qemu-ga-$(ARCH).msi
6629dacf32dSYossi Hindin
6630a18750fSLeonid Blochmsi: $(QEMU_GA_MSI)
6649dacf32dSYossi Hindin
665fafcaf1dSMichael Roth$(QEMU_GA_MSI): qemu-ga.exe $(QGA_VSS_PROVIDER)
6669dacf32dSYossi Hindin
6679dacf32dSYossi Hindin$(QEMU_GA_MSI): config-host.mak
6689dacf32dSYossi Hindin
669decdfbd2SLeonid Bloch$(QEMU_GA_MSI):  $(SRC_PATH)/qga/installer/qemu-ga.wxs
670decdfbd2SLeonid 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)" \
6710bdb12c7SPeter Maydell	wixl -o $@ $(QEMU_GA_MSI_ARCH) $(QEMU_GA_MSI_WITH_VSS) $(QEMU_GA_MSI_MINGW_DLL_PATH) $<,"WIXL","$@")
6729dacf32dSYossi Hindinelse
6739dacf32dSYossi Hindinmsi:
67415b19ed8SMichael Roth	@echo "MSI build not configured or dependency resolution failed (reconfigure with --enable-guest-agent-msi option)"
6759dacf32dSYossi Hindinendif
6769dacf32dSYossi Hindin
677fafcaf1dSMichael Rothifneq ($(EXESUF),)
678fafcaf1dSMichael Roth.PHONY: qemu-ga
679fafcaf1dSMichael Rothqemu-ga: qemu-ga$(EXESUF) $(QGA_VSS_PROVIDER) $(QEMU_GA_MSI)
680fafcaf1dSMichael Rothendif
681fafcaf1dSMichael Roth
6821b9d35f3SViktor Prutyanovelf2dmp$(EXESUF): $(elf2dmp-obj-y)
6833fa2d384SViktor Prutyanov	$(call LINK, $^)
6843fa2d384SViktor Prutyanov
685b1449edbSKamil Rytarowskiifdef CONFIG_IVSHMEM
6860ab8ed18SDaniel P. Berrangeivshmem-client$(EXESUF): $(ivshmem-client-obj-y) $(COMMON_LDADDS)
687a75eb03bSDavid Marchand	$(call LINK, $^)
6880ab8ed18SDaniel P. Berrangeivshmem-server$(EXESUF): $(ivshmem-server-obj-y) $(COMMON_LDADDS)
689a75eb03bSDavid Marchand	$(call LINK, $^)
690b1449edbSKamil Rytarowskiendif
691d59a031cSMarc-André Lureauvhost-user-scsi$(EXESUF): $(vhost-user-scsi-obj-y) libvhost-user.a
69249cc0340SFelipe Franciosi	$(call LINK, $^)
693406d2aa2SChangpeng Liuvhost-user-blk$(EXESUF): $(vhost-user-blk-obj-y) libvhost-user.a
694406d2aa2SChangpeng Liu	$(call LINK, $^)
6950f645ba1SMarcel Apfelbaum
6960f645ba1SMarcel Apfelbaumrdmacm-mux$(EXESUF): LIBS += "-libumad"
697a5d2f6f8SYuval Shaiardmacm-mux$(EXESUF): $(rdmacm-mux-obj-y) $(COMMON_LDADDS)
698a5d2f6f8SYuval Shaia	$(call LINK, $^)
699a75eb03bSDavid Marchand
7004f8bde99SStefan Hajnoczi# relies on Linux-specific syscalls
7012405f3c0SDr. David Alan Gilbertifeq ($(CONFIG_LINUX)$(CONFIG_SECCOMP)$(CONFIG_LIBCAP_NG),yyy)
70281bfc42dSDr. David Alan Gilbertvirtiofsd$(EXESUF): $(virtiofsd-obj-y) libvhost-user.a $(COMMON_LDADDS)
70381bfc42dSDr. David Alan Gilbert	$(call LINK, $^)
70481bfc42dSDr. David Alan Gilbertendif
70581bfc42dSDr. David Alan Gilbert
706d52c454aSMarc-André Lureauvhost-user-gpu$(EXESUF): $(vhost-user-gpu-obj-y) $(libvhost-user-obj-y) libqemuutil.a libqemustub.a
707d52c454aSMarc-André Lureau	$(call LINK, $^)
708d52c454aSMarc-André Lureau
70906914c97SMarc-André Lureauifdef CONFIG_VHOST_USER_INPUT
71006914c97SMarc-André Lureauifdef CONFIG_LINUX
71106914c97SMarc-André Lureauvhost-user-input$(EXESUF): $(vhost-user-input-obj-y) libvhost-user.a libqemuutil.a
71206914c97SMarc-André Lureau	$(call LINK, $^)
71306914c97SMarc-André Lureau
71406914c97SMarc-André Lureau# build by default, do not install
71506914c97SMarc-André Lureauall: vhost-user-input$(EXESUF)
71606914c97SMarc-André Lureauendif
71706914c97SMarc-André Lureauendif
71806914c97SMarc-André Lureau
7190c0c1fd9SMarc Marimodule_block.h: $(SRC_PATH)/scripts/modules/module_block.py config-host.mak
7200c0c1fd9SMarc Mari	$(call quiet-command,$(PYTHON) $< $@ \
7210c0c1fd9SMarc Mari	$(addprefix $(SRC_PATH)/,$(patsubst %.mo,%.c,$(block-obj-m))), \
7220bdb12c7SPeter Maydell	"GEN","$@")
7230c0c1fd9SMarc Mari
724990e6a27SAlex Bennéeifdef CONFIG_GCOV
725990e6a27SAlex Bennée.PHONY: clean-coverage
726990e6a27SAlex Bennéeclean-coverage:
727990e6a27SAlex Bennée	$(call quiet-command, \
728990e6a27SAlex Bennée		find . \( -name '*.gcda' -o -name '*.gcov' \) -type f -exec rm {} +, \
729990e6a27SAlex Bennée		"CLEAN", "coverage files")
730990e6a27SAlex Bennéeendif
731990e6a27SAlex Bennée
7321338a4b7SMarkus Armbrusterclean: recurse-clean
7332d80ae89Sbellard# avoid old build problems by removing potentially incorrect old files
73425be210fSJuan 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
735df2943baSMichael S. Tsirkin	rm -f qemu-options.def
7369dacf32dSYossi Hindin	rm -f *.msi
73723858f40SLaszlo Ersek	find . \( -name '*.so' -o -name '*.dll' -o -name '*.mo' -o -name '*.[oda]' \) -type f \
73823858f40SLaszlo Ersek		! -path ./roms/edk2/ArmPkg/Library/GccLto/liblto-aarch64.a \
73923858f40SLaszlo Ersek		! -path ./roms/edk2/ArmPkg/Library/GccLto/liblto-arm.a \
74023858f40SLaszlo Ersek		! -path ./roms/edk2/BaseTools/Source/Python/UPT/Dll/sqlite3.dll \
74123858f40SLaszlo Ersek		-exec rm {} +
74226ce90fdSLaszlo Ersek	rm -f $(edk2-decompressed)
7430814465aSPaolo Bonzini	rm -f $(filter-out %.tlb,$(TOOLS)) $(HELPERS-y) TAGS cscope.* *.pod *~ */*~
744b855f8d1SPaolo Bonzini	rm -f fsdev/*.pod scsi/*.pod
74507b44ce9SBlue Swirl	rm -f qemu-img-cmds.h
746d98bc0b6SGerd Hoffmann	rm -f ui/shader/*-vert.h ui/shader/*-frag.h
7473dff199cSLaurent Vivier	@# May not be present in generated-files-y
748eac236eaSLluís Vilanova	rm -f trace/generated-tracers-dtrace.dtrace*
749eac236eaSLluís Vilanova	rm -f trace/generated-tracers-dtrace.h*
7503dff199cSLaurent Vivier	rm -f $(foreach f,$(generated-files-y),$(f) $(f)-timestamp)
751fb0bc835SMarkus Armbruster	rm -f qapi-gen-timestamp
75254c2e502SDunrong Huang	rm -rf qga/qapi-generated
753e92af6ecSJuan Quintela	rm -f config-all-devices.mak
75431e31b8aSbellard
75534bb443eSAnthony LiguoriVERSION ?= $(shell cat VERSION)
75634bb443eSAnthony Liguori
75734bb443eSAnthony Liguoridist: qemu-$(VERSION).tar.bz2
75834bb443eSAnthony Liguori
75934bb443eSAnthony Liguoriqemu-%.tar.bz2:
76034bb443eSAnthony Liguori	$(SRC_PATH)/scripts/make-release "$(SRC_PATH)" "$(patsubst qemu-%.tar.bz2,%,$@)"
76134bb443eSAnthony Liguori
7625f71eac0SPeter Maydelldefine clean-manual =
7631290e671SPeter Maydellrm -rf $(MANUAL_BUILDDIR)/$1/_static
7641290e671SPeter Maydellrm -f $(MANUAL_BUILDDIR)/$1/objects.inv $(MANUAL_BUILDDIR)/$1/searchindex.js $(MANUAL_BUILDDIR)/$1/*.html
7655f71eac0SPeter Maydellendef
7665f71eac0SPeter Maydell
7677d13299dSbellarddistclean: clean
768e13c59faSPeter Maydell	rm -f config-host.mak config-host.h* config-host.ld $(DOCS) qemu-options.texi qemu-monitor.texi qemu-monitor-info.texi
7692038f8c8SPaolo Bonzini	rm -f tests/tcg/config-*.mak
770ae219359SThomas Huth	rm -f config-all-devices.mak config-all-disas.mak config.status
771e92af6ecSJuan Quintela	rm -f $(SUBDIR_DEVICES_MAK)
772ae219359SThomas Huth	rm -f po/*.mo tests/qemu-iotests/common.env
773fc8e320eSMagnus Damm	rm -f roms/seabios/config.mak roms/vgabios/config.mak
77426fffe29SEmilio G. Cota	rm -f qemu-plugins-ld.symbols qemu-plugins-ld64.symbols
775793553acSAlexandre Raymond	rm -f config.log
77667ed96f9SPeter Maydell	rm -f linux-headers/asm
777d59157eaSPaolo Bonzini	rm -f docs/version.texi
778d59157eaSPaolo Bonzini	rm -f docs/interop/qemu-ga-qapi.texi docs/interop/qemu-qmp-qapi.texi
779d59157eaSPaolo Bonzini	rm -f docs/interop/qemu-qmp-ref.7 docs/interop/qemu-ga-ref.7
780d59157eaSPaolo Bonzini	rm -f docs/interop/qemu-qmp-ref.txt docs/interop/qemu-ga-ref.txt
781d59157eaSPaolo Bonzini	rm -f docs/interop/qemu-qmp-ref.pdf docs/interop/qemu-ga-ref.pdf
782d59157eaSPaolo Bonzini	rm -f docs/interop/qemu-qmp-ref.html docs/interop/qemu-ga-ref.html
78381f33401SPeter Maydell	rm -rf .doctrees
7845f71eac0SPeter Maydell	$(call clean-manual,devel)
7855f71eac0SPeter Maydell	$(call clean-manual,interop)
7860783a732SPeter Maydell	$(call clean-manual,specs)
7870928523aSPeter Maydell	$(call clean-manual,system)
78865c3542bSPeter Maydell	$(call clean-manual,tools)
78909147930SPaolo Bonzini	$(call clean-manual,user)
7902b1f35b9SAlex Bennée	for d in $(TARGET_DIRS); do \
791bc1b050dSbellard	rm -rf $$d || exit 1 ; \
79276bc6838Sbellard        done
793d9840e25STomoki Sekiyama	rm -Rf .sdk
794fb8597bbSEd Maste	if test -f dtc/version_gen.h; then $(MAKE) $(DTC_MAKE_ARGS) clean; fi
7957d13299dSbellard
79606e7772fSGerd HoffmannKEYMAPS=da     en-gb  et  fr     fr-ch  is  lt  no  pt-br  sv \
797fed4a9adSbellardar      de     en-us  fi  fr-be  hr     it  lv  nl         pl  ru     th \
79826b1cbf8SGerd Hoffmannde-ch  es     fo  fr-ca  hu     ja  mk  pt  sl     tr \
7993751e722SJan Krupabepo    cz
800fed4a9adSbellard
80177755340Sthsifdef INSTALL_BLOBS
80232eb2da3SBruce RogersBLOBS=bios.bin bios-256k.bin bios-microvm.bin sgabios.bin vgabios.bin vgabios-cirrus.bin \
8037a4dfd1eSGerd Hoffmannvgabios-stdvga.bin vgabios-vmware.bin vgabios-qxl.bin vgabios-virtio.bin \
8040a87fd69SGerd Hoffmannvgabios-ramfb.bin vgabios-bochs-display.bin vgabios-ati.bin \
805b2ce76a0SThomas Huthopenbios-sparc32 openbios-sparc64 openbios-ppc QEMU,tcx.bin QEMU,cgthree.bin \
8065ee8ad71SAlex Williamsonpxe-e1000.rom pxe-eepro100.rom pxe-ne2k_pci.rom \
8075ee8ad71SAlex Williamsonpxe-pcnet.rom pxe-rtl8139.rom pxe-virtio.rom \
8089fd02979SSander Eikelenboomefi-e1000.rom efi-eepro100.rom efi-ne2k_pci.rom \
8099fd02979SSander Eikelenboomefi-pcnet.rom efi-rtl8139.rom efi-virtio.rom \
81045027808SGerd Hoffmannefi-e1000e.rom efi-vmxnet3.rom \
811b3ce38dcSPhilippe Mathieu-Daudéqemu-nsis.bmp \
8124b387f9eSBALATON Zoltanbamboo.dtb canyonlands.dtb petalogix-s3adsp1800.dtb petalogix-ml605.dtb \
8132785dc7bSStefano Garzarellamultiboot.bin linuxboot.bin linuxboot_dma.bin kvmvapic.bin pvh.bin \
8146c5359e1SChristian Borntraegers390-ccw.img s390-netboot.img \
815744a928cSAlexey Kardashevskiyslof.bin skiboot.lid \
8160c6ab8c9SCole Robinsonpalcode-clipper \
81782e65fe0SBALATON Zoltanu-boot.e500 u-boot-sam460-20100605.bin \
81843ad2564SRichard Hendersonqemu_vga.ndrv \
81926ce90fdSLaszlo Ersekedk2-licenses.txt \
82091f3a2f0SAlistair Francishppa-firmware.img \
82191f3a2f0SAlistair Francisopensbi-riscv32-virt-fw_jump.bin \
82291f3a2f0SAlistair Francisopensbi-riscv64-sifive_u-fw_jump.bin opensbi-riscv64-virt-fw_jump.bin
82391f3a2f0SAlistair Francis
82426ce90fdSLaszlo Ersek
82526ce90fdSLaszlo ErsekDESCS=50-edk2-i386-secure.json 50-edk2-x86_64-secure.json \
82626ce90fdSLaszlo Ersek60-edk2-aarch64.json 60-edk2-arm.json 60-edk2-i386.json 60-edk2-x86_64.json
82777755340Sthselse
82877755340SthsBLOBS=
82926ce90fdSLaszlo ErsekDESCS=
83077755340Sthsendif
83177755340Sths
832336cfef4SPeter Maydell# Note that we manually filter-out the non-Sphinx documentation which
83327a296fcSPeter Maydell# is currently built into the docs/interop directory in the build tree,
83427a296fcSPeter Maydell# and also any sphinx-built manpages.
8355f71eac0SPeter Maydelldefine install-manual =
8361290e671SPeter Maydellfor d in $$(cd $(MANUAL_BUILDDIR) && find $1 -type d); do $(INSTALL_DIR) "$(DESTDIR)$(qemu_docdir)/$$d"; done
83727a296fcSPeter 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
8385f71eac0SPeter Maydellendef
8395f71eac0SPeter Maydell
8405f71eac0SPeter Maydell# Note that we deliberately do not install the "devel" manual: it is
8415f71eac0SPeter Maydell# for QEMU developers, and not interesting to our users.
8425f71eac0SPeter Maydell.PHONY: install-sphinxdocs
8435f71eac0SPeter Maydellinstall-sphinxdocs: sphinxdocs
8445f71eac0SPeter Maydell	$(call install-manual,interop)
8450783a732SPeter Maydell	$(call install-manual,specs)
8460928523aSPeter Maydell	$(call install-manual,system)
84765c3542bSPeter Maydell	$(call install-manual,tools)
84809147930SPaolo Bonzini	$(call install-manual,user)
8495f71eac0SPeter Maydell
8505f71eac0SPeter Maydellinstall-doc: $(DOCS) install-sphinxdocs
851d7dd65baSEduardo Habkost	$(INSTALL_DIR) "$(DESTDIR)$(qemu_docdir)"
85222108f33SStefan Hajnoczi	$(INSTALL_DATA) $(MANUAL_BUILDDIR)/index.html "$(DESTDIR)$(qemu_docdir)"
853d59157eaSPaolo Bonzini	$(INSTALL_DATA) docs/interop/qemu-qmp-ref.html "$(DESTDIR)$(qemu_docdir)"
854d59157eaSPaolo Bonzini	$(INSTALL_DATA) docs/interop/qemu-qmp-ref.txt "$(DESTDIR)$(qemu_docdir)"
85596d409ebSJuan Quintelaifdef CONFIG_POSIX
85658f8aeadSaliguori	$(INSTALL_DIR) "$(DESTDIR)$(mandir)/man1"
857d06118bfSPeter Maydell	$(INSTALL_DATA) $(MANUAL_BUILDDIR)/system/qemu.1 "$(DESTDIR)$(mandir)/man1"
85856e8bdd4SMarc-André Lureau	$(INSTALL_DIR) "$(DESTDIR)$(mandir)/man7"
859d59157eaSPaolo Bonzini	$(INSTALL_DATA) docs/interop/qemu-qmp-ref.7 "$(DESTDIR)$(mandir)/man7"
860acab923dSPeter Maydell	$(INSTALL_DATA) $(MANUAL_BUILDDIR)/system/qemu-block-drivers.7 "$(DESTDIR)$(mandir)/man7"
8611bf84a1eSKashyap Chamarthy	$(INSTALL_DATA) $(MANUAL_BUILDDIR)/system/qemu-cpu-models.7 "$(DESTDIR)$(mandir)/man7"
862c932ce31SPaolo Bonziniifeq ($(CONFIG_TOOLS),y)
863a08b4a9fSPeter Maydell	$(INSTALL_DATA) $(MANUAL_BUILDDIR)/tools/qemu-img.1 "$(DESTDIR)$(mandir)/man1"
86458f8aeadSaliguori	$(INSTALL_DIR) "$(DESTDIR)$(mandir)/man8"
865a08b4a9fSPeter Maydell	$(INSTALL_DATA) $(MANUAL_BUILDDIR)/tools/qemu-nbd.8 "$(DESTDIR)$(mandir)/man8"
86638954dcaSpbrookendif
86762dd1048SDaniel P. Berrangéifdef CONFIG_TRACE_SYSTEMTAP
868a08b4a9fSPeter Maydell	$(INSTALL_DATA) $(MANUAL_BUILDDIR)/tools/qemu-trace-stap.1 "$(DESTDIR)$(mandir)/man1"
86962dd1048SDaniel P. Berrangéendif
870665b5d0dSMarc-André Lureauifneq (,$(findstring qemu-ga,$(TOOLS)))
871b53c54c6SPeter Maydell	$(INSTALL_DATA) $(MANUAL_BUILDDIR)/interop/qemu-ga.8 "$(DESTDIR)$(mandir)/man8"
872d59157eaSPaolo Bonzini	$(INSTALL_DATA) docs/interop/qemu-ga-ref.html "$(DESTDIR)$(qemu_docdir)"
873d59157eaSPaolo Bonzini	$(INSTALL_DATA) docs/interop/qemu-ga-ref.txt "$(DESTDIR)$(qemu_docdir)"
874d59157eaSPaolo Bonzini	$(INSTALL_DATA) docs/interop/qemu-ga-ref.7 "$(DESTDIR)$(mandir)/man7"
875665b5d0dSMarc-André Lureauendif
8768a3e8f7fSAndreas Färberendif
877a2d8f1beSM. Mohan Kumarifdef CONFIG_VIRTFS
878a2d8f1beSM. Mohan Kumar	$(INSTALL_DIR) "$(DESTDIR)$(mandir)/man1"
879a08b4a9fSPeter Maydell	$(INSTALL_DATA) $(MANUAL_BUILDDIR)/tools/virtfs-proxy-helper.1 "$(DESTDIR)$(mandir)/man1"
880a2d8f1beSM. Mohan Kumarendif
8816a7e2bbeSStefan Hajnocziifeq ($(CONFIG_LINUX)$(CONFIG_SECCOMP)$(CONFIG_LIBCAP_NG),yyy)
882a08b4a9fSPeter Maydell	$(INSTALL_DATA) $(MANUAL_BUILDDIR)/tools/virtiofsd.1 "$(DESTDIR)$(mandir)/man1"
8836a7e2bbeSStefan Hajnocziendif
884b5ec5ce0Sjohn cooper
885e2d87bffSEduardo Habkostinstall-datadir:
886e2d87bffSEduardo Habkost	$(INSTALL_DIR) "$(DESTDIR)$(qemu_datadir)"
887e2d87bffSEduardo Habkost
888f2e3978bSLaszlo Ersekinstall-localstatedir:
889f2e3978bSLaszlo Ersekifdef CONFIG_POSIX
890f2e3978bSLaszlo Ersekifneq (,$(findstring qemu-ga,$(TOOLS)))
891f2e3978bSLaszlo Ersek	$(INSTALL_DIR) "$(DESTDIR)$(qemu_localstatedir)"/run
892f2e3978bSLaszlo Ersekendif
893f2e3978bSLaszlo Ersekendif
894f2e3978bSLaszlo Ersek
895a8260d38SDaniel P. BerrangéICON_SIZES=16x16 24x24 32x32 48x48 64x64 128x128 256x256 512x512
896e2d87bffSEduardo Habkost
89754cb65d8SEmilio G. Cotainstall-includedir:
89854cb65d8SEmilio G. Cota	$(INSTALL_DIR) "$(DESTDIR)$(includedir)"
89954cb65d8SEmilio G. Cota
90054cb65d8SEmilio G. Cotainstall: all $(if $(BUILD_DOCS),install-doc) \
90154cb65d8SEmilio G. Cota	install-datadir install-localstatedir install-includedir \
9021338a4b7SMarkus Armbruster	$(if $(INSTALL_BLOBS),$(edk2-decompressed)) \
9031338a4b7SMarkus Armbruster	recurse-install
904932a79dfSthsifneq ($(TOOLS),)
9050814465aSPaolo Bonzini	$(call install-prog,$(TOOLS),$(DESTDIR)$(bindir))
906932a79dfSthsendif
907e3be6f0eSFam Zhengifneq ($(CONFIG_MODULES),)
908e3be6f0eSFam Zheng	$(INSTALL_DIR) "$(DESTDIR)$(qemu_moddir)"
9092115182fSMichael Tokarev	for s in $(modules-m:.mo=$(DSOSUF)); do \
9102115182fSMichael Tokarev		t="$(DESTDIR)$(qemu_moddir)/$$(echo $$s | tr / -)"; \
911264f8b4fSMichael Tokarev		$(INSTALL_LIB) $$s "$$t"; \
9122115182fSMichael Tokarev		test -z "$(STRIP)" || $(STRIP) "$$t"; \
913e3be6f0eSFam Zheng	done
914e3be6f0eSFam Zhengendif
9157b93fadfSCorey Bryantifneq ($(HELPERS-y),)
9160d659426SMichael Tokarev	$(call install-prog,$(HELPERS-y),$(DESTDIR)$(libexecdir))
9177b93fadfSCorey Bryantendif
918d52c454aSMarc-André Lureauifneq ($(vhost-user-json-y),)
919d52c454aSMarc-André Lureau	$(INSTALL_DIR) "$(DESTDIR)$(qemu_datadir)/vhost-user/"
920d52c454aSMarc-André Lureau	for x in $(vhost-user-json-y); do \
921d52c454aSMarc-André Lureau		$(INSTALL_DATA) $$x "$(DESTDIR)$(qemu_datadir)/vhost-user/"; \
922d52c454aSMarc-André Lureau	done
923d52c454aSMarc-André Lureauendif
92462dd1048SDaniel P. Berrangéifdef CONFIG_TRACE_SYSTEMTAP
92562dd1048SDaniel P. Berrangé	$(INSTALL_PROG) "scripts/qemu-trace-stap" $(DESTDIR)$(bindir)
92662dd1048SDaniel P. Berrangéendif
92777755340Sthsifneq ($(BLOBS),)
92877755340Sths	set -e; for x in $(BLOBS); do \
9296aae2a2eSEduardo Habkost		$(INSTALL_DATA) $(SRC_PATH)/pc-bios/$$x "$(DESTDIR)$(qemu_datadir)"; \
930ad064840Spbrook	done
93177755340Sthsendif
93226ce90fdSLaszlo Ersekifdef INSTALL_BLOBS
93326ce90fdSLaszlo Ersek	set -e; for x in $(edk2-decompressed); do \
93426ce90fdSLaszlo Ersek		$(INSTALL_DATA) $$x "$(DESTDIR)$(qemu_datadir)"; \
93526ce90fdSLaszlo Ersek	done
93626ce90fdSLaszlo Ersekendif
93726ce90fdSLaszlo Ersekifneq ($(DESCS),)
93826ce90fdSLaszlo Ersek	$(INSTALL_DIR) "$(DESTDIR)$(qemu_datadir)/firmware"
93926ce90fdSLaszlo Ersek	set -e; tmpf=$$(mktemp); trap 'rm -f -- "$$tmpf"' EXIT; \
94026ce90fdSLaszlo Ersek	for x in $(DESCS); do \
941177cd674SOlaf Hering		sed -e 's,@DATADIR@,$(qemu_datadir),' \
94226ce90fdSLaszlo Ersek			"$(SRC_PATH)/pc-bios/descriptors/$$x" > "$$tmpf"; \
94326ce90fdSLaszlo Ersek		$(INSTALL_DATA) "$$tmpf" \
94426ce90fdSLaszlo Ersek			"$(DESTDIR)$(qemu_datadir)/firmware/$$x"; \
94526ce90fdSLaszlo Ersek	done
94626ce90fdSLaszlo Ersekendif
947a8260d38SDaniel P. Berrangé	for s in $(ICON_SIZES); do \
9486c11dda9SStefan Hajnoczi		mkdir -p "$(DESTDIR)$(qemu_icondir)/hicolor/$${s}/apps"; \
949a8260d38SDaniel P. Berrangé		$(INSTALL_DATA) $(SRC_PATH)/ui/icons/qemu_$${s}.png \
9506c11dda9SStefan Hajnoczi			"$(DESTDIR)$(qemu_icondir)/hicolor/$${s}/apps/qemu.png"; \
951a8260d38SDaniel P. Berrangé	done; \
9526c11dda9SStefan Hajnoczi	mkdir -p "$(DESTDIR)$(qemu_icondir)/hicolor/32x32/apps"; \
953a8260d38SDaniel P. Berrangé	$(INSTALL_DATA) $(SRC_PATH)/ui/icons/qemu_32x32.bmp \
9546c11dda9SStefan Hajnoczi		"$(DESTDIR)$(qemu_icondir)/hicolor/32x32/apps/qemu.bmp"; \
9556c11dda9SStefan Hajnoczi	mkdir -p "$(DESTDIR)$(qemu_icondir)/hicolor/scalable/apps"; \
956a8260d38SDaniel P. Berrangé	$(INSTALL_DATA) $(SRC_PATH)/ui/icons/qemu.svg \
9576c11dda9SStefan Hajnoczi		"$(DESTDIR)$(qemu_icondir)/hicolor/scalable/apps/qemu.svg"
9586c11dda9SStefan Hajnoczi	mkdir -p "$(DESTDIR)$(qemu_desktopdir)"
95967ea9546SDaniel P. Berrangé	$(INSTALL_DATA) $(SRC_PATH)/ui/qemu.desktop \
9606c11dda9SStefan Hajnoczi		"$(DESTDIR)$(qemu_desktopdir)/qemu.desktop"
9612a6b5372SMichael Tokarevifdef CONFIG_GTK
962834574eaSAnthony Liguori	$(MAKE) -C po $@
963834574eaSAnthony Liguoriendif
96454cb65d8SEmilio G. Cotaifeq ($(CONFIG_PLUGIN),y)
96554cb65d8SEmilio G. Cota	$(INSTALL_DATA) $(SRC_PATH)/include/qemu/qemu-plugin.h "$(DESTDIR)$(includedir)/qemu-plugin.h"
96654cb65d8SEmilio G. Cotaendif
9676aae2a2eSEduardo Habkost	$(INSTALL_DIR) "$(DESTDIR)$(qemu_datadir)/keymaps"
96818be8d77Sblueswir1	set -e; for x in $(KEYMAPS); do \
9696aae2a2eSEduardo Habkost		$(INSTALL_DATA) $(SRC_PATH)/pc-bios/keymaps/$$x "$(DESTDIR)$(qemu_datadir)/keymaps"; \
970ad064840Spbrook	done
9711412cf58SDaniel P. Berrange	$(INSTALL_DATA) $(BUILD_DIR)/trace-events-all "$(DESTDIR)$(qemu_datadir)/trace-events-all"
972612384d7Sbellard
973ae5fdc81SFam Zheng.PHONY: ctags
974ae5fdc81SFam Zhengctags:
975ac99c624SSergey Fedorov	rm -f tags
976ae5fdc81SFam Zheng	find "$(SRC_PATH)" -name '*.[hc]' -exec ctags --append {} +
977ae5fdc81SFam Zheng
97821d4e8e3SAlexandre Bique.PHONY: TAGS
979367e86e8SbellardTAGS:
980ac99c624SSergey Fedorov	rm -f TAGS
981b1999e87SDavid Gibson	find "$(SRC_PATH)" -name '*.[hc]' -exec etags --append {} +
98231e31b8aSbellard
9836688bc6dSbellardcscope:
984eaa2ddbbSFam Zheng	rm -f "$(SRC_PATH)"/cscope.*
985eaa2ddbbSFam Zheng	find "$(SRC_PATH)/" -name "*.[chsS]" -print | sed 's,^\./,,' > "$(SRC_PATH)/cscope.files"
986eaa2ddbbSFam Zheng	cscope -b -i"$(SRC_PATH)/cscope.files"
9876688bc6dSbellard
988d98bc0b6SGerd Hoffmann# opengl shader programs
989d98bc0b6SGerd Hoffmannui/shader/%-vert.h: $(SRC_PATH)/ui/shader/%.vert $(SRC_PATH)/scripts/shaderinclude.pl
990d98bc0b6SGerd Hoffmann	@mkdir -p $(dir $@)
991d98bc0b6SGerd Hoffmann	$(call quiet-command,\
992d98bc0b6SGerd Hoffmann		perl $(SRC_PATH)/scripts/shaderinclude.pl $< > $@,\
9930bdb12c7SPeter Maydell		"VERT","$@")
994d98bc0b6SGerd Hoffmann
995d98bc0b6SGerd Hoffmannui/shader/%-frag.h: $(SRC_PATH)/ui/shader/%.frag $(SRC_PATH)/scripts/shaderinclude.pl
996d98bc0b6SGerd Hoffmann	@mkdir -p $(dir $@)
997d98bc0b6SGerd Hoffmann	$(call quiet-command,\
998d98bc0b6SGerd Hoffmann		perl $(SRC_PATH)/scripts/shaderinclude.pl $< > $@,\
9990bdb12c7SPeter Maydell		"FRAG","$@")
1000d98bc0b6SGerd Hoffmann
100146e19e14SGerd Hoffmannui/shader.o: $(SRC_PATH)/ui/shader.c \
10022e1d70b9SGerd Hoffmann	ui/shader/texture-blit-vert.h \
10032e1d70b9SGerd Hoffmann	ui/shader/texture-blit-flip-vert.h \
10042e1d70b9SGerd Hoffmann	ui/shader/texture-blit-frag.h
1005cd2bc889SGerd Hoffmann
10063ef693a0Sbellard# documentation
1007e8518c92SMarkus ArmbrusterMAKEINFO=makeinfo
1008d59157eaSPaolo BonziniMAKEINFOINCLUDES= -I docs -I $(<D) -I $(@D)
1009d59157eaSPaolo BonziniMAKEINFOFLAGS=--no-split --number-sections $(MAKEINFOINCLUDES)
1010e8338fdbSMarc-André LureauTEXI2PODFLAGS=$(MAKEINFOINCLUDES) -DVERSION="$(VERSION)" -DCONFDIR="$(qemu_confdir)"
1011d59157eaSPaolo BonziniTEXI2PDFFLAGS=$(if $(V),,--quiet) -I $(SRC_PATH) $(MAKEINFOINCLUDES)
101256e8bdd4SMarc-André Lureau
1013e8338fdbSMarc-André Lureaudocs/version.texi: $(SRC_PATH)/VERSION config-host.mak
1014e8338fdbSMarc-André Lureau	$(call quiet-command,(\
1015e8338fdbSMarc-André Lureau		echo "@set VERSION $(VERSION)" && \
1016e8338fdbSMarc-André Lureau		echo "@set CONFDIR $(qemu_confdir)" \
1017e8338fdbSMarc-André Lureau	)> $@,"GEN","$@")
1018fea346f5SPeter Maydell
101944cb280dSPaolo Bonzini%.html: %.texi docs/version.texi
1020e9ee06bdSMarc-André Lureau	$(call quiet-command,LC_ALL=C $(MAKEINFO) $(MAKEINFOFLAGS) --no-headers \
1021e9ee06bdSMarc-André Lureau	--html $< -o $@,"GEN","$@")
10223ef693a0Sbellard
102344cb280dSPaolo Bonzini%.info: %.texi docs/version.texi
1024e9ee06bdSMarc-André Lureau	$(call quiet-command,$(MAKEINFO) $(MAKEINFOFLAGS) $< -o $@,"GEN","$@")
1025f3548328Sbellard
102644cb280dSPaolo Bonzini%.txt: %.texi docs/version.texi
1027f8bab10bSMarc-André Lureau	$(call quiet-command,LC_ALL=C $(MAKEINFO) $(MAKEINFOFLAGS) --no-headers \
1028f8bab10bSMarc-André Lureau	--plaintext $< -o $@,"GEN","$@")
1029f8bab10bSMarc-André Lureau
103044cb280dSPaolo Bonzini%.pdf: %.texi docs/version.texi
1031d59157eaSPaolo Bonzini	$(call quiet-command,texi2pdf $(TEXI2PDFFLAGS) $< -o $@,"GEN","$@")
1032bd7f9747SMarkus Armbruster
10335f71eac0SPeter Maydell# Sphinx builds all its documentation at once in one invocation
10345f71eac0SPeter Maydell# and handles "don't rebuild things unless necessary" itself.
10355f71eac0SPeter Maydell# The '.doctrees' files are cached information to speed this up.
10365f71eac0SPeter Maydell.PHONY: sphinxdocs
10370928523aSPeter Maydellsphinxdocs: $(MANUAL_BUILDDIR)/devel/index.html \
10380928523aSPeter Maydell            $(MANUAL_BUILDDIR)/interop/index.html \
10390928523aSPeter Maydell            $(MANUAL_BUILDDIR)/specs/index.html \
104065c3542bSPeter Maydell            $(MANUAL_BUILDDIR)/system/index.html \
104109147930SPaolo Bonzini            $(MANUAL_BUILDDIR)/tools/index.html \
104209147930SPaolo Bonzini            $(MANUAL_BUILDDIR)/user/index.html
10435f71eac0SPeter Maydell
10445f71eac0SPeter Maydell# Canned command to build a single manual
104527a296fcSPeter Maydell# Arguments: $1 = manual name, $2 = Sphinx builder ('html' or 'man')
10466bda415cSEduardo Habkost# Note the use of different doctree for each (manual, builder) tuple;
10476bda415cSEduardo Habkost# this works around Sphinx not handling parallel invocation on
10486bda415cSEduardo Habkost# a single doctree: https://github.com/sphinx-doc/sphinx/issues/2946
10492eb054c2SPeter 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")
10505f71eac0SPeter Maydell# We assume all RST files in the manual's directory are used in it
105187c0868fSPeter Maydellmanual-deps = $(wildcard $(SRC_PATH)/docs/$1/*.rst) \
1052de1572caSPeter Maydell              $(SRC_PATH)/docs/defs.rst.inc \
105387c0868fSPeter Maydell              $(SRC_PATH)/docs/$1/conf.py $(SRC_PATH)/docs/conf.py
1054e0f3728dSPeter Maydell# Macro to write out the rule and dependencies for building manpages
1055e0f3728dSPeter Maydell# Usage: $(call define-manpage-rule,manualname,manpage1 manpage2...[,extradeps])
1056e0f3728dSPeter Maydell# 'extradeps' is optional, and specifies extra files (eg .hx files) that
1057e0f3728dSPeter Maydell# the manual page depends on.
1058e0f3728dSPeter Maydelldefine define-manpage-rule
1059e0f3728dSPeter Maydell$(call atomic,$(foreach manpage,$2,$(MANUAL_BUILDDIR)/$1/$(manpage)),$(call manual-deps,$1) $3)
1060e0f3728dSPeter Maydell	$(call build-manual,$1,man)
1061e0f3728dSPeter Maydellendef
10625f71eac0SPeter Maydell
10631290e671SPeter Maydell$(MANUAL_BUILDDIR)/devel/index.html: $(call manual-deps,devel)
106427a296fcSPeter Maydell	$(call build-manual,devel,html)
10655f71eac0SPeter Maydell
1066a08b4a9fSPeter Maydell$(MANUAL_BUILDDIR)/interop/index.html: $(call manual-deps,interop)
106727a296fcSPeter Maydell	$(call build-manual,interop,html)
10685f71eac0SPeter Maydell
10690783a732SPeter Maydell$(MANUAL_BUILDDIR)/specs/index.html: $(call manual-deps,specs)
107027a296fcSPeter Maydell	$(call build-manual,specs,html)
107127a296fcSPeter Maydell
107209ce5f2dSPeter 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
10730928523aSPeter Maydell	$(call build-manual,system,html)
10740928523aSPeter Maydell
1075a08b4a9fSPeter Maydell$(MANUAL_BUILDDIR)/tools/index.html: $(call manual-deps,tools) $(SRC_PATH)/qemu-img-cmds.hx $(SRC_PATH)/docs/qemu-option-trace.rst.inc
107665c3542bSPeter Maydell	$(call build-manual,tools,html)
107765c3542bSPeter Maydell
107809147930SPaolo Bonzini$(MANUAL_BUILDDIR)/user/index.html: $(call manual-deps,user)
107909147930SPaolo Bonzini	$(call build-manual,user,html)
108009147930SPaolo Bonzini
1081a08b4a9fSPeter Maydell$(call define-manpage-rule,interop,qemu-ga.8)
10820783a732SPeter Maydell
1083d06118bfSPeter Maydell$(call define-manpage-rule,system,qemu.1 qemu-block-drivers.7 qemu-cpu-models.7)
1084acab923dSPeter Maydell
1085a08b4a9fSPeter Maydell$(call define-manpage-rule,tools,\
1086a08b4a9fSPeter Maydell       qemu-img.1 qemu-nbd.8 qemu-trace-stap.1\
1087a08b4a9fSPeter Maydell       virtiofsd.1 virtfs-proxy-helper.1,\
1088a08b4a9fSPeter Maydell       $(SRC_PATH)/qemu-img-cmds.hx $(SRC_PATH)/docs/qemu-option-trace.rst.inc)
1089a08b4a9fSPeter Maydell
109022108f33SStefan Hajnoczi$(MANUAL_BUILDDIR)/index.html: $(SRC_PATH)/docs/index.html.in qemu-version.h
1091d83bbedaSStefan Hajnoczi	@mkdir -p "$(MANUAL_BUILDDIR)"
109222108f33SStefan Hajnoczi	$(call quiet-command, sed "s|@@VERSION@@|${VERSION}|g" $< >$@, \
109322108f33SStefan Hajnoczi             "GEN","$@")
109422108f33SStefan Hajnoczi
1095077de81aSPaolo Bonziniqemu-options.texi: $(SRC_PATH)/qemu-options.hx $(SRC_PATH)/scripts/hxtool
10960bdb12c7SPeter Maydell	$(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -t < $< > $@,"GEN","$@")
1097f3548328Sbellard
1098077de81aSPaolo Bonziniqemu-monitor.texi: $(SRC_PATH)/hmp-commands.hx $(SRC_PATH)/scripts/hxtool
10990bdb12c7SPeter Maydell	$(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -t < $< > $@,"GEN","$@")
11002313086aSBlue Swirl
1101077de81aSPaolo Bonziniqemu-monitor-info.texi: $(SRC_PATH)/hmp-commands-info.hx $(SRC_PATH)/scripts/hxtool
11020bdb12c7SPeter Maydell	$(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -t < $< > $@,"GEN","$@")
11032cd8af2dSPavel Butsykin
1104eb815e24SMarkus Armbrusterdocs/interop/qemu-qmp-qapi.texi: qapi/qapi-doc.texi
1105fb0bc835SMarkus Armbruster	@cp -p $< $@
11064afeeb57SMarkus Armbruster
1107fb0bc835SMarkus Armbrusterdocs/interop/qemu-ga-qapi.texi: qga/qapi-generated/qga-qapi-doc.texi
1108fb0bc835SMarkus Armbruster	@cp -p $< $@
110956e8bdd4SMarc-André Lureau
11105b1d0e92SPeter Maydellhtml: docs/interop/qemu-qmp-ref.html docs/interop/qemu-ga-ref.html sphinxdocs
11115b1d0e92SPeter Maydellinfo: docs/interop/qemu-qmp-ref.info docs/interop/qemu-ga-ref.info
11125b1d0e92SPeter Maydellpdf: docs/interop/qemu-qmp-ref.pdf docs/interop/qemu-ga-ref.pdf
11135b1d0e92SPeter Maydelltxt: docs/interop/qemu-qmp-ref.txt docs/interop/qemu-ga-ref.txt
1114818220f5Saliguori
1115d59157eaSPaolo Bonzinidocs/interop/qemu-ga-ref.dvi docs/interop/qemu-ga-ref.html \
1116d59157eaSPaolo Bonzini    docs/interop/qemu-ga-ref.info docs/interop/qemu-ga-ref.pdf \
1117d59157eaSPaolo Bonzini    docs/interop/qemu-ga-ref.txt docs/interop/qemu-ga-ref.7: \
1118d59157eaSPaolo Bonzini	docs/interop/qemu-ga-ref.texi docs/interop/qemu-ga-qapi.texi
111956e8bdd4SMarc-André Lureau
1120d59157eaSPaolo Bonzinidocs/interop/qemu-qmp-ref.dvi docs/interop/qemu-qmp-ref.html \
1121d59157eaSPaolo Bonzini    docs/interop/qemu-qmp-ref.info docs/interop/qemu-qmp-ref.pdf \
1122d59157eaSPaolo Bonzini    docs/interop/qemu-qmp-ref.txt docs/interop/qemu-qmp-ref.7: \
1123d59157eaSPaolo Bonzini	docs/interop/qemu-qmp-ref.texi docs/interop/qemu-qmp-qapi.texi
112456e8bdd4SMarc-André Lureau
1125ae560cc3SEric Blake$(filter %.1 %.7 %.8,$(DOCS)): scripts/texi2pod.pl
1126ae560cc3SEric Blake
1127fe8bf5f6SAlex Bennée# Reports/Analysis
1128fe8bf5f6SAlex Bennée
1129fe8bf5f6SAlex Bennée%/coverage-report.html:
1130fe8bf5f6SAlex Bennée	@mkdir -p $*
1131fe8bf5f6SAlex Bennée	$(call quiet-command,\
11325eda6e42SAlex Bennée		gcovr -r $(SRC_PATH) \
11335eda6e42SAlex Bennée		$(foreach t, $(TARGET_DIRS), --object-directory $(BUILD_DIR)/$(t)) \
11345eda6e42SAlex Bennée		 --object-directory $(BUILD_DIR) \
1135337f2311SAlex Bennée		-p --html --html-details -o $@, \
1136fe8bf5f6SAlex Bennée		"GEN", "coverage-report.html")
1137fe8bf5f6SAlex Bennée
1138fe8bf5f6SAlex Bennée.PHONY: coverage-report
1139fe8bf5f6SAlex Bennéecoverage-report: $(CURDIR)/reports/coverage/coverage-report.html
114056e8bdd4SMarc-André Lureau
1141f53ec699SStefan Weilifdef CONFIG_WIN32
1142f53ec699SStefan Weil
1143f53ec699SStefan WeilINSTALLER = qemu-setup-$(VERSION)$(EXESUF)
1144f53ec699SStefan Weil
1145f53ec699SStefan Weilnsisflags = -V2 -NOCD
1146f53ec699SStefan Weil
1147f53ec699SStefan Weilifneq ($(wildcard $(SRC_PATH)/dll),)
1148f53ec699SStefan Weilifeq ($(ARCH),x86_64)
1149f53ec699SStefan Weil# 64 bit executables
1150f53ec699SStefan WeilDLL_PATH = $(SRC_PATH)/dll/w64
1151f53ec699SStefan Weilnsisflags += -DW64
1152f53ec699SStefan Weilelse
1153f53ec699SStefan Weil# 32 bit executables
1154f53ec699SStefan WeilDLL_PATH = $(SRC_PATH)/dll/w32
1155f53ec699SStefan Weilendif
1156f53ec699SStefan Weilendif
1157f53ec699SStefan Weil
1158f53ec699SStefan Weil.PHONY: installer
1159f53ec699SStefan Weilinstaller: $(INSTALLER)
1160f53ec699SStefan Weil
1161f53ec699SStefan WeilINSTDIR=/tmp/qemu-nsis
1162f53ec699SStefan Weil
1163f84f9f75SPhilippe Mathieu-Daudé$(INSTALLER): install-doc $(SRC_PATH)/qemu.nsi
1164fb8597bbSEd Maste	$(MAKE) install prefix=${INSTDIR}
1165f53ec699SStefan Weilifdef SIGNCODE
1166f53ec699SStefan Weil	(cd ${INSTDIR}; \
1167f53ec699SStefan Weil         for i in *.exe; do \
1168f53ec699SStefan Weil           $(SIGNCODE) $${i}; \
1169f53ec699SStefan Weil         done \
1170f53ec699SStefan Weil        )
1171f53ec699SStefan Weilendif # SIGNCODE
1172f53ec699SStefan Weil	(cd ${INSTDIR}; \
1173f53ec699SStefan Weil         for i in qemu-system-*.exe; do \
1174f53ec699SStefan Weil           arch=$${i%.exe}; \
1175f53ec699SStefan Weil           arch=$${arch#qemu-system-}; \
1176f53ec699SStefan Weil           echo Section \"$$arch\" Section_$$arch; \
1177f53ec699SStefan Weil           echo SetOutPath \"\$$INSTDIR\"; \
1178f53ec699SStefan Weil           echo File \"\$${BINDIR}\\$$i\"; \
1179f53ec699SStefan Weil           echo SectionEnd; \
1180f53ec699SStefan Weil         done \
1181f53ec699SStefan Weil        ) >${INSTDIR}/system-emulations.nsh
1182f53ec699SStefan Weil	makensis $(nsisflags) \
1183f53ec699SStefan Weil                $(if $(BUILD_DOCS),-DCONFIG_DOCUMENTATION="y") \
1184f53ec699SStefan Weil                $(if $(CONFIG_GTK),-DCONFIG_GTK="y") \
1185f53ec699SStefan Weil                -DBINDIR="${INSTDIR}" \
1186f53ec699SStefan Weil                $(if $(DLL_PATH),-DDLLDIR="$(DLL_PATH)") \
1187f53ec699SStefan Weil                -DSRCDIR="$(SRC_PATH)" \
1188f53ec699SStefan Weil                -DOUTFILE="$(INSTALLER)" \
1189805d8a67SStefan Weil                -DDISPLAYVERSION="$(VERSION)" \
1190f53ec699SStefan Weil                $(SRC_PATH)/qemu.nsi
1191f53ec699SStefan Weil	rm -r ${INSTDIR}
1192f53ec699SStefan Weilifdef SIGNCODE
1193f53ec699SStefan Weil	$(SIGNCODE) $(INSTALLER)
1194f53ec699SStefan Weilendif # SIGNCODE
1195f53ec699SStefan Weilendif # CONFIG_WIN
1196f53ec699SStefan Weil
1197cb5fc67dSAnthony Liguori# Add a dependency on the generated files, so that they are always
1198cb5fc67dSAnthony Liguori# rebuilt before other object files
1199428952cfSThomas Huthifneq ($(wildcard config-host.mak),)
1200eaa2ddbbSFam Zhengifneq ($(filter-out $(UNCHECKED_GOALS),$(MAKECMDGOALS)),$(if $(MAKECMDGOALS),,fail))
12013dff199cSLaurent VivierMakefile: $(generated-files-y)
12027748b8cbSMike Frysingerendif
1203428952cfSThomas Huthendif
1204cb5fc67dSAnthony Liguori
12050ab8ed18SDaniel P. Berrange.SECONDARY: $(TRACE_HEADERS) $(TRACE_HEADERS:%=%-timestamp) \
12060ab8ed18SDaniel P. Berrange	$(TRACE_SOURCES) $(TRACE_SOURCES:%=%-timestamp) \
12070ab8ed18SDaniel P. Berrange	$(TRACE_DTRACE) $(TRACE_DTRACE:%=%-timestamp)
12080ab8ed18SDaniel P. Berrange
12094fb240a4Sbellard# Include automatically generated dependency files
12101435ddb8SPaolo Bonzini# Dependencies in Makefile.objs files come from our recursive subdir rules
12111435ddb8SPaolo Bonzini-include $(wildcard *.d tests/*.d)
1212324027c2SFam Zheng
1213324027c2SFam Zhenginclude $(SRC_PATH)/tests/docker/Makefile.include
1214b1fb9a63SFam Zhenginclude $(SRC_PATH)/tests/vm/Makefile.include
12150d8e065fSMarc-André Lureau
12160d8e065fSMarc-André Lureau.PHONY: help
12170d8e065fSMarc-André Lureauhelp:
12180d8e065fSMarc-André Lureau	@echo  'Generic targets:'
12190d8e065fSMarc-André Lureau	@echo  '  all             - Build all'
12200decdfe2SMarc-André Lureauifdef CONFIG_MODULES
12210decdfe2SMarc-André Lureau	@echo  '  modules         - Build all modules'
12220decdfe2SMarc-André Lureauendif
12230d8e065fSMarc-André Lureau	@echo  '  dir/file.o      - Build specified target only'
12240d8e065fSMarc-André Lureau	@echo  '  install         - Install QEMU, documentation and tools'
12250d8e065fSMarc-André Lureau	@echo  '  ctags/TAGS      - Generate tags file for editors'
12260d8e065fSMarc-André Lureau	@echo  '  cscope          - Generate cscope index'
12270d8e065fSMarc-André Lureau	@echo  ''
12282b1f35b9SAlex Bennée	@$(if $(TARGET_DIRS), \
12290d8e065fSMarc-André Lureau		echo 'Architecture specific targets:'; \
12302b1f35b9SAlex Bennée		$(foreach t, $(TARGET_DIRS), \
12313b8593eeSMarkus Armbruster		printf "  %-30s - Build for %s\\n" $(t)/all $(t);) \
12320d8e065fSMarc-André Lureau		echo '')
12330d8e065fSMarc-André Lureau	@echo  'Cleaning targets:'
12340d8e065fSMarc-André Lureau	@echo  '  clean           - Remove most generated files but keep the config'
1235990e6a27SAlex Bennéeifdef CONFIG_GCOV
1236990e6a27SAlex Bennée	@echo  '  clean-coverage  - Remove coverage files'
1237990e6a27SAlex Bennéeendif
12380d8e065fSMarc-André Lureau	@echo  '  distclean       - Remove all generated files'
12390d8e065fSMarc-André Lureau	@echo  '  dist            - Build a distributable tarball'
12400d8e065fSMarc-André Lureau	@echo  ''
12410d8e065fSMarc-André Lureau	@echo  'Test targets:'
12420d8e065fSMarc-André Lureau	@echo  '  check           - Run all tests (check-help for details)'
124305af039dSMarc-André Lureau	@echo  '  docker          - Help about targets running tests inside containers'
12444f2f6276SPhilippe Mathieu-Daudé	@echo  '  vm-help         - Help about targets running tests inside VM'
12450d8e065fSMarc-André Lureau	@echo  ''
12460d8e065fSMarc-André Lureau	@echo  'Documentation targets:'
1247f8bab10bSMarc-André Lureau	@echo  '  html info pdf txt'
12480d8e065fSMarc-André Lureau	@echo  '                  - Build documentation in specified format'
1249fe8bf5f6SAlex Bennéeifdef CONFIG_GCOV
1250fe8bf5f6SAlex Bennée	@echo  '  coverage-report - Create code coverage report'
1251fe8bf5f6SAlex Bennéeendif
12520d8e065fSMarc-André Lureau	@echo  ''
12530d8e065fSMarc-André Lureauifdef CONFIG_WIN32
12540d8e065fSMarc-André Lureau	@echo  'Windows targets:'
12556bd67f89SStefan Weil	@echo  '  installer       - Build NSIS-based installer for QEMU'
12560d8e065fSMarc-André Lureauifdef QEMU_GA_MSI_ENABLED
12570d8e065fSMarc-André Lureau	@echo  '  msi             - Build MSI-based installer for qemu-ga'
12580d8e065fSMarc-André Lureauendif
12590d8e065fSMarc-André Lureau	@echo  ''
12600d8e065fSMarc-André Lureauendif
12617b409519SDaniel P. Berrange	@echo  '  $(MAKE) [targets]      (quiet build, default)'
12627b409519SDaniel P. Berrange	@echo  '  $(MAKE) V=1 [targets]  (verbose build)'
1263