summaryrefslogtreecommitdiffstats
path: root/core/modules/virt-viewer/module.build
blob: e95d9adfd195f6cca9aee48e4bfd47645472e22e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash
fetch_source() {
	autoclone
}

build() {
	local SRCDIR="${MODULE_WORK_DIR}/src/virt-viewer"
	local DSTDIR="${MODULE_BUILD_DIR}"
	cde "${SRCDIR}"

	# install meson (>= 0.54.0) since packaged version is too old
	pip3 install "meson>=0.54.0"

	# set config paths for additional pkg-config files
	export PKG_CONFIG_PATH="${TARGET_BUILD_DIR}/usr/lib/x86_64-linux-gnu/pkgconfig:${TARGET_BUILD_DIR}/usr/lib64/pkgconfig"
	# set system root directory for prebuilt headers and libraries, e.g. libvirt-glib
	export PKG_CONFIG_SYSROOT_DIR="${TARGET_BUILD_DIR}"
	# enable output of all system include directories
	export PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1
	# enable output of all system library directories
	export PKG_CONFIG_ALLOW_SYSTEM_LIBS=1

	# create custom pkg-config program to patch paths from pkg-build config files in our build directory
	cat > "${SRCDIR}/pkg-config" <<-EOF
		#!/bin/bash

		# unset custom path to avoid call recursion of this custom pkg-config script
		unset PATH

		# call patched pkg-config wrapper from mltk bin directory
		exec "${ROOT_DIR}/core/bin/pkg-config.sh" "\${@}"
	EOF
	chmod +x "${SRCDIR}/pkg-config"

	# overwrite search path to inject custom pkg-config program
	PATH="${SRCDIR}:${PATH}" \
	meson build \
		--prefix="/usr" \
		--sysconfdir="/etc" \
		--localstatedir="/var" \
		-Dovirt=disabled \
		-Dspice=enabled \
		-Dvnc=enabled \
		-Dlibvirt=enabled || perror "'meson' failed."
	ninja -v -C build || perror "'ninja' failed."
	DESTDIR="${DSTDIR}" ninja -v -C build install || perror "'ninja install' failed."

	rm "${SRCDIR}/pkg-config"
}

post_copy() {
	:
}