summaryrefslogtreecommitdiffstats
path: root/core/modules/virt-viewer-video/module.build
blob: 9945249a9fa3d01710bba3d09f443ec312e40ab4 (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
63
64
65
66
67
68
69
70
71
72
73
#!/bin/bash

fetch_source() {
	autoclone
}

# () for subshell, so no need to clean up env
build() (
	local SRCDIR
	#local DSTDIR="${MODULE_BUILD_DIR}" TODO
	# This is messy for now. We build both libs and install to the actual system root
	# instead of MODULE_BUILD_DIR, because the sysroot wrapper magic would only look
	# in TARGET_BUILD_DIR where we only copy things after this mltk module finished.
	# Solving this might require splitting this up into three separate mltk modules,
	# but eh...
	export PKG_CONFIG_PATH="${TARGET_BUILD_DIR}/usr/lib/x86_64-linux-gnu/pkgconfig:${TARGET_BUILD_DIR}/usr/lib64/pkgconfig:/usr/lib/x86_64-linux-gnu/pkgconfig:/usr/lib64/pkgconfig"

	# create custom pkg-config program to patch paths from pkg-build config files in our build directory
	cat > "${MODULE_BUILD_DIR}/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 "${MODULE_BUILD_DIR}/pkg-config"

	# Part 1: spice-protocol
	SRCDIR="${MODULE_WORK_DIR}/src/spice-protocol"
	cde "${SRCDIR}"
	meson setup \
		--prefix=/usr \
		build || perror "meson for spice-protocol failed"
	ninja -C build install || perror "ninja spice-protocol failed"

	# Part 2: spice-gtk
	SRCDIR="${MODULE_WORK_DIR}/src/spice-gtk"
	cde "${SRCDIR}"
	echo -e '#!/bin/sh\nprintf "%s" "0.36"' > "build-aux/git-version-gen"
	meson setup --prefix=/usr \
		build \
		-Dwayland-protocols=enabled \
		-Dbuiltin-mjpeg=false \
		-Dopus=enabled \
		-Dgtk=enabled || perror "meson for spice-gtk failed"
	ninja -C build install || perror "ninja for spice-gtk failed"

	# Part 3: 
	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
	SRCDIR="${MODULE_WORK_DIR}/src/virt-viewer"
	cde "${SRCDIR}"
	PATH="${MODULE_BUILD_DIR}:${PATH}" meson setup \
		--prefix="/usr" \
		--sysconfdir="/etc" \
		--localstatedir="/var" \
		build \
		-Dovirt=disabled \
		-Dspice=enabled \
		-Dvnc=enabled \
		-Dlibvirt=enabled || perror "'meson' for virt-viewer failed."
	ninja -v -C build || perror "'ninja' for virt-viewer failed."
	ninja -v -C build install || perror "'ninja install' failed."
)

post_copy() {
	:
}