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.

453 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:=6.1.0
  11. PKG_RELEASE:=$(AUTORELEASE)
  12. PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
  13. PKG_HASH:=eebc089db3414bbeedf1e464beda0a7515aad30f73261abc246c9b27503a3c96
  14. PKG_SOURCE_URL:=http://download.qemu.org/
  15. PKG_LICENSE:=GPL-2.0-only
  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)/build/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)/build/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 +libbpf $(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. +QEMU_DEV_USB:libusb-1.0 \
  165. $(if $(filter %-softmmu,$(1)),+libncurses +libfdt +pixman +qemu-firmware-efi $(ICONV_DEPENDS))
  166. endef
  167. define Package/qemu-$(1)/description
  168. This package contains the QEMU target $(1)
  169. endef
  170. define Package/qemu-$(1)/install
  171. $(INSTALL_DIR) $$(1)/usr/bin
  172. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/$(call qemu-prog,$(1)) $$(1)/usr/bin
  173. $(foreach f,$(qemu-target-$(1)-extra-files),
  174. $(INSTALL_DIR) $$(1)/$(dir $(f))
  175. $(CP) $(PKG_INSTALL_DIR)/$(f) $$(1)/$(f)
  176. )
  177. endef
  178. endef
  179. qemu-target-list := \
  180. x86_64-softmmu \
  181. arm-softmmu \
  182. qemu-target-x86_64-softmmu-deps:= \
  183. +qemu-firmware-pxe \
  184. +qemu-firmware-seabios \
  185. +qemu-firmware-seavgabios
  186. qemu-target-x86_64-softmmu-extra-files:= \
  187. usr/share/qemu/kvmvapic.bin \
  188. usr/share/qemu/linuxboot.bin \
  189. usr/share/qemu/linuxboot_dma.bin \
  190. usr/share/qemu/multiboot.bin \
  191. usr/share/qemu/pvh.bin
  192. $(foreach target,$(qemu-target-list), \
  193. $(eval $(call qemu-target,$(target))) \
  194. )
  195. define Package/qemu-$(firstword $(qemu-target-list))/config
  196. if $(subst $(space),||,$(foreach target,$(qemu-target-list),PACKAGE_qemu-$(target)))
  197. config QEMU_UI_VNC
  198. bool "QEMU VNC support"
  199. default y
  200. config QEMU_UI_VNC_JPEG
  201. bool "QEMU VNC jpeg tight encoding support"
  202. default n
  203. depends on QEMU_UI_VNC
  204. config QEMU_UI_VNC_PNG
  205. bool "QEMU VNC png tight encoding support"
  206. default n
  207. depends on QEMU_UI_VNC
  208. config QEMU_UI_VNC_SASL
  209. bool "QEMU VNC SASL auth support"
  210. default n
  211. depends on QEMU_UI_VNC
  212. config QEMU_UI_SPICE
  213. bool "QEMU SPICE ui support"
  214. config QEMU_DEV_USB
  215. bool "QEMU USB passthrough support"
  216. endif
  217. endef
  218. PKG_CONFIG_DEPENDS += \
  219. CONFIG_QEMU_UI_VNC \
  220. CONFIG_QEMU_UI_VNC_JPEG \
  221. CONFIG_QEMU_UI_VNC_PNG \
  222. CONFIG_QEMU_UI_VNC_SASL \
  223. CONFIG_QEMU_UI_SPICE \
  224. CONFIG_QEMU_DEV_USB \
  225. # QEMU configure script does not recognize these options
  226. CONFIGURE_ARGS:=$(filter-out \
  227. --target=% \
  228. --host=% \
  229. --build=% \
  230. --program-prefix=% \
  231. --program-suffix=% \
  232. --exec-prefix=% \
  233. $(DISABLE_NLS) \
  234. $(DISABLE_IPV6) \
  235. , $(CONFIGURE_ARGS))
  236. # Tell build system of qemu to not add _FORTIFY_SOURCE options and let the base
  237. # build system decide flavor of fortify_source to use
  238. CONFIGURE_ARGS += \
  239. --cross-prefix=$(TARGET_CROSS) \
  240. --host-cc="$(HOSTCC)" \
  241. --disable-fortify-source \
  242. --disable-stack-protector \
  243. --extra-cflags="$(TARGET_CFLAGS) $(EXTRA_CFLAGS)" \
  244. --extra-cxxflags="$(TARGET_CXXFLAGS) $(EXTRA_CXXFLAGS)" \
  245. --extra-ldflags="$(TARGET_LDFLAGS) $(EXTRA_LDFLAGS)" \
  246. # VHost features
  247. CONFIGURE_ARGS += \
  248. --enable-vhost-crypto \
  249. --enable-vhost-kernel \
  250. --enable-vhost-net \
  251. --enable-vhost-scsi \
  252. --enable-vhost-user \
  253. --enable-vhost-user-fs \
  254. --enable-vhost-user-blk-server \
  255. --enable-vhost-vsock \
  256. --enable-vhost-vdpa \
  257. # Image formats support
  258. CONFIGURE_ARGS += \
  259. --disable-bochs \
  260. --disable-cloop \
  261. --disable-dmg \
  262. --disable-qcow1 \
  263. --disable-vdi \
  264. --disable-vvfat \
  265. --disable-qed \
  266. --disable-parallels \
  267. # system/user-mode emulation
  268. CONFIGURE_ARGS += \
  269. --disable-user \
  270. --disable-bsd-user \
  271. --disable-linux-user \
  272. --enable-system \
  273. # accel
  274. CONFIGURE_ARGS += \
  275. --disable-hax \
  276. --disable-hvf \
  277. --disable-whpx \
  278. --disable-xen \
  279. --enable-kvm \
  280. --enable-tcg \
  281. # UI
  282. CONFIGURE_ARGS += \
  283. --disable-cocoa \
  284. --disable-gtk \
  285. --disable-sdl \
  286. --disable-sdl-image \
  287. --$(if $(CONFIG_QEMU_UI_SPICE),enable,disable)-spice \
  288. --disable-virglrenderer \
  289. --$(if $(CONFIG_QEMU_UI_VNC),enable,disable)-vnc \
  290. --$(if $(CONFIG_QEMU_UI_VNC_JPEG),enable,disable)-vnc-jpeg \
  291. --$(if $(CONFIG_QEMU_UI_VNC_PNG),enable,disable)-vnc-png \
  292. --$(if $(CONFIG_QEMU_UI_VNC_SASL),enable,disable)-vnc-sasl \
  293. --disable-vte \
  294. --enable-curses \
  295. --enable-iconv \
  296. # Features for performance & no external dependency
  297. CONFIGURE_ARGS += \
  298. --enable-coroutine-pool \
  299. --enable-crypto-afalg \
  300. --enable-live-block-migration \
  301. --enable-membarrier \
  302. --enable-replication \
  303. --enable-lto \
  304. --enable-tools \
  305. # Review configure options not explicitly specified here
  306. #
  307. # openwrt_makefile=openwrt/packages/utils/qemu/Makefile
  308. # qemu_configure=qemu/configure
  309. # for arg in $(grep -E '^\s*--disable-[^)]+\)' "$qemu_configure" | cut -f1 -d')'); do
  310. # grep -qE "(--enable|--disable)${arg#--disable}" "$openwrt_makefile" || echo "$arg"
  311. # done
  312. #
  313. CONFIGURE_ARGS += \
  314. --audio-drv-list='' \
  315. --disable-attr \
  316. --disable-auth-pam \
  317. --disable-brlapi \
  318. --disable-bzip2 \
  319. --disable-cap-ng \
  320. --disable-capstone \
  321. --disable-containers \
  322. --disable-curl \
  323. --disable-debug-info \
  324. --disable-debug-mutex \
  325. --disable-debug-tcg \
  326. --disable-docs \
  327. --disable-fuse \
  328. --disable-gcrypt \
  329. --with-git-submodules=ignore \
  330. --disable-glusterfs \
  331. --disable-gnutls \
  332. --disable-guest-agent-msi \
  333. --disable-jemalloc \
  334. --disable-libiscsi \
  335. --disable-libnfs \
  336. --disable-libpmem \
  337. --disable-libssh \
  338. --disable-libudev \
  339. --$(if $(CONFIG_QEMU_DEV_USB),enable,disable)-libusb \
  340. --disable-libxml2 \
  341. --disable-linux-aio \
  342. --disable-linux-io-uring \
  343. --disable-lzfse \
  344. --disable-lzo \
  345. --disable-modules \
  346. --disable-module-upgrades \
  347. --disable-mpath \
  348. --disable-netmap \
  349. --disable-nettle \
  350. --disable-numa \
  351. --disable-opengl \
  352. --disable-plugins \
  353. --disable-pvrdma \
  354. --disable-qom-cast-debug \
  355. --disable-rbd \
  356. --disable-rdma \
  357. --disable-sanitizers \
  358. --disable-seccomp \
  359. --disable-smartcard \
  360. --disable-snappy \
  361. --disable-sparse \
  362. --disable-strip \
  363. --disable-tcg-interpreter \
  364. --disable-tcmalloc \
  365. --disable-tpm \
  366. --disable-usb-redir \
  367. --disable-vde \
  368. --disable-virtfs \
  369. --disable-werror \
  370. --disable-xen-pci-passthrough \
  371. --disable-xkbcommon \
  372. --disable-xfsctl \
  373. --disable-zstd \
  374. CONFIGURE_ARGS += --target-list='$(foreach target,$(qemu-target-list),$(if $(CONFIG_PACKAGE_qemu-$(target)),$(target)))'
  375. CONFIGURE_ARGS += $(if $(CONFIG_PACKAGE_qemu-ga),--enable-guest-agent)
  376. TARGET_LDFLAGS += -Wl,--as-needed
  377. MAKE_VARS += V=1
  378. # ARCH is special in qemu's build system, e.g. ARCH mips64 will be translated
  379. # there to mips and stored in config-host.mak
  380. MAKE_FLAGS:=$(filter-out \
  381. ARCH=% \
  382. ,$(MAKE_FLAGS))
  383. $(eval $(call BuildPackage,virtio-console-helper))
  384. $(eval $(call BuildPackage,qemu-ga))
  385. $(eval $(call BuildPackage,qemu-bridge-helper))
  386. $(eval $(call BuildPackage,qemu-img))
  387. $(eval $(call BuildPackage,qemu-nbd))
  388. $(eval $(call BuildPackage,qemu-keymaps))
  389. $(foreach p,$(QEMU_PACKAGES), \
  390. $(eval $(call BuildPackage,$(p))) \
  391. )