1 ################################################################################
5 ################################################################################
8 QEMU_SOURCE = qemu-$(QEMU_VERSION).tar.xz
9 QEMU_SITE = http://download.qemu.org
10 QEMU_LICENSE = GPL-2.0, LGPL-2.1, MIT, BSD-3-Clause, BSD-2-Clause, Others/BSD-1c
11 QEMU_LICENSE_FILES = COPYING COPYING.LIB
12 # NOTE: there is no top-level license file for non-(L)GPL licenses;
13 # the non-(L)GPL license texts are specified in the affected
14 # individual source files.
16 #-------------------------------------------------------------
19 QEMU_DEPENDENCIES = host-pkgconf host-python libglib2 zlib pixman
21 # Need the LIBS variable because librt and libm are
22 # not automatically pulled. :-(
28 LIBTOOL=$(HOST_DIR)/bin/libtool \
29 PYTHON=$(HOST_DIR)/bin/python2 \
30 PYTHONPATH=$(TARGET_DIR)/usr/lib/python$(PYTHON_VERSION_MAJOR)/site-packages
32 # If we want to specify only a subset of targets, we must still enable all
33 # of them, so that QEMU properly builds its list of default targets, from
34 # which it then checks if the specified sub-set is valid. That's what we
35 # do in the first part of the if-clause.
36 # Otherwise, if we do not want to pass a sub-set of targets, we then need
37 # to either enable or disable -user and/or -system emulation appropriately.
38 # That's what we do in the else-clause.
39 ifneq ($(call qstrip,$(BR2_PACKAGE_QEMU_CUSTOM_TARGETS)),)
40 QEMU_OPTS += --enable-system --enable-linux-user
41 QEMU_OPTS += --target-list="$(call qstrip,$(BR2_PACKAGE_QEMU_CUSTOM_TARGETS))"
44 ifeq ($(BR2_PACKAGE_QEMU_SYSTEM),y)
45 QEMU_OPTS += --enable-system
47 QEMU_OPTS += --disable-system
50 ifeq ($(BR2_PACKAGE_QEMU_LINUX_USER),y)
51 QEMU_OPTS += --enable-linux-user
53 QEMU_OPTS += --disable-linux-user
58 ifeq ($(BR2_PACKAGE_QEMU_SDL),y)
59 QEMU_OPTS += --enable-sdl
60 QEMU_DEPENDENCIES += sdl
61 QEMU_VARS += SDL_CONFIG=$(BR2_STAGING_DIR)/usr/bin/sdl-config
63 QEMU_OPTS += --disable-sdl
66 ifeq ($(BR2_PACKAGE_QEMU_FDT),y)
67 QEMU_OPTS += --enable-fdt
68 QEMU_DEPENDENCIES += dtc
70 QEMU_OPTS += --disable-fdt
73 ifeq ($(BR2_PACKAGE_QEMU_TOOLS),y)
74 QEMU_OPTS += --enable-tools
76 QEMU_OPTS += --disable-tools
79 ifeq ($(BR2_PACKAGE_LIBSSH2),y)
80 QEMU_OPTS += --enable-libssh2
81 QEMU_DEPENDENCIES += libssh2
83 QEMU_OPTS += --disable-libssh2
86 # Override CPP, as it expects to be able to call it like it'd
88 define QEMU_CONFIGURE_CMDS
91 $(TARGET_CONFIGURE_OPTS) \
92 $(TARGET_CONFIGURE_ARGS) \
93 CPP="$(TARGET_CC) -E" \
97 --cross-prefix=$(TARGET_CROSS) \
98 --with-system-pixman \
113 --disable-linux-aio \
119 --disable-usb-redir \
127 define QEMU_BUILD_CMDS
128 $(TARGET_MAKE_ENV) $(MAKE) -C $(@D)
131 define QEMU_INSTALL_TARGET_CMDS
132 $(TARGET_MAKE_ENV) $(MAKE) -C $(@D) $(QEMU_MAKE_ENV) DESTDIR=$(TARGET_DIR) install
135 $(eval $(generic-package))
137 #-------------------------------------------------------------
140 HOST_QEMU_DEPENDENCIES = host-pkgconf host-python host-zlib host-libglib2 host-pixman
151 # microblaze microblaze
158 # powerpc64le ppc64 (system) / ppc64le (usermode)
167 HOST_QEMU_ARCH = $(ARCH)
168 ifeq ($(HOST_QEMU_ARCH),i486)
169 HOST_QEMU_ARCH = i386
171 ifeq ($(HOST_QEMU_ARCH),i586)
172 HOST_QEMU_ARCH = i386
174 ifeq ($(HOST_QEMU_ARCH),i686)
175 HOST_QEMU_ARCH = i386
177 ifeq ($(HOST_QEMU_ARCH),powerpc)
180 ifeq ($(HOST_QEMU_ARCH),powerpc64)
181 HOST_QEMU_ARCH = ppc64
183 ifeq ($(HOST_QEMU_ARCH),powerpc64le)
184 HOST_QEMU_ARCH = ppc64le
185 HOST_QEMU_SYS_ARCH = ppc64
187 ifeq ($(HOST_QEMU_ARCH),sh4a)
190 ifeq ($(HOST_QEMU_ARCH),sh4aeb)
191 HOST_QEMU_ARCH = sh4eb
193 HOST_QEMU_SYS_ARCH ?= $(HOST_QEMU_ARCH)
195 ifeq ($(BR2_PACKAGE_HOST_QEMU_SYSTEM_MODE),y)
196 HOST_QEMU_TARGETS += $(HOST_QEMU_SYS_ARCH)-softmmu
197 HOST_QEMU_OPTS += --enable-system --enable-fdt
198 HOST_QEMU_DEPENDENCIES += host-dtc
200 HOST_QEMU_OPTS += --disable-system
203 ifeq ($(BR2_PACKAGE_HOST_QEMU_LINUX_USER_MODE),y)
204 HOST_QEMU_TARGETS += $(HOST_QEMU_ARCH)-linux-user
205 HOST_QEMU_OPTS += --enable-linux-user
207 HOST_QEMU_HOST_SYSTEM_TYPE = $(shell uname -s)
208 ifneq ($(HOST_QEMU_HOST_SYSTEM_TYPE),Linux)
209 $(error "qemu-user can only be used on Linux hosts")
212 # kernel version as major*256 + minor
213 HOST_QEMU_HOST_SYSTEM_VERSION = $(shell uname -r | awk -F. '{ print $$1 * 256 + $$2 }')
214 HOST_QEMU_TARGET_SYSTEM_VERSION = $(shell echo $(BR2_TOOLCHAIN_HEADERS_AT_LEAST) | awk -F. '{ print $$1 * 256 + $$2 }')
215 HOST_QEMU_COMPARE_VERSION = $(shell test $(HOST_QEMU_HOST_SYSTEM_VERSION) -ge $(HOST_QEMU_TARGET_SYSTEM_VERSION) && echo OK)
218 # The principle of qemu-user is that it emulates the instructions of
219 # the target architecture when running the binary, and then when this
220 # binary does a system call, it converts this system call into a
221 # system call on the host machine. This mechanism makes an assumption:
222 # that the target binary will not do system calls that do not exist on
223 # the host. This basically requires that the target binary should be
224 # built with kernel headers that are older or the same as the kernel
225 # version running on the host machine.
228 ifeq ($(BR_BUILDING),y)
229 ifneq ($(HOST_QEMU_COMPARE_VERSION),OK)
230 $(error "Refusing to build qemu-user: target Linux version newer than host's.")
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
238 ifeq ($(BR2_PACKAGE_HOST_QEMU_VDE2),y)
239 HOST_QEMU_OPTS += --enable-vde
240 HOST_QEMU_DEPENDENCIES += host-vde2
243 # Override CPP, as it expects to be able to call it like it'd
245 define HOST_QEMU_CONFIGURE_CMDS
246 cd $(@D); $(HOST_CONFIGURE_OPTS) CPP="$(HOSTCC) -E" \
248 --target-list="$(HOST_QEMU_TARGETS)" \
249 --prefix="$(HOST_DIR)" \
250 --interp-prefix=$(STAGING_DIR) \
252 --host-cc="$(HOSTCC)" \
253 --python=$(HOST_DIR)/bin/python2 \
254 --extra-cflags="$(HOST_CFLAGS)" \
255 --extra-ldflags="$(HOST_LDFLAGS)" \
259 define HOST_QEMU_BUILD_CMDS
260 $(HOST_MAKE_ENV) $(MAKE) -C $(@D)
263 define HOST_QEMU_INSTALL_CMDS
264 $(HOST_MAKE_ENV) $(MAKE) -C $(@D) install
267 $(eval $(host-generic-package))
269 # variable used by other packages
270 QEMU_USER = $(HOST_DIR)/bin/qemu-$(HOST_QEMU_ARCH)