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.

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