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.

1066 lines
38KB

  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. # Don't try to regenerate Makefile or configure
  252. # We don't generate any of them
  253. Makefile: ;
  254. configure: ;
  255. .PHONY: all clean cscope distclean html info install install-doc \
  256. pdf txt recurse-all dist msi FORCE
  257. $(call set-vpath, $(SRC_PATH))
  258. LIBS+=-lz $(LIBS_TOOLS)
  259. HELPERS-$(call land,$(CONFIG_SOFTMMU),$(CONFIG_LINUX)) = qemu-bridge-helper$(EXESUF)
  260. ifdef BUILD_DOCS
  261. DOCS=qemu-doc.html qemu-doc.txt qemu.1 qemu-img.1 qemu-nbd.8 qemu-ga.8
  262. DOCS+=docs/interop/qemu-qmp-ref.html docs/interop/qemu-qmp-ref.txt docs/interop/qemu-qmp-ref.7
  263. DOCS+=docs/interop/qemu-ga-ref.html docs/interop/qemu-ga-ref.txt docs/interop/qemu-ga-ref.7
  264. DOCS+=docs/qemu-block-drivers.7
  265. DOCS+=docs/qemu-cpu-models.7
  266. ifdef CONFIG_VIRTFS
  267. DOCS+=fsdev/virtfs-proxy-helper.1
  268. endif
  269. ifdef CONFIG_TRACE_SYSTEMTAP
  270. DOCS+=scripts/qemu-trace-stap.1
  271. endif
  272. else
  273. DOCS=
  274. endif
  275. SUBDIR_MAKEFLAGS=$(if $(V),,--no-print-directory --quiet) BUILD_DIR=$(BUILD_DIR)
  276. SUBDIR_DEVICES_MAK=$(patsubst %, %/config-devices.mak, $(TARGET_DIRS))
  277. SUBDIR_DEVICES_MAK_DEP=$(patsubst %, %-config-devices.mak.d, $(TARGET_DIRS))
  278. ifeq ($(SUBDIR_DEVICES_MAK),)
  279. config-all-devices.mak:
  280. $(call quiet-command,echo '# no devices' > $@,"GEN","$@")
  281. else
  282. config-all-devices.mak: $(SUBDIR_DEVICES_MAK)
  283. $(call quiet-command, sed -n \
  284. 's|^\([^=]*\)=\(.*\)$$|\1:=$$(findstring y,$$(\1)\2)|p' \
  285. $(SUBDIR_DEVICES_MAK) | sort -u > $@, \
  286. "GEN","$@")
  287. endif
  288. -include $(SUBDIR_DEVICES_MAK_DEP)
  289. %/config-devices.mak: default-configs/%.mak $(SRC_PATH)/scripts/make_device_config.sh
  290. $(call quiet-command, \
  291. $(SHELL) $(SRC_PATH)/scripts/make_device_config.sh $< $*-config-devices.mak.d $@ > $@.tmp,"GEN","$@.tmp")
  292. $(call quiet-command, if test -f $@; then \
  293. if cmp -s $@.old $@; then \
  294. mv $@.tmp $@; \
  295. cp -p $@ $@.old; \
  296. else \
  297. if test -f $@.old; then \
  298. echo "WARNING: $@ (user modified) out of date.";\
  299. else \
  300. echo "WARNING: $@ out of date.";\
  301. fi; \
  302. echo "Run \"$(MAKE) defconfig\" to regenerate."; \
  303. rm $@.tmp; \
  304. fi; \
  305. else \
  306. mv $@.tmp $@; \
  307. cp -p $@ $@.old; \
  308. fi,"GEN","$@");
  309. defconfig:
  310. rm -f config-all-devices.mak $(SUBDIR_DEVICES_MAK)
  311. ifneq ($(wildcard config-host.mak),)
  312. include $(SRC_PATH)/Makefile.objs
  313. endif
  314. dummy := $(call unnest-vars,, \
  315. stub-obj-y \
  316. authz-obj-y \
  317. chardev-obj-y \
  318. util-obj-y \
  319. qga-obj-y \
  320. elf2dmp-obj-y \
  321. ivshmem-client-obj-y \
  322. ivshmem-server-obj-y \
  323. rdmacm-mux-obj-y \
  324. libvhost-user-obj-y \
  325. vhost-user-scsi-obj-y \
  326. vhost-user-blk-obj-y \
  327. qga-vss-dll-obj-y \
  328. block-obj-y \
  329. block-obj-m \
  330. crypto-obj-y \
  331. crypto-aes-obj-y \
  332. qom-obj-y \
  333. io-obj-y \
  334. common-obj-y \
  335. common-obj-m \
  336. ui-obj-y \
  337. ui-obj-m \
  338. audio-obj-y \
  339. audio-obj-m \
  340. trace-obj-y \
  341. slirp-obj-y)
  342. include $(SRC_PATH)/tests/Makefile.include
  343. all: $(DOCS) $(if $(BUILD_DOCS),sphinxdocs) $(TOOLS) $(HELPERS-y) recurse-all modules
  344. qemu-version.h: FORCE
  345. $(call quiet-command, \
  346. (printf '#define QEMU_PKGVERSION "$(QEMU_PKGVERSION)"\n'; \
  347. printf '#define QEMU_FULL_VERSION "$(FULL_VERSION)"\n'; \
  348. ) > $@.tmp)
  349. $(call quiet-command, if ! cmp -s $@ $@.tmp; then \
  350. mv $@.tmp $@; \
  351. else \
  352. rm $@.tmp; \
  353. fi)
  354. config-host.h: config-host.h-timestamp
  355. config-host.h-timestamp: config-host.mak
  356. qemu-options.def: $(SRC_PATH)/qemu-options.hx $(SRC_PATH)/scripts/hxtool
  357. $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@,"GEN","$@")
  358. SUBDIR_RULES=$(patsubst %,subdir-%, $(TARGET_DIRS))
  359. SOFTMMU_SUBDIR_RULES=$(filter %-softmmu,$(SUBDIR_RULES))
  360. $(SOFTMMU_SUBDIR_RULES): $(authz-obj-y)
  361. $(SOFTMMU_SUBDIR_RULES): $(block-obj-y)
  362. $(SOFTMMU_SUBDIR_RULES): $(crypto-obj-y)
  363. $(SOFTMMU_SUBDIR_RULES): $(io-obj-y)
  364. $(SOFTMMU_SUBDIR_RULES): config-all-devices.mak
  365. subdir-%:
  366. $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C $* V="$(V)" TARGET_DIR="$*/" all,)
  367. DTC_MAKE_ARGS=-I$(SRC_PATH)/dtc VPATH=$(SRC_PATH)/dtc -C dtc V="$(V)" LIBFDT_srcdir=$(SRC_PATH)/dtc/libfdt
  368. DTC_CFLAGS=$(CFLAGS) $(QEMU_CFLAGS)
  369. DTC_CPPFLAGS=-I$(BUILD_DIR)/dtc -I$(SRC_PATH)/dtc -I$(SRC_PATH)/dtc/libfdt
  370. subdir-dtc: .git-submodule-status dtc/libfdt dtc/tests
  371. $(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,)
  372. dtc/%: .git-submodule-status
  373. @mkdir -p $@
  374. # Overriding CFLAGS causes us to lose defines added in the sub-makefile.
  375. # Not overriding CFLAGS leads to mis-matches between compilation modes.
  376. # Therefore we replicate some of the logic in the sub-makefile.
  377. # Remove all the extra -Warning flags that QEMU uses that Capstone doesn't;
  378. # no need to annoy QEMU developers with such things.
  379. CAP_CFLAGS = $(patsubst -W%,,$(CFLAGS) $(QEMU_CFLAGS))
  380. CAP_CFLAGS += -DCAPSTONE_USE_SYS_DYN_MEM
  381. CAP_CFLAGS += -DCAPSTONE_HAS_ARM
  382. CAP_CFLAGS += -DCAPSTONE_HAS_ARM64
  383. CAP_CFLAGS += -DCAPSTONE_HAS_POWERPC
  384. CAP_CFLAGS += -DCAPSTONE_HAS_X86
  385. subdir-capstone: .git-submodule-status
  386. $(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))
  387. $(SUBDIR_RULES): libqemuutil.a $(common-obj-y) $(chardev-obj-y) $(slirp-obj-y) \
  388. $(qom-obj-y) $(crypto-aes-obj-$(CONFIG_USER_ONLY))
  389. ROMSUBDIR_RULES=$(patsubst %,romsubdir-%, $(ROMS))
  390. # Only keep -O and -g cflags
  391. romsubdir-%:
  392. $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C pc-bios/$* V="$(V)" TARGET_DIR="$*/" CFLAGS="$(filter -O% -g%,$(CFLAGS))",)
  393. ALL_SUBDIRS=$(TARGET_DIRS) $(patsubst %,pc-bios/%, $(ROMS))
  394. recurse-all: $(SUBDIR_RULES) $(ROMSUBDIR_RULES)
  395. $(BUILD_DIR)/version.o: $(SRC_PATH)/version.rc config-host.h
  396. $(call quiet-command,$(WINDRES) -I$(BUILD_DIR) -o $@ $<,"RC","version.o")
  397. Makefile: $(version-obj-y)
  398. ######################################################################
  399. # Build libraries
  400. libqemuutil.a: $(util-obj-y) $(trace-obj-y) $(stub-obj-y)
  401. libvhost-user.a: $(libvhost-user-obj-y)
  402. ######################################################################
  403. COMMON_LDADDS = libqemuutil.a
  404. qemu-img.o: qemu-img-cmds.h
  405. qemu-img$(EXESUF): qemu-img.o $(authz-obj-y) $(block-obj-y) $(crypto-obj-y) $(io-obj-y) $(qom-obj-y) $(COMMON_LDADDS)
  406. qemu-nbd$(EXESUF): qemu-nbd.o $(authz-obj-y) $(block-obj-y) $(crypto-obj-y) $(io-obj-y) $(qom-obj-y) $(COMMON_LDADDS)
  407. qemu-io$(EXESUF): qemu-io.o $(authz-obj-y) $(block-obj-y) $(crypto-obj-y) $(io-obj-y) $(qom-obj-y) $(COMMON_LDADDS)
  408. qemu-bridge-helper$(EXESUF): qemu-bridge-helper.o $(COMMON_LDADDS)
  409. qemu-keymap$(EXESUF): qemu-keymap.o ui/input-keymap.o $(COMMON_LDADDS)
  410. qemu-edid$(EXESUF): qemu-edid.o hw/display/edid-generate.o $(COMMON_LDADDS)
  411. fsdev/virtfs-proxy-helper$(EXESUF): fsdev/virtfs-proxy-helper.o fsdev/9p-marshal.o fsdev/9p-iov-marshal.o $(COMMON_LDADDS)
  412. fsdev/virtfs-proxy-helper$(EXESUF): LIBS += -lcap
  413. 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)
  414. ifdef CONFIG_MPATH
  415. scsi/qemu-pr-helper$(EXESUF): LIBS += -ludev -lmultipath -lmpathpersist
  416. endif
  417. qemu-img-cmds.h: $(SRC_PATH)/qemu-img-cmds.hx $(SRC_PATH)/scripts/hxtool
  418. $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@,"GEN","$@")
  419. qemu-ga$(EXESUF): LIBS = $(LIBS_QGA)
  420. qemu-ga$(EXESUF): QEMU_CFLAGS += -I qga/qapi-generated
  421. qemu-keymap$(EXESUF): LIBS += $(XKBCOMMON_LIBS)
  422. qemu-keymap$(EXESUF): QEMU_CFLAGS += $(XKBCOMMON_CFLAGS)
  423. qapi-py = $(SRC_PATH)/scripts/qapi/commands.py \
  424. $(SRC_PATH)/scripts/qapi/events.py \
  425. $(SRC_PATH)/scripts/qapi/introspect.py \
  426. $(SRC_PATH)/scripts/qapi/types.py \
  427. $(SRC_PATH)/scripts/qapi/visit.py \
  428. $(SRC_PATH)/scripts/qapi/common.py \
  429. $(SRC_PATH)/scripts/qapi/doc.py \
  430. $(SRC_PATH)/scripts/qapi-gen.py
  431. qga/qapi-generated/qga-qapi-types.c qga/qapi-generated/qga-qapi-types.h \
  432. qga/qapi-generated/qga-qapi-visit.c qga/qapi-generated/qga-qapi-visit.h \
  433. qga/qapi-generated/qga-qapi-commands.h qga/qapi-generated/qga-qapi-commands.c \
  434. qga/qapi-generated/qga-qapi-doc.texi: \
  435. qga/qapi-generated/qapi-gen-timestamp ;
  436. qga/qapi-generated/qapi-gen-timestamp: $(SRC_PATH)/qga/qapi-schema.json $(qapi-py)
  437. $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-gen.py \
  438. -o qga/qapi-generated -p "qga-" $<, \
  439. "GEN","$(@:%-timestamp=%)")
  440. @>$@
  441. qapi-modules = $(SRC_PATH)/qapi/qapi-schema.json \
  442. $(QAPI_MODULES:%=$(SRC_PATH)/qapi/%.json)
  443. $(GENERATED_QAPI_FILES): qapi-gen-timestamp ;
  444. qapi-gen-timestamp: $(qapi-modules) $(qapi-py)
  445. $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-gen.py \
  446. -o "qapi" -b $<, \
  447. "GEN","$(@:%-timestamp=%)")
  448. @>$@
  449. QGALIB_GEN=$(addprefix qga/qapi-generated/, qga-qapi-types.h qga-qapi-visit.h qga-qapi-commands.h)
  450. $(qga-obj-y): $(QGALIB_GEN)
  451. qemu-ga$(EXESUF): $(qga-obj-y) $(COMMON_LDADDS)
  452. $(call LINK, $^)
  453. ifdef QEMU_GA_MSI_ENABLED
  454. QEMU_GA_MSI=qemu-ga-$(ARCH).msi
  455. msi: $(QEMU_GA_MSI)
  456. $(QEMU_GA_MSI): qemu-ga.exe $(QGA_VSS_PROVIDER)
  457. $(QEMU_GA_MSI): config-host.mak
  458. $(QEMU_GA_MSI): $(SRC_PATH)/qga/installer/qemu-ga.wxs
  459. $(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)" \
  460. wixl -o $@ $(QEMU_GA_MSI_ARCH) $(QEMU_GA_MSI_WITH_VSS) $(QEMU_GA_MSI_MINGW_DLL_PATH) $<,"WIXL","$@")
  461. else
  462. msi:
  463. @echo "MSI build not configured or dependency resolution failed (reconfigure with --enable-guest-agent-msi option)"
  464. endif
  465. ifneq ($(EXESUF),)
  466. .PHONY: qemu-ga
  467. qemu-ga: qemu-ga$(EXESUF) $(QGA_VSS_PROVIDER) $(QEMU_GA_MSI)
  468. endif
  469. elf2dmp$(EXESUF): LIBS += $(CURL_LIBS)
  470. elf2dmp$(EXESUF): $(elf2dmp-obj-y)
  471. $(call LINK, $^)
  472. ifdef CONFIG_IVSHMEM
  473. ivshmem-client$(EXESUF): $(ivshmem-client-obj-y) $(COMMON_LDADDS)
  474. $(call LINK, $^)
  475. ivshmem-server$(EXESUF): $(ivshmem-server-obj-y) $(COMMON_LDADDS)
  476. $(call LINK, $^)
  477. endif
  478. vhost-user-scsi$(EXESUF): $(vhost-user-scsi-obj-y) libvhost-user.a
  479. $(call LINK, $^)
  480. vhost-user-blk$(EXESUF): $(vhost-user-blk-obj-y) libvhost-user.a
  481. $(call LINK, $^)
  482. rdmacm-mux$(EXESUF): LIBS += "-libumad"
  483. rdmacm-mux$(EXESUF): $(rdmacm-mux-obj-y) $(COMMON_LDADDS)
  484. $(call LINK, $^)
  485. module_block.h: $(SRC_PATH)/scripts/modules/module_block.py config-host.mak
  486. $(call quiet-command,$(PYTHON) $< $@ \
  487. $(addprefix $(SRC_PATH)/,$(patsubst %.mo,%.c,$(block-obj-m))), \
  488. "GEN","$@")
  489. ifdef CONFIG_GCOV
  490. .PHONY: clean-coverage
  491. clean-coverage:
  492. $(call quiet-command, \
  493. find . \( -name '*.gcda' -o -name '*.gcov' \) -type f -exec rm {} +, \
  494. "CLEAN", "coverage files")
  495. endif
  496. clean:
  497. # avoid old build problems by removing potentially incorrect old files
  498. rm -f config.mak op-i386.h opc-i386.h gen-op-i386.h op-arm.h opc-arm.h gen-op-arm.h
  499. rm -f qemu-options.def
  500. rm -f *.msi
  501. find . \( -name '*.so' -o -name '*.dll' -o -name '*.mo' -o -name '*.[oda]' \) -type f \
  502. ! -path ./roms/edk2/ArmPkg/Library/GccLto/liblto-aarch64.a \
  503. ! -path ./roms/edk2/ArmPkg/Library/GccLto/liblto-arm.a \
  504. ! -path ./roms/edk2/BaseTools/Source/Python/UPT/Dll/sqlite3.dll \
  505. -exec rm {} +
  506. rm -f $(filter-out %.tlb,$(TOOLS)) $(HELPERS-y) qemu-ga TAGS cscope.* *.pod *~ */*~
  507. rm -f fsdev/*.pod scsi/*.pod
  508. rm -f qemu-img-cmds.h
  509. rm -f ui/shader/*-vert.h ui/shader/*-frag.h
  510. @# May not be present in GENERATED_FILES
  511. rm -f trace/generated-tracers-dtrace.dtrace*
  512. rm -f trace/generated-tracers-dtrace.h*
  513. rm -f $(foreach f,$(GENERATED_FILES),$(f) $(f)-timestamp)
  514. rm -f qapi-gen-timestamp
  515. rm -rf qga/qapi-generated
  516. for d in $(ALL_SUBDIRS); do \
  517. if test -d $$d; then $(MAKE) -C $$d $@ || exit 1; fi; \
  518. rm -f $$d/qemu-options.def; \
  519. done
  520. rm -f config-all-devices.mak
  521. VERSION ?= $(shell cat VERSION)
  522. dist: qemu-$(VERSION).tar.bz2
  523. qemu-%.tar.bz2:
  524. $(SRC_PATH)/scripts/make-release "$(SRC_PATH)" "$(patsubst qemu-%.tar.bz2,%,$@)"
  525. # Note that these commands assume that there are no HTML files in
  526. # the docs subdir in the source tree! If there are then this will
  527. # blow them away for an in-source-tree 'make clean'.
  528. define clean-manual =
  529. rm -rf docs/$1/_static
  530. rm -f docs/$1/objects.inv docs/$1/searchindex.js docs/$1/*.html
  531. endef
  532. distclean: clean
  533. 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
  534. rm -f config-all-devices.mak config-all-disas.mak config.status
  535. rm -f $(SUBDIR_DEVICES_MAK)
  536. rm -f po/*.mo tests/qemu-iotests/common.env
  537. rm -f roms/seabios/config.mak roms/vgabios/config.mak
  538. rm -f qemu-doc.info qemu-doc.aux qemu-doc.cp qemu-doc.cps
  539. rm -f qemu-doc.fn qemu-doc.fns qemu-doc.info qemu-doc.ky qemu-doc.kys
  540. rm -f qemu-doc.log qemu-doc.pdf qemu-doc.pg qemu-doc.toc qemu-doc.tp
  541. rm -f qemu-doc.vr qemu-doc.txt
  542. rm -f config.log
  543. rm -f linux-headers/asm
  544. rm -f docs/version.texi
  545. rm -f docs/interop/qemu-ga-qapi.texi docs/interop/qemu-qmp-qapi.texi
  546. rm -f docs/interop/qemu-qmp-ref.7 docs/interop/qemu-ga-ref.7
  547. rm -f docs/interop/qemu-qmp-ref.txt docs/interop/qemu-ga-ref.txt
  548. rm -f docs/interop/qemu-qmp-ref.pdf docs/interop/qemu-ga-ref.pdf
  549. rm -f docs/interop/qemu-qmp-ref.html docs/interop/qemu-ga-ref.html
  550. rm -f docs/qemu-block-drivers.7
  551. rm -f docs/qemu-cpu-models.7
  552. rm -f .doctrees
  553. $(call clean-manual,devel)
  554. $(call clean-manual,interop)
  555. for d in $(TARGET_DIRS); do \
  556. rm -rf $$d || exit 1 ; \
  557. done
  558. rm -Rf .sdk
  559. if test -f dtc/version_gen.h; then $(MAKE) $(DTC_MAKE_ARGS) clean; fi
  560. KEYMAPS=da en-gb et fr fr-ch is lt no pt-br sv \
  561. ar de en-us fi fr-be hr it lv nl pl ru th \
  562. de-ch es fo fr-ca hu ja mk pt sl tr \
  563. bepo cz
  564. ifdef INSTALL_BLOBS
  565. BLOBS=bios.bin bios-256k.bin sgabios.bin vgabios.bin vgabios-cirrus.bin \
  566. vgabios-stdvga.bin vgabios-vmware.bin vgabios-qxl.bin vgabios-virtio.bin \
  567. vgabios-ramfb.bin vgabios-bochs-display.bin \
  568. ppc_rom.bin openbios-sparc32 openbios-sparc64 openbios-ppc QEMU,tcx.bin QEMU,cgthree.bin \
  569. pxe-e1000.rom pxe-eepro100.rom pxe-ne2k_pci.rom \
  570. pxe-pcnet.rom pxe-rtl8139.rom pxe-virtio.rom \
  571. efi-e1000.rom efi-eepro100.rom efi-ne2k_pci.rom \
  572. efi-pcnet.rom efi-rtl8139.rom efi-virtio.rom \
  573. efi-e1000e.rom efi-vmxnet3.rom \
  574. bamboo.dtb canyonlands.dtb petalogix-s3adsp1800.dtb petalogix-ml605.dtb \
  575. multiboot.bin linuxboot.bin linuxboot_dma.bin kvmvapic.bin pvh.bin \
  576. s390-ccw.img s390-netboot.img \
  577. spapr-rtas.bin slof.bin skiboot.lid \
  578. palcode-clipper \
  579. u-boot.e500 u-boot-sam460-20100605.bin \
  580. qemu_vga.ndrv \
  581. hppa-firmware.img
  582. else
  583. BLOBS=
  584. endif
  585. define install-manual =
  586. for d in $$(cd docs && find $1 -type d); do $(INSTALL_DIR) "$(DESTDIR)$(qemu_docdir)/$$d"; done
  587. for f in $$(cd docs && find $1 -type f); do $(INSTALL_DATA) "docs/$$f" "$(DESTDIR)$(qemu_docdir)/$$f"; done
  588. endef
  589. # Note that we deliberately do not install the "devel" manual: it is
  590. # for QEMU developers, and not interesting to our users.
  591. .PHONY: install-sphinxdocs
  592. install-sphinxdocs: sphinxdocs
  593. $(call install-manual,interop)
  594. install-doc: $(DOCS) install-sphinxdocs
  595. $(INSTALL_DIR) "$(DESTDIR)$(qemu_docdir)"
  596. $(INSTALL_DATA) qemu-doc.html "$(DESTDIR)$(qemu_docdir)"
  597. $(INSTALL_DATA) qemu-doc.txt "$(DESTDIR)$(qemu_docdir)"
  598. $(INSTALL_DATA) docs/interop/qemu-qmp-ref.html "$(DESTDIR)$(qemu_docdir)"
  599. $(INSTALL_DATA) docs/interop/qemu-qmp-ref.txt "$(DESTDIR)$(qemu_docdir)"
  600. ifdef CONFIG_POSIX
  601. $(INSTALL_DIR) "$(DESTDIR)$(mandir)/man1"
  602. $(INSTALL_DATA) qemu.1 "$(DESTDIR)$(mandir)/man1"
  603. $(INSTALL_DIR) "$(DESTDIR)$(mandir)/man7"
  604. $(INSTALL_DATA) docs/interop/qemu-qmp-ref.7 "$(DESTDIR)$(mandir)/man7"
  605. $(INSTALL_DATA) docs/qemu-block-drivers.7 "$(DESTDIR)$(mandir)/man7"
  606. $(INSTALL_DATA) docs/qemu-cpu-models.7 "$(DESTDIR)$(mandir)/man7"
  607. ifneq ($(TOOLS),)
  608. $(INSTALL_DATA) qemu-img.1 "$(DESTDIR)$(mandir)/man1"
  609. $(INSTALL_DIR) "$(DESTDIR)$(mandir)/man8"
  610. $(INSTALL_DATA) qemu-nbd.8 "$(DESTDIR)$(mandir)/man8"
  611. endif
  612. ifdef CONFIG_TRACE_SYSTEMTAP
  613. $(INSTALL_DATA) scripts/qemu-trace-stap.1 "$(DESTDIR)$(mandir)/man1"
  614. endif
  615. ifneq (,$(findstring qemu-ga,$(TOOLS)))
  616. $(INSTALL_DATA) qemu-ga.8 "$(DESTDIR)$(mandir)/man8"
  617. $(INSTALL_DATA) docs/interop/qemu-ga-ref.html "$(DESTDIR)$(qemu_docdir)"
  618. $(INSTALL_DATA) docs/interop/qemu-ga-ref.txt "$(DESTDIR)$(qemu_docdir)"
  619. $(INSTALL_DATA) docs/interop/qemu-ga-ref.7 "$(DESTDIR)$(mandir)/man7"
  620. endif
  621. endif
  622. ifdef CONFIG_VIRTFS
  623. $(INSTALL_DIR) "$(DESTDIR)$(mandir)/man1"
  624. $(INSTALL_DATA) fsdev/virtfs-proxy-helper.1 "$(DESTDIR)$(mandir)/man1"
  625. endif
  626. install-datadir:
  627. $(INSTALL_DIR) "$(DESTDIR)$(qemu_datadir)"
  628. install-localstatedir:
  629. ifdef CONFIG_POSIX
  630. ifneq (,$(findstring qemu-ga,$(TOOLS)))
  631. $(INSTALL_DIR) "$(DESTDIR)$(qemu_localstatedir)"/run
  632. endif
  633. endif
  634. ICON_SIZES=16x16 24x24 32x32 48x48 64x64 128x128 256x256 512x512
  635. install: all $(if $(BUILD_DOCS),install-doc) install-datadir install-localstatedir
  636. ifneq ($(TOOLS),)
  637. $(call install-prog,$(subst qemu-ga,qemu-ga$(EXESUF),$(TOOLS)),$(DESTDIR)$(bindir))
  638. endif
  639. ifneq ($(CONFIG_MODULES),)
  640. $(INSTALL_DIR) "$(DESTDIR)$(qemu_moddir)"
  641. for s in $(modules-m:.mo=$(DSOSUF)); do \
  642. t="$(DESTDIR)$(qemu_moddir)/$$(echo $$s | tr / -)"; \
  643. $(INSTALL_LIB) $$s "$$t"; \
  644. test -z "$(STRIP)" || $(STRIP) "$$t"; \
  645. done
  646. endif
  647. ifneq ($(HELPERS-y),)
  648. $(call install-prog,$(HELPERS-y),$(DESTDIR)$(libexecdir))
  649. endif
  650. ifdef CONFIG_TRACE_SYSTEMTAP
  651. $(INSTALL_PROG) "scripts/qemu-trace-stap" $(DESTDIR)$(bindir)
  652. endif
  653. ifneq ($(BLOBS),)
  654. set -e; for x in $(BLOBS); do \
  655. $(INSTALL_DATA) $(SRC_PATH)/pc-bios/$$x "$(DESTDIR)$(qemu_datadir)"; \
  656. done
  657. endif
  658. for s in $(ICON_SIZES); do \
  659. mkdir -p "$(DESTDIR)/$(qemu_icondir)/hicolor/$${s}/apps"; \
  660. $(INSTALL_DATA) $(SRC_PATH)/ui/icons/qemu_$${s}.png \
  661. "$(DESTDIR)/$(qemu_icondir)/hicolor/$${s}/apps/qemu.png"; \
  662. done; \
  663. mkdir -p "$(DESTDIR)/$(qemu_icondir)/hicolor/32x32/apps"; \
  664. $(INSTALL_DATA) $(SRC_PATH)/ui/icons/qemu_32x32.bmp \
  665. "$(DESTDIR)/$(qemu_icondir)/hicolor/32x32/apps/qemu.bmp"; \
  666. mkdir -p "$(DESTDIR)/$(qemu_icondir)/hicolor/scalable/apps"; \
  667. $(INSTALL_DATA) $(SRC_PATH)/ui/icons/qemu.svg \
  668. "$(DESTDIR)/$(qemu_icondir)/hicolor/scalable/apps/qemu.svg"
  669. mkdir -p "$(DESTDIR)/$(qemu_desktopdir)"
  670. $(INSTALL_DATA) $(SRC_PATH)/ui/qemu.desktop \
  671. "$(DESTDIR)/$(qemu_desktopdir)/qemu.desktop"
  672. ifdef CONFIG_GTK
  673. $(MAKE) -C po $@
  674. endif
  675. $(INSTALL_DIR) "$(DESTDIR)$(qemu_datadir)/keymaps"
  676. set -e; for x in $(KEYMAPS); do \
  677. $(INSTALL_DATA) $(SRC_PATH)/pc-bios/keymaps/$$x "$(DESTDIR)$(qemu_datadir)/keymaps"; \
  678. done
  679. $(INSTALL_DATA) $(BUILD_DIR)/trace-events-all "$(DESTDIR)$(qemu_datadir)/trace-events-all"
  680. for d in $(TARGET_DIRS); do \
  681. $(MAKE) $(SUBDIR_MAKEFLAGS) TARGET_DIR=$$d/ -C $$d $@ || exit 1 ; \
  682. done
  683. .PHONY: ctags
  684. ctags:
  685. rm -f tags
  686. find "$(SRC_PATH)" -name '*.[hc]' -exec ctags --append {} +
  687. .PHONY: TAGS
  688. TAGS:
  689. rm -f TAGS
  690. find "$(SRC_PATH)" -name '*.[hc]' -exec etags --append {} +
  691. cscope:
  692. rm -f "$(SRC_PATH)"/cscope.*
  693. find "$(SRC_PATH)/" -name "*.[chsS]" -print | sed 's,^\./,,' > "$(SRC_PATH)/cscope.files"
  694. cscope -b -i"$(SRC_PATH)/cscope.files"
  695. # opengl shader programs
  696. ui/shader/%-vert.h: $(SRC_PATH)/ui/shader/%.vert $(SRC_PATH)/scripts/shaderinclude.pl
  697. @mkdir -p $(dir $@)
  698. $(call quiet-command,\
  699. perl $(SRC_PATH)/scripts/shaderinclude.pl $< > $@,\
  700. "VERT","$@")
  701. ui/shader/%-frag.h: $(SRC_PATH)/ui/shader/%.frag $(SRC_PATH)/scripts/shaderinclude.pl
  702. @mkdir -p $(dir $@)
  703. $(call quiet-command,\
  704. perl $(SRC_PATH)/scripts/shaderinclude.pl $< > $@,\
  705. "FRAG","$@")
  706. ui/shader.o: $(SRC_PATH)/ui/shader.c \
  707. ui/shader/texture-blit-vert.h \
  708. ui/shader/texture-blit-flip-vert.h \
  709. ui/shader/texture-blit-frag.h
  710. # documentation
  711. MAKEINFO=makeinfo
  712. MAKEINFOINCLUDES= -I docs -I $(<D) -I $(@D)
  713. MAKEINFOFLAGS=--no-split --number-sections $(MAKEINFOINCLUDES)
  714. TEXI2PODFLAGS=$(MAKEINFOINCLUDES) "-DVERSION=$(VERSION)"
  715. TEXI2PDFFLAGS=$(if $(V),,--quiet) -I $(SRC_PATH) $(MAKEINFOINCLUDES)
  716. docs/version.texi: $(SRC_PATH)/VERSION
  717. $(call quiet-command,echo "@set VERSION $(VERSION)" > $@,"GEN","$@")
  718. %.html: %.texi docs/version.texi
  719. $(call quiet-command,LC_ALL=C $(MAKEINFO) $(MAKEINFOFLAGS) --no-headers \
  720. --html $< -o $@,"GEN","$@")
  721. %.info: %.texi docs/version.texi
  722. $(call quiet-command,$(MAKEINFO) $(MAKEINFOFLAGS) $< -o $@,"GEN","$@")
  723. %.txt: %.texi docs/version.texi
  724. $(call quiet-command,LC_ALL=C $(MAKEINFO) $(MAKEINFOFLAGS) --no-headers \
  725. --plaintext $< -o $@,"GEN","$@")
  726. %.pdf: %.texi docs/version.texi
  727. $(call quiet-command,texi2pdf $(TEXI2PDFFLAGS) $< -o $@,"GEN","$@")
  728. # Sphinx builds all its documentation at once in one invocation
  729. # and handles "don't rebuild things unless necessary" itself.
  730. # The '.doctrees' files are cached information to speed this up.
  731. .PHONY: sphinxdocs
  732. sphinxdocs: docs/devel/index.html docs/interop/index.html
  733. # Canned command to build a single manual
  734. build-manual = $(call quiet-command,sphinx-build $(if $(V),,-q) -b html -D version=$(VERSION) -D release="$(FULL_VERSION)" -d .doctrees/$1 $(SRC_PATH)/docs/$1 docs/$1 ,"SPHINX","docs/$1")
  735. # We assume all RST files in the manual's directory are used in it
  736. manual-deps = $(wildcard $(SRC_PATH)/docs/$1/*.rst) $(SRC_PATH)/docs/$1/conf.py $(SRC_PATH)/docs/conf.py
  737. docs/devel/index.html: $(call manual-deps,devel)
  738. $(call build-manual,devel)
  739. docs/interop/index.html: $(call manual-deps,interop)
  740. $(call build-manual,interop)
  741. qemu-options.texi: $(SRC_PATH)/qemu-options.hx $(SRC_PATH)/scripts/hxtool
  742. $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -t < $< > $@,"GEN","$@")
  743. qemu-monitor.texi: $(SRC_PATH)/hmp-commands.hx $(SRC_PATH)/scripts/hxtool
  744. $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -t < $< > $@,"GEN","$@")
  745. qemu-monitor-info.texi: $(SRC_PATH)/hmp-commands-info.hx $(SRC_PATH)/scripts/hxtool
  746. $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -t < $< > $@,"GEN","$@")
  747. qemu-img-cmds.texi: $(SRC_PATH)/qemu-img-cmds.hx $(SRC_PATH)/scripts/hxtool
  748. $(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -t < $< > $@,"GEN","$@")
  749. docs/interop/qemu-qmp-qapi.texi: qapi/qapi-doc.texi
  750. @cp -p $< $@
  751. docs/interop/qemu-ga-qapi.texi: qga/qapi-generated/qga-qapi-doc.texi
  752. @cp -p $< $@
  753. qemu.1: qemu-doc.texi qemu-options.texi qemu-monitor.texi qemu-monitor-info.texi
  754. qemu.1: qemu-option-trace.texi
  755. qemu-img.1: qemu-img.texi qemu-option-trace.texi qemu-img-cmds.texi
  756. fsdev/virtfs-proxy-helper.1: fsdev/virtfs-proxy-helper.texi
  757. qemu-nbd.8: qemu-nbd.texi qemu-option-trace.texi
  758. qemu-ga.8: qemu-ga.texi
  759. docs/qemu-block-drivers.7: docs/qemu-block-drivers.texi
  760. docs/qemu-cpu-models.7: docs/qemu-cpu-models.texi
  761. scripts/qemu-trace-stap.1: scripts/qemu-trace-stap.texi
  762. html: qemu-doc.html docs/interop/qemu-qmp-ref.html docs/interop/qemu-ga-ref.html sphinxdocs
  763. info: qemu-doc.info docs/interop/qemu-qmp-ref.info docs/interop/qemu-ga-ref.info
  764. pdf: qemu-doc.pdf docs/interop/qemu-qmp-ref.pdf docs/interop/qemu-ga-ref.pdf
  765. txt: qemu-doc.txt docs/interop/qemu-qmp-ref.txt docs/interop/qemu-ga-ref.txt
  766. qemu-doc.html qemu-doc.info qemu-doc.pdf qemu-doc.txt: \
  767. qemu-img.texi qemu-nbd.texi qemu-options.texi qemu-option-trace.texi \
  768. qemu-deprecated.texi qemu-monitor.texi qemu-img-cmds.texi qemu-ga.texi \
  769. qemu-monitor-info.texi docs/qemu-block-drivers.texi \
  770. docs/qemu-cpu-models.texi
  771. docs/interop/qemu-ga-ref.dvi docs/interop/qemu-ga-ref.html \
  772. docs/interop/qemu-ga-ref.info docs/interop/qemu-ga-ref.pdf \
  773. docs/interop/qemu-ga-ref.txt docs/interop/qemu-ga-ref.7: \
  774. docs/interop/qemu-ga-ref.texi docs/interop/qemu-ga-qapi.texi
  775. docs/interop/qemu-qmp-ref.dvi docs/interop/qemu-qmp-ref.html \
  776. docs/interop/qemu-qmp-ref.info docs/interop/qemu-qmp-ref.pdf \
  777. docs/interop/qemu-qmp-ref.txt docs/interop/qemu-qmp-ref.7: \
  778. docs/interop/qemu-qmp-ref.texi docs/interop/qemu-qmp-qapi.texi
  779. $(filter %.1 %.7 %.8,$(DOCS)): scripts/texi2pod.pl
  780. # Reports/Analysis
  781. %/coverage-report.html:
  782. @mkdir -p $*
  783. $(call quiet-command,\
  784. gcovr -p --html --html-details -o $@, \
  785. "GEN", "coverage-report.html")
  786. .PHONY: coverage-report
  787. coverage-report: $(CURDIR)/reports/coverage/coverage-report.html
  788. ifdef CONFIG_WIN32
  789. INSTALLER = qemu-setup-$(VERSION)$(EXESUF)
  790. nsisflags = -V2 -NOCD
  791. ifneq ($(wildcard $(SRC_PATH)/dll),)
  792. ifeq ($(ARCH),x86_64)
  793. # 64 bit executables
  794. DLL_PATH = $(SRC_PATH)/dll/w64
  795. nsisflags += -DW64
  796. else
  797. # 32 bit executables
  798. DLL_PATH = $(SRC_PATH)/dll/w32
  799. endif
  800. endif
  801. .PHONY: installer
  802. installer: $(INSTALLER)
  803. INSTDIR=/tmp/qemu-nsis
  804. $(INSTALLER): $(SRC_PATH)/qemu.nsi
  805. $(MAKE) install prefix=${INSTDIR}
  806. ifdef SIGNCODE
  807. (cd ${INSTDIR}; \
  808. for i in *.exe; do \
  809. $(SIGNCODE) $${i}; \
  810. done \
  811. )
  812. endif # SIGNCODE
  813. (cd ${INSTDIR}; \
  814. for i in qemu-system-*.exe; do \
  815. arch=$${i%.exe}; \
  816. arch=$${arch#qemu-system-}; \
  817. echo Section \"$$arch\" Section_$$arch; \
  818. echo SetOutPath \"\$$INSTDIR\"; \
  819. echo File \"\$${BINDIR}\\$$i\"; \
  820. echo SectionEnd; \
  821. done \
  822. ) >${INSTDIR}/system-emulations.nsh
  823. makensis $(nsisflags) \
  824. $(if $(BUILD_DOCS),-DCONFIG_DOCUMENTATION="y") \
  825. $(if $(CONFIG_GTK),-DCONFIG_GTK="y") \
  826. -DBINDIR="${INSTDIR}" \
  827. $(if $(DLL_PATH),-DDLLDIR="$(DLL_PATH)") \
  828. -DSRCDIR="$(SRC_PATH)" \
  829. -DOUTFILE="$(INSTALLER)" \
  830. -DDISPLAYVERSION="$(VERSION)" \
  831. $(SRC_PATH)/qemu.nsi
  832. rm -r ${INSTDIR}
  833. ifdef SIGNCODE
  834. $(SIGNCODE) $(INSTALLER)
  835. endif # SIGNCODE
  836. endif # CONFIG_WIN
  837. # Add a dependency on the generated files, so that they are always
  838. # rebuilt before other object files
  839. ifneq ($(wildcard config-host.mak),)
  840. ifneq ($(filter-out $(UNCHECKED_GOALS),$(MAKECMDGOALS)),$(if $(MAKECMDGOALS),,fail))
  841. Makefile: $(GENERATED_FILES)
  842. endif
  843. endif
  844. .SECONDARY: $(TRACE_HEADERS) $(TRACE_HEADERS:%=%-timestamp) \
  845. $(TRACE_SOURCES) $(TRACE_SOURCES:%=%-timestamp) \
  846. $(TRACE_DTRACE) $(TRACE_DTRACE:%=%-timestamp)
  847. # Include automatically generated dependency files
  848. # Dependencies in Makefile.objs files come from our recursive subdir rules
  849. -include $(wildcard *.d tests/*.d)
  850. include $(SRC_PATH)/tests/docker/Makefile.include
  851. include $(SRC_PATH)/tests/vm/Makefile.include
  852. .PHONY: help
  853. help:
  854. @echo 'Generic targets:'
  855. @echo ' all - Build all'
  856. ifdef CONFIG_MODULES
  857. @echo ' modules - Build all modules'
  858. endif
  859. @echo ' dir/file.o - Build specified target only'
  860. @echo ' install - Install QEMU, documentation and tools'
  861. @echo ' ctags/TAGS - Generate tags file for editors'
  862. @echo ' cscope - Generate cscope index'
  863. @echo ''
  864. @$(if $(TARGET_DIRS), \
  865. echo 'Architecture specific targets:'; \
  866. $(foreach t, $(TARGET_DIRS), \
  867. printf " %-30s - Build for %s\\n" $(patsubst %,subdir-%,$(t)) $(t);) \
  868. echo '')
  869. @echo 'Cleaning targets:'
  870. @echo ' clean - Remove most generated files but keep the config'
  871. ifdef CONFIG_GCOV
  872. @echo ' clean-coverage - Remove coverage files'
  873. endif
  874. @echo ' distclean - Remove all generated files'
  875. @echo ' dist - Build a distributable tarball'
  876. @echo ''
  877. @echo 'Test targets:'
  878. @echo ' check - Run all tests (check-help for details)'
  879. @echo ' docker - Help about targets running tests inside Docker containers'
  880. @echo ' vm-test - Help about targets running tests inside VM'
  881. @echo ''
  882. @echo 'Documentation targets:'
  883. @echo ' html info pdf txt'
  884. @echo ' - Build documentation in specified format'
  885. ifdef CONFIG_GCOV
  886. @echo ' coverage-report - Create code coverage report'
  887. endif
  888. @echo ''
  889. ifdef CONFIG_WIN32
  890. @echo 'Windows targets:'
  891. @echo ' installer - Build NSIS-based installer for QEMU'
  892. ifdef QEMU_GA_MSI_ENABLED
  893. @echo ' msi - Build MSI-based installer for qemu-ga'
  894. endif
  895. @echo ''
  896. endif
  897. @echo ' $(MAKE) [targets] (quiet build, default)'
  898. @echo ' $(MAKE) V=1 [targets] (verbose build)'