treewide: add PKG_CPE_ID for better cvescanner coverage
[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:=4.1.0
13 PKG_RELEASE:=1
14 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
15 PKG_HASH:=656e60218689bdeec69903087fd7582d5d3e72238d02f4481d8dc6d79fd909c6
16 PKG_SOURCE_URL:=http://download.qemu.org/
17 PKG_LICENSE:=GPL-2.0
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_USE_MIPS16:=0
25
26 include $(INCLUDE_DIR)/uclibc++.mk
27 include $(INCLUDE_DIR)/nls.mk
28 include $(INCLUDE_DIR)/package.mk
29
30
31 QEMU_DEPS_IN_GUEST := @(TARGET_x86_64||TARGET_armvirt||TARGET_arm64||TARGET_malta)
32 QEMU_DEPS_IN_HOST := @(TARGET_x86_64||TARGET_sunxi)
33
34 define Package/virtio-console-helper
35 SECTION:=utils
36 CATEGORY:=Utilities
37 SUBMENU:=Virtualization
38 TITLE:=Helper script for vportNpn virtio-console devices
39 DEPENDS:=$(QEMU_DEPS_IN_GUEST)
40 endef
41
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
45 endef
46
47
48 define Package/qemu-ga
49 SECTION:=utils
50 CATEGORY:=Utilities
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)
55 endef
56
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
64 endef
65
66 PKG_CONFIG_DEPENDS += CONFIG_PACKAGE_qemu-ga
67
68
69 define Package/qemu-bridge-helper
70 SECTION:=utils
71 CATEGORY:=Utilities
72 SUBMENU:=Virtualization
73 TITLE:=QEMU bridge helper
74 URL:=http://www.qemu.org
75 DEPENDS:=+glib2 $(CXX_DEPENDS) $(QEMU_DEPS_IN_HOST)
76 endef
77
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
83 endef
84
85
86 define Package/qemu-img
87 SECTION:=utils
88 CATEGORY:=Utilities
89 SUBMENU:=Virtualization
90 TITLE:=QEMU Image utility
91 URL:=http://www.qemu.org
92 DEPENDS:=+glib2 $(QEMU_DEPS_IN_HOST)
93 endef
94
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
98 endef
99
100
101 define Package/qemu-nbd
102 SECTION:=utils
103 CATEGORY:=Utilities
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
108 endef
109
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
113 endef
114
115
116 define qemu-firmware
117 QEMU_PACKAGES += qemu-firmware-$(1)
118
119 define Package/qemu-firmware-$(1)
120 SECTION:=utils
121 CATEGORY:=Utilities
122 SUBMENU:=Virtualization
123 TITLE:=$(qemu-firmware-$(1)-title)
124 URL:=http://www.qemu.org
125 DEPENDS:=$(QEMU_DEPS_IN_HOST)
126 endef
127
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
131 endef
132 endef
133
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))
137
138 qemu-firmware-seavgabios-title:=QEMU build of SeaVGABIOS
139 qemu-firmware-seavgabios-files:=vgabios-*.bin
140 $(eval $(call qemu-firmware,seavgabios))
141
142 qemu-firmware-pxe-title:=QEMU build of iPXE PXE roms
143 qemu-firmware-pxe-files:=pxe-*.rom
144 $(eval $(call qemu-firmware,pxe))
145
146 qemu-firmware-efi-title:=QEMU build of iPXE EFI roms
147 qemu-firmware-efi-files:=efi-*.rom
148 $(eval $(call qemu-firmware,efi))
149
150
151 # Naming rules used in qemu Makefile.target
152 define qemu-prog_
153 $(if $(filter %-softmmu,$(1)), \
154 $(patsubst %-softmmu,qemu-system-%,$(1)), \
155 $(error unknown qemu target $(1)) \
156 )
157 endef
158 qemu-prog = $(strip $(call qemu-prog_,$(1)))
159
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.
164 #
165 # aarch64%-softmmu arm%-softmmu ppc%-softmmu microblaze%-softmmu
166 #
167 define qemu-target
168 PKG_CONFIG_DEPENDS += CONFIG_PACKAGE_qemu-$(1)
169 QEMU_PACKAGES += qemu-$(1)
170
171 define Package/qemu-$(1)
172 SECTION:=utils
173 CATEGORY:=Utilities
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))
179 endef
180
181 define Package/qemu-$(1)/description
182 This package contains the QEMU target $(1)
183 endef
184
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)
191 )
192 endef
193
194 endef
195
196 qemu-target-list := \
197 x86_64-softmmu \
198 arm-softmmu \
199
200 qemu-target-x86_64-softmmu-deps:= \
201 +qemu-firmware-pxe \
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
210
211 $(foreach target,$(qemu-target-list), \
212 $(eval $(call qemu-target,$(target))) \
213 )
214
215
216 # QEMU configure script does not recognize these options
217 CONFIGURE_ARGS:=$(filter-out \
218 --target=% \
219 --host=% \
220 --build=% \
221 --program-prefix=% \
222 --program-suffix=% \
223 --exec-prefix=% \
224 --disable-nls \
225 , $(CONFIGURE_ARGS))
226
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
229 CONFIGURE_ARGS += \
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)" \
237
238 # VHost features
239 CONFIGURE_ARGS += \
240 --enable-vhost-crypto \
241 --enable-vhost-kernel \
242 --enable-vhost-net \
243 --enable-vhost-scsi \
244 --enable-vhost-user \
245 --enable-vhost-vsock \
246
247 # Image formats support
248 CONFIGURE_ARGS += \
249 --disable-bochs \
250 --disable-cloop \
251 --disable-dmg \
252 --disable-qcow1 \
253 --disable-vdi \
254 --disable-vvfat \
255 --disable-qed \
256 --disable-parallels \
257
258 # system/user-mode emulation
259 CONFIGURE_ARGS += \
260 --disable-user \
261 --disable-bsd-user \
262 --disable-linux-user \
263 --enable-system \
264
265 # accel
266 CONFIGURE_ARGS += \
267 --disable-hax \
268 --disable-hvf \
269 --disable-whpx \
270 --disable-xen \
271 --enable-kvm \
272 --enable-tcg \
273
274 # UI
275 CONFIGURE_ARGS += \
276 --disable-cocoa \
277 --disable-gtk \
278 --disable-sdl \
279 --disable-sdl-image \
280 --disable-spice \
281 --disable-virglrenderer \
282 --disable-vnc \
283 --disable-vnc-jpeg \
284 --disable-vnc-png \
285 --disable-vnc-sasl \
286 --disable-vte \
287 --enable-curses \
288 --enable-iconv \
289
290 # Features for performance & no external dependency
291 CONFIGURE_ARGS += \
292 --enable-coroutine-pool \
293 --enable-crypto-afalg \
294 --enable-live-block-migration \
295 --enable-membarrier \
296 --enable-replication \
297
298 # Review configure options not explicitly specified here
299 #
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"
304 # done
305 #
306 CONFIGURE_ARGS += \
307 --audio-drv-list='' \
308 --disable-attr \
309 --disable-auth-pam \
310 --disable-bluez \
311 --disable-brlapi \
312 --disable-bzip2 \
313 --disable-cap-ng \
314 --disable-capstone \
315 --disable-curl \
316 --disable-debug-info \
317 --disable-debug-mutex \
318 --disable-debug-tcg \
319 --disable-docs \
320 --disable-gcrypt \
321 --disable-git-update \
322 --disable-glusterfs \
323 --disable-gnutls \
324 --disable-guest-agent-msi \
325 --disable-jemalloc \
326 --disable-libiscsi \
327 --disable-libnfs \
328 --disable-libpmem \
329 --disable-libssh \
330 --disable-libudev \
331 --disable-libusb \
332 --disable-libxml2 \
333 --disable-linux-aio \
334 --disable-lzfse \
335 --disable-lzo \
336 --disable-modules \
337 --disable-mpath \
338 --disable-netmap \
339 --disable-nettle \
340 --disable-numa \
341 --disable-opengl \
342 --disable-pvrdma \
343 --disable-qom-cast-debug \
344 --disable-rbd \
345 --disable-rdma \
346 --disable-sanitizers \
347 --disable-seccomp \
348 --disable-sheepdog \
349 --disable-smartcard \
350 --disable-snappy \
351 --disable-sparse \
352 --disable-strip \
353 --disable-tcg-interpreter \
354 --disable-tcmalloc \
355 --disable-tools \
356 --disable-tpm \
357 --disable-usb-redir \
358 --disable-vde \
359 --disable-virtfs \
360 --disable-vxhs \
361 --disable-werror \
362 --disable-xen-pci-passthrough \
363 --disable-xfsctl \
364
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)
367
368 TARGET_LDFLAGS += -Wl,--as-needed
369 MAKE_VARS += V=1
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 \
373 ARCH=% \
374 ,$(MAKE_FLAGS))
375
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)) \
382
383 define Build/Compile
384 $(if $(strip $(QEMU_MAKE_TARGETS)),$(call Build/Compile/Default,$(QEMU_MAKE_TARGETS)))
385 endef
386
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))) \
394 )