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.

457 lines
12 KiB

  1. #
  2. # Copyright (C) 2016 OpenWrt.org
  3. # Copyright (C) 2016-2019 Yousong Zhou <yszhou4tech@gmail.com>
  4. #
  5. # This is free software, licensed under the GNU General Public License v2.
  6. # See /LICENSE for more information.
  7. #
  8. include $(TOPDIR)/rules.mk
  9. PKG_NAME:=qemu
  10. PKG_VERSION:=5.0.0
  11. PKG_RELEASE:=5
  12. PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
  13. PKG_HASH:=2f13a92a0fa5c8b69ff0796b59b86b080bbb92ebad5d301a7724dd06b5e78cb6
  14. PKG_SOURCE_URL:=http://download.qemu.org/
  15. PKG_LICENSE:=GPL-2.0
  16. PKG_LICENSE_FILES:=LICENSE tcg/LICENSE
  17. PKG_MAINTAINER:=Yousong Zhou <yszhou4tech@gmail.com>
  18. PKG_CPE_ID:=cpe:/a:qemu:qemu
  19. PKG_BUILD_PARALLEL:=1
  20. PKG_INSTALL:=1
  21. PKG_USE_MIPS16:=0
  22. PKG_BUILD_DEPENDS+=spice-protocol
  23. include $(INCLUDE_DIR)/nls.mk
  24. include $(INCLUDE_DIR)/package.mk
  25. QEMU_DEPS_IN_GUEST := @(TARGET_x86_64||TARGET_armvirt||TARGET_malta)
  26. QEMU_DEPS_IN_HOST := @(TARGET_x86_64||TARGET_sunxi)
  27. QEMU_DEPS_IN_HOST += +libstdcpp
  28. QEMU_DEPS_IN_HOST += $(ICONV_DEPENDS)
  29. define Package/virtio-console-helper
  30. SECTION:=utils
  31. CATEGORY:=Utilities
  32. SUBMENU:=Virtualization
  33. TITLE:=Helper script for vportNpn virtio-console devices
  34. DEPENDS:=$(QEMU_DEPS_IN_GUEST)
  35. endef
  36. define Package/virtio-console-helper/install
  37. $(INSTALL_DIR) $(1)/etc/hotplug.d/virtio-ports
  38. $(INSTALL_BIN) ./files/00-virtio-ports.hotplug $(1)/etc/hotplug.d/virtio-ports/00-virtio-ports
  39. endef
  40. define Package/qemu-ga
  41. SECTION:=utils
  42. CATEGORY:=Utilities
  43. SUBMENU:=Virtualization
  44. TITLE:=QEMU Guest Agent
  45. URL:=http://www.qemu.org
  46. DEPENDS:= +glib2 +virtio-console-helper +libstdcpp $(QEMU_DEPS_IN_GUEST)
  47. endef
  48. define Package/qemu-ga/install
  49. $(INSTALL_DIR) $(1)/usr/bin
  50. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/qemu-ga $(1)/usr/bin
  51. $(INSTALL_DIR) $(1)/etc/init.d
  52. $(INSTALL_BIN) ./files/qemu-ga.init $(1)/etc/init.d/qemu-ga
  53. $(INSTALL_DIR) $(1)/etc/hotplug.d/virtio-ports
  54. $(INSTALL_BIN) ./files/10-qemu-ga.hotplug $(1)/etc/hotplug.d/virtio-ports/10-qemu-ga
  55. endef
  56. PKG_CONFIG_DEPENDS += CONFIG_PACKAGE_qemu-ga
  57. define Package/qemu-bridge-helper
  58. SECTION:=utils
  59. CATEGORY:=Utilities
  60. SUBMENU:=Virtualization
  61. TITLE:=QEMU bridge helper
  62. URL:=http://www.qemu.org
  63. DEPENDS:=+glib2 $(QEMU_DEPS_IN_HOST)
  64. endef
  65. define Package/qemu-bridge-helper/install
  66. $(INSTALL_DIR) $(1)/usr/lib/
  67. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/qemu-bridge-helper $(1)/usr/lib
  68. $(INSTALL_DIR) $(1)/etc/qemu
  69. $(INSTALL_DATA) ./files/bridge.conf $(1)/etc/qemu
  70. endef
  71. define Package/qemu-img
  72. SECTION:=utils
  73. CATEGORY:=Utilities
  74. SUBMENU:=Virtualization
  75. TITLE:=QEMU Image utility
  76. URL:=http://www.qemu.org
  77. DEPENDS:=+glib2 $(QEMU_DEPS_IN_HOST)
  78. endef
  79. define Package/qemu-img/install
  80. $(INSTALL_DIR) $(1)/usr/bin/
  81. $(INSTALL_BIN) $(PKG_BUILD_DIR)/qemu-img $(1)/usr/bin/qemu-img
  82. endef
  83. define Package/qemu-nbd
  84. SECTION:=utils
  85. CATEGORY:=Utilities
  86. SUBMENU:=Virtualization
  87. TITLE:=QEMU Network Block Device Utility
  88. URL:=http://www.qemu.org
  89. DEPENDS:=+glib2 $(QEMU_DEPS_IN_HOST) +kmod-nbd
  90. endef
  91. define Package/qemu-nbd/install
  92. $(INSTALL_DIR) $(1)/usr/sbin/
  93. $(INSTALL_BIN) $(PKG_BUILD_DIR)/qemu-nbd $(1)/usr/sbin/qemu-nbd
  94. endef
  95. define qemu-firmware
  96. QEMU_PACKAGES += qemu-firmware-$(1)
  97. define Package/qemu-firmware-$(1)
  98. SECTION:=utils
  99. CATEGORY:=Utilities
  100. SUBMENU:=Virtualization
  101. TITLE:=$(qemu-firmware-$(1)-title)
  102. URL:=http://www.qemu.org
  103. DEPENDS:=$(QEMU_DEPS_IN_HOST)
  104. endef
  105. define Package/qemu-firmware-$(1)/install
  106. $$(INSTALL_DIR) $$(1)/usr/share/qemu
  107. $$(CP) $(foreach f,$(qemu-firmware-$(1)-files),$$(PKG_INSTALL_DIR)/usr/share/qemu/$(f)) $$(1)/usr/share/qemu
  108. endef
  109. endef
  110. qemu-firmware-seabios-title:=QEMU build of SeaBIOS for x86 guest
  111. qemu-firmware-seabios-files:=bios.bin bios-256k.bin
  112. $(eval $(call qemu-firmware,seabios))
  113. qemu-firmware-seavgabios-title:=QEMU build of SeaVGABIOS
  114. qemu-firmware-seavgabios-files:=vgabios-*.bin
  115. $(eval $(call qemu-firmware,seavgabios))
  116. qemu-firmware-pxe-title:=QEMU build of iPXE PXE roms
  117. qemu-firmware-pxe-files:=pxe-*.rom
  118. $(eval $(call qemu-firmware,pxe))
  119. qemu-firmware-efi-title:=QEMU build of iPXE EFI roms
  120. qemu-firmware-efi-files:=efi-*.rom
  121. $(eval $(call qemu-firmware,efi))
  122. define Package/qemu-keymaps
  123. SECTION:=utils
  124. CATEGORY:=Utilities
  125. SUBMENU:=Virtualization
  126. TITLE:=QEMU reverse keymaps for use with -k argument
  127. URL:=http://www.qemu.org
  128. DEPENDS:=$(QEMU_DEPS_IN_HOST)
  129. endef
  130. define Package/qemu-keymaps/install
  131. $(INSTALL_DIR) $(1)/usr/share/qemu/keymaps
  132. $(CP) $(PKG_INSTALL_DIR)/usr/share/qemu/keymaps/* $(1)/usr/share/qemu/keymaps
  133. endef
  134. # Naming rules used in qemu Makefile.target
  135. define qemu-prog_
  136. $(if $(filter %-softmmu,$(1)), \
  137. $(patsubst %-softmmu,qemu-system-%,$(1)), \
  138. $(error unknown qemu target $(1)) \
  139. )
  140. endef
  141. qemu-prog = $(strip $(call qemu-prog_,$(1)))
  142. # Why libfdt was enabled for all softmmu targets: according to qemu's
  143. # configure script, libfdt is only strictly required for the following targets
  144. # and is optional for others. But libfdt support will be built into other
  145. # targets when any single target enabled it.
  146. #
  147. # aarch64%-softmmu arm%-softmmu ppc%-softmmu microblaze%-softmmu
  148. #
  149. define qemu-target
  150. PKG_CONFIG_DEPENDS += CONFIG_PACKAGE_qemu-$(1)
  151. QEMU_PACKAGES += qemu-$(1)
  152. define Package/qemu-$(1)
  153. SECTION:=utils
  154. CATEGORY:=Utilities
  155. SUBMENU:=Virtualization
  156. TITLE:=QEMU target $(1)
  157. URL:=http://www.qemu.org
  158. DEPENDS:= +glib2 +libpthread +zlib $(QEMU_DEPS_IN_HOST) $(qemu-target-$(1)-deps) \
  159. +QEMU_UI_VNC:qemu-keymaps \
  160. +QEMU_UI_VNC_JPEG:libjpeg \
  161. +QEMU_UI_VNC_PNG:libpng \
  162. +QEMU_UI_VNC_SASL:libsasl2 \
  163. +QEMU_UI_SPICE:libspice-server \
  164. $(if $(filter %-softmmu,$(1)),+libncurses +libfdt +pixman +qemu-firmware-efi $(ICONV_DEPENDS))
  165. endef
  166. define Package/qemu-$(1)/description
  167. This package contains the QEMU target $(1)
  168. endef
  169. define Package/qemu-$(1)/install
  170. $(INSTALL_DIR) $$(1)/usr/bin
  171. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/$(call qemu-prog,$(1)) $$(1)/usr/bin
  172. $(foreach f,$(qemu-target-$(1)-extra-files),
  173. $(INSTALL_DIR) $$(1)/$(dir $(f))
  174. $(CP) $(PKG_INSTALL_DIR)/$(f) $$(1)/$(f)
  175. )
  176. endef
  177. endef
  178. qemu-target-list := \
  179. x86_64-softmmu \
  180. arm-softmmu \
  181. qemu-target-x86_64-softmmu-deps:= \
  182. +qemu-firmware-pxe \
  183. +qemu-firmware-seabios \
  184. +qemu-firmware-seavgabios
  185. qemu-target-x86_64-softmmu-extra-files:= \
  186. usr/share/qemu/kvmvapic.bin \
  187. usr/share/qemu/linuxboot.bin \
  188. usr/share/qemu/linuxboot_dma.bin \
  189. usr/share/qemu/multiboot.bin \
  190. usr/share/qemu/pvh.bin
  191. $(foreach target,$(qemu-target-list), \
  192. $(eval $(call qemu-target,$(target))) \
  193. )
  194. define Package/qemu-$(firstword $(qemu-target-list))/config
  195. if $(subst $(space),||,$(foreach target,$(qemu-target-list),PACKAGE_qemu-$(target)))
  196. config QEMU_UI_VNC
  197. bool "QEMU VNC support"
  198. default y
  199. config QEMU_UI_VNC_JPEG
  200. bool "QEMU VNC jpeg tight encoding support"
  201. default n
  202. depends on QEMU_UI_VNC
  203. config QEMU_UI_VNC_PNG
  204. bool "QEMU VNC png tight encoding support"
  205. default n
  206. depends on QEMU_UI_VNC
  207. config QEMU_UI_VNC_SASL
  208. bool "QEMU VNC SASL auth support"
  209. default n
  210. depends on QEMU_UI_VNC
  211. config QEMU_UI_SPICE
  212. bool "QEMU SPICE ui support"
  213. endif
  214. endef
  215. PKG_CONFIG_DEPENDS += \
  216. CONFIG_QEMU_UI_VNC \
  217. CONFIG_QEMU_UI_VNC_JPEG \
  218. CONFIG_QEMU_UI_VNC_PNG \
  219. CONFIG_QEMU_UI_VNC_SASL \
  220. CONFIG_QEMU_UI_SPICE \
  221. # QEMU configure script does not recognize these options
  222. CONFIGURE_ARGS:=$(filter-out \
  223. --target=% \
  224. --host=% \
  225. --build=% \
  226. --program-prefix=% \
  227. --program-suffix=% \
  228. --exec-prefix=% \
  229. $(DISABLE_NLS) \
  230. $(DISABLE_IPV6) \
  231. , $(CONFIGURE_ARGS))
  232. # Tell build system of qemu to not add _FORTIFY_SOURCE options and let the base
  233. # build system decide flavor of fortify_source to use
  234. CONFIGURE_ARGS += \
  235. --cross-prefix=$(TARGET_CROSS) \
  236. --host-cc="$(HOSTCC)" \
  237. --disable-fortify-source \
  238. --disable-stack-protector \
  239. --extra-cflags="$(TARGET_CFLAGS) $(EXTRA_CFLAGS)" \
  240. --extra-cxxflags="$(TARGET_CXXFLAGS) $(EXTRA_CXXFLAGS)" \
  241. --extra-ldflags="$(TARGET_LDFLAGS) $(EXTRA_LDFLAGS)" \
  242. # VHost features
  243. CONFIGURE_ARGS += \
  244. --enable-vhost-crypto \
  245. --enable-vhost-kernel \
  246. --enable-vhost-net \
  247. --enable-vhost-scsi \
  248. --enable-vhost-user \
  249. --enable-vhost-user-fs \
  250. --enable-vhost-vsock \
  251. # Image formats support
  252. CONFIGURE_ARGS += \
  253. --disable-bochs \
  254. --disable-cloop \
  255. --disable-dmg \
  256. --disable-qcow1 \
  257. --disable-vdi \
  258. --disable-vvfat \
  259. --disable-qed \
  260. --disable-parallels \
  261. # system/user-mode emulation
  262. CONFIGURE_ARGS += \
  263. --disable-user \
  264. --disable-bsd-user \
  265. --disable-linux-user \
  266. --enable-system \
  267. # accel
  268. CONFIGURE_ARGS += \
  269. --disable-hax \
  270. --disable-hvf \
  271. --disable-whpx \
  272. --disable-xen \
  273. --enable-kvm \
  274. --enable-tcg \
  275. # UI
  276. CONFIGURE_ARGS += \
  277. --disable-cocoa \
  278. --disable-gtk \
  279. --disable-sdl \
  280. --disable-sdl-image \
  281. --$(if $(CONFIG_QEMU_UI_SPICE),enable,disable)-spice \
  282. --disable-virglrenderer \
  283. --$(if $(CONFIG_QEMU_UI_VNC),enable,disable)-vnc \
  284. --$(if $(CONFIG_QEMU_UI_VNC_JPEG),enable,disable)-vnc-jpeg \
  285. --$(if $(CONFIG_QEMU_UI_VNC_PNG),enable,disable)-vnc-png \
  286. --$(if $(CONFIG_QEMU_UI_VNC_SASL),enable,disable)-vnc-sasl \
  287. --disable-vte \
  288. --enable-curses \
  289. --enable-iconv \
  290. # Features for performance & no external dependency
  291. CONFIGURE_ARGS += \
  292. --enable-coroutine-pool \
  293. --enable-crypto-afalg \
  294. --enable-live-block-migration \
  295. --enable-membarrier \
  296. --enable-replication \
  297. # Review configure options not explicitly specified here
  298. #
  299. # openwrt_makefile=openwrt/packages/utils/qemu/Makefile
  300. # qemu_configure=qemu/configure
  301. # for arg in $(grep -E '^\s*--disable-[^)]+\)' "$qemu_configure" | cut -f1 -d')'); do
  302. # grep -qE "(--enable|--disable)${arg#--disable}" "$openwrt_makefile" || echo "$arg"
  303. # done
  304. #
  305. CONFIGURE_ARGS += \
  306. --audio-drv-list='' \
  307. --disable-attr \
  308. --disable-auth-pam \
  309. --disable-brlapi \
  310. --disable-bzip2 \
  311. --disable-cap-ng \
  312. --disable-capstone \
  313. --disable-containers \
  314. --disable-curl \
  315. --disable-debug-info \
  316. --disable-debug-mutex \
  317. --disable-debug-tcg \
  318. --disable-docs \
  319. --disable-gcrypt \
  320. --disable-git-update \
  321. --disable-glusterfs \
  322. --disable-gnutls \
  323. --disable-guest-agent-msi \
  324. --disable-jemalloc \
  325. --disable-libiscsi \
  326. --disable-libnfs \
  327. --disable-libpmem \
  328. --disable-libssh \
  329. --disable-libudev \
  330. --disable-libusb \
  331. --disable-libxml2 \
  332. --disable-linux-aio \
  333. --disable-linux-io-uring \
  334. --disable-lzfse \
  335. --disable-lzo \
  336. --disable-modules \
  337. --disable-module-upgrades \
  338. --disable-mpath \
  339. --disable-netmap \
  340. --disable-nettle \
  341. --disable-numa \
  342. --disable-opengl \
  343. --disable-plugins \
  344. --disable-pvrdma \
  345. --disable-qom-cast-debug \
  346. --disable-rbd \
  347. --disable-rdma \
  348. --disable-sanitizers \
  349. --disable-seccomp \
  350. --disable-sheepdog \
  351. --disable-smartcard \
  352. --disable-snappy \
  353. --disable-sparse \
  354. --disable-strip \
  355. --disable-tcg-interpreter \
  356. --disable-tcmalloc \
  357. --disable-tools \
  358. --disable-tpm \
  359. --disable-usb-redir \
  360. --disable-vde \
  361. --disable-virtfs \
  362. --disable-vxhs \
  363. --disable-werror \
  364. --disable-xen-pci-passthrough \
  365. --disable-xkbcommon \
  366. --disable-xfsctl \
  367. --disable-zstd \
  368. CONFIGURE_ARGS += --target-list='$(foreach target,$(qemu-target-list),$(if $(CONFIG_PACKAGE_qemu-$(target)),$(target)))'
  369. CONFIGURE_ARGS += $(if $(CONFIG_PACKAGE_qemu-ga),--enable-guest-agent)
  370. TARGET_LDFLAGS += -Wl,--as-needed
  371. MAKE_VARS += V=1
  372. # ARCH is special in qemu's build system, e.g. ARCH mips64 will be translated
  373. # there to mips and stored in config-host.mak
  374. MAKE_FLAGS:=$(filter-out \
  375. ARCH=% \
  376. ,$(MAKE_FLAGS))
  377. QEMU_MAKE_TARGETS := \
  378. $(if $(CONFIG_PACKAGE_qemu-ga),qemu-ga) \
  379. $(if $(CONFIG_PACKAGE_qemu-bridge-helper),qemu-bridge-helper) \
  380. $(if $(CONFIG_PACKAGE_qemu-img),qemu-img) \
  381. $(if $(CONFIG_PACKAGE_qemu-nbd),qemu-nbd) \
  382. $(foreach target,$(qemu-target-list),$(if $(CONFIG_PACKAGE_qemu-$(target)),$(target)/all)) \
  383. define Build/Compile
  384. $(if $(strip $(QEMU_MAKE_TARGETS)),$(call Build/Compile/Default,$(QEMU_MAKE_TARGETS)))
  385. endef
  386. $(eval $(call BuildPackage,virtio-console-helper))
  387. $(eval $(call BuildPackage,qemu-ga))
  388. $(eval $(call BuildPackage,qemu-bridge-helper))
  389. $(eval $(call BuildPackage,qemu-img))
  390. $(eval $(call BuildPackage,qemu-nbd))
  391. $(eval $(call BuildPackage,qemu-keymaps))
  392. $(foreach p,$(QEMU_PACKAGES), \
  393. $(eval $(call BuildPackage,$(p))) \
  394. )