Makefile 6.9 KB

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