qemu.mk 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. ################################################################################
  2. #
  3. # qemu
  4. #
  5. ################################################################################
  6. ifeq ($(BR2_csky),y)
  7. QEMU_VERSION = b517e1dc3125a57555d67a8deed9eac7b42288e2
  8. QEMU_SITE = $(call github,c-sky,qemu,$(QEMU_VERSION))
  9. else
  10. QEMU_VERSION = 3.1.0
  11. QEMU_SOURCE = qemu-$(QEMU_VERSION).tar.xz
  12. QEMU_SITE = http://download.qemu.org
  13. endif
  14. QEMU_LICENSE = GPL-2.0, LGPL-2.1, MIT, BSD-3-Clause, BSD-2-Clause, Others/BSD-1c
  15. QEMU_LICENSE_FILES = COPYING COPYING.LIB
  16. # NOTE: there is no top-level license file for non-(L)GPL licenses;
  17. # the non-(L)GPL license texts are specified in the affected
  18. # individual source files.
  19. #-------------------------------------------------------------
  20. # Target-qemu
  21. QEMU_DEPENDENCIES = host-pkgconf libglib2 zlib pixman
  22. # Need the LIBS variable because librt and libm are
  23. # not automatically pulled. :-(
  24. QEMU_LIBS = -lrt -lm
  25. QEMU_OPTS =
  26. QEMU_VARS = LIBTOOL=$(HOST_DIR)/bin/libtool
  27. # If we want to specify only a subset of targets, we must still enable all
  28. # of them, so that QEMU properly builds its list of default targets, from
  29. # which it then checks if the specified sub-set is valid. That's what we
  30. # do in the first part of the if-clause.
  31. # Otherwise, if we do not want to pass a sub-set of targets, we then need
  32. # to either enable or disable -user and/or -system emulation appropriately.
  33. # That's what we do in the else-clause.
  34. ifneq ($(call qstrip,$(BR2_PACKAGE_QEMU_CUSTOM_TARGETS)),)
  35. QEMU_OPTS += --enable-system --enable-linux-user
  36. QEMU_OPTS += --target-list="$(call qstrip,$(BR2_PACKAGE_QEMU_CUSTOM_TARGETS))"
  37. else
  38. ifeq ($(BR2_PACKAGE_QEMU_SYSTEM),y)
  39. QEMU_OPTS += --enable-system
  40. else
  41. QEMU_OPTS += --disable-system
  42. endif
  43. ifeq ($(BR2_PACKAGE_QEMU_LINUX_USER),y)
  44. QEMU_OPTS += --enable-linux-user
  45. else
  46. QEMU_OPTS += --disable-linux-user
  47. endif
  48. endif
  49. # There is no "--enable-slirp"
  50. ifeq ($(BR2_PACKAGE_QEMU_SLIRP),)
  51. QEMU_OPTS += --disable-slirp
  52. endif
  53. ifeq ($(BR2_PACKAGE_QEMU_SDL),y)
  54. QEMU_OPTS += --enable-sdl
  55. QEMU_DEPENDENCIES += sdl2
  56. QEMU_VARS += SDL2_CONFIG=$(BR2_STAGING_DIR)/usr/bin/sdl2-config
  57. else
  58. QEMU_OPTS += --disable-sdl
  59. endif
  60. ifeq ($(BR2_PACKAGE_QEMU_FDT),y)
  61. QEMU_OPTS += --enable-fdt
  62. QEMU_DEPENDENCIES += dtc
  63. else
  64. QEMU_OPTS += --disable-fdt
  65. endif
  66. ifeq ($(BR2_PACKAGE_QEMU_TOOLS),y)
  67. QEMU_OPTS += --enable-tools
  68. else
  69. QEMU_OPTS += --disable-tools
  70. endif
  71. ifeq ($(BR2_PACKAGE_LIBSECCOMP),y)
  72. QEMU_OPTS += --enable-seccomp
  73. QEMU_DEPENDENCIES += libseccomp
  74. else
  75. QEMU_OPTS += --disable-seccomp
  76. endif
  77. ifeq ($(BR2_PACKAGE_LIBSSH2),y)
  78. QEMU_OPTS += --enable-libssh2
  79. QEMU_DEPENDENCIES += libssh2
  80. else
  81. QEMU_OPTS += --disable-libssh2
  82. endif
  83. # Override CPP, as it expects to be able to call it like it'd
  84. # call the compiler.
  85. define QEMU_CONFIGURE_CMDS
  86. unset TARGET_DIR; \
  87. cd $(@D); \
  88. LIBS='$(QEMU_LIBS)' \
  89. $(TARGET_CONFIGURE_OPTS) \
  90. $(TARGET_CONFIGURE_ARGS) \
  91. CPP="$(TARGET_CC) -E" \
  92. $(QEMU_VARS) \
  93. ./configure \
  94. --prefix=/usr \
  95. --cross-prefix=$(TARGET_CROSS) \
  96. --audio-drv-list= \
  97. --enable-kvm \
  98. --enable-attr \
  99. --enable-vhost-net \
  100. --disable-bsd-user \
  101. --disable-xen \
  102. --disable-vnc \
  103. --disable-virtfs \
  104. --disable-brlapi \
  105. --disable-curses \
  106. --disable-curl \
  107. --disable-bluez \
  108. --disable-vde \
  109. --disable-linux-aio \
  110. --disable-cap-ng \
  111. --disable-docs \
  112. --disable-spice \
  113. --disable-rbd \
  114. --disable-libiscsi \
  115. --disable-usb-redir \
  116. --disable-strip \
  117. --disable-sparse \
  118. --disable-mpath \
  119. --disable-sanitizers \
  120. --disable-hvf \
  121. --disable-whpx \
  122. --disable-malloc-trim \
  123. --disable-membarrier \
  124. --disable-vhost-crypto \
  125. --disable-libxml2 \
  126. --disable-capstone \
  127. --disable-git-update \
  128. --disable-opengl \
  129. $(QEMU_OPTS)
  130. endef
  131. define QEMU_BUILD_CMDS
  132. unset TARGET_DIR; \
  133. $(TARGET_MAKE_ENV) $(MAKE) -C $(@D)
  134. endef
  135. define QEMU_INSTALL_TARGET_CMDS
  136. unset TARGET_DIR; \
  137. $(TARGET_MAKE_ENV) $(MAKE) -C $(@D) $(QEMU_MAKE_ENV) DESTDIR=$(TARGET_DIR) install
  138. endef
  139. $(eval $(generic-package))
  140. #-------------------------------------------------------------
  141. # Host-qemu
  142. HOST_QEMU_DEPENDENCIES = host-pkgconf host-zlib host-libglib2 host-pixman
  143. # BR ARCH qemu
  144. # ------- ----
  145. # arm arm
  146. # armeb armeb
  147. # i486 i386
  148. # i586 i386
  149. # i686 i386
  150. # x86_64 x86_64
  151. # m68k m68k
  152. # microblaze microblaze
  153. # mips mips
  154. # mipsel mipsel
  155. # mips64 mips64
  156. # mips64el mips64el
  157. # powerpc ppc
  158. # powerpc64 ppc64
  159. # powerpc64le ppc64 (system) / ppc64le (usermode)
  160. # sh2a not supported
  161. # sh4 sh4
  162. # sh4eb sh4eb
  163. # sh4a sh4
  164. # sh4aeb sh4eb
  165. # sh64 not supported
  166. # sparc sparc
  167. HOST_QEMU_ARCH = $(ARCH)
  168. ifeq ($(HOST_QEMU_ARCH),i486)
  169. HOST_QEMU_ARCH = i386
  170. endif
  171. ifeq ($(HOST_QEMU_ARCH),i586)
  172. HOST_QEMU_ARCH = i386
  173. endif
  174. ifeq ($(HOST_QEMU_ARCH),i686)
  175. HOST_QEMU_ARCH = i386
  176. endif
  177. ifeq ($(HOST_QEMU_ARCH),powerpc)
  178. HOST_QEMU_ARCH = ppc
  179. endif
  180. ifeq ($(HOST_QEMU_ARCH),powerpc64)
  181. HOST_QEMU_ARCH = ppc64
  182. endif
  183. ifeq ($(HOST_QEMU_ARCH),powerpc64le)
  184. HOST_QEMU_ARCH = ppc64le
  185. HOST_QEMU_SYS_ARCH = ppc64
  186. endif
  187. ifeq ($(HOST_QEMU_ARCH),sh4a)
  188. HOST_QEMU_ARCH = sh4
  189. endif
  190. ifeq ($(HOST_QEMU_ARCH),sh4aeb)
  191. HOST_QEMU_ARCH = sh4eb
  192. endif
  193. ifeq ($(HOST_QEMU_ARCH),csky)
  194. ifeq ($(BR2_ck610),y)
  195. HOST_QEMU_ARCH = cskyv1
  196. else
  197. HOST_QEMU_ARCH = cskyv2
  198. endif
  199. endif
  200. HOST_QEMU_SYS_ARCH ?= $(HOST_QEMU_ARCH)
  201. ifeq ($(BR2_PACKAGE_HOST_QEMU_SYSTEM_MODE),y)
  202. HOST_QEMU_TARGETS += $(HOST_QEMU_SYS_ARCH)-softmmu
  203. HOST_QEMU_OPTS += --enable-system --enable-fdt
  204. HOST_QEMU_DEPENDENCIES += host-dtc
  205. else
  206. HOST_QEMU_OPTS += --disable-system
  207. endif
  208. ifeq ($(BR2_PACKAGE_HOST_QEMU_LINUX_USER_MODE),y)
  209. HOST_QEMU_TARGETS += $(HOST_QEMU_ARCH)-linux-user
  210. HOST_QEMU_OPTS += --enable-linux-user
  211. HOST_QEMU_HOST_SYSTEM_TYPE = $(shell uname -s)
  212. ifneq ($(HOST_QEMU_HOST_SYSTEM_TYPE),Linux)
  213. $(error "qemu-user can only be used on Linux hosts")
  214. endif
  215. # kernel version as major*256 + minor
  216. HOST_QEMU_HOST_SYSTEM_VERSION = $(shell uname -r | awk -F. '{ print $$1 * 256 + $$2 }')
  217. HOST_QEMU_TARGET_SYSTEM_VERSION = $(shell echo $(BR2_TOOLCHAIN_HEADERS_AT_LEAST) | awk -F. '{ print $$1 * 256 + $$2 }')
  218. HOST_QEMU_COMPARE_VERSION = $(shell test $(HOST_QEMU_HOST_SYSTEM_VERSION) -ge $(HOST_QEMU_TARGET_SYSTEM_VERSION) && echo OK)
  219. #
  220. # The principle of qemu-user is that it emulates the instructions of
  221. # the target architecture when running the binary, and then when this
  222. # binary does a system call, it converts this system call into a
  223. # system call on the host machine. This mechanism makes an assumption:
  224. # that the target binary will not do system calls that do not exist on
  225. # the host. This basically requires that the target binary should be
  226. # built with kernel headers that are older or the same as the kernel
  227. # version running on the host machine.
  228. #
  229. ifeq ($(BR_BUILDING),y)
  230. ifneq ($(HOST_QEMU_COMPARE_VERSION),OK)
  231. $(error "Refusing to build qemu-user: target Linux version newer than host's.")
  232. endif
  233. endif # BR_BUILDING
  234. else # BR2_PACKAGE_HOST_QEMU_LINUX_USER_MODE
  235. HOST_QEMU_OPTS += --disable-linux-user
  236. endif # BR2_PACKAGE_HOST_QEMU_LINUX_USER_MODE
  237. ifeq ($(BR2_PACKAGE_HOST_QEMU_VDE2),y)
  238. HOST_QEMU_OPTS += --enable-vde
  239. HOST_QEMU_DEPENDENCIES += host-vde2
  240. endif
  241. ifeq ($(BR2_PACKAGE_HOST_QEMU_VIRTFS),y)
  242. HOST_QEMU_OPTS += --enable-virtfs
  243. HOST_QEMU_DEPENDENCIES += host-libcap
  244. else
  245. HOST_QEMU_OPTS += --disable-virtfs
  246. endif
  247. # Override CPP, as it expects to be able to call it like it'd
  248. # call the compiler.
  249. define HOST_QEMU_CONFIGURE_CMDS
  250. unset TARGET_DIR; \
  251. cd $(@D); $(HOST_CONFIGURE_OPTS) CPP="$(HOSTCC) -E" \
  252. ./configure \
  253. --target-list="$(HOST_QEMU_TARGETS)" \
  254. --prefix="$(HOST_DIR)" \
  255. --interp-prefix=$(STAGING_DIR) \
  256. --cc="$(HOSTCC)" \
  257. --host-cc="$(HOSTCC)" \
  258. --extra-cflags="$(HOST_CFLAGS)" \
  259. --extra-ldflags="$(HOST_LDFLAGS)" \
  260. $(HOST_QEMU_OPTS)
  261. endef
  262. define HOST_QEMU_BUILD_CMDS
  263. unset TARGET_DIR; \
  264. $(HOST_MAKE_ENV) $(MAKE) -C $(@D)
  265. endef
  266. define HOST_QEMU_INSTALL_CMDS
  267. unset TARGET_DIR; \
  268. $(HOST_MAKE_ENV) $(MAKE) -C $(@D) install
  269. endef
  270. $(eval $(host-generic-package))
  271. # variable used by other packages
  272. QEMU_USER = $(HOST_DIR)/bin/qemu-$(HOST_QEMU_ARCH)