2 # Copyright (C) 2016 OpenWrt.org
3 # Copyright (C) 2016-2019 Yousong Zhou <yszhou4tech@gmail.com>
5 # This is free software, licensed under the GNU General Public License v2.
6 # See /LICENSE for more information.
9 include $(TOPDIR
)/rules.mk
14 PKG_SOURCE
:=$(PKG_NAME
)-$(PKG_VERSION
).
tar.xz
15 PKG_HASH
:=32708ac66c30d8c892633ea968c771c1c76d597d70ddead21a0d22ccf386da69
16 PKG_SOURCE_URL
:=https
://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
24 PKG_BUILD_FLAGS
:=no-mips16
26 PKG_BUILD_DEPENDS
+=spice-protocol
28 include $(INCLUDE_DIR
)/nls.mk
29 include $(INCLUDE_DIR
)/package.mk
31 QEMU_DEPS_IN_GUEST
:= @
(TARGET_x86_64||TARGET_armsr||TARGET_malta
)
32 QEMU_DEPS_IN_HOST
:= @
(TARGET_x86_64||TARGET_armsr_armv8||TARGET_sunxi
)
33 QEMU_DEPS_IN_HOST
+= +libstdcpp
34 QEMU_DEPS_IN_HOST
+= $(ICONV_DEPENDS
)
36 define Package
/virtio-console-helper
39 SUBMENU
:=Virtualization
40 TITLE
:=Helper script for vportNpn virtio-console devices
41 DEPENDS
:=$(QEMU_DEPS_IN_GUEST
)
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
50 define Package
/qemu-ga
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
)
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
68 PKG_CONFIG_DEPENDS
+= CONFIG_PACKAGE_qemu-ga
71 define Package
/qemu-bridge-helper
74 SUBMENU
:=Virtualization
75 TITLE
:=QEMU bridge helper
76 URL
:=http
://www.qemu.org
77 DEPENDS
:=+glib2
$(QEMU_DEPS_IN_HOST
)
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
88 define Package
/qemu-img
91 SUBMENU
:=Virtualization
92 TITLE
:=QEMU Image utility
93 URL
:=http
://www.qemu.org
94 DEPENDS
:=+glib2
+QEMU_ZSTD
:libzstd
$(QEMU_DEPS_IN_HOST
)
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
103 define Package
/qemu-nbd
106 SUBMENU
:=Virtualization
107 TITLE
:=QEMU Network Block Device Utility
108 URL
:=http
://www.qemu.org
109 DEPENDS
:=+glib2
+QEMU_ZSTD
:libzstd
$(QEMU_DEPS_IN_HOST
) +kmod-nbd
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
119 QEMU_PACKAGES
+= qemu-firmware-
$(1)
121 define Package
/qemu-firmware-
$(1)
124 SUBMENU
:=Virtualization
125 TITLE
:=$(qemu-firmware-
$(1)-title
)
126 URL
:=http
://www.qemu.org
127 DEPENDS
:=$(QEMU_DEPS_IN_HOST
)
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
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
))
140 qemu-firmware-seavgabios-title
:=QEMU build of SeaVGABIOS
141 qemu-firmware-seavgabios-files
:=vgabios-
*.bin
142 $(eval
$(call qemu-firmware
,seavgabios
))
144 qemu-firmware-pxe-title
:=QEMU build of iPXE PXE roms
145 qemu-firmware-pxe-files
:=pxe-
*.rom
146 $(eval
$(call qemu-firmware
,pxe
))
148 qemu-firmware-efi-title
:=QEMU build of iPXE EFI roms
149 qemu-firmware-efi-files
:=efi-
*.rom
150 $(eval
$(call qemu-firmware
,efi
))
152 define Package
/qemu-keymaps
155 SUBMENU
:=Virtualization
156 TITLE
:=QEMU reverse keymaps for use with
-k argument
157 URL
:=https
://www.qemu.org
158 DEPENDS
:=$(QEMU_DEPS_IN_HOST
)
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
167 # Naming rules used in qemu Makefile.target
169 $(if
$(filter %-softmmu
,$(1)), \
170 $(patsubst %-softmmu
,qemu-system-
%,$(1)), \
171 $(error unknown qemu target
$(1)) \
174 qemu-prog
= $(strip $(call qemu-prog_
,$(1)))
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.
181 # aarch64%-softmmu arm%-softmmu ppc%-softmmu microblaze%-softmmu
184 PKG_CONFIG_DEPENDS
+= CONFIG_PACKAGE_qemu-
$(1)
185 QEMU_PACKAGES
+= qemu-
$(1)
187 define Package
/qemu-
$(1)
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 \
202 $(if
$(filter %-softmmu
,$(1)),+libncurses
+libfdt
+libslirp
+libudev
+pixman
+qemu-firmware-efi
$(ICONV_DEPENDS
))
205 define Package
/qemu-
$(1)/description
206 This package contains the QEMU target
$(1)
209 define Package
/qemu-
$(1)/install
210 $(INSTALL_DIR
) $$(1)/usr
/bin
211 $(INSTALL_BIN
) $(PKG_INSTALL_DIR
)/usr
/bin
/$(call qemu-prog
,$(1)) $$(1)/usr
/bin
212 $(foreach f
,$(qemu-target-
$(1)-extra-files
),
213 $(INSTALL_DIR
) $$(1)/$(dir $(f
))
214 $(CP
) $(PKG_INSTALL_DIR
)/$(f
) $$(1)/$(f
)
220 qemu-target-list
:= \
225 qemu-target-x86_64-softmmu-deps
:= \
227 +qemu-firmware-seabios \
228 +qemu-firmware-seavgabios
229 qemu-target-x86_64-softmmu-extra-files
:= \
230 usr
/share
/qemu
/kvmvapic.bin \
231 usr
/share
/qemu
/linuxboot.bin \
232 usr
/share
/qemu
/linuxboot_dma.bin \
233 usr
/share
/qemu
/multiboot.bin \
234 usr
/share
/qemu
/pvh.bin
236 $(foreach target
,$(qemu-target-list
), \
237 $(eval
$(call qemu-target
,$(target
))) \
240 define Package
/qemu-
$(firstword $(qemu-target-list
))/config
241 if
$(subst $(space
),||
,$(foreach target
,$(qemu-target-list
),PACKAGE_qemu-
$(target
)))
243 bool
"QEMU VNC support"
246 config QEMU_UI_VNC_JPEG
247 bool
"QEMU VNC jpeg tight encoding support"
249 depends on QEMU_UI_VNC
251 config QEMU_UI_VNC_SASL
252 bool
"QEMU VNC SASL auth support"
254 depends on QEMU_UI_VNC
257 bool
"QEMU SPICE ui support"
260 bool
"QEMU USB passthrough support"
264 bool
"Enable support for seccomp in QEMU"
265 default KERNEL_SECCOMP
267 Build QEMU with support for seccomp filters.
268 Select libseccomp which also pulls-in the needed kernel features.
271 bool
"QEMU ZSTD compression support"
277 PKG_CONFIG_DEPENDS
+= \
279 CONFIG_QEMU_UI_VNC_JPEG \
280 CONFIG_QEMU_UI_VNC_SASL \
281 CONFIG_QEMU_UI_SPICE \
282 CONFIG_QEMU_DEV_USB \
283 CONFIG_QEMU_SECCOMP \
287 # QEMU configure script does not recognize these options
288 CONFIGURE_ARGS
:=$(filter-out \
299 # Tell build system of qemu to not add _FORTIFY_SOURCE options and let the base
300 # build system decide flavor of fortify_source to use
302 --cross-prefix
=$(TARGET_CROSS
) \
303 --host-cc
="$(HOSTCC)" \
304 --disable-fortify-source \
305 --disable-stack-protector \
306 --extra-cflags
="$(TARGET_CFLAGS) $(EXTRA_CFLAGS)" \
307 --extra-cxxflags
="$(TARGET_CXXFLAGS) $(EXTRA_CXXFLAGS)" \
308 --extra-ldflags
="$(TARGET_LDFLAGS) $(EXTRA_LDFLAGS)" \
312 --enable-vhost-crypto \
313 --enable-vhost-kernel \
315 --enable-vhost-user \
316 --enable-vhost-user-blk-server \
317 --enable-vhost-vdpa \
319 # Image formats support
328 --disable-parallels \
330 # system/user-mode emulation
334 --disable-linux-user \
350 --disable-sdl-image \
351 --$(if
$(CONFIG_QEMU_UI_SPICE
),enable
,disable
)-spice \
352 --disable-virglrenderer \
353 --$(if
$(CONFIG_QEMU_UI_VNC
),enable
,disable
)-vnc \
354 --$(if
$(CONFIG_QEMU_UI_VNC_JPEG
),enable
,disable
)-vnc-jpeg \
355 --$(if
$(CONFIG_QEMU_UI_VNC_SASL
),enable
,disable
)-vnc-sasl \
360 # Features for performance & no external dependency
362 --enable-coroutine-pool \
363 --enable-crypto-afalg \
364 --enable-live-block-migration \
365 --enable-membarrier \
366 --enable-replication \
370 # Review configure options not explicitly specified here
372 # openwrt_makefile=openwrt/packages/utils/qemu/Makefile
373 # qemu_configure=qemu/configure
374 # for arg in $(grep -E '^\s*--disable-[^)]+\)' "$qemu_configure" | cut -f1 -d')'); do
375 # grep -qE "(--enable|--disable)${arg#--disable}" "$openwrt_makefile" || echo "$arg"
379 --audio-drv-list
='' \
387 --disable-containers \
389 --disable-debug-info \
390 --disable-debug-mutex \
391 --disable-debug-tcg \
396 --disable-glusterfs \
398 --disable-guest-agent-msi \
403 --$(if
$(CONFIG_QEMU_DEV_USB
),enable
,disable
)-libusb \
404 --disable-libkeyutils \
405 --disable-linux-aio \
406 --disable-linux-io-uring \
410 --disable-module-upgrades \
418 --disable-qom-cast-debug \
421 --disable-rutabaga-gfx \
422 --disable-sanitizers \
423 --$(if
$(CONFIG_QEMU_SECCOMP
),enable
,disable
)-seccomp \
424 --disable-smartcard \
428 --disable-tcg-interpreter \
430 --disable-usb-redir \
434 --disable-xen-pci-passthrough \
435 --disable-xkbcommon \
436 --$(if
$(CONFIG_QEMU_ZSTD
),enable
,disable
)-zstd \
441 --disable-vduse-blk-export \
444 CONFIGURE_ARGS
+= --target-list
='$(foreach target,$(qemu-target-list),$(if $(CONFIG_PACKAGE_qemu-$(target)),$(target)))'
445 CONFIGURE_ARGS
+= $(if
$(CONFIG_PACKAGE_qemu-ga
),--enable-guest-agent
)
447 TARGET_LDFLAGS
+= -Wl
,--as-needed
449 # ARCH is special in qemu's build system, e.g. ARCH mips64 will be translated
450 # there to mips and stored in config-host.mak
451 MAKE_FLAGS
:=$(filter-out \
455 $(eval
$(call BuildPackage
,virtio-console-helper
))
456 $(eval
$(call BuildPackage
,qemu-ga
))
457 $(eval
$(call BuildPackage
,qemu-bridge-helper
))
458 $(eval
$(call BuildPackage
,qemu-img
))
459 $(eval
$(call BuildPackage
,qemu-nbd
))
460 $(eval
$(call BuildPackage
,qemu-keymaps
))
461 $(foreach p
,$(QEMU_PACKAGES
), \
462 $(eval
$(call BuildPackage
,$(p
))) \