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
13 PKG_RELEASE
:=$(AUTORELEASE
)
14 PKG_SOURCE
:=$(PKG_NAME
)-$(PKG_VERSION
).
tar.xz
15 PKG_HASH
:=68e15d8e45ac56326e0b9a4afa8b49a3dfe8aba3488221d098c84698bca65b45
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
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_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
)
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_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_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
:=http
://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_JPEG
:libjpeg \
196 +QEMU_UI_VNC_PNG
:libpng \
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
))
204 define Package
/qemu-
$(1)/description
205 This package contains the QEMU target
$(1)
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
)
219 qemu-target-list
:= \
223 qemu-target-x86_64-softmmu-deps
:= \
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
234 $(foreach target
,$(qemu-target-list
), \
235 $(eval
$(call qemu-target
,$(target
))) \
238 define Package
/qemu-
$(firstword $(qemu-target-list
))/config
239 if
$(subst $(space
),||
,$(foreach target
,$(qemu-target-list
),PACKAGE_qemu-
$(target
)))
241 bool
"QEMU VNC support"
244 config QEMU_UI_VNC_JPEG
245 bool
"QEMU VNC jpeg tight encoding support"
247 depends on QEMU_UI_VNC
249 config QEMU_UI_VNC_PNG
250 bool
"QEMU VNC png tight encoding support"
252 depends on QEMU_UI_VNC
254 config QEMU_UI_VNC_SASL
255 bool
"QEMU VNC SASL auth support"
257 depends on QEMU_UI_VNC
260 bool
"QEMU SPICE ui support"
263 bool
"QEMU USB passthrough support"
267 bool
"Enable support for seccomp in QEMU"
268 default KERNEL_SECCOMP
270 Build QEMU with support for seccomp filters.
271 Select libseccomp which also pulls-in the needed kernel features.
276 PKG_CONFIG_DEPENDS
+= \
278 CONFIG_QEMU_UI_VNC_JPEG \
279 CONFIG_QEMU_UI_VNC_PNG \
280 CONFIG_QEMU_UI_VNC_SASL \
281 CONFIG_QEMU_UI_SPICE \
282 CONFIG_QEMU_DEV_USB \
283 CONFIG_QEMU_SECCOMP \
286 # QEMU configure script does not recognize these options
287 CONFIGURE_ARGS
:=$(filter-out \
298 # Tell build system of qemu to not add _FORTIFY_SOURCE options and let the base
299 # build system decide flavor of fortify_source to use
301 --cross-prefix
=$(TARGET_CROSS
) \
302 --host-cc
="$(HOSTCC)" \
303 --disable-fortify-source \
304 --disable-stack-protector \
305 --extra-cflags
="$(TARGET_CFLAGS) $(EXTRA_CFLAGS)" \
306 --extra-cxxflags
="$(TARGET_CXXFLAGS) $(EXTRA_CXXFLAGS)" \
307 --extra-ldflags
="$(TARGET_LDFLAGS) $(EXTRA_LDFLAGS)" \
311 --enable-vhost-crypto \
312 --enable-vhost-kernel \
314 --enable-vhost-scsi \
315 --enable-vhost-user \
316 --enable-vhost-user-fs \
317 --enable-vhost-user-blk-server \
318 --enable-vhost-vsock \
319 --enable-vhost-vdpa \
321 # Image formats support
330 --disable-parallels \
332 # system/user-mode emulation
336 --disable-linux-user \
338 --enable-slirp
=system \
354 --disable-sdl-image \
355 --$(if
$(CONFIG_QEMU_UI_SPICE
),enable
,disable
)-spice \
356 --disable-virglrenderer \
357 --$(if
$(CONFIG_QEMU_UI_VNC
),enable
,disable
)-vnc \
358 --$(if
$(CONFIG_QEMU_UI_VNC_JPEG
),enable
,disable
)-vnc-jpeg \
359 --$(if
$(CONFIG_QEMU_UI_VNC_PNG
),enable
,disable
)-vnc-png \
360 --$(if
$(CONFIG_QEMU_UI_VNC_SASL
),enable
,disable
)-vnc-sasl \
365 # Features for performance & no external dependency
367 --enable-coroutine-pool \
368 --enable-crypto-afalg \
369 --enable-live-block-migration \
370 --enable-membarrier \
371 --enable-replication \
375 # Review configure options not explicitly specified here
377 # openwrt_makefile=openwrt/packages/utils/qemu/Makefile
378 # qemu_configure=qemu/configure
379 # for arg in $(grep -E '^\s*--disable-[^)]+\)' "$qemu_configure" | cut -f1 -d')'); do
380 # grep -qE "(--enable|--disable)${arg#--disable}" "$openwrt_makefile" || echo "$arg"
384 --audio-drv-list
='' \
391 --disable-containers \
393 --disable-debug-info \
394 --disable-debug-mutex \
395 --disable-debug-tcg \
399 --with-git-submodules
=ignore \
400 --disable-glusterfs \
402 --disable-guest-agent-msi \
407 --$(if
$(CONFIG_QEMU_DEV_USB
),enable
,disable
)-libusb \
409 --disable-linux-aio \
410 --disable-linux-io-uring \
414 --disable-module-upgrades \
422 --disable-qom-cast-debug \
425 --disable-sanitizers \
426 --$(if
$(CONFIG_QEMU_SECCOMP
),enable
,disable
)-seccomp \
427 --disable-smartcard \
431 --disable-tcg-interpreter \
433 --disable-usb-redir \
437 --disable-xen-pci-passthrough \
438 --disable-xkbcommon \
446 CONFIGURE_ARGS
+= --target-list
='$(foreach target,$(qemu-target-list),$(if $(CONFIG_PACKAGE_qemu-$(target)),$(target)))'
447 CONFIGURE_ARGS
+= $(if
$(CONFIG_PACKAGE_qemu-ga
),--enable-guest-agent
)
449 TARGET_LDFLAGS
+= -Wl
,--as-needed
451 # ARCH is special in qemu's build system, e.g. ARCH mips64 will be translated
452 # there to mips and stored in config-host.mak
453 MAKE_FLAGS
:=$(filter-out \
457 $(eval
$(call BuildPackage
,virtio-console-helper
))
458 $(eval
$(call BuildPackage
,qemu-ga
))
459 $(eval
$(call BuildPackage
,qemu-bridge-helper
))
460 $(eval
$(call BuildPackage
,qemu-img
))
461 $(eval
$(call BuildPackage
,qemu-nbd
))
462 $(eval
$(call BuildPackage
,qemu-keymaps
))
463 $(foreach p
,$(QEMU_PACKAGES
), \
464 $(eval
$(call BuildPackage
,$(p
))) \