qemu.mk 7.5 KB

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