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.

295 lines
7.9 KiB

  1. #
  2. # Copyright (C) 2016 OpenWrt.org
  3. # Copyright (C) 2016-2018 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:=3.1.0
  11. PKG_RELEASE:=2
  12. PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
  13. PKG_HASH:=6a0508df079a0a33c2487ca936a56c12122f105b8a96a44374704bef6c69abfc
  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)/package.mk
  23. QEMU_DEPS_IN_GUEST := @(TARGET_x86_64||TARGET_armvirt||TARGET_arm64||TARGET_malta)
  24. QEMU_DEPS_IN_HOST := @(TARGET_x86_64||TARGET_sunxi)
  25. define Package/virtio-console-helper
  26. SECTION:=utils
  27. CATEGORY:=Utilities
  28. SUBMENU:=Virtualization
  29. TITLE:=Helper script for vportNpn virtio-console devices
  30. DEPENDS:=$(QEMU_DEPS_IN_GUEST)
  31. endef
  32. define Package/virtio-console-helper/install
  33. $(INSTALL_DIR) $(1)/etc/hotplug.d/virtio-ports
  34. $(INSTALL_BIN) ./files/00-virtio-ports.hotplug $(1)/etc/hotplug.d/virtio-ports/00-virtio-ports
  35. endef
  36. define Package/qemu-ga
  37. SECTION:=utils
  38. CATEGORY:=Utilities
  39. SUBMENU:=Virtualization
  40. TITLE:=QEMU Guest Agent
  41. URL:=http://www.qemu.org
  42. DEPENDS:= +glib2 +virtio-console-helper $(CXX_DEPENDS) $(QEMU_DEPS_IN_GUEST)
  43. endef
  44. define Package/qemu-ga/description
  45. This package contains the QEMU Guest Agent daemon
  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. define Package/qemu-blobs
  56. SECTION:=utils
  57. CATEGORY:=Utilities
  58. SUBMENU:=Virtualization
  59. TITLE:=QEMU blobs of BIOS, VGA BIOS and keymaps
  60. URL:=http://www.qemu.org
  61. DEPENDS:=$(QEMU_DEPS_IN_HOST)
  62. endef
  63. define Package/qemu-blobs/install
  64. $(INSTALL_DIR) $(1)/usr/share/qemu
  65. $(CP) $(PKG_INSTALL_DIR)/usr/share/qemu/* $(1)/usr/share/qemu
  66. endef
  67. define Package/qemu-bridge-helper
  68. SECTION:=utils
  69. CATEGORY:=Utilities
  70. SUBMENU:=Virtualization
  71. TITLE:=QEMU bridge helper
  72. URL:=http://www.qemu.org
  73. DEPENDS:=+glib2 $(CXX_DEPENDS) $(QEMU_DEPS_IN_HOST)
  74. endef
  75. define Package/qemu-bridge-helper/install
  76. $(INSTALL_DIR) $(1)/usr/lib/
  77. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/qemu-bridge-helper $(1)/usr/lib
  78. $(INSTALL_DIR) $(1)/etc/qemu
  79. $(INSTALL_DATA) ./files/bridge.conf $(1)/etc/qemu
  80. endef
  81. define Package/qemu-img
  82. SECTION:=utils
  83. CATEGORY:=Utilities
  84. SUBMENU:=Virtualization
  85. TITLE:=QEMU Image utility
  86. URL:=http://www.qemu.org
  87. DEPENDS:=+glib2 $(CXX_DEPENDS) $(QEMU_DEPS_IN_HOST)
  88. endef
  89. define Package/qemu-img/install
  90. $(INSTALL_DIR) $(1)/usr/bin/
  91. $(INSTALL_BIN) $(PKG_BUILD_DIR)/qemu-img $(1)/usr/bin/qemu-img
  92. endef
  93. define Package/qemu-nbd
  94. SECTION:=utils
  95. CATEGORY:=Utilities
  96. SUBMENU:=Virtualization
  97. TITLE:=QEMU Network Block Device Utility
  98. URL:=http://www.qemu.org
  99. DEPENDS:=+glib2 $(CXX_DEPENDS) $(QEMU_DEPS_IN_HOST) +kmod-nbd
  100. endef
  101. define Package/qemu-nbd/install
  102. $(INSTALL_DIR) $(1)/usr/sbin/
  103. $(INSTALL_BIN) $(PKG_BUILD_DIR)/qemu-nbd $(1)/usr/sbin/qemu-nbd
  104. endef
  105. PKG_CONFIG_DEPENDS += CONFIG_PACKAGE_qemu-ga
  106. # Naming rules used in qemu Makefile.target
  107. define qemu-prog_
  108. $(if $(filter %-softmmu,$(1)), \
  109. $(patsubst %-softmmu,qemu-system-%,$(1)), \
  110. $(error unknown qemu target $(1)) \
  111. )
  112. endef
  113. qemu-prog = $(strip $(call qemu-prog_,$(1)))
  114. # Why libfdt was enabled for all softmmu targets: according to qemu's
  115. # configure script, libfdt is only strictly required for the following targets
  116. # and is optional for others. But libfdt support will be built into other
  117. # targets when any single target enabled it.
  118. #
  119. # aarch64%-softmmu arm%-softmmu ppc%-softmmu microblaze%-softmmu
  120. #
  121. define qemu-target
  122. PKG_CONFIG_DEPENDS += CONFIG_PACKAGE_qemu-$(1)
  123. define Package/qemu-$(1)
  124. SECTION:=utils
  125. CATEGORY:=Utilities
  126. SUBMENU:=Virtualization
  127. TITLE:=QEMU target $(1)
  128. URL:=http://www.qemu.org
  129. DEPENDS:= +glib2 +libpthread +zlib $(CXX_DEPENDS) $(QEMU_DEPS_IN_HOST) \
  130. $(if $(filter %-softmmu,$(1)),+libncurses +libfdt +pixman +qemu-blobs)
  131. endef
  132. define Package/qemu-$(1)/description
  133. This package contains the QEMU target $(1)
  134. endef
  135. define Package/qemu-$(1)/install
  136. $(INSTALL_DIR) $$(1)/usr/bin
  137. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/$(call qemu-prog,$(1)) $$(1)/usr/bin
  138. endef
  139. endef
  140. QEMU_TARGET_LIST := \
  141. x86_64-softmmu \
  142. arm-softmmu \
  143. $(foreach target,$(QEMU_TARGET_LIST), \
  144. $(eval $(call qemu-target,$(target))) \
  145. )
  146. # QEMU configure script does not recognize these options
  147. CONFIGURE_ARGS:=$(filter-out \
  148. --target=% \
  149. --host=% \
  150. --build=% \
  151. --program-prefix=% \
  152. --program-suffix=% \
  153. --exec-prefix=% \
  154. --disable-nls \
  155. , $(CONFIGURE_ARGS))
  156. # Tell build system of qemu to not add _FORTIFY_SOURCE options and let the base
  157. # build system decide flavor of fortify_source to use
  158. CONFIGURE_ARGS += \
  159. --cross-prefix=$(TARGET_CROSS) \
  160. --host-cc="$(HOSTCC)" \
  161. --disable-fortify-source \
  162. --disable-stack-protector \
  163. # Make a list from QEMU source code for reference
  164. #
  165. # grep -E '^\s*--disable-[^)]+\)' configure | cut -f1 -d')' | sort -u
  166. #
  167. CONFIGURE_ARGS += \
  168. --audio-drv-list='' \
  169. --disable-attr \
  170. --disable-bluez \
  171. --disable-brlapi \
  172. --disable-bsd-user \
  173. --disable-bzip2 \
  174. --disable-cap-ng \
  175. --disable-cocoa \
  176. --disable-curl \
  177. --disable-debug-info \
  178. --disable-debug-tcg \
  179. --disable-docs \
  180. --disable-gcrypt \
  181. --disable-glusterfs \
  182. --disable-gnutls \
  183. --disable-gtk \
  184. --disable-guest-agent-msi \
  185. --disable-jemalloc \
  186. --disable-libiscsi \
  187. --disable-libnfs \
  188. --disable-libpmem \
  189. --disable-libssh2 \
  190. --disable-libudev \
  191. --disable-libusb \
  192. --disable-libxml2 \
  193. --disable-linux-aio \
  194. --disable-lzo \
  195. --disable-modules \
  196. --disable-netmap \
  197. --disable-nettle \
  198. --disable-numa \
  199. --disable-opengl \
  200. --disable-qom-cast-debug \
  201. --disable-rbd \
  202. --disable-rdma \
  203. --disable-sdl \
  204. --disable-seccomp \
  205. --disable-smartcard \
  206. --disable-snappy \
  207. --disable-sparse \
  208. --disable-spice \
  209. --disable-strip \
  210. --disable-tcg-interpreter \
  211. --disable-tcmalloc \
  212. --disable-tools \
  213. --disable-tpm \
  214. --disable-usb-redir \
  215. --disable-uuid \
  216. --disable-vde \
  217. --disable-vhdx \
  218. --disable-virglrenderer \
  219. --disable-virtfs \
  220. --disable-vnc \
  221. --disable-vnc-jpeg \
  222. --disable-vnc-png \
  223. --disable-vnc-sasl \
  224. --disable-vte \
  225. --disable-werror \
  226. --disable-xen \
  227. --disable-xen-pci-passthrough \
  228. --disable-xen-pv-domain-build \
  229. --disable-xfsctl \
  230. --disable-zlib-test \
  231. CONFIGURE_ARGS += --target-list='$(foreach target,$(QEMU_TARGET_LIST),$(if $(CONFIG_PACKAGE_qemu-$(target)),$(target)))'
  232. CONFIGURE_ARGS += $(if $(CONFIG_PACKAGE_qemu-ga),--enable-guest-agent)
  233. TARGET_LDFLAGS += -Wl,--as-needed
  234. MAKE_VARS += V=s
  235. # ARCH is special in qemu's build system, e.g. ARCH mips64 will be translated
  236. # there to mips and stored in config-host.mak
  237. MAKE_FLAGS:=$(filter-out \
  238. ARCH=% \
  239. ,$(MAKE_FLAGS))
  240. QEMU_MAKE_TARGETS := \
  241. $(if $(CONFIG_PACKAGE_qemu-ga),qemu-ga) \
  242. $(if $(CONFIG_PACKAGE_qemu-bridge-helper),qemu-bridge-helper) \
  243. $(if $(CONFIG_PACKAGE_qemu-img),qemu-img) \
  244. $(if $(CONFIG_PACKAGE_qemu-nbd),qemu-nbd) \
  245. $(foreach target,$(QEMU_TARGET_LIST),$(if $(CONFIG_PACKAGE_qemu-$(target)),subdir-$(target))) \
  246. define Build/Compile
  247. $(if $(strip $(QEMU_MAKE_TARGETS)),$(call Build/Compile/Default,$(QEMU_MAKE_TARGETS)))
  248. endef
  249. $(eval $(call BuildPackage,virtio-console-helper))
  250. $(eval $(call BuildPackage,qemu-ga))
  251. $(eval $(call BuildPackage,qemu-bridge-helper))
  252. $(eval $(call BuildPackage,qemu-img))
  253. $(eval $(call BuildPackage,qemu-nbd))
  254. $(eval $(call BuildPackage,qemu-blobs))
  255. $(foreach target,$(QEMU_TARGET_LIST), \
  256. $(eval $(call BuildPackage,qemu-$(target))) \
  257. )