2
1

qemu.mk 7.4 KB

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