xref: /OK3568_Linux_fs/buildroot/package/libvirt/libvirt.mk (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1################################################################################
2#
3# libvirt
4#
5################################################################################
6
7LIBVIRT_VERSION = 7.7.0
8LIBVIRT_SITE = https://libvirt.org/sources
9LIBVIRT_SOURCE = libvirt-$(LIBVIRT_VERSION).tar.xz
10LIBVIRT_LICENSE = LGPL-2.1+
11LIBVIRT_LICENSE_FILES = COPYING
12LIBVIRT_CPE_ID_VENDOR = redhat
13LIBVIRT_DEPENDENCIES = \
14	host-libxslt \
15	host-nfs-utils \
16	host-pkgconf \
17	host-python-docutils \
18	gnutls \
19	libglib2 \
20	libpciaccess \
21	libtirpc \
22	libxml2 \
23	udev \
24	zlib \
25	$(TARGET_NLS_DEPENDENCIES)
26
27LIBVIRT_LDFLAGS = $(TARGET_LDFLAGS) $(TARGET_NLS_LIBS)
28
29LIBVIRT_CONF_ENV += \
30	CFLAGS="$(TARGET_CFLAGS) `$(PKG_CONFIG_HOST_BINARY) --cflags libtirpc`" \
31	LIBS="`$(PKG_CONFIG_HOST_BINARY) --libs libtirpc`"
32
33LIBVIRT_CONF_OPTS = \
34	-Drpath=disabled \
35	-Dapparmor=disabled \
36	-Ddocs=disabled \
37	-Ddriver_bhyve=disabled \
38	-Ddriver_ch=disabled \
39	-Ddriver_esx=disabled \
40	-Ddriver_hyperv=disabled \
41	-Ddriver_interface=enabled \
42	-Ddriver_libxl=disabled \
43	-Ddriver_openvz=disabled \
44	-Ddriver_remote=enabled \
45	-Ddriver_secrets=enabled \
46	-Ddriver_test=disabled \
47	-Ddriver_vbox=disabled \
48	-Ddriver_vmware=disabled \
49	-Ddriver_vz=disabled \
50	-Ddtrace=disabled \
51	-Dexpensive_tests=disabled \
52	-Dfirewalld=disabled \
53	-Dfirewalld_zone=disabled \
54	-Dglusterfs=disabled \
55	-Dhost_validate=enabled \
56	-Dinit_script=$(if $(BR2_INIT_SYSTEMD),systemd,none) \
57	-Dlogin_shell=disabled \
58	-Dnetcf=disabled \
59	-Dnls=$(if $(BR2_SYSTEM_ENABLE_NLS),enabled,disabled) \
60	-Dnumad=disabled \
61	-Dopenwsman=disabled \
62	-Dpciaccess=enabled \
63	-Dpm_utils=disabled \
64	-Dsanlock=disabled \
65	-Dsecdriver_apparmor=disabled \
66	-Dstorage_iscsi=disabled \
67	-Dstorage_iscsi_direct=disabled \
68	-Dstorage_mpath=disabled \
69	-Dsysctl_config=enabled \
70	-Dtest_coverage=false \
71	-Dtests=disabled \
72	-Dudev=enabled \
73	-Dwireshark_dissector=disabled
74
75# warning_level should only drive the level of warnings during the
76# compilation of C code. However, libvirt misuses that to also
77# enable SSP when warning_level == 2
78# Force warning_level=1 to disable SSP, and let our toolchain wrapper
79# handle it.
80LIBVIRT_CONF_OPTS += -Dwarning_level=1
81
82ifeq ($(BR2_PACKAGE_ATTR),y)
83LIBVIRT_CONF_OPTS += -Dattr=enabled
84LIBVIRT_DEPENDENCIES += attr
85else
86LIBVIRT_CONF_OPTS += -Dattr=disabled
87endif
88
89ifeq ($(BR2_PACKAGE_AUDIT),y)
90LIBVIRT_CONF_OPTS += -Daudit=enabled
91LIBVIRT_DEPENDENCIES += audit
92else
93LIBVIRT_CONF_OPTS += -Daudit=disabled
94endif
95
96ifeq ($(BR2_PACKAGE_BASH_COMPLETION),y)
97LIBVIRT_CONF_OPTS += -Dbash_completion=enabled
98LIBVIRT_DEPENDENCIES += bash-completion
99else
100LIBVIRT_CONF_OPTS += -Dbash_completion=disabled
101endif
102
103ifeq ($(BR2_PACKAGE_UTIL_LINUX_LIBBLKID),y)
104LIBVIRT_CONF_OPTS += -Dblkid=enabled
105LIBVIRT_DEPENDENCIES += util-linux
106else
107LIBVIRT_CONF_OPTS += -Dblkid=disabled
108endif
109
110ifeq ($(BR2_PACKAGE_LIBCAP_NG),y)
111LIBVIRT_CONF_OPTS += -Dcapng=enabled
112LIBVIRT_DEPENDENCIES += libcap-ng
113else
114LIBVIRT_CONF_OPTS += -Dcapng=disabled
115endif
116
117ifeq ($(BR2_PACKAGE_LIBCURL),y)
118LIBVIRT_CONF_OPTS += -Dcurl=enabled
119LIBVIRT_DEPENDENCIES += libcurl
120else
121LIBVIRT_CONF_OPTS += -Dcurl=disabled
122endif
123
124ifeq ($(BR2_PACKAGE_LIBFUSE),y)
125LIBVIRT_CONF_OPTS += -Dfuse=enabled
126LIBVIRT_DEPENDENCIES += libfuse
127else
128LIBVIRT_CONF_OPTS += -Dfuse=disabled
129endif
130
131ifeq ($(BR2_PACKAGE_LIBISCSI),y)
132LIBVIRT_CONF_OPTS += -Dlibiscsi=enabled
133LIBVIRT_DEPENDENCIES += libiscsi
134else
135LIBVIRT_CONF_OPTS += -Dlibiscsi=disabled
136endif
137
138ifeq ($(BR2_PACKAGE_LIBNL),y)
139LIBVIRT_CONF_OPTS += -Dlibnl=enabled
140LIBVIRT_DEPENDENCIES += libnl
141else
142LIBVIRT_CONF_OPTS += -Dlibnl=disabled
143endif
144
145ifeq ($(BR2_PACKAGE_LIBPCAP),y)
146LIBVIRT_CONF_OPTS += -Dlibpcap=enabled
147LIBVIRT_DEPENDENCIES += libpcap
148else
149LIBVIRT_CONF_OPTS += -Dlibpcap=disabled
150endif
151
152ifeq ($(BR2_PACKAGE_NUMACTL),y)
153LIBVIRT_CONF_OPTS += -Dnumactl=enabled
154LIBVIRT_DEPENDENCIES += numactl
155else
156LIBVIRT_CONF_OPTS += -Dnumactl=disabled
157endif
158
159ifeq ($(BR2_PACKAGE_POLKIT),y)
160LIBVIRT_CONF_OPTS += -Dpolkit=enabled
161LIBVIRT_DEPENDENCIES += polkit
162else
163LIBVIRT_CONF_OPTS += -Dpolkit=disabled
164endif
165
166ifeq ($(BR2_PACKAGE_READLINE),y)
167LIBVIRT_CONF_OPTS += -Dreadline=enabled
168LIBVIRT_DEPENDENCIES += readline
169else
170LIBVIRT_CONF_OPTS += -Dreadline=disabled
171endif
172
173ifeq ($(BR2_PACKAGE_LIBSELINUX),y)
174LIBVIRT_CONF_OPTS += -Dselinux=enabled -Dsecdriver_selinux=enabled \
175	-Dselinux_mount=/sys/fs/selinux
176LIBVIRT_DEPENDENCIES += libselinux
177else
178LIBVIRT_CONF_OPTS += -Dselinux=disabled -Dsecdriver_selinux=disabled
179endif
180
181ifeq ($(BR2_PACKAGE_LVM2_STANDARD_INSTALL),y)
182LIBVIRT_CONF_OPTS += -Dstorage_lvm=enabled
183LIBVIRT_DEPENDENCIES += host-lvm2 lvm2
184else
185LIBVIRT_CONF_OPTS += -Dstorage_lvm=disabled
186endif
187
188ifeq ($(BR2_PACKAGE_YAJL),y)
189LIBVIRT_CONF_OPTS += -Dyajl=enabled
190LIBVIRT_DEPENDENCIES += yajl
191else
192LIBVIRT_CONF_OPTS += -Dyajl=disabled
193endif
194
195ifeq ($(BR2_PACKAGE_LIBVIRT_DAEMON),y)
196# Network is used by daemon, only
197LIBVIRT_CONF_OPTS += -Dlibvirtd=enabled -Ddriver_network=enabled
198
199ifeq ($(BR2_PACKAGE_LIBSSH),y)
200LIBVIRT_CONF_OPTS += -Dlibssh=enabled
201LIBVIRT_DEPENDENCIES += libssh
202else
203LIBVIRT_CONF_OPTS += -Dlibssh=disabled
204endif
205
206# Can't build nss plugin without network or yajl
207ifeq ($(BR2_PACKAGE_LIBNSS)$(BR2_PACKAGE_YAJL),yy)
208LIBVIRT_CONF_OPTS += -Dnss=enabled
209LIBVIRT_DEPENDENCIES += libnss
210else
211LIBVIRT_CONF_OPTS += -Dnss=disabled
212endif
213
214ifeq ($(BR2_PACKAGE_LIBGSASL),y)
215LIBVIRT_CONF_OPTS += -Dsasl=enabled
216LIBVIRT_DEPENDENCIES += libgsasl
217else
218LIBVIRT_CONF_OPTS += -Dsasl=disabled
219endif
220
221ifeq ($(BR2_PACKAGE_LIBSSH2),y)
222LIBVIRT_CONF_OPTS += -Dssh2=enabled
223LIBVIRT_DEPENDENCIES += libssh2
224else
225LIBVIRT_CONF_OPTS += -Dssh2=disabled
226endif
227
228ifeq ($(BR2_PACKAGE_LIBVIRT_LXC),y)
229LIBVIRT_CONF_OPTS += -Dlogin_shell=enabled -Ddriver_lxc=enabled
230LIBVIRT_DEPENDENCIES += lxc
231else
232LIBVIRT_CONF_OPTS += -Dlogin_shell=disabled -Ddriver_lxc=disabled
233endif
234
235ifeq ($(BR2_PACKAGE_LIBVIRT_QEMU),y)
236LIBVIRT_CONF_OPTS += -Ddriver_qemu=enabled -Dqemu_user=qemu -Dqemu_group=kvm
237else
238LIBVIRT_CONF_OPTS += -Ddriver_qemu=disabled -Dqemu_user=no -Dqemu_group=no
239endif
240
241else # BR2_PACKAGE_LIBVIRT_DAEMON
242
243LIBVIRT_CONF_OPTS += -Dlibvirtd=disabled -Ddriver_network=disabled
244
245endif
246
247define LIBVIRT_INSTALL_UDEV_RULES
248	$(INSTALL) -D -m 644 package/libvirt/90-kvm.rules \
249		$(TARGET_DIR)/etc/udev/rules.d/90-kvm.rules
250endef
251LIBVIRT_POST_INSTALL_TARGET_HOOKS += LIBVIRT_INSTALL_UDEV_RULES
252
253# Adjust directory ownerships and permissions. Notice /var/log is a symlink to
254# /tmp in the default sysvinit skeleton, so some directories may disappear at
255# run-time. Set the permissions anyway, since they are valid for the default
256# systemd skeleton.
257define LIBVIRT_PERMISSIONS
258	/etc/libvirt                             d  700  root  root  -  -  -  -  -
259	/etc/libvirt/nwfilter                    d  700  root  root  -  -  -  -  -
260	/var/lib/libvirt                         d  755  root  root  -  -  -  -  -
261	/var/lib/libvirt/boot                    d  711  root  root  -  -  -  -  -
262	/var/lib/libvirt/dnsmasq                 d  755  root  root  -  -  -  -  -
263	/var/lib/libvirt/filesystems             d  711  root  root  -  -  -  -  -
264	/var/lib/libvirt/images                  d  711  root  root  -  -  -  -  -
265	/var/lib/libvirt/network                 d  700  root  root  -  -  -  -  -
266	/var/lib/libvirt/qemu                    d  751  qemu  kvm   -  -  -  -  -
267	/var/lib/libvirt/qemu/autostart          d  700  root  root  -  -  -  -  -
268	/var/lib/libvirt/qemu/networks           d  700  root  root  -  -  -  -  -
269	/var/lib/libvirt/qemu/networks/autostart d  700  root  root  -  -  -  -  -
270	/var/lib/libvirt/qemu/channel            d  755  qemu  kvm   -  -  -  -  -
271	/var/lib/libvirt/qemu/channel/target     d  755  qemu  kvm   -  -  -  -  -
272	/var/lib/libvirt/qemu/dump               d  755  qemu  kvm   -  -  -  -  -
273	/var/lib/libvirt/qemu/nvram              d  755  qemu  kvm   -  -  -  -  -
274	/var/lib/libvirt/qemu/save               d  755  qemu  kvm   -  -  -  -  -
275	/var/lib/libvirt/qemu/snapshot           d  755  qemu  kvm   -  -  -  -  -
276	/var/lib/libvirt/secrets                 d  700  root  root  -  -  -  -  -
277	/var/lib/libvirt/storage                 d  755  root  root  -  -  -  -  -
278	/var/lib/libvirt/storage/autostart       d  755  root  root  -  -  -  -  -
279	/var/cache/libvirt                       d  711  root  root  -  -  -  -  -
280	/var/cache/libvirt/lxc                   d  750  root  root  -  -  -  -  -
281	/var/cache/libvirt/qemu                  d  750  qemu  kvm   -  -  -  -  -
282	/var/cache/libvirt/qemu/capabilities     d  755  root  root  -  -  -  -  -
283	/var/log/libvirt                         d  700  root  root  -  -  -  -  -
284	/var/log/libvirt/lxc                     d  750  root  root  -  -  -  -  -
285	/var/log/libvirt/qemu                    d  750  root  root  -  -  -  -  -
286	/var/log/swtpm                           d  755  root  root  -  -  -  -  -
287	/var/log/swtpm/libvirt                   d  755  root  root  -  -  -  -  -
288	/var/log/swtpm/libvirt/qemu              d  711  root  root  -  -  -  -  -
289endef
290
291# libvirt may need to create persistent files (e.g. VM definitions) in these
292# directories. Move them to /var/lib because /etc may be on a read-only or
293# volatile (initramfs) filesystem. We could tweak the code to change these
294# paths but the patch would be large and would break compatibility with
295# ordinary installations and with the documentation.
296define LIBVIRT_CREATE_SYMLINKS
297	$(INSTALL) -m 700 -d $(TARGET_DIR)/etc/libvirt
298	$(INSTALL) -m 755 -d $(TARGET_DIR)/var/lib/libvirt
299	$(INSTALL) -m 751 -d $(TARGET_DIR)/var/lib/libvirt/qemu
300	$(INSTALL) -m 700 -d $(TARGET_DIR)/var/lib/libvirt/secrets
301	$(INSTALL) -m 755 -d $(TARGET_DIR)/var/lib/libvirt/storage
302	ln -s -f ../../var/lib/libvirt/qemu $(TARGET_DIR)/etc/libvirt/
303	ln -s -f ../../var/lib/libvirt/secrets $(TARGET_DIR)/etc/libvirt/
304	ln -s -f ../../var/lib/libvirt/storage $(TARGET_DIR)/etc/libvirt/
305endef
306
307LIBVIRT_PRE_INSTALL_TARGET_HOOKS += LIBVIRT_CREATE_SYMLINKS
308
309ifeq ($(BR2_PACKAGE_LIBVIRT_QEMU),y)
310define LIBVIRT_USERS
311	qemu -1 kvm -1 * - - - Libvirt qemu/kvm daemon
312endef
313endif
314
315ifeq ($(BR2_PACKAGE_LIBVIRT_DAEMON),y)
316define LIBVIRT_INSTALL_INIT_SYSV
317	$(INSTALL) -D -m 0755 package/libvirt/S91virtlogd $(TARGET_DIR)/etc/init.d/S91virtlogd
318	$(INSTALL) -D -m 0755 package/libvirt/S92libvirtd $(TARGET_DIR)/etc/init.d/S92libvirtd
319endef
320endif
321
322$(eval $(meson-package))
323