2
1

qemu.mk 6.9 KB

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