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