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.

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