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.

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