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

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