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.

293 lines
7.8 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:=2.12.1
  11. PKG_RELEASE:=1
  12. PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
  13. PKG_HASH:=4150809a52d821398dfd38c94b065513ef26b393fda9aba4bb6f09644cf1e5ca
  14. PKG_SOURCE_URL:=http://wiki.qemu-project.org/download/
  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. CONFIGURE_ARGS += \
  164. --audio-drv-list='' \
  165. --disable-debug-info \
  166. --disable-modules \
  167. --disable-sdl \
  168. --disable-qom-cast-debug \
  169. --disable-virtfs \
  170. --disable-vnc \
  171. --disable-debug-tcg \
  172. --disable-sparse \
  173. --disable-strip \
  174. --disable-vnc-sasl \
  175. --disable-vnc-jpeg \
  176. --disable-vnc-png \
  177. --disable-uuid \
  178. --disable-vde \
  179. --disable-netmap \
  180. --disable-xen \
  181. --disable-xen-pci-passthrough \
  182. --disable-xen-pv-domain-build \
  183. --disable-brlapi \
  184. --disable-bluez \
  185. --disable-tcg-interpreter \
  186. --disable-cap-ng \
  187. --disable-spice \
  188. --disable-libiscsi \
  189. --disable-libnfs \
  190. --disable-cocoa \
  191. --disable-bsd-user \
  192. --disable-curl \
  193. --disable-linux-aio \
  194. --disable-attr \
  195. --disable-docs \
  196. --disable-opengl \
  197. --disable-rbd \
  198. --disable-xfsctl \
  199. --disable-smartcard \
  200. --disable-libusb \
  201. --disable-usb-redir \
  202. --disable-zlib-test \
  203. --disable-lzo \
  204. --disable-snappy \
  205. --disable-bzip2 \
  206. --disable-guest-agent-msi \
  207. --disable-tools \
  208. --disable-seccomp \
  209. --disable-glusterfs \
  210. --disable-gtk \
  211. --disable-gnutls \
  212. --disable-nettle \
  213. --disable-gcrypt \
  214. --disable-rdma \
  215. --disable-vte \
  216. --disable-virglrenderer \
  217. --disable-tpm \
  218. --disable-libssh2 \
  219. --disable-vhdx \
  220. --disable-numa \
  221. --disable-tcmalloc \
  222. --disable-jemalloc \
  223. --disable-strip \
  224. --disable-werror \
  225. QEMU_CONFIGURE_TARGET_LIST := $(foreach target,$(QEMU_TARGET_LIST),$(if $(CONFIG_PACKAGE_qemu-$(target)),$(target)))
  226. CONFIGURE_ARGS += --target-list='$(QEMU_CONFIGURE_TARGET_LIST)'
  227. ifneq ($(CONFIG_PACKAGE_qemu-ga),)
  228. CONFIGURE_ARGS += --enable-guest-agent
  229. endif
  230. TARGET_LDFLAGS += -Wl,--as-needed
  231. MAKE_VARS += V=s
  232. # ARCH is special in qemu's build system, e.g. ARCH mips64 will be translated
  233. # there to mips and stored in config-host.mak
  234. MAKE_FLAGS:=$(filter-out \
  235. ARCH=% \
  236. ,$(MAKE_FLAGS))
  237. QEMU_MAKE_TARGETS := \
  238. $(if $(CONFIG_PACKAGE_qemu-ga),qemu-ga) \
  239. $(if $(CONFIG_PACKAGE_qemu-bridge-helper),qemu-bridge-helper) \
  240. $(if $(CONFIG_PACKAGE_qemu-img),qemu-img) \
  241. $(if $(CONFIG_PACKAGE_qemu-nbd),qemu-nbd) \
  242. $(foreach target,$(QEMU_TARGET_LIST),$(if $(CONFIG_PACKAGE_qemu-$(target)),subdir-$(target))) \
  243. define Build/Compile
  244. $(if $(strip $(QEMU_MAKE_TARGETS)),$(call Build/Compile/Default,$(QEMU_MAKE_TARGETS)))
  245. endef
  246. $(eval $(call BuildPackage,virtio-console-helper))
  247. $(eval $(call BuildPackage,qemu-ga))
  248. $(eval $(call BuildPackage,qemu-bridge-helper))
  249. $(eval $(call BuildPackage,qemu-img))
  250. $(eval $(call BuildPackage,qemu-nbd))
  251. $(eval $(call BuildPackage,qemu-blobs))
  252. $(foreach target,$(QEMU_TARGET_LIST), \
  253. $(eval $(call BuildPackage,qemu-$(target))) \
  254. )