summaryrefslogtreecommitdiffstats
path: root/meta/classes/relocatable.bbclass
blob: d0a623fb0a98ecacf4f84a473d1bcfbdd5fe49b3 (plain)
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
#
# Copyright OpenEmbedded Contributors
#
# SPDX-License-Identifier: MIT
#

inherit chrpath

SYSROOT_PREPROCESS_FUNCS += "relocatable_binaries_preprocess relocatable_native_pcfiles"

python relocatable_binaries_preprocess() {
    rpath_replace(d.expand('${SYSROOT_DESTDIR}'), d)
}

relocatable_native_pcfiles() {
	for dir in ${libdir}/pkgconfig ${datadir}/pkgconfig; do
		files_template=${SYSROOT_DESTDIR}$dir/*.pc
		# Expand to any files matching $files_template
		files=$(echo $files_template)
		# $files_template and $files will differ if any files were found
		if [ "$files_template" != "$files" ]; then
			rel=$(realpath -m --relative-to=$dir ${base_prefix})
			sed -i -e "s:${base_prefix}:\${pcfiledir}/$rel:g" $files
		fi
	done
}