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.

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