]> rtime.felk.cvut.cz Git - coffee/buildroot.git/blob - package/qemu/qemu.mk
package/qemu: declare target variant before host variant
[coffee/buildroot.git] / package / qemu / qemu.mk
1 ################################################################################
2 #
3 # qemu
4 #
5 ################################################################################
6
7 QEMU_VERSION = 2.10.2
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.
15
16 #-------------------------------------------------------------
17 # Target-qemu
18
19 QEMU_DEPENDENCIES = host-pkgconf host-python libglib2 zlib pixman
20
21 # Need the LIBS variable because librt and libm are
22 # not automatically pulled. :-(
23 QEMU_LIBS = -lrt -lm
24
25 QEMU_OPTS =
26
27 QEMU_VARS = \
28         LIBTOOL=$(HOST_DIR)/bin/libtool \
29         PYTHON=$(HOST_DIR)/bin/python2 \
30         PYTHONPATH=$(TARGET_DIR)/usr/lib/python$(PYTHON_VERSION_MAJOR)/site-packages
31
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))"
42 else
43
44 ifeq ($(BR2_PACKAGE_QEMU_SYSTEM),y)
45 QEMU_OPTS += --enable-system
46 else
47 QEMU_OPTS += --disable-system
48 endif
49
50 ifeq ($(BR2_PACKAGE_QEMU_LINUX_USER),y)
51 QEMU_OPTS += --enable-linux-user
52 else
53 QEMU_OPTS += --disable-linux-user
54 endif
55
56 endif
57
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
62 else
63 QEMU_OPTS += --disable-sdl
64 endif
65
66 ifeq ($(BR2_PACKAGE_QEMU_FDT),y)
67 QEMU_OPTS += --enable-fdt
68 QEMU_DEPENDENCIES += dtc
69 else
70 QEMU_OPTS += --disable-fdt
71 endif
72
73 ifeq ($(BR2_PACKAGE_QEMU_TOOLS),y)
74 QEMU_OPTS += --enable-tools
75 else
76 QEMU_OPTS += --disable-tools
77 endif
78
79 ifeq ($(BR2_PACKAGE_LIBSSH2),y)
80 QEMU_OPTS += --enable-libssh2
81 QEMU_DEPENDENCIES += libssh2
82 else
83 QEMU_OPTS += --disable-libssh2
84 endif
85
86 # Override CPP, as it expects to be able to call it like it'd
87 # call the compiler.
88 define QEMU_CONFIGURE_CMDS
89         ( cd $(@D); \
90                 LIBS='$(QEMU_LIBS)' \
91                 $(TARGET_CONFIGURE_OPTS) \
92                 $(TARGET_CONFIGURE_ARGS) \
93                 CPP="$(TARGET_CC) -E" \
94                 $(QEMU_VARS) \
95                 ./configure \
96                         --prefix=/usr \
97                         --cross-prefix=$(TARGET_CROSS) \
98                         --with-system-pixman \
99                         --audio-drv-list= \
100                         --enable-kvm \
101                         --enable-attr \
102                         --enable-vhost-net \
103                         --disable-bsd-user \
104                         --disable-xen \
105                         --disable-slirp \
106                         --disable-vnc \
107                         --disable-virtfs \
108                         --disable-brlapi \
109                         --disable-curses \
110                         --disable-curl \
111                         --disable-bluez \
112                         --disable-vde \
113                         --disable-linux-aio \
114                         --disable-cap-ng \
115                         --disable-docs \
116                         --disable-spice \
117                         --disable-rbd \
118                         --disable-libiscsi \
119                         --disable-usb-redir \
120                         --disable-strip \
121                         --disable-seccomp \
122                         --disable-sparse \
123                         $(QEMU_OPTS) \
124         )
125 endef
126
127 define QEMU_BUILD_CMDS
128         $(TARGET_MAKE_ENV) $(MAKE) -C $(@D)
129 endef
130
131 define QEMU_INSTALL_TARGET_CMDS
132         $(TARGET_MAKE_ENV) $(MAKE) -C $(@D) $(QEMU_MAKE_ENV) DESTDIR=$(TARGET_DIR) install
133 endef
134
135 $(eval $(generic-package))
136
137 #-------------------------------------------------------------
138 # Host-qemu
139
140 HOST_QEMU_DEPENDENCIES = host-pkgconf host-python host-zlib host-libglib2 host-pixman
141
142 #       BR ARCH         qemu
143 #       -------         ----
144 #       arm             arm
145 #       armeb           armeb
146 #       i486            i386
147 #       i586            i386
148 #       i686            i386
149 #       x86_64          x86_64
150 #       m68k            m68k
151 #       microblaze      microblaze
152 #       mips            mips
153 #       mipsel          mipsel
154 #       mips64          mips64
155 #       mips64el        mips64el
156 #       powerpc         ppc
157 #       powerpc64       ppc64
158 #       powerpc64le     ppc64 (system) / ppc64le (usermode)
159 #       sh2a            not supported
160 #       sh4             sh4
161 #       sh4eb           sh4eb
162 #       sh4a            sh4
163 #       sh4aeb          sh4eb
164 #       sh64            not supported
165 #       sparc           sparc
166
167 HOST_QEMU_ARCH = $(ARCH)
168 ifeq ($(HOST_QEMU_ARCH),i486)
169 HOST_QEMU_ARCH = i386
170 endif
171 ifeq ($(HOST_QEMU_ARCH),i586)
172 HOST_QEMU_ARCH = i386
173 endif
174 ifeq ($(HOST_QEMU_ARCH),i686)
175 HOST_QEMU_ARCH = i386
176 endif
177 ifeq ($(HOST_QEMU_ARCH),powerpc)
178 HOST_QEMU_ARCH = ppc
179 endif
180 ifeq ($(HOST_QEMU_ARCH),powerpc64)
181 HOST_QEMU_ARCH = ppc64
182 endif
183 ifeq ($(HOST_QEMU_ARCH),powerpc64le)
184 HOST_QEMU_ARCH = ppc64le
185 HOST_QEMU_SYS_ARCH = ppc64
186 endif
187 ifeq ($(HOST_QEMU_ARCH),sh4a)
188 HOST_QEMU_ARCH = sh4
189 endif
190 ifeq ($(HOST_QEMU_ARCH),sh4aeb)
191 HOST_QEMU_ARCH = sh4eb
192 endif
193 HOST_QEMU_SYS_ARCH ?= $(HOST_QEMU_ARCH)
194
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
199 else
200 HOST_QEMU_OPTS += --disable-system
201 endif
202
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
206
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")
210 endif
211
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)
216
217 #
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.
226 #
227
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.")
231 endif
232 endif # BR_BUILDING
233
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
237
238 ifeq ($(BR2_PACKAGE_HOST_QEMU_VDE2),y)
239 HOST_QEMU_OPTS += --enable-vde
240 HOST_QEMU_DEPENDENCIES += host-vde2
241 endif
242
243 # Override CPP, as it expects to be able to call it like it'd
244 # call the compiler.
245 define HOST_QEMU_CONFIGURE_CMDS
246         cd $(@D); $(HOST_CONFIGURE_OPTS) CPP="$(HOSTCC) -E" \
247                 ./configure \
248                 --target-list="$(HOST_QEMU_TARGETS)" \
249                 --prefix="$(HOST_DIR)" \
250                 --interp-prefix=$(STAGING_DIR) \
251                 --cc="$(HOSTCC)" \
252                 --host-cc="$(HOSTCC)" \
253                 --python=$(HOST_DIR)/bin/python2 \
254                 --extra-cflags="$(HOST_CFLAGS)" \
255                 --extra-ldflags="$(HOST_LDFLAGS)" \
256                 $(HOST_QEMU_OPTS)
257 endef
258
259 define HOST_QEMU_BUILD_CMDS
260         $(HOST_MAKE_ENV) $(MAKE) -C $(@D)
261 endef
262
263 define HOST_QEMU_INSTALL_CMDS
264         $(HOST_MAKE_ENV) $(MAKE) -C $(@D) install
265 endef
266
267 $(eval $(host-generic-package))
268
269 # variable used by other packages
270 QEMU_USER = $(HOST_DIR)/bin/qemu-$(HOST_QEMU_ARCH)