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.

442 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.1.1
  11. PKG_RELEASE:=1
  12. PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
  13. PKG_HASH:=ed6fdbbdd272611446ff8036991e9b9f04a2ab2e3ffa9e79f3bab0eb9a95a1d2
  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. # QEMU configure script does not recognize these options
  215. CONFIGURE_ARGS:=$(filter-out \
  216. --target=% \
  217. --host=% \
  218. --build=% \
  219. --program-prefix=% \
  220. --program-suffix=% \
  221. --exec-prefix=% \
  222. --disable-nls \
  223. , $(CONFIGURE_ARGS))
  224. # Tell build system of qemu to not add _FORTIFY_SOURCE options and let the base
  225. # build system decide flavor of fortify_source to use
  226. CONFIGURE_ARGS += \
  227. --cross-prefix=$(TARGET_CROSS) \
  228. --host-cc="$(HOSTCC)" \
  229. --disable-fortify-source \
  230. --disable-stack-protector \
  231. --extra-cflags="$(EXTRA_CFLAGS)" \
  232. --extra-cxxflags="$(EXTRA_CXXFLAGS)" \
  233. --extra-ldflags="$(EXTRA_LDFLAGS)" \
  234. # VHost features
  235. CONFIGURE_ARGS += \
  236. --enable-vhost-crypto \
  237. --enable-vhost-kernel \
  238. --enable-vhost-net \
  239. --enable-vhost-scsi \
  240. --enable-vhost-user \
  241. --enable-vhost-vsock \
  242. # Image formats support
  243. CONFIGURE_ARGS += \
  244. --disable-bochs \
  245. --disable-cloop \
  246. --disable-dmg \
  247. --disable-qcow1 \
  248. --disable-vdi \
  249. --disable-vvfat \
  250. --disable-qed \
  251. --disable-parallels \
  252. # system/user-mode emulation
  253. CONFIGURE_ARGS += \
  254. --disable-user \
  255. --disable-bsd-user \
  256. --disable-linux-user \
  257. --enable-system \
  258. # accel
  259. CONFIGURE_ARGS += \
  260. --disable-hax \
  261. --disable-hvf \
  262. --disable-whpx \
  263. --disable-xen \
  264. --enable-kvm \
  265. --enable-tcg \
  266. # UI
  267. CONFIGURE_ARGS += \
  268. --disable-cocoa \
  269. --disable-gtk \
  270. --disable-sdl \
  271. --disable-sdl-image \
  272. --$(if $(CONFIG_QEMU_UI_SPICE),enable,disable)-spice \
  273. --disable-virglrenderer \
  274. --$(if $(CONFIG_QEMU_UI_VNC),enable,disable)-vnc \
  275. --$(if $(CONFIG_QEMU_UI_VNC_JPEG),enable,disable)-vnc-jpeg \
  276. --$(if $(CONFIG_QEMU_UI_VNC_PNG),enable,disable)-vnc-png \
  277. --$(if $(CONFIG_QEMU_UI_VNC_SASL),enable,disable)-vnc-sasl \
  278. --disable-vte \
  279. --enable-curses \
  280. --enable-iconv \
  281. # Features for performance & no external dependency
  282. CONFIGURE_ARGS += \
  283. --enable-coroutine-pool \
  284. --enable-crypto-afalg \
  285. --enable-live-block-migration \
  286. --enable-membarrier \
  287. --enable-replication \
  288. # Review configure options not explicitly specified here
  289. #
  290. # openwrt_makefile=openwrt/packages/utils/qemu/Makefile
  291. # qemu_configure=qemu/configure
  292. # for arg in $(grep -E '^\s*--disable-[^)]+\)' "$qemu_configure" | cut -f1 -d')'); do
  293. # grep -qE "(--enable|--disable)${arg#--disable}" "$openwrt_makefile" || echo "$arg"
  294. # done
  295. #
  296. CONFIGURE_ARGS += \
  297. --audio-drv-list='' \
  298. --disable-attr \
  299. --disable-auth-pam \
  300. --disable-bluez \
  301. --disable-brlapi \
  302. --disable-bzip2 \
  303. --disable-cap-ng \
  304. --disable-capstone \
  305. --disable-curl \
  306. --disable-debug-info \
  307. --disable-debug-mutex \
  308. --disable-debug-tcg \
  309. --disable-docs \
  310. --disable-gcrypt \
  311. --disable-git-update \
  312. --disable-glusterfs \
  313. --disable-gnutls \
  314. --disable-guest-agent-msi \
  315. --disable-jemalloc \
  316. --disable-libiscsi \
  317. --disable-libnfs \
  318. --disable-libpmem \
  319. --disable-libssh \
  320. --disable-libudev \
  321. --disable-libusb \
  322. --disable-libxml2 \
  323. --disable-linux-aio \
  324. --disable-lzfse \
  325. --disable-lzo \
  326. --disable-modules \
  327. --disable-mpath \
  328. --disable-netmap \
  329. --disable-nettle \
  330. --disable-numa \
  331. --disable-opengl \
  332. --disable-pvrdma \
  333. --disable-qom-cast-debug \
  334. --disable-rbd \
  335. --disable-rdma \
  336. --disable-sanitizers \
  337. --disable-seccomp \
  338. --disable-sheepdog \
  339. --disable-smartcard \
  340. --disable-snappy \
  341. --disable-sparse \
  342. --disable-strip \
  343. --disable-tcg-interpreter \
  344. --disable-tcmalloc \
  345. --disable-tools \
  346. --disable-tpm \
  347. --disable-usb-redir \
  348. --disable-vde \
  349. --disable-virtfs \
  350. --disable-vxhs \
  351. --disable-werror \
  352. --disable-xen-pci-passthrough \
  353. --disable-xfsctl \
  354. CONFIGURE_ARGS += --target-list='$(foreach target,$(qemu-target-list),$(if $(CONFIG_PACKAGE_qemu-$(target)),$(target)))'
  355. CONFIGURE_ARGS += $(if $(CONFIG_PACKAGE_qemu-ga),--enable-guest-agent)
  356. TARGET_LDFLAGS += -Wl,--as-needed
  357. MAKE_VARS += V=1
  358. # ARCH is special in qemu's build system, e.g. ARCH mips64 will be translated
  359. # there to mips and stored in config-host.mak
  360. MAKE_FLAGS:=$(filter-out \
  361. ARCH=% \
  362. ,$(MAKE_FLAGS))
  363. QEMU_MAKE_TARGETS := \
  364. $(if $(CONFIG_PACKAGE_qemu-ga),qemu-ga) \
  365. $(if $(CONFIG_PACKAGE_qemu-bridge-helper),qemu-bridge-helper) \
  366. $(if $(CONFIG_PACKAGE_qemu-img),qemu-img) \
  367. $(if $(CONFIG_PACKAGE_qemu-nbd),qemu-nbd) \
  368. $(foreach target,$(qemu-target-list),$(if $(CONFIG_PACKAGE_qemu-$(target)),$(target)/all)) \
  369. define Build/Compile
  370. $(if $(strip $(QEMU_MAKE_TARGETS)),$(call Build/Compile/Default,$(QEMU_MAKE_TARGETS)))
  371. endef
  372. $(eval $(call BuildPackage,virtio-console-helper))
  373. $(eval $(call BuildPackage,qemu-ga))
  374. $(eval $(call BuildPackage,qemu-bridge-helper))
  375. $(eval $(call BuildPackage,qemu-img))
  376. $(eval $(call BuildPackage,qemu-nbd))
  377. $(eval $(call BuildPackage,qemu-keymaps))
  378. $(foreach p,$(QEMU_PACKAGES), \
  379. $(eval $(call BuildPackage,$(p))) \
  380. )