qemu.mk 7.7 KB

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