summaryrefslogtreecommitdiffhomepage
path: root/subr/pkg_install_libs.subr
blob: 3dcc0ac2acf3c8a47c8533286f6843295432cde4 (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
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
#
# set +o errexit -o noglob -o nounset is assumed.
#

pkgp_install_libs_purge_la() {
	local _la_path="";
	for _la_path in $(find "${PKG_DESTDIR}" -type f -name \*.la); do
		if ! rtl_fileop rm "${_la_path}"; then
			return 1;
		fi;
	done;
};

pkgp_install_libs_shared_link() {
	local _lib_name="${1}" _so_dir="${2}" _so_path="${3}" _lib_link_path="${3%.so*}.lib.a" _lib_link_tgt="";
	if _lib_link_tgt="$(find "${_so_dir}" -name "${_lib_name%%.*}.*.lib.a" | sort | tail -1)"\
	&& [ -n "${_lib_link_tgt}" ]\
	&& [ "${_lib_link_tgt}" != "${_lib_link_path}" ]; then
		if ! rtl_fileop rm "${_lib_link_path}"\
		|| ! rtl_fileop ln_symbolic "$(rtl_basename "${_lib_link_tgt}")" "${_lib_link_path}"; then
			return 1;
		fi;
	fi;
};

pkgp_install_libs_shared() {
	local _lib_dst_path="" _lib_name="" _lib_src_path="" _so_dst_dir="" _so_src_path="";
	if [ "${PKG_BUILD_TYPE}" != "host" ]; then
		for _so_src_path in \
			$(find	"${PKG_DESTDIR}"							  	\
				\(  -name "*.so" -or -name "*.so.*" \) -print);
		do	if [ "$(readlink -f "${_so_src_path}")" != "/dev/null" ]\
			&& [ -z "$(rtl_head "[0-9.]" "${_so_src_path##*.so}")" ]; then
				case "${_so_src_path}" in
				*.so)	_lib_src_path="${_so_src_path%%.so}.lib.a"; ;;
				*.so.*)	_lib_src_path="${_so_src_path%%.so.*}.${_so_src_path##*.so.}.lib.a"; ;;
				esac;
				_so_dst_dir="${_so_src_path%/*}";
				_lib_name="$(rtl_basename "${_lib_src_path}")";
				_lib_dst_path="${_so_dst_dir}/${_lib_name}";
				if [ ! -L "${_lib_src_path}" ]\
				&& [ ! -e "${_lib_dst_path}" ]; then
					if ! (rtl_fileop cd "$(rtl_dirname "${_so_src_path}")" 	&&		\
							perk -e "$(rtl_basename "${_so_src_path}")"		|\
								"${PKG_TARGET}-mdso"				\
									-i "$(rtl_basename "${_lib_dst_path}")"	\
									-n "$(rtl_basename "${_so_src_path}")" -); then
						return 1;
					fi;
				fi;
				if ! pkgp_install_libs_shared_link "${_lib_name}" "${_so_dst_dir}" "${_so_src_path}"; then
					return 1;
				fi;
			fi;
		done;
	fi;
};

pkg_install_libs() {
	if ! pkgp_install_libs_purge_la\
	|| ! pkgp_install_libs_shared; then
		return 1;
	fi;
};

# vim:filetype=sh