You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1124 lines
40KB

  1. # Makefile for QEMU.
  2. # Always point to the root of the build tree (needs GNU make).
  3. BUILD_DIR=$(CURDIR)
  4. # Before including a proper config-host.mak, assume we are in the source tree
  5. SRC_PATH=.
  6. UNCHECKED_GOALS := %clean TAGS cscope ctags dist \
  7. html info pdf txt \
  8. help check-help print-% \
  9. docker docker-% vm-test vm-build-%
  10. print-%:
  11. @echo '$*=$($*)'
  12. # All following code might depend on configuration variables
  13. ifneq ($(wildcard config-host.mak),)
  14. # Put the all: rule here so that config-host.mak can contain dependencies.
  15. all:
  16. include config-host.mak
  17. git-submodule-update:
  18. .PHONY: git-submodule-update
  19. git_module_status := $(shell \
  20. cd '$(SRC_PATH)' && \
  21. GIT="$(GIT)" ./scripts/git-submodule.sh status $(GIT_SUBMODULES); \
  22. echo $$?; \
  23. )
  24. ifeq (1,$(git_module_status))
  25. ifeq (no,$(GIT_UPDATE))
  26. git-submodule-update:
  27. $(call quiet-command, \
  28. echo && \
  29. echo "GIT submodule checkout is out of date. Please run" && \
  30. echo " scripts/git-submodule.sh update $(GIT_SUBMODULES)" && \
  31. echo "from the source directory checkout $(SRC_PATH)" && \
  32. echo && \
  33. exit 1)
  34. else
  35. git-submodule-update:
  36. $(call quiet-command, \
  37. (cd $(SRC_PATH) && GIT="$(GIT)" ./scripts/git-submodule.sh update $(GIT_SUBMODULES)), \
  38. "GIT","$(GIT_SUBMODULES)")
  39. endif
  40. endif
  41. .git-submodule-status: git-submodule-update config-host.mak
  42. # Check that we're not trying to do an out-of-tree build from
  43. # a tree that's been used for an in-tree build.
  44. ifneq ($(realpath $(SRC_PATH)),$(realpath .))
  45. ifneq ($(wildcard $(SRC_PATH)/config-host.mak),)
  46. $(error This is an out of tree build but your source tree ($(SRC_PATH)) \
  47. seems to have been used for an in-tree build. You can fix this by running \
  48. "$(MAKE) distclean && rm -rf *-linux-user *-softmmu" in your source tree)
  49. endif
  50. endif
  51. CONFIG_SOFTMMU := $(if $(filter %-softmmu,$(TARGET_DIRS)),y)
  52. CONFIG_USER_ONLY := $(if $(filter %-user,$(TARGET_DIRS)),y)
  53. CONFIG_XEN := $(CONFIG_XEN_BACKEND)
  54. CONFIG_ALL=y
  55. -include config-all-devices.mak
  56. -include config-all-disas.mak
  57. config-host.mak: $(SRC_PATH)/configure $(SRC_PATH)/pc-bios $(SRC_PATH)/VERSION
  58. @echo $@ is out-of-date, running configure
  59. @# TODO: The next lines include code which supports a smooth
  60. @# transition from old configurations without config.status.
  61. @# This code can be removed after QEMU 1.7.
  62. @if test -x config.status; then \
  63. ./config.status; \
  64. else \
  65. sed -n "/.*Configured with/s/[^:]*: //p" $@ | sh; \
  66. fi
  67. else
  68. config-host.mak:
  69. ifneq ($(filter-out $(UNCHECKED_GOALS),$(MAKECMDGOALS)),$(if $(MAKECMDGOALS),,fail))
  70. @echo "Please call configure before running make!"
  71. @exit 1
  72. endif
  73. endif
  74. include $(SRC_PATH)/rules.mak
  75. # Create QEMU_PKGVERSION and FULL_VERSION strings
  76. # If PKGVERSION is set, use that; otherwise get version and -dirty status from git
  77. QEMU_PKGVERSION := $(if $(PKGVERSION),$(PKGVERSION),$(shell \
  78. cd $(SRC_PATH); \
  79. if test -e .git; then \
  80. git describe --match 'v*' 2>/dev/null | tr -d '\n'; \
  81. if ! git diff-index --quiet HEAD &>/dev/null; then \
  82. echo "-dirty"; \
  83. fi; \
  84. fi))
  85. # Either "version (pkgversion)", or just "version" if pkgversion not set
  86. FULL_VERSION := $(if $(QEMU_PKGVERSION),$(VERSION) ($(QEMU_PKGVERSION)),$(VERSION))
  87. GENERATED_FILES = qemu-version.h config-host.h qemu-options.def
  88. GENERATED_QAPI_FILES = qapi/qapi-builtin-types.h qapi/qapi-builtin-types.c
  89. GENERATED_QAPI_FILES += qapi/qapi-types.h qapi/qapi-types.c
  90. GENERATED_QAPI_FILES += $(QAPI_MODULES:%=qapi/qapi-types-%.h)
  91. GENERATED_QAPI_FILES += $(QAPI_MODULES:%=qapi/qapi-types-%.c)
  92. GENERATED_QAPI_FILES += qapi/qapi-builtin-visit.h qapi/qapi-builtin-visit.c
  93. GENERATED_QAPI_FILES += qapi/qapi-visit.h qapi/qapi-visit.c
  94. GENERATED_QAPI_FILES += $(QAPI_MODULES:%=qapi/qapi-visit-%.h)
  95. GENERATED_QAPI_FILES += $(QAPI_MODULES:%=qapi/qapi-visit-%.c)
  96. GENERATED_QAPI_FILES += qapi/qapi-commands.h qapi/qapi-commands.c
  97. GENERATED_QAPI_FILES += $(QAPI_MODULES:%=qapi/qapi-commands-%.h)
  98. GENERATED_QAPI_FILES += $(QAPI_MODULES:%=qapi/qapi-commands-%.c)
  99. GENERATED_QAPI_FILES += qapi/qapi-emit-events.h qapi/qapi-emit-events.c
  100. GENERATED_QAPI_FILES += qapi/qapi-events.h qapi/qapi-events.c
  101. GENERATED_QAPI_FILES += $(QAPI_MODULES:%=qapi/qapi-events-%.h)
  102. GENERATED_QAPI_FILES += $(QAPI_MODULES:%=qapi/qapi-events-%.c)
  103. GENERATED_QAPI_FILES += qapi/qapi-introspect.c qapi/qapi-introspect.h
  104. GENERATED_QAPI_FILES += qapi/qapi-doc.texi
  105. GENERATED_FILES += $(GENERATED_QAPI_FILES)
  106. GENERATED_FILES += trace/generated-tcg-tracers.h
  107. GENERATED_FILES += trace/generated-helpers-wrappers.h
  108. GENERATED_FILES += trace/generated-helpers.h
  109. GENERATED_FILES += trace/generated-helpers.c
  110. ifdef CONFIG_TRACE_UST
  111. GENERATED_FILES += trace-ust-all.h
  112. GENERATED_FILES += trace-ust-all.c
  113. endif
  114. GENERATED_FILES += module_block.h
  115. TRACE_HEADERS = trace-root.h $(trace-events-subdirs:%=%/trace.h)
  116. TRACE_SOURCES = trace-root.c $(trace-events-subdirs:%=%/trace.c)
  117. TRACE_DTRACE =
  118. ifdef CONFIG_TRACE_DTRACE
  119. TRACE_HEADERS += trace-dtrace-root.h $(trace-events-subdirs:%=%/trace-dtrace.h)
  120. TRACE_DTRACE += trace-dtrace-root.dtrace $(trace-events-subdirs:%=%/trace-dtrace.dtrace)
  121. endif
  122. ifdef CONFIG_TRACE_UST
  123. TRACE_HEADERS += trace-ust-root.h $(trace-events-subdirs:%=%/trace-ust.h)
  124. endif
  125. GENERATED_FILES += $(TRACE_HEADERS)
  126. GENERATED_FILES += $(TRACE_SOURCES)
  127. GENERATED_FILES += $(BUILD_DIR)/trace-events-all
  128. GENERATED_FILES += .git-submodule-status
  129. trace-group-name = $(shell dirname $1 | sed -e 's/[^a-zA-Z0-9]/_/g')
  130. tracetool-y = $(SRC_PATH)/scripts/tracetool.py
  131. tracetool-y += $(shell find $(SRC_PATH)/scripts/tracetool -name "*.py")
  132. %/trace.h: %/trace.h-timestamp
  133. @cmp $< $@ >/dev/null 2>&1 || cp $< $@
  134. %/trace.h-timestamp: $(SRC_PATH)/%/trace-events $(tracetool-y) $(BUILD_DIR)/config-host.mak
  135. $(call quiet-command,$(TRACETOOL) \
  136. --group=$(call trace-group-name,$@) \
  137. --format=h \
  138. --backends=$(TRACE_BACKENDS) \
  139. $< > $@,"GEN","$(@:%-timestamp=%)")
  140. %/trace.c: %/trace.c-timestamp
  141. @cmp $< $@ >/dev/null 2>&1 || cp $< $@
  142. %/trace.c-timestamp: $(SRC_PATH)/%/trace-events $(tracetool-y) $(BUILD_DIR)/config-host.mak
  143. $(call quiet-command,$(TRACETOOL) \
  144. --group=$(call trace-group-name,$@) \
  145. --format=c \
  146. --backends=$(TRACE_BACKENDS) \
  147. $< > $@,"GEN","$(@:%-timestamp=%)")
  148. %/trace-ust.h: %/trace-ust.h-timestamp
  149. @cmp $< $@ >/dev/null 2>&1 || cp $< $@
  150. %/trace-ust.h-timestamp: $(SRC_PATH)/%/trace-events $(tracetool-y) $(BUILD_DIR)/config-host.mak
  151. $(call quiet-command,$(TRACETOOL) \
  152. --group=$(call trace-group-name,$@) \
  153. --format=ust-events-h \
  154. --backends=$(TRACE_BACKENDS) \
  155. $< > $@,"GEN","$(@:%-timestamp=%)")
  156. %/trace-dtrace.dtrace: %/trace-dtrace.dtrace-timestamp
  157. @cmp $< $@ >/dev/null 2>&1 || cp $< $@
  158. %/trace-dtrace.dtrace-timestamp: $(SRC_PATH)/%/trace-events $(BUILD_DIR)/config-host.mak $(tracetool-y)
  159. $(call quiet-command,$(TRACETOOL) \
  160. --group=$(call trace-group-name,$@) \
  161. --format=d \
  162. --backends=$(TRACE_BACKENDS) \
  163. $< > $@,"GEN","$(@:%-timestamp=%)")
  164. %/trace-dtrace.h: %/trace-dtrace.dtrace $(tracetool-y)
  165. $(call quiet-command,dtrace -o $@ -h -s $<, "GEN","$@")
  166. %/trace-dtrace.o: %/trace-dtrace.dtrace $(tracetool-y)
  167. trace-root.h: trace-root.h-timestamp
  168. @cmp $< $@ >/dev/null 2>&1 || cp $< $@
  169. trace-root.h-timestamp: $(SRC_PATH)/trace-events $(tracetool-y) $(BUILD_DIR)/config-host.mak
  170. $(call quiet-command,$(TRACETOOL) \
  171. --group=root \
  172. --format=h \
  173. --backends=$(TRACE_BACKENDS) \
  174. $< > $@,"GEN","$(@:%-timestamp=%)")
  175. trace-root.c: trace-root.c-timestamp
  176. @cmp $< $@ >/dev/null 2>&1 || cp $< $@
  177. trace-root.c-timestamp: $(SRC_PATH)/trace-events $(tracetool-y) $(BUILD_DIR)/config-host.mak
  178. $(call quiet-command,$(TRACETOOL) \
  179. --group=root \
  180. --format=c \
  181. --backends=$(TRACE_BACKENDS) \
  182. $< > $@,"GEN","$(@:%-timestamp=%)")
  183. trace-ust-root.h: trace-ust-root.h-timestamp
  184. @cmp $< $@ >/dev/null 2>&1 || cp $< $@
  185. trace-ust-root.h-timestamp: $(SRC_PATH)/trace-events $(tracetool-y) $(BUILD_DIR)/config-host.mak
  186. $(call quiet-command,$(TRACETOOL) \
  187. --group=root \
  188. --format=ust-events-h \
  189. --backends=$(TRACE_BACKENDS) \
  190. $< > $@,"GEN","$(@:%-timestamp=%)")
  191. trace-ust-all.h: trace-ust-all.h-timestamp
  192. @cmp $< $@ >/dev/null 2>&1 || cp $< $@
  193. trace-ust-all.h-timestamp: $(trace-events-files) $(tracetool-y) $(BUILD_DIR)/config-host.mak
  194. $(call quiet-command,$(TRACETOOL) \
  195. --group=all \
  196. --format=ust-events-h \
  197. --backends=$(TRACE_BACKENDS) \
  198. $(trace-events-files) > $@,"GEN","$(@:%-timestamp=%)")
  199. trace-ust-all.c: trace-ust-all.c-timestamp
  200. @cmp $< $@ >/dev/null 2>&1 || cp $< $@
  201. trace-ust-all.c-timestamp: $(trace-events-files) $(tracetool-y) $(BUILD_DIR)/config-host.mak
  202. $(call quiet-command,$(TRACETOOL) \
  203. --group=all \
  204. --format=ust-events-c \
  205. --backends=$(TRACE_BACKENDS) \
  206. $(trace-events-files) > $@,"GEN","$(@:%-timestamp=%)")
  207. trace-dtrace-root.dtrace: trace-dtrace-root.dtrace-timestamp
  208. @cmp $< $@ >/dev/null 2>&1 || cp $< $@
  209. trace-dtrace-root.dtrace-timestamp: $(SRC_PATH)/trace-events $(BUILD_DIR)/config-host.mak $(tracetool-y)
  210. $(call quiet-command,$(TRACETOOL) \
  211. --group=root \
  212. --format=d \
  213. --backends=$(TRACE_BACKENDS) \
  214. $< > $@,"GEN","$(@:%-timestamp=%)")
  215. trace-dtrace-root.h: trace-dtrace-root.dtrace
  216. $(call quiet-command,dtrace -o $@ -h -s $<, "GEN","$@")
  217. trace-dtrace-root.o: trace-dtrace-root.dtrace
  218. KEYCODEMAP_GEN = $(SRC_PATH)/ui/keycodemapdb/tools/keymap-gen
  219. KEYCODEMAP_CSV = $(SRC_PATH)/ui/keycodemapdb/data/keymaps.csv
  220. KEYCODEMAP_FILES = \
  221. ui/input-keymap-atset1-to-qcode.c \
  222. ui/input-keymap-linux-to-qcode.c \
  223. ui/input-keymap-qcode-to-atset1.c \
  224. ui/input-keymap-qcode-to-atset2.c \
  225. ui/input-keymap-qcode-to-atset3.c \
  226. ui/input-keymap-qcode-to-linux.c \
  227. ui/input-keymap-qcode-to-qnum.c \
  228. ui/input-keymap-qcode-to-sun.c \
  229. ui/input-keymap-qnum-to-qcode.c \
  230. ui/input-keymap-usb-to-qcode.c \
  231. ui/input-keymap-win32-to-qcode.c \
  232. ui/input-keymap-x11-to-qcode.c \
  233. ui/input-keymap-xorgevdev-to-qcode.c \
  234. ui/input-keymap-xorgkbd-to-qcode.c \
  235. ui/input-keymap-xorgxquartz-to-qcode.c \
  236. ui/input-keymap-xorgxwin-to-qcode.c \
  237. ui/input-keymap-osx-to-qcode.c \
  238. $(NULL)
  239. GENERATED_FILES += $(KEYCODEMAP_FILES)
  240. ui/input-keymap-%.c: $(KEYCODEMAP_GEN) $(KEYCODEMAP_CSV) $(SRC_PATH)/ui/Makefile.objs
  241. $(call quiet-command,\
  242. stem=$* && src=$${stem%-to-*} dst=$${stem#*-to-} && \
  243. test -e $(KEYCODEMAP_GEN) && \
  244. $(PYTHON) $(KEYCODEMAP_GEN) \
  245. --lang glib2 \
  246. --varname qemu_input_map_$${src}_to_$${dst} \
  247. code-map $(KEYCODEMAP_CSV) $${src} $${dst} \
  248. > $@ || rm -f $@, "GEN", "$@")
  249. $(KEYCODEMAP_GEN): .git-submodule-status
  250. $(KEYCODEMAP_CSV): .git-submodule-status
  251. edk2-decompressed = $(basename $(wildcard pc-bios/edk2-*.fd.bz2))
  252. pc-bios/edk2-%.fd: pc-bios/edk2-%.fd.bz2
  253. $(call quiet-command,bzip2 -d -c $< > $@,"BUNZIP2",$<)
  254. # Don't try to regenerate Makefile or configure
  255. # We don't generate any of them
  256. Makefile: ;
  257. configure: ;
  258. .PHONY: all clean cscope distclean html info install install-doc \
  259. pdf txt recurse-all dist msi FORCE
  260. $(call set-vpath, $(SRC_PATH))
  261. LIBS+=-lz $(LIBS_TOOLS)
  262. HELPERS-$(call land,$(CONFIG_SOFTMMU),$(CONFIG_LINUX)) = qemu-bridge-helper$(EXESUF)
  263. ifdef BUILD_DOCS
  264. DOCS=qemu-doc.html qemu-doc.txt qemu.1 qemu-img.1 qemu-nbd.8 qemu-ga.8
  265. DOCS+=docs/interop/qemu-qmp-ref.html docs/interop/qemu-qmp-ref.txt docs/interop/qemu-qmp-ref.7
  266. DOCS+=docs/interop/qemu-ga-ref.html docs/interop/qemu-ga-ref.txt docs/interop/qemu-ga-ref.7
  267. DOCS+=docs/qemu-block-drivers.7
  268. DOCS+=docs/qemu-cpu-models.7
  269. ifdef CONFIG_VIRTFS
  270. DOCS+=fsdev/virtfs-proxy-helper.1
  271. endif
  272. ifdef CONFIG_TRACE_SYSTEMTAP
  273. DOCS+=scripts/qemu-trace-stap.1
  274. endif
  275. else
  276. DOCS=
  277. endif
  278. SUBDIR_MAKEFLAGS=$(if $(V),,--no-print-directory --quiet) BUILD_DIR=$(BUILD_DIR)
  279. SUBDIR_DEVICES_MAK=$(patsubst %, %/config-devices.mak, $(filter %-softmmu, $(TARGET_DIRS)))
  280. SUBDIR_DEVICES_MAK_DEP=$(patsubst %, %.d, $(SUBDIR_DEVICES_MAK))
  281. ifeq ($(SUBDIR_DEVICES_MAK),)
  282. config-all-devices.mak: config-host.mak
  283. $(call quiet-command,echo '# no devices' > $@,"GEN","$@")
  284. else
  285. config-all-devices.mak: $(SUBDIR_DEVICES_MAK) config-host.mak
  286. $(call quiet-command, sed -n \
  287. 's|^\([^=]*\)=\(.*\)$$|\1:=$$(findstring y,$$(\1)\2)|p' \
  288. $(SUBDIR_DEVICES_MAK) | sort -u > $@, \
  289. "GEN","$@")
  290. endif
  291. -include $(SUBDIR_DEVICES_MAK_DEP)
  292. # This has to be kept in sync with Kconfig.host.
  293. MINIKCONF_ARGS = \
  294. $(CONFIG_MINIKCONF_MODE) \
  295. $@ $*-config.devices.mak.d $< $(MINIKCONF_INPUTS) \
  296. CONFIG_KVM=$(CONFIG_KVM) \
  297. CONFIG_SPICE=$(CONFIG_SPICE) \
  298. CONFIG_IVSHMEM=$(CONFIG_IVSHMEM) \
  299. CONFIG_TPM=$(CONFIG_TPM) \
  300. CONFIG_XEN=$(CONFIG_XEN) \
  301. CONFIG_OPENGL=$(CONFIG_OPENGL) \
  302. CONFIG_X11=$(CONFIG_X11) \
  303. CONFIG_VHOST_USER=$(CONFIG_VHOST_USER) \
  304. CONFIG_VIRTFS=$(CONFIG_VIRTFS) \
  305. CONFIG_LINUX=$(CONFIG_LINUX) \
  306. CONFIG_PVRDMA=$(CONFIG_PVRDMA)
  307. MINIKCONF_INPUTS = $(SRC_PATH)/Kconfig.host $(SRC_PATH)/hw/Kconfig
  308. MINIKCONF = $(PYTHON) $(SRC_PATH)/scripts/minikconf.py \
  309. $(SUBDIR_DEVICES_MAK): %/config-devices.mak: default-configs/%.mak $(MINIKCONF_INPUTS) $(BUILD_DIR)/config-host.mak
  310. $(call quiet-command, $(MINIKCONF) $(MINIKCONF_ARGS) > $@.tmp, "GEN", "$@.tmp")
  311. $(call quiet-command, if test -f $@; then \
  312. if cmp -s $@.old $@; then \
  313. mv $@.tmp $@; \
  314. cp -p $@ $@.old; \
  315. else \
  316. if test -f $@.old; then \
  317. echo "WARNING: $@ (user modified) out of date.";\
  318. else \
  319. echo "WARNING: $@ out of date.";\
  320. fi; \
  321. echo "Run \"$(MAKE) defconfig\" to regenerate."; \
  322. rm $@.tmp; \
  323. fi; \
  324. else \
  325. mv $@.tmp $@; \
  326. cp -p $@ $@.old; \
  327. fi,"GEN","$@");
  328. defconfig:
  329. rm -f config-all-devices.mak $(SUBDIR_DEVICES_MAK)
  330. ifneq ($(wildcard config-host.mak),)
  331. include $(SRC_PATH)/Makefile.objs
  332. endif
  333. dummy := $(call unnest-vars,, \
  334. stub-obj-y \
  335. authz-obj-y \
  336. chardev-obj-y \
  337. util-obj-y \
  338. qga-obj-y \
  339. elf2dmp-obj-y \
  340. ivshmem-client-obj-y \
  341. ivshmem-server-obj-y \
  342. rdmacm-mux-obj-y \
  343. libvhost-user-obj-y \
  344. vhost-user-scsi-obj-y \
  345. vhost-user-blk-obj-y \
  346. qga-vss-dll-obj-y \
  347. block-obj-y \
  348. block-obj-m \
  349. crypto-obj-y \
  350. crypto-aes-obj-y \
  351. qom-obj-y \
  352. io-obj-y \
  353. common-obj-y \
  354. common-obj-m \
  355. ui-obj-y \
  356. ui-obj-m \
  357. audio-obj-y \
  358. audio-obj-m \
  359. trace-obj-y)
  360. include $(SRC_PATH)/tests/Makefile.include
  361. all: $(DOCS) $(if $(BUILD_DOCS),sphinxdocs) $(TOOLS) $(HELPERS-y) recurse-all modules
  362. qemu-version.h: FORCE
  363. $(call quiet-command, \
  364. (printf '#define QEMU_PKGVERSION "$(QEMU_PKGVERSION)"\n'; \
  365. printf '#define QEMU_FULL_VERSION "$(FULL_VERSION)"\n'; \
  366. ) > $@.tmp)
  367. $(call quiet-command, if ! cmp -s $@ $@.tmp; then \
  368. mv $@.tmp $@; \
  369. else \
  370. rm $@.tmp; \
  371. fi)
  372. config-host.h: config-host.h-timestamp
  373. config-host.h-timestamp: config-host.mak
  374. qemu-options.def: $(SRC_PATH)/qemu-options.hx $(SRC_PATH)/scripts/hxtool
  375. $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@,"GEN","$@")
  376. SUBDIR_RULES=$(patsubst %,subdir-%, $(TARGET_DIRS))
  377. SOFTMMU_SUBDIR_RULES=$(filter %-softmmu,$(SUBDIR_RULES))
  378. $(SOFTMMU_SUBDIR_RULES): $(authz-obj-y)
  379. $(SOFTMMU_SUBDIR_RULES): $(block-obj-y)
  380. $(SOFTMMU_SUBDIR_RULES): $(crypto-obj-y)
  381. $(SOFTMMU_SUBDIR_RULES): $(io-obj-y)
  382. $(SOFTMMU_SUBDIR_RULES): config-all-devices.mak
  383. $(SOFTMMU_SUBDIR_RULES): $(edk2-decompressed)
  384. subdir-%:
  385. $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C $* V="$(V)" TARGET_DIR="$*/" all,)
  386. DTC_MAKE_ARGS=-I$(SRC_PATH)/dtc VPATH=$(SRC_PATH)/dtc -C dtc V="$(V)" LIBFDT_srcdir=$(SRC_PATH)/dtc/libfdt
  387. DTC_CFLAGS=$(CFLAGS) $(QEMU_CFLAGS)
  388. DTC_CPPFLAGS=-I$(BUILD_DIR)/dtc -I$(SRC_PATH)/dtc -I$(SRC_PATH)/dtc/libfdt
  389. subdir-dtc: .git-submodule-status dtc/libfdt dtc/tests
  390. $(call quiet-command,$(MAKE) $(DTC_MAKE_ARGS) CPPFLAGS="$(DTC_CPPFLAGS)" CFLAGS="$(DTC_CFLAGS)" LDFLAGS="$(LDFLAGS)" ARFLAGS="$(ARFLAGS)" CC="$(CC)" AR="$(AR)" LD="$(LD)" $(SUBDIR_MAKEFLAGS) libfdt/libfdt.a,)
  391. dtc/%: .git-submodule-status
  392. @mkdir -p $@
  393. # Overriding CFLAGS causes us to lose defines added in the sub-makefile.
  394. # Not overriding CFLAGS leads to mis-matches between compilation modes.
  395. # Therefore we replicate some of the logic in the sub-makefile.
  396. # Remove all the extra -Warning flags that QEMU uses that Capstone doesn't;
  397. # no need to annoy QEMU developers with such things.
  398. CAP_CFLAGS = $(patsubst -W%,,$(CFLAGS) $(QEMU_CFLAGS))
  399. CAP_CFLAGS += -DCAPSTONE_USE_SYS_DYN_MEM
  400. CAP_CFLAGS += -DCAPSTONE_HAS_ARM
  401. CAP_CFLAGS += -DCAPSTONE_HAS_ARM64
  402. CAP_CFLAGS += -DCAPSTONE_HAS_POWERPC
  403. CAP_CFLAGS += -DCAPSTONE_HAS_X86
  404. subdir-capstone: .git-submodule-status
  405. $(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))
  406. subdir-slirp: .git-submodule-status
  407. $(call quiet-command,$(MAKE) -C $(SRC_PATH)/slirp BUILD_DIR="$(BUILD_DIR)/slirp" CC="$(CC)" AR="$(AR)" LD="$(LD)" RANLIB="$(RANLIB)" CFLAGS="$(QEMU_CFLAGS)")
  408. $(SUBDIR_RULES): libqemuutil.a $(common-obj-y) $(chardev-obj-y) \
  409. $(qom-obj-y) $(crypto-aes-obj-$(CONFIG_USER_ONLY))
  410. ROMSUBDIR_RULES=$(patsubst %,romsubdir-%, $(ROMS))
  411. # Only keep -O and -g cflags
  412. romsubdir-%:
  413. $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C pc-bios/$* V="$(V)" TARGET_DIR="$*/" CFLAGS="$(filter -O% -g%,$(CFLAGS))",)
  414. ALL_SUBDIRS=$(TARGET_DIRS) $(patsubst %,pc-bios/%, $(ROMS))
  415. recurse-all: $(SUBDIR_RULES) $(ROMSUBDIR_RULES)
  416. $(BUILD_DIR)/version.o: $(SRC_PATH)/version.rc config-host.h
  417. $(call quiet-command,$(WINDRES) -I$(BUILD_DIR) -o $@ $<,"RC","version.o")
  418. Makefile: $(version-obj-y)
  419. ######################################################################
  420. # Build libraries
  421. libqemuutil.a: $(util-obj-y) $(trace-obj-y) $(stub-obj-y)
  422. libvhost-user.a: $(libvhost-user-obj-y) $(util-obj-y) $(stub-obj-y)
  423. ######################################################################
  424. COMMON_LDADDS = libqemuutil.a
  425. qemu-img.o: qemu-img-cmds.h
  426. qemu-img$(EXESUF): qemu-img.o $(authz-obj-y) $(block-obj-y) $(crypto-obj-y) $(io-obj-y) $(qom-obj-y) $(COMMON_LDADDS)
  427. qemu-nbd$(EXESUF): qemu-nbd.o $(authz-obj-y) $(block-obj-y) $(crypto-obj-y) $(io-obj-y) $(qom-obj-y) $(COMMON_LDADDS)
  428. qemu-io$(EXESUF): qemu-io.o $(authz-obj-y) $(block-obj-y) $(crypto-obj-y) $(io-obj-y) $(qom-obj-y) $(COMMON_LDADDS)
  429. qemu-bridge-helper$(EXESUF): qemu-bridge-helper.o $(COMMON_LDADDS)
  430. qemu-keymap$(EXESUF): qemu-keymap.o ui/input-keymap.o $(COMMON_LDADDS)
  431. qemu-edid$(EXESUF): qemu-edid.o hw/display/edid-generate.o $(COMMON_LDADDS)
  432. fsdev/virtfs-proxy-helper$(EXESUF): fsdev/virtfs-proxy-helper.o fsdev/9p-marshal.o fsdev/9p-iov-marshal.o $(COMMON_LDADDS)
  433. fsdev/virtfs-proxy-helper$(EXESUF): LIBS += -lcap
  434. scsi/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)
  435. ifdef CONFIG_MPATH
  436. scsi/qemu-pr-helper$(EXESUF): LIBS += -ludev -lmultipath -lmpathpersist
  437. endif
  438. qemu-img-cmds.h: $(SRC_PATH)/qemu-img-cmds.hx $(SRC_PATH)/scripts/hxtool
  439. $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@,"GEN","$@")
  440. qemu-ga$(EXESUF): LIBS = $(LIBS_QGA)
  441. qemu-ga$(EXESUF): QEMU_CFLAGS += -I qga/qapi-generated
  442. qemu-keymap$(EXESUF): LIBS += $(XKBCOMMON_LIBS)
  443. qemu-keymap$(EXESUF): QEMU_CFLAGS += $(XKBCOMMON_CFLAGS)
  444. qapi-py = $(SRC_PATH)/scripts/qapi/commands.py \
  445. $(SRC_PATH)/scripts/qapi/events.py \
  446. $(SRC_PATH)/scripts/qapi/introspect.py \
  447. $(SRC_PATH)/scripts/qapi/types.py \
  448. $(SRC_PATH)/scripts/qapi/visit.py \
  449. $(SRC_PATH)/scripts/qapi/common.py \
  450. $(SRC_PATH)/scripts/qapi/doc.py \
  451. $(SRC_PATH)/scripts/qapi-gen.py
  452. qga/qapi-generated/qga-qapi-types.c qga/qapi-generated/qga-qapi-types.h \
  453. qga/qapi-generated/qga-qapi-visit.c qga/qapi-generated/qga-qapi-visit.h \
  454. qga/qapi-generated/qga-qapi-commands.h qga/qapi-generated/qga-qapi-commands.c \
  455. qga/qapi-generated/qga-qapi-doc.texi: \
  456. qga/qapi-generated/qapi-gen-timestamp ;
  457. qga/qapi-generated/qapi-gen-timestamp: $(SRC_PATH)/qga/qapi-schema.json $(qapi-py)
  458. $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-gen.py \
  459. -o qga/qapi-generated -p "qga-" $<, \
  460. "GEN","$(@:%-timestamp=%)")
  461. @>$@
  462. qapi-modules = $(SRC_PATH)/qapi/qapi-schema.json \
  463. $(QAPI_MODULES:%=$(SRC_PATH)/qapi/%.json)
  464. $(GENERATED_QAPI_FILES): qapi-gen-timestamp ;
  465. qapi-gen-timestamp: $(qapi-modules) $(qapi-py)
  466. $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-gen.py \
  467. -o "qapi" -b $<, \
  468. "GEN","$(@:%-timestamp=%)")
  469. @>$@
  470. QGALIB_GEN=$(addprefix qga/qapi-generated/, qga-qapi-types.h qga-qapi-visit.h qga-qapi-commands.h)
  471. $(qga-obj-y): $(QGALIB_GEN)
  472. qemu-ga$(EXESUF): $(qga-obj-y) $(COMMON_LDADDS)
  473. $(call LINK, $^)
  474. ifdef QEMU_GA_MSI_ENABLED
  475. QEMU_GA_MSI=qemu-ga-$(ARCH).msi
  476. msi: $(QEMU_GA_MSI)
  477. $(QEMU_GA_MSI): qemu-ga.exe $(QGA_VSS_PROVIDER)
  478. $(QEMU_GA_MSI): config-host.mak
  479. $(QEMU_GA_MSI): $(SRC_PATH)/qga/installer/qemu-ga.wxs
  480. $(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)" \
  481. wixl -o $@ $(QEMU_GA_MSI_ARCH) $(QEMU_GA_MSI_WITH_VSS) $(QEMU_GA_MSI_MINGW_DLL_PATH) $<,"WIXL","$@")
  482. else
  483. msi:
  484. @echo "MSI build not configured or dependency resolution failed (reconfigure with --enable-guest-agent-msi option)"
  485. endif
  486. ifneq ($(EXESUF),)
  487. .PHONY: qemu-ga
  488. qemu-ga: qemu-ga$(EXESUF) $(QGA_VSS_PROVIDER) $(QEMU_GA_MSI)
  489. endif
  490. elf2dmp$(EXESUF): LIBS += $(CURL_LIBS)
  491. elf2dmp$(EXESUF): $(elf2dmp-obj-y)
  492. $(call LINK, $^)
  493. ifdef CONFIG_IVSHMEM
  494. ivshmem-client$(EXESUF): $(ivshmem-client-obj-y) $(COMMON_LDADDS)
  495. $(call LINK, $^)
  496. ivshmem-server$(EXESUF): $(ivshmem-server-obj-y) $(COMMON_LDADDS)
  497. $(call LINK, $^)
  498. endif
  499. vhost-user-scsi$(EXESUF): $(vhost-user-scsi-obj-y) libvhost-user.a
  500. $(call LINK, $^)
  501. vhost-user-blk$(EXESUF): $(vhost-user-blk-obj-y) libvhost-user.a
  502. $(call LINK, $^)
  503. rdmacm-mux$(EXESUF): LIBS += "-libumad"
  504. rdmacm-mux$(EXESUF): $(rdmacm-mux-obj-y) $(COMMON_LDADDS)
  505. $(call LINK, $^)
  506. module_block.h: $(SRC_PATH)/scripts/modules/module_block.py config-host.mak
  507. $(call quiet-command,$(PYTHON) $< $@ \
  508. $(addprefix $(SRC_PATH)/,$(patsubst %.mo,%.c,$(block-obj-m))), \
  509. "GEN","$@")
  510. ifdef CONFIG_GCOV
  511. .PHONY: clean-coverage
  512. clean-coverage:
  513. $(call quiet-command, \
  514. find . \( -name '*.gcda' -o -name '*.gcov' \) -type f -exec rm {} +, \
  515. "CLEAN", "coverage files")
  516. endif
  517. clean:
  518. # avoid old build problems by removing potentially incorrect old files
  519. rm -f config.mak op-i386.h opc-i386.h gen-op-i386.h op-arm.h opc-arm.h gen-op-arm.h
  520. rm -f qemu-options.def
  521. rm -f *.msi
  522. find . \( -name '*.so' -o -name '*.dll' -o -name '*.mo' -o -name '*.[oda]' \) -type f \
  523. ! -path ./roms/edk2/ArmPkg/Library/GccLto/liblto-aarch64.a \
  524. ! -path ./roms/edk2/ArmPkg/Library/GccLto/liblto-arm.a \
  525. ! -path ./roms/edk2/BaseTools/Source/Python/UPT/Dll/sqlite3.dll \
  526. -exec rm {} +
  527. rm -f $(edk2-decompressed)
  528. rm -f $(filter-out %.tlb,$(TOOLS)) $(HELPERS-y) qemu-ga TAGS cscope.* *.pod *~ */*~
  529. rm -f fsdev/*.pod scsi/*.pod
  530. rm -f qemu-img-cmds.h
  531. rm -f ui/shader/*-vert.h ui/shader/*-frag.h
  532. @# May not be present in GENERATED_FILES
  533. rm -f trace/generated-tracers-dtrace.dtrace*
  534. rm -f trace/generated-tracers-dtrace.h*
  535. rm -f $(foreach f,$(GENERATED_FILES),$(f) $(f)-timestamp)
  536. rm -f qapi-gen-timestamp
  537. rm -rf qga/qapi-generated
  538. for d in $(ALL_SUBDIRS); do \
  539. if test -d $$d; then $(MAKE) -C $$d $@ || exit 1; fi; \
  540. rm -f $$d/qemu-options.def; \
  541. done
  542. rm -f config-all-devices.mak
  543. VERSION ?= $(shell cat VERSION)
  544. dist: qemu-$(VERSION).tar.bz2
  545. qemu-%.tar.bz2:
  546. $(SRC_PATH)/scripts/make-release "$(SRC_PATH)" "$(patsubst qemu-%.tar.bz2,%,$@)"
  547. # Sphinx does not allow building manuals into the same directory as
  548. # the source files, so if we're doing an in-tree QEMU build we must
  549. # build the manuals into a subdirectory (and then install them from
  550. # there for 'make install'). For an out-of-tree build we can just
  551. # use the docs/ subdirectory in the build tree as normal.
  552. ifeq ($(realpath $(SRC_PATH)),$(realpath .))
  553. MANUAL_BUILDDIR := docs/built
  554. else
  555. MANUAL_BUILDDIR := docs
  556. endif
  557. define clean-manual =
  558. rm -rf $(MANUAL_BUILDDIR)/$1/_static
  559. rm -f $(MANUAL_BUILDDIR)/$1/objects.inv $(MANUAL_BUILDDIR)/$1/searchindex.js $(MANUAL_BUILDDIR)/$1/*.html
  560. endef
  561. distclean: clean
  562. rm -f config-host.mak config-host.h* config-host.ld $(DOCS) qemu-options.texi qemu-img-cmds.texi qemu-monitor.texi qemu-monitor-info.texi
  563. rm -f config-all-devices.mak config-all-disas.mak config.status
  564. rm -f $(SUBDIR_DEVICES_MAK)
  565. rm -f po/*.mo tests/qemu-iotests/common.env
  566. rm -f roms/seabios/config.mak roms/vgabios/config.mak
  567. rm -f qemu-doc.info qemu-doc.aux qemu-doc.cp qemu-doc.cps
  568. rm -f qemu-doc.fn qemu-doc.fns qemu-doc.info qemu-doc.ky qemu-doc.kys
  569. rm -f qemu-doc.log qemu-doc.pdf qemu-doc.pg qemu-doc.toc qemu-doc.tp
  570. rm -f qemu-doc.vr qemu-doc.txt
  571. rm -f config.log
  572. rm -f linux-headers/asm
  573. rm -f docs/version.texi
  574. rm -f docs/interop/qemu-ga-qapi.texi docs/interop/qemu-qmp-qapi.texi
  575. rm -f docs/interop/qemu-qmp-ref.7 docs/interop/qemu-ga-ref.7
  576. rm -f docs/interop/qemu-qmp-ref.txt docs/interop/qemu-ga-ref.txt
  577. rm -f docs/interop/qemu-qmp-ref.pdf docs/interop/qemu-ga-ref.pdf
  578. rm -f docs/interop/qemu-qmp-ref.html docs/interop/qemu-ga-ref.html
  579. rm -f docs/qemu-block-drivers.7
  580. rm -f docs/qemu-cpu-models.7
  581. rm -rf .doctrees
  582. $(call clean-manual,devel)
  583. $(call clean-manual,interop)
  584. for d in $(TARGET_DIRS); do \
  585. rm -rf $$d || exit 1 ; \
  586. done
  587. rm -Rf .sdk
  588. if test -f dtc/version_gen.h; then $(MAKE) $(DTC_MAKE_ARGS) clean; fi
  589. KEYMAPS=da en-gb et fr fr-ch is lt no pt-br sv \
  590. ar de en-us fi fr-be hr it lv nl pl ru th \
  591. de-ch es fo fr-ca hu ja mk pt sl tr \
  592. bepo cz
  593. ifdef INSTALL_BLOBS
  594. BLOBS=bios.bin bios-256k.bin sgabios.bin vgabios.bin vgabios-cirrus.bin \
  595. vgabios-stdvga.bin vgabios-vmware.bin vgabios-qxl.bin vgabios-virtio.bin \
  596. vgabios-ramfb.bin vgabios-bochs-display.bin \
  597. ppc_rom.bin openbios-sparc32 openbios-sparc64 openbios-ppc QEMU,tcx.bin QEMU,cgthree.bin \
  598. pxe-e1000.rom pxe-eepro100.rom pxe-ne2k_pci.rom \
  599. pxe-pcnet.rom pxe-rtl8139.rom pxe-virtio.rom \
  600. efi-e1000.rom efi-eepro100.rom efi-ne2k_pci.rom \
  601. efi-pcnet.rom efi-rtl8139.rom efi-virtio.rom \
  602. efi-e1000e.rom efi-vmxnet3.rom \
  603. bamboo.dtb canyonlands.dtb petalogix-s3adsp1800.dtb petalogix-ml605.dtb \
  604. multiboot.bin linuxboot.bin linuxboot_dma.bin kvmvapic.bin pvh.bin \
  605. s390-ccw.img s390-netboot.img \
  606. spapr-rtas.bin slof.bin skiboot.lid \
  607. palcode-clipper \
  608. u-boot.e500 u-boot-sam460-20100605.bin \
  609. qemu_vga.ndrv \
  610. edk2-licenses.txt \
  611. hppa-firmware.img
  612. DESCS=50-edk2-i386-secure.json 50-edk2-x86_64-secure.json \
  613. 60-edk2-aarch64.json 60-edk2-arm.json 60-edk2-i386.json 60-edk2-x86_64.json
  614. else
  615. BLOBS=
  616. DESCS=
  617. endif
  618. # Note that we manually filter-out the non-Sphinx documentation which
  619. # is currently built into the docs/interop directory in the build tree.
  620. define install-manual =
  621. for d in $$(cd $(MANUAL_BUILDDIR) && find $1 -type d); do $(INSTALL_DIR) "$(DESTDIR)$(qemu_docdir)/$$d"; done
  622. for f in $$(cd $(MANUAL_BUILDDIR) && find $1 -type f -a '!' '(' -name 'qemu-*-qapi.*' -o -name 'qemu-*-ref.*' ')' ); do $(INSTALL_DATA) "$(MANUAL_BUILDDIR)/$$f" "$(DESTDIR)$(qemu_docdir)/$$f"; done
  623. endef
  624. # Note that we deliberately do not install the "devel" manual: it is
  625. # for QEMU developers, and not interesting to our users.
  626. .PHONY: install-sphinxdocs
  627. install-sphinxdocs: sphinxdocs
  628. $(call install-manual,interop)
  629. install-doc: $(DOCS) install-sphinxdocs
  630. $(INSTALL_DIR) "$(DESTDIR)$(qemu_docdir)"
  631. $(INSTALL_DATA) qemu-doc.html "$(DESTDIR)$(qemu_docdir)"
  632. $(INSTALL_DATA) qemu-doc.txt "$(DESTDIR)$(qemu_docdir)"
  633. $(INSTALL_DATA) docs/interop/qemu-qmp-ref.html "$(DESTDIR)$(qemu_docdir)"
  634. $(INSTALL_DATA) docs/interop/qemu-qmp-ref.txt "$(DESTDIR)$(qemu_docdir)"
  635. ifdef CONFIG_POSIX
  636. $(INSTALL_DIR) "$(DESTDIR)$(mandir)/man1"
  637. $(INSTALL_DATA) qemu.1 "$(DESTDIR)$(mandir)/man1"
  638. $(INSTALL_DIR) "$(DESTDIR)$(mandir)/man7"
  639. $(INSTALL_DATA) docs/interop/qemu-qmp-ref.7 "$(DESTDIR)$(mandir)/man7"
  640. $(INSTALL_DATA) docs/qemu-block-drivers.7 "$(DESTDIR)$(mandir)/man7"
  641. $(INSTALL_DATA) docs/qemu-cpu-models.7 "$(DESTDIR)$(mandir)/man7"
  642. ifneq ($(TOOLS),)
  643. $(INSTALL_DATA) qemu-img.1 "$(DESTDIR)$(mandir)/man1"
  644. $(INSTALL_DIR) "$(DESTDIR)$(mandir)/man8"
  645. $(INSTALL_DATA) qemu-nbd.8 "$(DESTDIR)$(mandir)/man8"
  646. endif
  647. ifdef CONFIG_TRACE_SYSTEMTAP
  648. $(INSTALL_DATA) scripts/qemu-trace-stap.1 "$(DESTDIR)$(mandir)/man1"
  649. endif
  650. ifneq (,$(findstring qemu-ga,$(TOOLS)))
  651. $(INSTALL_DATA) qemu-ga.8 "$(DESTDIR)$(mandir)/man8"
  652. $(INSTALL_DATA) docs/interop/qemu-ga-ref.html "$(DESTDIR)$(qemu_docdir)"
  653. $(INSTALL_DATA) docs/interop/qemu-ga-ref.txt "$(DESTDIR)$(qemu_docdir)"
  654. $(INSTALL_DATA) docs/interop/qemu-ga-ref.7 "$(DESTDIR)$(mandir)/man7"
  655. endif
  656. endif
  657. ifdef CONFIG_VIRTFS
  658. $(INSTALL_DIR) "$(DESTDIR)$(mandir)/man1"
  659. $(INSTALL_DATA) fsdev/virtfs-proxy-helper.1 "$(DESTDIR)$(mandir)/man1"
  660. endif
  661. install-datadir:
  662. $(INSTALL_DIR) "$(DESTDIR)$(qemu_datadir)"
  663. install-localstatedir:
  664. ifdef CONFIG_POSIX
  665. ifneq (,$(findstring qemu-ga,$(TOOLS)))
  666. $(INSTALL_DIR) "$(DESTDIR)$(qemu_localstatedir)"/run
  667. endif
  668. endif
  669. ICON_SIZES=16x16 24x24 32x32 48x48 64x64 128x128 256x256 512x512
  670. install: all $(if $(BUILD_DOCS),install-doc) install-datadir install-localstatedir \
  671. $(if $(INSTALL_BLOBS),$(edk2-decompressed))
  672. ifneq ($(TOOLS),)
  673. $(call install-prog,$(subst qemu-ga,qemu-ga$(EXESUF),$(TOOLS)),$(DESTDIR)$(bindir))
  674. endif
  675. ifneq ($(CONFIG_MODULES),)
  676. $(INSTALL_DIR) "$(DESTDIR)$(qemu_moddir)"
  677. for s in $(modules-m:.mo=$(DSOSUF)); do \
  678. t="$(DESTDIR)$(qemu_moddir)/$$(echo $$s | tr / -)"; \
  679. $(INSTALL_LIB) $$s "$$t"; \
  680. test -z "$(STRIP)" || $(STRIP) "$$t"; \
  681. done
  682. endif
  683. ifneq ($(HELPERS-y),)
  684. $(call install-prog,$(HELPERS-y),$(DESTDIR)$(libexecdir))
  685. endif
  686. ifdef CONFIG_TRACE_SYSTEMTAP
  687. $(INSTALL_PROG) "scripts/qemu-trace-stap" $(DESTDIR)$(bindir)
  688. endif
  689. ifneq ($(BLOBS),)
  690. set -e; for x in $(BLOBS); do \
  691. $(INSTALL_DATA) $(SRC_PATH)/pc-bios/$$x "$(DESTDIR)$(qemu_datadir)"; \
  692. done
  693. endif
  694. ifdef INSTALL_BLOBS
  695. set -e; for x in $(edk2-decompressed); do \
  696. $(INSTALL_DATA) $$x "$(DESTDIR)$(qemu_datadir)"; \
  697. done
  698. endif
  699. ifneq ($(DESCS),)
  700. $(INSTALL_DIR) "$(DESTDIR)$(qemu_datadir)/firmware"
  701. set -e; tmpf=$$(mktemp); trap 'rm -f -- "$$tmpf"' EXIT; \
  702. for x in $(DESCS); do \
  703. sed -e 's,@DATADIR@,$(DESTDIR)$(qemu_datadir),' \
  704. "$(SRC_PATH)/pc-bios/descriptors/$$x" > "$$tmpf"; \
  705. $(INSTALL_DATA) "$$tmpf" \
  706. "$(DESTDIR)$(qemu_datadir)/firmware/$$x"; \
  707. done
  708. endif
  709. for s in $(ICON_SIZES); do \
  710. mkdir -p "$(DESTDIR)/$(qemu_icondir)/hicolor/$${s}/apps"; \
  711. $(INSTALL_DATA) $(SRC_PATH)/ui/icons/qemu_$${s}.png \
  712. "$(DESTDIR)/$(qemu_icondir)/hicolor/$${s}/apps/qemu.png"; \
  713. done; \
  714. mkdir -p "$(DESTDIR)/$(qemu_icondir)/hicolor/32x32/apps"; \
  715. $(INSTALL_DATA) $(SRC_PATH)/ui/icons/qemu_32x32.bmp \
  716. "$(DESTDIR)/$(qemu_icondir)/hicolor/32x32/apps/qemu.bmp"; \
  717. mkdir -p "$(DESTDIR)/$(qemu_icondir)/hicolor/scalable/apps"; \
  718. $(INSTALL_DATA) $(SRC_PATH)/ui/icons/qemu.svg \
  719. "$(DESTDIR)/$(qemu_icondir)/hicolor/scalable/apps/qemu.svg"
  720. mkdir -p "$(DESTDIR)/$(qemu_desktopdir)"
  721. $(INSTALL_DATA) $(SRC_PATH)/ui/qemu.desktop \
  722. "$(DESTDIR)/$(qemu_desktopdir)/qemu.desktop"
  723. ifdef CONFIG_GTK
  724. $(MAKE) -C po $@
  725. endif
  726. $(INSTALL_DIR) "$(DESTDIR)$(qemu_datadir)/keymaps"
  727. set -e; for x in $(KEYMAPS); do \
  728. $(INSTALL_DATA) $(SRC_PATH)/pc-bios/keymaps/$$x "$(DESTDIR)$(qemu_datadir)/keymaps"; \
  729. done
  730. $(INSTALL_DATA) $(BUILD_DIR)/trace-events-all "$(DESTDIR)$(qemu_datadir)/trace-events-all"
  731. for d in $(TARGET_DIRS); do \
  732. $(MAKE) $(SUBDIR_MAKEFLAGS) TARGET_DIR=$$d/ -C $$d $@ || exit 1 ; \
  733. done
  734. .PHONY: ctags
  735. ctags:
  736. rm -f tags
  737. find "$(SRC_PATH)" -name '*.[hc]' -exec ctags --append {} +
  738. .PHONY: TAGS
  739. TAGS:
  740. rm -f TAGS
  741. find "$(SRC_PATH)" -name '*.[hc]' -exec etags --append {} +
  742. cscope:
  743. rm -f "$(SRC_PATH)"/cscope.*
  744. find "$(SRC_PATH)/" -name "*.[chsS]" -print | sed 's,^\./,,' > "$(SRC_PATH)/cscope.files"
  745. cscope -b -i"$(SRC_PATH)/cscope.files"
  746. # opengl shader programs
  747. ui/shader/%-vert.h: $(SRC_PATH)/ui/shader/%.vert $(SRC_PATH)/scripts/shaderinclude.pl
  748. @mkdir -p $(dir $@)
  749. $(call quiet-command,\
  750. perl $(SRC_PATH)/scripts/shaderinclude.pl $< > $@,\
  751. "VERT","$@")
  752. ui/shader/%-frag.h: $(SRC_PATH)/ui/shader/%.frag $(SRC_PATH)/scripts/shaderinclude.pl
  753. @mkdir -p $(dir $@)
  754. $(call quiet-command,\
  755. perl $(SRC_PATH)/scripts/shaderinclude.pl $< > $@,\
  756. "FRAG","$@")
  757. ui/shader.o: $(SRC_PATH)/ui/shader.c \
  758. ui/shader/texture-blit-vert.h \
  759. ui/shader/texture-blit-flip-vert.h \
  760. ui/shader/texture-blit-frag.h
  761. # documentation
  762. MAKEINFO=makeinfo
  763. MAKEINFOINCLUDES= -I docs -I $(<D) -I $(@D)
  764. MAKEINFOFLAGS=--no-split --number-sections $(MAKEINFOINCLUDES)
  765. TEXI2PODFLAGS=$(MAKEINFOINCLUDES) "-DVERSION=$(VERSION)"
  766. TEXI2PDFFLAGS=$(if $(V),,--quiet) -I $(SRC_PATH) $(MAKEINFOINCLUDES)
  767. docs/version.texi: $(SRC_PATH)/VERSION
  768. $(call quiet-command,echo "@set VERSION $(VERSION)" > $@,"GEN","$@")
  769. %.html: %.texi docs/version.texi
  770. $(call quiet-command,LC_ALL=C $(MAKEINFO) $(MAKEINFOFLAGS) --no-headers \
  771. --html $< -o $@,"GEN","$@")
  772. %.info: %.texi docs/version.texi
  773. $(call quiet-command,$(MAKEINFO) $(MAKEINFOFLAGS) $< -o $@,"GEN","$@")
  774. %.txt: %.texi docs/version.texi
  775. $(call quiet-command,LC_ALL=C $(MAKEINFO) $(MAKEINFOFLAGS) --no-headers \
  776. --plaintext $< -o $@,"GEN","$@")
  777. %.pdf: %.texi docs/version.texi
  778. $(call quiet-command,texi2pdf $(TEXI2PDFFLAGS) $< -o $@,"GEN","$@")
  779. # Sphinx builds all its documentation at once in one invocation
  780. # and handles "don't rebuild things unless necessary" itself.
  781. # The '.doctrees' files are cached information to speed this up.
  782. .PHONY: sphinxdocs
  783. sphinxdocs: $(MANUAL_BUILDDIR)/devel/index.html $(MANUAL_BUILDDIR)/interop/index.html
  784. # Canned command to build a single manual
  785. build-manual = $(call quiet-command,sphinx-build $(if $(V),,-q) -W -n -b html -D version=$(VERSION) -D release="$(FULL_VERSION)" -d .doctrees/$1 $(SRC_PATH)/docs/$1 $(MANUAL_BUILDDIR)/$1 ,"SPHINX","$(MANUAL_BUILDDIR)/$1")
  786. # We assume all RST files in the manual's directory are used in it
  787. manual-deps = $(wildcard $(SRC_PATH)/docs/$1/*.rst) $(SRC_PATH)/docs/$1/conf.py $(SRC_PATH)/docs/conf.py
  788. $(MANUAL_BUILDDIR)/devel/index.html: $(call manual-deps,devel)
  789. $(call build-manual,devel)
  790. $(MANUAL_BUILDDIR)/interop/index.html: $(call manual-deps,interop)
  791. $(call build-manual,interop)
  792. qemu-options.texi: $(SRC_PATH)/qemu-options.hx $(SRC_PATH)/scripts/hxtool
  793. $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -t < $< > $@,"GEN","$@")
  794. qemu-monitor.texi: $(SRC_PATH)/hmp-commands.hx $(SRC_PATH)/scripts/hxtool
  795. $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -t < $< > $@,"GEN","$@")
  796. qemu-monitor-info.texi: $(SRC_PATH)/hmp-commands-info.hx $(SRC_PATH)/scripts/hxtool
  797. $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -t < $< > $@,"GEN","$@")
  798. qemu-img-cmds.texi: $(SRC_PATH)/qemu-img-cmds.hx $(SRC_PATH)/scripts/hxtool
  799. $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -t < $< > $@,"GEN","$@")
  800. docs/interop/qemu-qmp-qapi.texi: qapi/qapi-doc.texi
  801. @cp -p $< $@
  802. docs/interop/qemu-ga-qapi.texi: qga/qapi-generated/qga-qapi-doc.texi
  803. @cp -p $< $@
  804. qemu.1: qemu-doc.texi qemu-options.texi qemu-monitor.texi qemu-monitor-info.texi
  805. qemu.1: qemu-option-trace.texi
  806. qemu-img.1: qemu-img.texi qemu-option-trace.texi qemu-img-cmds.texi
  807. fsdev/virtfs-proxy-helper.1: fsdev/virtfs-proxy-helper.texi
  808. qemu-nbd.8: qemu-nbd.texi qemu-option-trace.texi
  809. qemu-ga.8: qemu-ga.texi
  810. docs/qemu-block-drivers.7: docs/qemu-block-drivers.texi
  811. docs/qemu-cpu-models.7: docs/qemu-cpu-models.texi
  812. scripts/qemu-trace-stap.1: scripts/qemu-trace-stap.texi
  813. html: qemu-doc.html docs/interop/qemu-qmp-ref.html docs/interop/qemu-ga-ref.html sphinxdocs
  814. info: qemu-doc.info docs/interop/qemu-qmp-ref.info docs/interop/qemu-ga-ref.info
  815. pdf: qemu-doc.pdf docs/interop/qemu-qmp-ref.pdf docs/interop/qemu-ga-ref.pdf
  816. txt: qemu-doc.txt docs/interop/qemu-qmp-ref.txt docs/interop/qemu-ga-ref.txt
  817. qemu-doc.html qemu-doc.info qemu-doc.pdf qemu-doc.txt: \
  818. qemu-img.texi qemu-nbd.texi qemu-options.texi qemu-option-trace.texi \
  819. qemu-deprecated.texi qemu-monitor.texi qemu-img-cmds.texi qemu-ga.texi \
  820. qemu-monitor-info.texi docs/qemu-block-drivers.texi \
  821. docs/qemu-cpu-models.texi
  822. docs/interop/qemu-ga-ref.dvi docs/interop/qemu-ga-ref.html \
  823. docs/interop/qemu-ga-ref.info docs/interop/qemu-ga-ref.pdf \
  824. docs/interop/qemu-ga-ref.txt docs/interop/qemu-ga-ref.7: \
  825. docs/interop/qemu-ga-ref.texi docs/interop/qemu-ga-qapi.texi
  826. docs/interop/qemu-qmp-ref.dvi docs/interop/qemu-qmp-ref.html \
  827. docs/interop/qemu-qmp-ref.info docs/interop/qemu-qmp-ref.pdf \
  828. docs/interop/qemu-qmp-ref.txt docs/interop/qemu-qmp-ref.7: \
  829. docs/interop/qemu-qmp-ref.texi docs/interop/qemu-qmp-qapi.texi
  830. $(filter %.1 %.7 %.8,$(DOCS)): scripts/texi2pod.pl
  831. # Reports/Analysis
  832. %/coverage-report.html:
  833. @mkdir -p $*
  834. $(call quiet-command,\
  835. gcovr -r $(SRC_PATH) --object-directory $(BUILD_PATH) \
  836. -p --html --html-details -o $@, \
  837. "GEN", "coverage-report.html")
  838. .PHONY: coverage-report
  839. coverage-report: $(CURDIR)/reports/coverage/coverage-report.html
  840. ifdef CONFIG_WIN32
  841. INSTALLER = qemu-setup-$(VERSION)$(EXESUF)
  842. nsisflags = -V2 -NOCD
  843. ifneq ($(wildcard $(SRC_PATH)/dll),)
  844. ifeq ($(ARCH),x86_64)
  845. # 64 bit executables
  846. DLL_PATH = $(SRC_PATH)/dll/w64
  847. nsisflags += -DW64
  848. else
  849. # 32 bit executables
  850. DLL_PATH = $(SRC_PATH)/dll/w32
  851. endif
  852. endif
  853. .PHONY: installer
  854. installer: $(INSTALLER)
  855. INSTDIR=/tmp/qemu-nsis
  856. $(INSTALLER): $(SRC_PATH)/qemu.nsi
  857. $(MAKE) install prefix=${INSTDIR}
  858. ifdef SIGNCODE
  859. (cd ${INSTDIR}; \
  860. for i in *.exe; do \
  861. $(SIGNCODE) $${i}; \
  862. done \
  863. )
  864. endif # SIGNCODE
  865. (cd ${INSTDIR}; \
  866. for i in qemu-system-*.exe; do \
  867. arch=$${i%.exe}; \
  868. arch=$${arch#qemu-system-}; \
  869. echo Section \"$$arch\" Section_$$arch; \
  870. echo SetOutPath \"\$$INSTDIR\"; \
  871. echo File \"\$${BINDIR}\\$$i\"; \
  872. echo SectionEnd; \
  873. done \
  874. ) >${INSTDIR}/system-emulations.nsh
  875. makensis $(nsisflags) \
  876. $(if $(BUILD_DOCS),-DCONFIG_DOCUMENTATION="y") \
  877. $(if $(CONFIG_GTK),-DCONFIG_GTK="y") \
  878. -DBINDIR="${INSTDIR}" \
  879. $(if $(DLL_PATH),-DDLLDIR="$(DLL_PATH)") \
  880. -DSRCDIR="$(SRC_PATH)" \
  881. -DOUTFILE="$(INSTALLER)" \
  882. -DDISPLAYVERSION="$(VERSION)" \
  883. $(SRC_PATH)/qemu.nsi
  884. rm -r ${INSTDIR}
  885. ifdef SIGNCODE
  886. $(SIGNCODE) $(INSTALLER)
  887. endif # SIGNCODE
  888. endif # CONFIG_WIN
  889. # Add a dependency on the generated files, so that they are always
  890. # rebuilt before other object files
  891. ifneq ($(wildcard config-host.mak),)
  892. ifneq ($(filter-out $(UNCHECKED_GOALS),$(MAKECMDGOALS)),$(if $(MAKECMDGOALS),,fail))
  893. Makefile: $(GENERATED_FILES)
  894. endif
  895. endif
  896. .SECONDARY: $(TRACE_HEADERS) $(TRACE_HEADERS:%=%-timestamp) \
  897. $(TRACE_SOURCES) $(TRACE_SOURCES:%=%-timestamp) \
  898. $(TRACE_DTRACE) $(TRACE_DTRACE:%=%-timestamp)
  899. # Include automatically generated dependency files
  900. # Dependencies in Makefile.objs files come from our recursive subdir rules
  901. -include $(wildcard *.d tests/*.d)
  902. include $(SRC_PATH)/tests/docker/Makefile.include
  903. include $(SRC_PATH)/tests/vm/Makefile.include
  904. .PHONY: help
  905. help:
  906. @echo 'Generic targets:'
  907. @echo ' all - Build all'
  908. ifdef CONFIG_MODULES
  909. @echo ' modules - Build all modules'
  910. endif
  911. @echo ' dir/file.o - Build specified target only'
  912. @echo ' install - Install QEMU, documentation and tools'
  913. @echo ' ctags/TAGS - Generate tags file for editors'
  914. @echo ' cscope - Generate cscope index'
  915. @echo ''
  916. @$(if $(TARGET_DIRS), \
  917. echo 'Architecture specific targets:'; \
  918. $(foreach t, $(TARGET_DIRS), \
  919. printf " %-30s - Build for %s\\n" $(patsubst %,subdir-%,$(t)) $(t);) \
  920. echo '')
  921. @echo 'Cleaning targets:'
  922. @echo ' clean - Remove most generated files but keep the config'
  923. ifdef CONFIG_GCOV
  924. @echo ' clean-coverage - Remove coverage files'
  925. endif
  926. @echo ' distclean - Remove all generated files'
  927. @echo ' dist - Build a distributable tarball'
  928. @echo ''
  929. @echo 'Test targets:'
  930. @echo ' check - Run all tests (check-help for details)'
  931. @echo ' docker - Help about targets running tests inside Docker containers'
  932. @echo ' vm-test - Help about targets running tests inside VM'
  933. @echo ''
  934. @echo 'Documentation targets:'
  935. @echo ' html info pdf txt'
  936. @echo ' - Build documentation in specified format'
  937. ifdef CONFIG_GCOV
  938. @echo ' coverage-report - Create code coverage report'
  939. endif
  940. @echo ''
  941. ifdef CONFIG_WIN32
  942. @echo 'Windows targets:'
  943. @echo ' installer - Build NSIS-based installer for QEMU'
  944. ifdef QEMU_GA_MSI_ENABLED
  945. @echo ' msi - Build MSI-based installer for qemu-ga'
  946. endif
  947. @echo ''
  948. endif
  949. @echo ' $(MAKE) [targets] (quiet build, default)'
  950. @echo ' $(MAKE) V=1 [targets] (verbose build)'