summaryrefslogtreecommitdiffstats
path: root/core/modules/virt-viewer/module.build
blob: d37d750ea3c442b3faa0f843bd6d7fde3199e99d (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
54
55
56
57
58
59
60
61
62
#!/bin/bash
fetch_source() {
	autoclone
}

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

	# save original path content before modifying path variable
	local PATH_OLD="${PATH}"

	# 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"

	# restore old environment so that following pkg-config calls are not modified
	unset PKG_CONFIG_PATH
	unset PKG_CONFIG_SYSROOT_DIR
	unset PKG_CONFIG_ALLOW_SYSTEM_CFLAGS
	unset PKG_CONFIG_ALLOW_SYSTEM_LIBS

	# restore original path variable
	export PATH="${PATH_OLD}"
}

post_copy() {
	:
}