treewide: refactor to use PKG_BUILD_FLAGS:=no-mips16
[feed/packages.git] / utils / qemu / Makefile
1 #
2 # Copyright (C) 2016 OpenWrt.org
3 # Copyright (C) 2016-2019 Yousong Zhou <yszhou4tech@gmail.com>
4 #
5 # This is free software, licensed under the GNU General Public License v2.
6 # See /LICENSE for more information.
7 #
8
9 include $(TOPDIR)/rules.mk
10
11 PKG_NAME:=qemu
12 PKG_VERSION:=7.2.0
13 PKG_RELEASE:=1
14 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
15 PKG_HASH:=5b49ce2687744dad494ae90a898c52204a3406e84d072482a1e1be854eeb2157
16 PKG_SOURCE_URL:=http://download.qemu.org/
17 PKG_LICENSE:=GPL-2.0-only
18 PKG_LICENSE_FILES:=LICENSE tcg/LICENSE
19 PKG_MAINTAINER:=Yousong Zhou <yszhou4tech@gmail.com>
20 PKG_CPE_ID:=cpe:/a:qemu:qemu
21
22 PKG_BUILD_PARALLEL:=1
23 PKG_INSTALL:=1
24 PKG_BUILD_FLAGS:=no-mips16
25
26 PKG_BUILD_DEPENDS+=spice-protocol
27
28 include $(INCLUDE_DIR)/nls.mk
29 include $(INCLUDE_DIR)/package.mk
30
31 QEMU_DEPS_IN_GUEST := @(TARGET_x86_64||TARGET_armvirt||TARGET_malta)
32 QEMU_DEPS_IN_HOST := @(TARGET_x86_64||TARGET_sunxi)
33 QEMU_DEPS_IN_HOST += +libstdcpp
34 QEMU_DEPS_IN_HOST += $(ICONV_DEPENDS)
35
36 define Package/virtio-console-helper
37 SECTION:=utils
38 CATEGORY:=Utilities
39 SUBMENU:=Virtualization
40 TITLE:=Helper script for vportNpn virtio-console devices
41 DEPENDS:=$(QEMU_DEPS_IN_GUEST)
42 endef
43
44 define Package/virtio-console-helper/install
45 $(INSTALL_DIR) $(1)/etc/hotplug.d/virtio-ports
46 $(INSTALL_BIN) ./files/00-virtio-ports.hotplug $(1)/etc/hotplug.d/virtio-ports/00-virtio-ports
47 endef
48
49
50 define Package/qemu-ga
51 SECTION:=utils
52 CATEGORY:=Utilities
53 SUBMENU:=Virtualization
54 TITLE:=QEMU Guest Agent
55 URL:=http://www.qemu.org
56 DEPENDS:= +glib2 +virtio-console-helper +libstdcpp +libudev $(QEMU_DEPS_IN_GUEST)
57 endef
58
59 define Package/qemu-ga/install
60 $(INSTALL_DIR) $(1)/usr/bin
61 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/qemu-ga $(1)/usr/bin
62 $(INSTALL_DIR) $(1)/etc/init.d
63 $(INSTALL_BIN) ./files/qemu-ga.init $(1)/etc/init.d/qemu-ga
64 $(INSTALL_DIR) $(1)/etc/hotplug.d/virtio-ports
65 $(INSTALL_BIN) ./files/10-qemu-ga.hotplug $(1)/etc/hotplug.d/virtio-ports/10-qemu-ga
66 endef
67
68 PKG_CONFIG_DEPENDS += CONFIG_PACKAGE_qemu-ga
69
70
71 define Package/qemu-bridge-helper
72 SECTION:=utils
73 CATEGORY:=Utilities
74 SUBMENU:=Virtualization
75 TITLE:=QEMU bridge helper
76 URL:=http://www.qemu.org
77 DEPENDS:=+glib2 $(QEMU_DEPS_IN_HOST)
78 endef
79
80 define Package/qemu-bridge-helper/install
81 $(INSTALL_DIR) $(1)/usr/lib/
82 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/qemu-bridge-helper $(1)/usr/lib
83 $(INSTALL_DIR) $(1)/etc/qemu
84 $(INSTALL_DATA) ./files/bridge.conf $(1)/etc/qemu
85 endef
86
87
88 define Package/qemu-img
89 SECTION:=utils
90 CATEGORY:=Utilities
91 SUBMENU:=Virtualization
92 TITLE:=QEMU Image utility
93 URL:=http://www.qemu.org
94 DEPENDS:=+glib2 $(QEMU_DEPS_IN_HOST)
95 endef
96
97 define Package/qemu-img/install
98 $(INSTALL_DIR) $(1)/usr/bin/
99 $(INSTALL_BIN) $(PKG_BUILD_DIR)/build/qemu-img $(1)/usr/bin/qemu-img
100 endef
101
102
103 define Package/qemu-nbd
104 SECTION:=utils
105 CATEGORY:=Utilities
106 SUBMENU:=Virtualization
107 TITLE:=QEMU Network Block Device Utility
108 URL:=http://www.qemu.org
109 DEPENDS:=+glib2 $(QEMU_DEPS_IN_HOST) +kmod-nbd
110 endef
111
112 define Package/qemu-nbd/install
113 $(INSTALL_DIR) $(1)/usr/sbin/
114 $(INSTALL_BIN) $(PKG_BUILD_DIR)/build/qemu-nbd $(1)/usr/sbin/qemu-nbd
115 endef
116
117
118 define qemu-firmware
119 QEMU_PACKAGES += qemu-firmware-$(1)
120
121 define Package/qemu-firmware-$(1)
122 SECTION:=utils
123 CATEGORY:=Utilities
124 SUBMENU:=Virtualization
125 TITLE:=$(qemu-firmware-$(1)-title)
126 URL:=http://www.qemu.org
127 DEPENDS:=$(QEMU_DEPS_IN_HOST)
128 endef
129
130 define Package/qemu-firmware-$(1)/install
131 $$(INSTALL_DIR) $$(1)/usr/share/qemu
132 $$(CP) $(foreach f,$(qemu-firmware-$(1)-files),$$(PKG_INSTALL_DIR)/usr/share/qemu/$(f)) $$(1)/usr/share/qemu
133 endef
134 endef
135
136 qemu-firmware-seabios-title:=QEMU build of SeaBIOS for x86 guest
137 qemu-firmware-seabios-files:=bios.bin bios-256k.bin
138 $(eval $(call qemu-firmware,seabios))
139
140 qemu-firmware-seavgabios-title:=QEMU build of SeaVGABIOS
141 qemu-firmware-seavgabios-files:=vgabios-*.bin
142 $(eval $(call qemu-firmware,seavgabios))
143
144 qemu-firmware-pxe-title:=QEMU build of iPXE PXE roms
145 qemu-firmware-pxe-files:=pxe-*.rom
146 $(eval $(call qemu-firmware,pxe))
147
148 qemu-firmware-efi-title:=QEMU build of iPXE EFI roms
149 qemu-firmware-efi-files:=efi-*.rom
150 $(eval $(call qemu-firmware,efi))
151
152 define Package/qemu-keymaps
153 SECTION:=utils
154 CATEGORY:=Utilities
155 SUBMENU:=Virtualization
156 TITLE:=QEMU reverse keymaps for use with -k argument
157 URL:=http://www.qemu.org
158 DEPENDS:=$(QEMU_DEPS_IN_HOST)
159 endef
160
161 define Package/qemu-keymaps/install
162 $(INSTALL_DIR) $(1)/usr/share/qemu/keymaps
163 $(CP) $(PKG_INSTALL_DIR)/usr/share/qemu/keymaps/* $(1)/usr/share/qemu/keymaps
164 endef
165
166
167 # Naming rules used in qemu Makefile.target
168 define qemu-prog_
169 $(if $(filter %-softmmu,$(1)), \
170 $(patsubst %-softmmu,qemu-system-%,$(1)), \
171 $(error unknown qemu target $(1)) \
172 )
173 endef
174 qemu-prog = $(strip $(call qemu-prog_,$(1)))
175
176 # Why libfdt was enabled for all softmmu targets: according to qemu's
177 # configure script, libfdt is only strictly required for the following targets
178 # and is optional for others. But libfdt support will be built into other
179 # targets when any single target enabled it.
180 #
181 # aarch64%-softmmu arm%-softmmu ppc%-softmmu microblaze%-softmmu
182 #
183 define qemu-target
184 PKG_CONFIG_DEPENDS += CONFIG_PACKAGE_qemu-$(1)
185 QEMU_PACKAGES += qemu-$(1)
186
187 define Package/qemu-$(1)
188 SECTION:=utils
189 CATEGORY:=Utilities
190 SUBMENU:=Virtualization
191 TITLE:=QEMU target $(1)
192 URL:=http://www.qemu.org
193 DEPENDS:= +glib2 +libpthread +zlib +libbpf $(QEMU_DEPS_IN_HOST) $(qemu-target-$(1)-deps) \
194 +QEMU_UI_VNC:qemu-keymaps \
195 +QEMU_UI_VNC:libpng \
196 +QEMU_UI_VNC_JPEG:libjpeg \
197 +QEMU_UI_VNC_SASL:libsasl2 \
198 +QEMU_UI_SPICE:libspice-server \
199 +QEMU_DEV_USB:libusb-1.0 \
200 +QEMU_SECCOMP:libseccomp \
201 $(if $(filter %-softmmu,$(1)),+libncurses +libfdt +libslirp +libudev +pixman +qemu-firmware-efi $(ICONV_DEPENDS))
202 endef
203
204 define Package/qemu-$(1)/description
205 This package contains the QEMU target $(1)
206 endef
207
208 define Package/qemu-$(1)/install
209 $(INSTALL_DIR) $$(1)/usr/bin
210 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/$(call qemu-prog,$(1)) $$(1)/usr/bin
211 $(foreach f,$(qemu-target-$(1)-extra-files),
212 $(INSTALL_DIR) $$(1)/$(dir $(f))
213 $(CP) $(PKG_INSTALL_DIR)/$(f) $$(1)/$(f)
214 )
215 endef
216
217 endef
218
219 qemu-target-list := \
220 x86_64-softmmu \
221 arm-softmmu \
222
223 qemu-target-x86_64-softmmu-deps:= \
224 +qemu-firmware-pxe \
225 +qemu-firmware-seabios \
226 +qemu-firmware-seavgabios
227 qemu-target-x86_64-softmmu-extra-files:= \
228 usr/share/qemu/kvmvapic.bin \
229 usr/share/qemu/linuxboot.bin \
230 usr/share/qemu/linuxboot_dma.bin \
231 usr/share/qemu/multiboot.bin \
232 usr/share/qemu/pvh.bin
233
234 $(foreach target,$(qemu-target-list), \
235 $(eval $(call qemu-target,$(target))) \
236 )
237
238 define Package/qemu-$(firstword $(qemu-target-list))/config
239 if $(subst $(space),||,$(foreach target,$(qemu-target-list),PACKAGE_qemu-$(target)))
240 config QEMU_UI_VNC
241 bool "QEMU VNC support"
242 default y
243
244 config QEMU_UI_VNC_JPEG
245 bool "QEMU VNC jpeg tight encoding support"
246 default n
247 depends on QEMU_UI_VNC
248
249 config QEMU_UI_VNC_SASL
250 bool "QEMU VNC SASL auth support"
251 default n
252 depends on QEMU_UI_VNC
253
254 config QEMU_UI_SPICE
255 bool "QEMU SPICE ui support"
256
257 config QEMU_DEV_USB
258 bool "QEMU USB passthrough support"
259 default y
260
261 config QEMU_SECCOMP
262 bool "Enable support for seccomp in QEMU"
263 default KERNEL_SECCOMP
264 help
265 Build QEMU with support for seccomp filters.
266 Select libseccomp which also pulls-in the needed kernel features.
267
268 endif
269 endef
270
271 PKG_CONFIG_DEPENDS += \
272 CONFIG_QEMU_UI_VNC \
273 CONFIG_QEMU_UI_VNC_JPEG \
274 CONFIG_QEMU_UI_VNC_SASL \
275 CONFIG_QEMU_UI_SPICE \
276 CONFIG_QEMU_DEV_USB \
277 CONFIG_QEMU_SECCOMP \
278
279
280 # QEMU configure script does not recognize these options
281 CONFIGURE_ARGS:=$(filter-out \
282 --target=% \
283 --host=% \
284 --build=% \
285 --program-prefix=% \
286 --program-suffix=% \
287 --exec-prefix=% \
288 $(DISABLE_NLS) \
289 $(DISABLE_IPV6) \
290 , $(CONFIGURE_ARGS))
291
292 # Tell build system of qemu to not add _FORTIFY_SOURCE options and let the base
293 # build system decide flavor of fortify_source to use
294 CONFIGURE_ARGS += \
295 --cross-prefix=$(TARGET_CROSS) \
296 --host-cc="$(HOSTCC)" \
297 --disable-fortify-source \
298 --disable-stack-protector \
299 --extra-cflags="$(TARGET_CFLAGS) $(EXTRA_CFLAGS)" \
300 --extra-cxxflags="$(TARGET_CXXFLAGS) $(EXTRA_CXXFLAGS)" \
301 --extra-ldflags="$(TARGET_LDFLAGS) $(EXTRA_LDFLAGS)" \
302
303 # VHost features
304 CONFIGURE_ARGS += \
305 --enable-vhost-crypto \
306 --enable-vhost-kernel \
307 --enable-vhost-net \
308 --enable-vhost-user \
309 --enable-vhost-user-blk-server \
310 --enable-vhost-vdpa \
311
312 # Image formats support
313 CONFIGURE_ARGS += \
314 --disable-bochs \
315 --disable-cloop \
316 --disable-dmg \
317 --disable-qcow1 \
318 --disable-vdi \
319 --disable-vvfat \
320 --disable-qed \
321 --disable-parallels \
322
323 # system/user-mode emulation
324 CONFIGURE_ARGS += \
325 --disable-user \
326 --disable-bsd-user \
327 --disable-linux-user \
328 --enable-system \
329
330 # accel
331 CONFIGURE_ARGS += \
332 --disable-hax \
333 --disable-hvf \
334 --disable-whpx \
335 --disable-xen \
336 --enable-kvm \
337 --enable-tcg \
338
339 # UI
340 CONFIGURE_ARGS += \
341 --disable-cocoa \
342 --disable-gtk \
343 --disable-sdl \
344 --disable-sdl-image \
345 --$(if $(CONFIG_QEMU_UI_SPICE),enable,disable)-spice \
346 --disable-virglrenderer \
347 --$(if $(CONFIG_QEMU_UI_VNC),enable,disable)-vnc \
348 --$(if $(CONFIG_QEMU_UI_VNC_JPEG),enable,disable)-vnc-jpeg \
349 --$(if $(CONFIG_QEMU_UI_VNC_SASL),enable,disable)-vnc-sasl \
350 --disable-vte \
351 --enable-curses \
352 --enable-iconv \
353
354 # Features for performance & no external dependency
355 CONFIGURE_ARGS += \
356 --enable-coroutine-pool \
357 --enable-crypto-afalg \
358 --enable-live-block-migration \
359 --enable-membarrier \
360 --enable-replication \
361 --enable-lto \
362 --enable-tools \
363
364 # Review configure options not explicitly specified here
365 #
366 # openwrt_makefile=openwrt/packages/utils/qemu/Makefile
367 # qemu_configure=qemu/configure
368 # for arg in $(grep -E '^\s*--disable-[^)]+\)' "$qemu_configure" | cut -f1 -d')'); do
369 # grep -qE "(--enable|--disable)${arg#--disable}" "$openwrt_makefile" || echo "$arg"
370 # done
371 #
372 CONFIGURE_ARGS += \
373 --audio-drv-list='' \
374 --disable-attr \
375 --disable-auth-pam \
376 --disable-brlapi \
377 --disable-bzip2 \
378 --disable-cap-ng \
379 --disable-capstone \
380 --disable-containers \
381 --disable-curl \
382 --disable-debug-info \
383 --disable-debug-mutex \
384 --disable-debug-tcg \
385 --disable-docs \
386 --disable-fuse \
387 --disable-gcrypt \
388 --with-git-submodules=ignore \
389 --disable-glusterfs \
390 --disable-gnutls \
391 --disable-guest-agent-msi \
392 --disable-libiscsi \
393 --disable-libnfs \
394 --disable-libpmem \
395 --disable-libssh \
396 --$(if $(CONFIG_QEMU_DEV_USB),enable,disable)-libusb \
397 --disable-linux-aio \
398 --disable-linux-io-uring \
399 --disable-lzfse \
400 --disable-lzo \
401 --disable-modules \
402 --disable-module-upgrades \
403 --disable-mpath \
404 --disable-netmap \
405 --disable-nettle \
406 --disable-numa \
407 --disable-opengl \
408 --disable-plugins \
409 --disable-pvrdma \
410 --disable-qom-cast-debug \
411 --disable-rbd \
412 --disable-rdma \
413 --disable-sanitizers \
414 --$(if $(CONFIG_QEMU_SECCOMP),enable,disable)-seccomp \
415 --disable-smartcard \
416 --disable-snappy \
417 --disable-sparse \
418 --disable-strip \
419 --disable-tcg-interpreter \
420 --disable-tpm \
421 --disable-usb-redir \
422 --disable-vde \
423 --disable-virtfs \
424 --disable-werror \
425 --disable-xen-pci-passthrough \
426 --disable-xkbcommon \
427 --disable-zstd \
428 --disable-selinux \
429 --disable-oss \
430 --disable-alsa \
431 --disable-pa \
432 --disable-vduse-blk-export \
433
434 CONFIGURE_ARGS += --target-list='$(foreach target,$(qemu-target-list),$(if $(CONFIG_PACKAGE_qemu-$(target)),$(target)))'
435 CONFIGURE_ARGS += $(if $(CONFIG_PACKAGE_qemu-ga),--enable-guest-agent)
436
437 TARGET_LDFLAGS += -Wl,--as-needed
438 MAKE_VARS += V=1
439 # ARCH is special in qemu's build system, e.g. ARCH mips64 will be translated
440 # there to mips and stored in config-host.mak
441 MAKE_FLAGS:=$(filter-out \
442 ARCH=% \
443 ,$(MAKE_FLAGS))
444
445 $(eval $(call BuildPackage,virtio-console-helper))
446 $(eval $(call BuildPackage,qemu-ga))
447 $(eval $(call BuildPackage,qemu-bridge-helper))
448 $(eval $(call BuildPackage,qemu-img))
449 $(eval $(call BuildPackage,qemu-nbd))
450 $(eval $(call BuildPackage,qemu-keymaps))
451 $(foreach p,$(QEMU_PACKAGES), \
452 $(eval $(call BuildPackage,$(p))) \
453 )