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
:=656e60218689bdeec69903087fd7582d5d3e72238d02f4481d8dc6d79fd909c6
16 PKG_SOURCE_URL
:=http
://download.qemu.org
/
18 PKG_LICENSE_FILES
:=LICENSE tcg
/LICENSE
19 PKG_MAINTAINER
:=Yousong Zhou
<yszhou4tech@gmail.com
>
20 PKG_CPE_ID
:=cpe
:/a
:qemu
:qemu
26 include $(INCLUDE_DIR
)/uclibc
++.mk
27 include $(INCLUDE_DIR
)/nls.mk
28 include $(INCLUDE_DIR
)/package.mk
31 QEMU_DEPS_IN_GUEST
:= @
(TARGET_x86_64||TARGET_armvirt||TARGET_arm64||TARGET_malta
)
32 QEMU_DEPS_IN_HOST
:= @
(TARGET_x86_64||TARGET_sunxi
)
34 define Package
/virtio-console-helper
37 SUBMENU
:=Virtualization
38 TITLE
:=Helper script for vportNpn virtio-console devices
39 DEPENDS
:=$(QEMU_DEPS_IN_GUEST
)
42 define Package
/virtio-console-helper
/install
43 $(INSTALL_DIR
) $(1)/etc
/hotplug.d
/virtio-ports
44 $(INSTALL_BIN
) .
/files
/00-virtio-ports.hotplug
$(1)/etc
/hotplug.d
/virtio-ports
/00-virtio-ports
48 define Package
/qemu-ga
51 SUBMENU
:=Virtualization
52 TITLE
:=QEMU Guest Agent
53 URL
:=http
://www.qemu.org
54 DEPENDS
:= +glib2
+virtio-console-helper
$(CXX_DEPENDS
) $(QEMU_DEPS_IN_GUEST
)
57 define Package
/qemu-ga
/install
58 $(INSTALL_DIR
) $(1)/usr
/bin
59 $(INSTALL_BIN
) $(PKG_INSTALL_DIR
)/usr
/bin
/qemu-ga
$(1)/usr
/bin
60 $(INSTALL_DIR
) $(1)/etc
/init.d
61 $(INSTALL_BIN
) .
/files
/qemu-ga.init
$(1)/etc
/init.d
/qemu-ga
62 $(INSTALL_DIR
) $(1)/etc
/hotplug.d
/virtio-ports
63 $(INSTALL_BIN
) .
/files
/10-qemu-ga.hotplug
$(1)/etc
/hotplug.d
/virtio-ports
/10-qemu-ga
66 PKG_CONFIG_DEPENDS
+= CONFIG_PACKAGE_qemu-ga
69 define Package
/qemu-bridge-helper
72 SUBMENU
:=Virtualization
73 TITLE
:=QEMU bridge helper
74 URL
:=http
://www.qemu.org
75 DEPENDS
:=+glib2
$(CXX_DEPENDS
) $(QEMU_DEPS_IN_HOST
)
78 define Package
/qemu-bridge-helper
/install
79 $(INSTALL_DIR
) $(1)/usr
/lib
/
80 $(INSTALL_BIN
) $(PKG_INSTALL_DIR
)/usr
/lib
/qemu-bridge-helper
$(1)/usr
/lib
81 $(INSTALL_DIR
) $(1)/etc
/qemu
82 $(INSTALL_DATA
) .
/files
/bridge.conf
$(1)/etc
/qemu
86 define Package
/qemu-img
89 SUBMENU
:=Virtualization
90 TITLE
:=QEMU Image utility
91 URL
:=http
://www.qemu.org
92 DEPENDS
:=+glib2
$(QEMU_DEPS_IN_HOST
)
95 define Package
/qemu-img
/install
96 $(INSTALL_DIR
) $(1)/usr
/bin
/
97 $(INSTALL_BIN
) $(PKG_BUILD_DIR
)/qemu-img
$(1)/usr
/bin
/qemu-img
101 define Package
/qemu-nbd
104 SUBMENU
:=Virtualization
105 TITLE
:=QEMU Network Block Device Utility
106 URL
:=http
://www.qemu.org
107 DEPENDS
:=+glib2
$(QEMU_DEPS_IN_HOST
) +kmod-nbd
110 define Package
/qemu-nbd
/install
111 $(INSTALL_DIR
) $(1)/usr
/sbin
/
112 $(INSTALL_BIN
) $(PKG_BUILD_DIR
)/qemu-nbd
$(1)/usr
/sbin
/qemu-nbd
117 QEMU_PACKAGES
+= qemu-firmware-
$(1)
119 define Package
/qemu-firmware-
$(1)
122 SUBMENU
:=Virtualization
123 TITLE
:=$(qemu-firmware-
$(1)-title
)
124 URL
:=http
://www.qemu.org
125 DEPENDS
:=$(QEMU_DEPS_IN_HOST
)
128 define Package
/qemu-firmware-
$(1)/install
129 $$(INSTALL_DIR
) $$(1)/usr
/share
/qemu
130 $$(CP
) $(foreach f
,$(qemu-firmware-
$(1)-files
),$$(PKG_INSTALL_DIR
)/usr
/share
/qemu
/$(f
)) $$(1)/usr
/share
/qemu
134 qemu-firmware-seabios-title
:=QEMU build of SeaBIOS for x86 guest
135 qemu-firmware-seabios-files
:=bios.bin bios-256k.bin
136 $(eval
$(call qemu-firmware
,seabios
))
138 qemu-firmware-seavgabios-title
:=QEMU build of SeaVGABIOS
139 qemu-firmware-seavgabios-files
:=vgabios-
*.bin
140 $(eval
$(call qemu-firmware
,seavgabios
))
142 qemu-firmware-pxe-title
:=QEMU build of iPXE PXE roms
143 qemu-firmware-pxe-files
:=pxe-
*.rom
144 $(eval
$(call qemu-firmware
,pxe
))
146 qemu-firmware-efi-title
:=QEMU build of iPXE EFI roms
147 qemu-firmware-efi-files
:=efi-
*.rom
148 $(eval
$(call qemu-firmware
,efi
))
151 # Naming rules used in qemu Makefile.target
153 $(if
$(filter %-softmmu
,$(1)), \
154 $(patsubst %-softmmu
,qemu-system-
%,$(1)), \
155 $(error unknown qemu target
$(1)) \
158 qemu-prog
= $(strip $(call qemu-prog_
,$(1)))
160 # Why libfdt was enabled for all softmmu targets: according to qemu's
161 # configure script, libfdt is only strictly required for the following targets
162 # and is optional for others. But libfdt support will be built into other
163 # targets when any single target enabled it.
165 # aarch64%-softmmu arm%-softmmu ppc%-softmmu microblaze%-softmmu
168 PKG_CONFIG_DEPENDS
+= CONFIG_PACKAGE_qemu-
$(1)
169 QEMU_PACKAGES
+= qemu-
$(1)
171 define Package
/qemu-
$(1)
174 SUBMENU
:=Virtualization
175 TITLE
:=QEMU target
$(1)
176 URL
:=http
://www.qemu.org
177 DEPENDS
:= +glib2
+libpthread
+zlib
$(CXX_DEPENDS
) $(QEMU_DEPS_IN_HOST
) $(qemu-target-
$(1)-deps
) \
178 $(if
$(filter %-softmmu
,$(1)),+libncurses
+libfdt
+pixman
+qemu-firmware-efi
$(ICONV_DEPENDS
))
181 define Package
/qemu-
$(1)/description
182 This package contains the QEMU target
$(1)
185 define Package
/qemu-
$(1)/install
186 $(INSTALL_DIR
) $$(1)/usr
/bin
187 $(INSTALL_BIN
) $(PKG_INSTALL_DIR
)/usr
/bin
/$(call qemu-prog
,$(1)) $$(1)/usr
/bin
188 $(foreach f
,$(qemu-target-
$(1)-extra-files
),
189 $(INSTALL_DIR
) $$(1)/$(dir $(f
))
190 $(CP
) $(PKG_INSTALL_DIR
)/$(f
) $$(1)/$(f
)
196 qemu-target-list
:= \
200 qemu-target-x86_64-softmmu-deps
:= \
202 +qemu-firmware-seabios \
203 +qemu-firmware-seavgabios
204 qemu-target-x86_64-softmmu-extra-files
:= \
205 usr
/share
/qemu
/kvmvapic.bin \
206 usr
/share
/qemu
/linuxboot.bin \
207 usr
/share
/qemu
/linuxboot_dma.bin \
208 usr
/share
/qemu
/multiboot.bin \
209 usr
/share
/qemu
/pvh.bin
211 $(foreach target
,$(qemu-target-list
), \
212 $(eval
$(call qemu-target
,$(target
))) \
216 # QEMU configure script does not recognize these options
217 CONFIGURE_ARGS
:=$(filter-out \
227 # Tell build system of qemu to not add _FORTIFY_SOURCE options and let the base
228 # build system decide flavor of fortify_source to use
230 --cross-prefix
=$(TARGET_CROSS
) \
231 --host-cc
="$(HOSTCC)" \
232 --disable-fortify-source \
233 --disable-stack-protector \
234 --extra-cflags
="$(EXTRA_CFLAGS)" \
235 --extra-cxxflags
="$(EXTRA_CXXFLAGS)" \
236 --extra-ldflags
="$(EXTRA_LDFLAGS)" \
240 --enable-vhost-crypto \
241 --enable-vhost-kernel \
243 --enable-vhost-scsi \
244 --enable-vhost-user \
245 --enable-vhost-vsock \
247 # Image formats support
256 --disable-parallels \
258 # system/user-mode emulation
262 --disable-linux-user \
279 --disable-sdl-image \
281 --disable-virglrenderer \
290 # Features for performance & no external dependency
292 --enable-coroutine-pool \
293 --enable-crypto-afalg \
294 --enable-live-block-migration \
295 --enable-membarrier \
296 --enable-replication \
298 # Review configure options not explicitly specified here
300 # openwrt_makefile=openwrt/packages/utils/qemu/Makefile
301 # qemu_configure=qemu/configure
302 # for arg in $(grep -E '^\s*--disable-[^)]+\)' "$qemu_configure" | cut -f1 -d')'); do
303 # grep -qE "(--enable|--disable)${arg#--disable}" "$openwrt_makefile" || echo "$arg"
307 --audio-drv-list
='' \
316 --disable-debug-info \
317 --disable-debug-mutex \
318 --disable-debug-tcg \
321 --disable-git-update \
322 --disable-glusterfs \
324 --disable-guest-agent-msi \
333 --disable-linux-aio \
343 --disable-qom-cast-debug \
346 --disable-sanitizers \
349 --disable-smartcard \
353 --disable-tcg-interpreter \
357 --disable-usb-redir \
362 --disable-xen-pci-passthrough \
365 CONFIGURE_ARGS
+= --target-list
='$(foreach target,$(qemu-target-list),$(if $(CONFIG_PACKAGE_qemu-$(target)),$(target)))'
366 CONFIGURE_ARGS
+= $(if
$(CONFIG_PACKAGE_qemu-ga
),--enable-guest-agent
)
368 TARGET_LDFLAGS
+= -Wl
,--as-needed
370 # ARCH is special in qemu's build system, e.g. ARCH mips64 will be translated
371 # there to mips and stored in config-host.mak
372 MAKE_FLAGS
:=$(filter-out \
376 QEMU_MAKE_TARGETS
:= \
377 $(if
$(CONFIG_PACKAGE_qemu-ga
),qemu-ga
) \
378 $(if
$(CONFIG_PACKAGE_qemu-bridge-helper
),qemu-bridge-helper
) \
379 $(if
$(CONFIG_PACKAGE_qemu-img
),qemu-img
) \
380 $(if
$(CONFIG_PACKAGE_qemu-nbd
),qemu-nbd
) \
381 $(foreach target
,$(qemu-target-list
),$(if
$(CONFIG_PACKAGE_qemu-
$(target
)),$(target
)/all)) \
384 $(if
$(strip $(QEMU_MAKE_TARGETS
)),$(call Build
/Compile
/Default
,$(QEMU_MAKE_TARGETS
)))
387 $(eval
$(call BuildPackage
,virtio-console-helper
))
388 $(eval
$(call BuildPackage
,qemu-ga
))
389 $(eval
$(call BuildPackage
,qemu-bridge-helper
))
390 $(eval
$(call BuildPackage
,qemu-img
))
391 $(eval
$(call BuildPackage
,qemu-nbd
))
392 $(foreach p
,$(QEMU_PACKAGES
), \
393 $(eval
$(call BuildPackage
,$(p
))) \