uboot-tools: add patch to fix linking with libubootenv
[buildroot-gz.git] / package / qemu / qemu.mk
blob522910eabf685fa471bced619a170aa9686b6c86
1 ################################################################################
3 # qemu
5 ################################################################################
7 QEMU_VERSION = 2.5.1
8 QEMU_SOURCE = qemu-$(QEMU_VERSION).tar.bz2
9 QEMU_SITE = http://wiki.qemu.org/download
10 QEMU_LICENSE = GPLv2, LGPLv2.1, MIT, BSD-3c, BSD-2c, 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 #-------------------------------------------------------------
17 # Host-qemu
19 HOST_QEMU_DEPENDENCIES = host-pkgconf host-python host-zlib host-libglib2 host-pixman
21 # BR ARCH qemu
22 # ------- ----
23 # arm arm
24 # armeb armeb
25 # bfin not supported
26 # i486 i386
27 # i586 i386
28 # i686 i386
29 # x86_64 x86_64
30 # m68k m68k
31 # microblaze microblaze
32 # mips mips
33 # mipsel mipsel
34 # mips64 mips64
35 # mips64el mips64el
36 # powerpc ppc
37 # sh2a not supported
38 # sh4 sh4
39 # sh4eb sh4eb
40 # sh4a sh4
41 # sh4aeb sh4eb
42 # sh64 not supported
43 # sparc sparc
45 HOST_QEMU_ARCH = $(ARCH)
46 ifeq ($(HOST_QEMU_ARCH),i486)
47 HOST_QEMU_ARCH = i386
48 endif
49 ifeq ($(HOST_QEMU_ARCH),i586)
50 HOST_QEMU_ARCH = i386
51 endif
52 ifeq ($(HOST_QEMU_ARCH),i686)
53 HOST_QEMU_ARCH = i386
54 endif
55 ifeq ($(HOST_QEMU_ARCH),powerpc)
56 HOST_QEMU_ARCH = ppc
57 endif
58 ifeq ($(HOST_QEMU_ARCH),sh4a)
59 HOST_QEMU_ARCH = sh4
60 endif
61 ifeq ($(HOST_QEMU_ARCH),sh4aeb)
62 HOST_QEMU_ARCH = sh4eb
63 endif
64 HOST_QEMU_TARGETS = $(HOST_QEMU_ARCH)-linux-user
66 ifeq ($(BR2_PACKAGE_HOST_QEMU),y)
67 HOST_QEMU_HOST_SYSTEM_TYPE = $(shell uname -s)
68 ifneq ($(HOST_QEMU_HOST_SYSTEM_TYPE),Linux)
69 $(error "qemu-user can only be used on Linux hosts")
70 endif
72 # kernel version as major*256 + minor
73 HOST_QEMU_HOST_SYSTEM_VERSION = $(shell uname -r | awk -F. '{ print $$1 * 256 + $$2 }')
74 HOST_QEMU_TARGET_SYSTEM_VERSION = $(shell echo $(BR2_TOOLCHAIN_HEADERS_AT_LEAST) | awk -F. '{ print $$1 * 256 + $$2 }')
75 HOST_QEMU_COMPARE_VERSION = $(shell test $(HOST_QEMU_HOST_SYSTEM_VERSION) -ge $(HOST_QEMU_TARGET_SYSTEM_VERSION) && echo OK)
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.
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
92 endif
94 define HOST_QEMU_CONFIGURE_CMDS
95 cd $(@D); $(HOST_CONFIGURE_OPTS) ./configure \
96 --target-list="$(HOST_QEMU_TARGETS)" \
97 --prefix="$(HOST_DIR)/usr" \
98 --interp-prefix=$(STAGING_DIR) \
99 --cc="$(HOSTCC)" \
100 --host-cc="$(HOSTCC)" \
101 --python=$(HOST_DIR)/usr/bin/python2 \
102 --extra-cflags="$(HOST_CFLAGS)" \
103 --extra-ldflags="$(HOST_LDFLAGS)"
104 endef
106 define HOST_QEMU_BUILD_CMDS
107 $(HOST_MAKE_ENV) $(MAKE) -C $(@D)
108 endef
110 define HOST_QEMU_INSTALL_CMDS
111 $(HOST_MAKE_ENV) $(MAKE) -C $(@D) install
112 endef
114 $(eval $(host-generic-package))
116 # variable used by other packages
117 QEMU_USER = $(HOST_DIR)/usr/bin/qemu-$(HOST_QEMU_ARCH)
119 #-------------------------------------------------------------
120 # Target-qemu
122 QEMU_DEPENDENCIES = host-pkgconf host-python libglib2 zlib pixman
124 # Need the LIBS variable because librt and libm are
125 # not automatically pulled. :-(
126 QEMU_LIBS = -lrt -lm
128 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
135 # If we want to specify only a subset of targets, we must still enable all
136 # of them, so that QEMU properly builds its list of default targets, from
137 # which it then checks if the specified sub-set is valid. That's what we
138 # do in the first part of the if-clause.
139 # Otherwise, if we do not want to pass a sub-set of targets, we then need
140 # to either enable or disable -user and/or -system emulation appropriately.
141 # That's what we do in the else-clause.
142 ifneq ($(call qstrip,$(BR2_PACKAGE_QEMU_CUSTOM_TARGETS)),)
143 QEMU_OPTS += --enable-system --enable-linux-user
144 QEMU_OPTS += --target-list="$(call qstrip,$(BR2_PACKAGE_QEMU_CUSTOM_TARGETS))"
145 else
147 ifeq ($(BR2_PACKAGE_QEMU_SYSTEM),y)
148 QEMU_OPTS += --enable-system
149 else
150 QEMU_OPTS += --disable-system
151 endif
153 ifeq ($(BR2_PACKAGE_QEMU_LINUX_USER),y)
154 QEMU_OPTS += --enable-linux-user
155 else
156 QEMU_OPTS += --disable-linux-user
157 endif
159 endif
161 ifeq ($(BR2_PACKAGE_QEMU_SDL),y)
162 QEMU_OPTS += --enable-sdl
163 QEMU_DEPENDENCIES += sdl
164 QEMU_VARS += SDL_CONFIG=$(BR2_STAGING_DIR)/usr/bin/sdl-config
165 else
166 QEMU_OPTS += --disable-sdl
167 endif
169 ifeq ($(BR2_PACKAGE_QEMU_FDT),y)
170 QEMU_OPTS += --enable-fdt
171 QEMU_DEPENDENCIES += dtc
172 else
173 QEMU_OPTS += --disable-fdt
174 endif
176 define QEMU_CONFIGURE_CMDS
177 ( cd $(@D); \
178 LIBS='$(QEMU_LIBS)' \
179 $(TARGET_CONFIGURE_OPTS) \
180 $(TARGET_CONFIGURE_ARGS) \
181 $(QEMU_VARS) \
182 ./configure \
183 --prefix=/usr \
184 --cross-prefix=$(TARGET_CROSS) \
185 --with-system-pixman \
186 --audio-drv-list= \
187 --enable-kvm \
188 --enable-attr \
189 --enable-vhost-net \
190 --disable-bsd-user \
191 --disable-xen \
192 --disable-slirp \
193 --disable-vnc \
194 --disable-virtfs \
195 --disable-brlapi \
196 --disable-curses \
197 --disable-curl \
198 --disable-bluez \
199 --disable-uuid \
200 --disable-vde \
201 --disable-linux-aio \
202 --disable-cap-ng \
203 --disable-docs \
204 --disable-spice \
205 --disable-rbd \
206 --disable-libiscsi \
207 --disable-usb-redir \
208 --disable-strip \
209 --disable-seccomp \
210 --disable-sparse \
211 --disable-tools \
212 $(QEMU_OPTS) \
214 endef
216 define QEMU_BUILD_CMDS
217 $(TARGET_MAKE_ENV) $(MAKE) -C $(@D)
218 endef
220 define QEMU_INSTALL_TARGET_CMDS
221 $(TARGET_MAKE_ENV) $(MAKE) -C $(@D) $(QEMU_MAKE_ENV) DESTDIR=$(TARGET_DIR) install
222 endef
224 $(eval $(generic-package))