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.

Makefile 42KB

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