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
:=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
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_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
: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
))
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_SASL
250 bool
"QEMU VNC SASL auth support"
252 depends on QEMU_UI_VNC
255 bool
"QEMU SPICE ui support"
258 bool
"QEMU USB passthrough support"
262 bool
"Enable support for seccomp in QEMU"
263 default KERNEL_SECCOMP
265 Build QEMU with support for seccomp filters.
266 Select libseccomp which also pulls-in the needed kernel features.
271 PKG_CONFIG_DEPENDS
+= \
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 \
280 # QEMU configure script does not recognize these options
281 CONFIGURE_ARGS
:=$(filter-out \
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
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)" \
305 --enable-vhost-crypto \
306 --enable-vhost-kernel \
308 --enable-vhost-user \
309 --enable-vhost-user-blk-server \
310 --enable-vhost-vdpa \
312 # Image formats support
321 --disable-parallels \
323 # system/user-mode emulation
327 --disable-linux-user \
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 \
354 # Features for performance & no external dependency
356 --enable-coroutine-pool \
357 --enable-crypto-afalg \
358 --enable-live-block-migration \
359 --enable-membarrier \
360 --enable-replication \
364 # Review configure options not explicitly specified here
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"
373 --audio-drv-list
='' \
380 --disable-containers \
382 --disable-debug-info \
383 --disable-debug-mutex \
384 --disable-debug-tcg \
388 --with-git-submodules
=ignore \
389 --disable-glusterfs \
391 --disable-guest-agent-msi \
396 --$(if
$(CONFIG_QEMU_DEV_USB
),enable
,disable
)-libusb \
397 --disable-linux-aio \
398 --disable-linux-io-uring \
402 --disable-module-upgrades \
410 --disable-qom-cast-debug \
413 --disable-sanitizers \
414 --$(if
$(CONFIG_QEMU_SECCOMP
),enable
,disable
)-seccomp \
415 --disable-smartcard \
419 --disable-tcg-interpreter \
421 --disable-usb-redir \
425 --disable-xen-pci-passthrough \
426 --disable-xkbcommon \
432 --disable-vduse-blk-export \
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
)
437 TARGET_LDFLAGS
+= -Wl
,--as-needed
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 \
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
))) \