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.

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