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.

456 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:=1
  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_arm64||TARGET_malta)
  27. QEMU_DEPS_IN_HOST := @(TARGET_x86_64||TARGET_sunxi)
  28. QEMU_DEPS_IN_HOST += $(CXX_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 $(CXX_DEPENDS) $(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="$(EXTRA_CFLAGS)" \
  240. --extra-cxxflags="$(EXTRA_CXXFLAGS)" \
  241. --extra-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-lzfse \
  334. --disable-lzo \
  335. --disable-modules \
  336. --disable-module-upgrades \
  337. --disable-mpath \
  338. --disable-netmap \
  339. --disable-nettle \
  340. --disable-numa \
  341. --disable-opengl \
  342. --disable-plugins \
  343. --disable-pvrdma \
  344. --disable-qom-cast-debug \
  345. --disable-rbd \
  346. --disable-rdma \
  347. --disable-sanitizers \
  348. --disable-seccomp \
  349. --disable-sheepdog \
  350. --disable-smartcard \
  351. --disable-snappy \
  352. --disable-sparse \
  353. --disable-strip \
  354. --disable-tcg-interpreter \
  355. --disable-tcmalloc \
  356. --disable-tools \
  357. --disable-tpm \
  358. --disable-usb-redir \
  359. --disable-vde \
  360. --disable-virtfs \
  361. --disable-vxhs \
  362. --disable-werror \
  363. --disable-xen-pci-passthrough \
  364. --disable-xkbcommon \
  365. --disable-xfsctl \
  366. --disable-zstd \
  367. CONFIGURE_ARGS += --target-list='$(foreach target,$(qemu-target-list),$(if $(CONFIG_PACKAGE_qemu-$(target)),$(target)))'
  368. CONFIGURE_ARGS += $(if $(CONFIG_PACKAGE_qemu-ga),--enable-guest-agent)
  369. TARGET_LDFLAGS += -Wl,--as-needed
  370. MAKE_VARS += V=1
  371. # ARCH is special in qemu's build system, e.g. ARCH mips64 will be translated
  372. # there to mips and stored in config-host.mak
  373. MAKE_FLAGS:=$(filter-out \
  374. ARCH=% \
  375. ,$(MAKE_FLAGS))
  376. QEMU_MAKE_TARGETS := \
  377. $(if $(CONFIG_PACKAGE_qemu-ga),qemu-ga) \
  378. $(if $(CONFIG_PACKAGE_qemu-bridge-helper),qemu-bridge-helper) \
  379. $(if $(CONFIG_PACKAGE_qemu-img),qemu-img) \
  380. $(if $(CONFIG_PACKAGE_qemu-nbd),qemu-nbd) \
  381. $(foreach target,$(qemu-target-list),$(if $(CONFIG_PACKAGE_qemu-$(target)),$(target)/all)) \
  382. define Build/Compile
  383. $(if $(strip $(QEMU_MAKE_TARGETS)),$(call Build/Compile/Default,$(QEMU_MAKE_TARGETS)))
  384. endef
  385. $(eval $(call BuildPackage,virtio-console-helper))
  386. $(eval $(call BuildPackage,qemu-ga))
  387. $(eval $(call BuildPackage,qemu-bridge-helper))
  388. $(eval $(call BuildPackage,qemu-img))
  389. $(eval $(call BuildPackage,qemu-nbd))
  390. $(eval $(call BuildPackage,qemu-keymaps))
  391. $(foreach p,$(QEMU_PACKAGES), \
  392. $(eval $(call BuildPackage,$(p))) \
  393. )