Conan_Kudo / build / midipix_build

Forked from build/midipix_build 4 years ago
Clone

Blame subr/pkg_install_libs.subr

Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
#
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
# set -o errexit -o noglob are assumed.
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
#
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
Lucio Andrés Illanes Albornoz (arab, vxp) 981a63
pkgp_install_lib_check() {
Lucio Andrés Illanes Albornoz (arab, vxp) 981a63
	local _so_path="${1}" _so_ver="${1##*.so}";
Lucio Andrés Illanes Albornoz (arab, vxp) 5725cd
	if [ -z "${_so_ver}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 5725cd
		return 1;
Lucio Andrés Illanes Albornoz (arab, vxp) 5725cd
	fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 981a63
	while [ -n "${_so_ver}" ]; do
Lucio Andrés Illanes Albornoz (arab, vxp) d7eaa6
		if [ "${_so_ver#[0-9.]}" = "${_so_ver}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 5725cd
			return 1;
Lucio Andrés Illanes Albornoz (arab, vxp) 981a63
		else
Lucio Andrés Illanes Albornoz (arab, vxp) 412fec
			_so_ver="${_so_ver#[0-9.]}";
Lucio Andrés Illanes Albornoz (arab, vxp) 981a63
		fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 5725cd
	done; return 0;
Lucio Andrés Illanes Albornoz (arab, vxp) 981a63
};
Lucio Andrés Illanes Albornoz (arab, vxp) 981a63
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
pkgp_install_lib_link() {
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
	local _so_path="${1}" _so_dir="${2}" _lib_name="${3}"				\
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
		_lib_link_tgt _lib_link_path;
Lucio Andrés Illanes Albornoz (arab, vxp) 9b2278
	_lib_link_path="${_so_path%.so*}.lib.a";
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
	_lib_link_tgt="$(find "${_so_dir}"						\
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
			-name "${_lib_name%%.*}.*.lib.a"				|\
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
			sort | tail -1)";
Lucio Andrés Illanes Albornoz (arab, vxp) 9b2278
	if [ -n "${_lib_link_tgt}" ]\
Lucio Andrés Illanes Albornoz (arab, vxp) 9b2278
	&& [ "${_lib_link_tgt}" != "${_lib_link_path}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
		ex_build_fileop rm "${_lib_link_path}";
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
		ex_build_fileop ln_symbolic "$(ex_basename "${_lib_link_tgt}")"		\
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
			"${_lib_link_path}";
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
	fi;
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
};
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
pkg_install_libs() {
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
	local _so_src_path _so_dst_dir _lib_src_path _lib_name _lib_dst_path;
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
	if [ "${PKG_BUILD_TYPE}" != "host" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
		for _so_src_path in							\
Lucio Andrés Illanes Albornoz (arab, vxp) 022f7e
			$(find	"${PKG_DESTDIR}"					\
Lucio Andrés Illanes Albornoz (arab, vxp) 981a63
				\(  -name "*.so" -or -name "*.so.*" \) -print);
Lucio Andrés Illanes Albornoz (arab, vxp) 981a63
		do	if ! pkgp_install_lib_check "${_so_src_path}"			\
Lucio Andrés Illanes Albornoz (arab, vxp) 981a63
			|| [ "$(readlink -f "${_so_src_path}")" = "/dev/null" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
				continue;
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
			else	case "${_so_src_path}" in
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
				*.so)	_lib_src_path="${_so_src_path%%.so}.lib.a"; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
				*.so.*)	_lib_src_path="${_so_src_path%%.so.*}.${_so_src_path##*.so.}.lib.a"; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
				esac;
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
				_lib_name="$(ex_basename "${_lib_src_path}")";
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
				_so_dst_dir="${_so_src_path%/*}";
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
			fi;
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
			if [ ! -L "${_lib_src_path}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
				_lib_dst_path="${_so_dst_dir}/${_lib_name}";
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
				perk -e "${_so_src_path}"				|\
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
					"${PKG_TARGET}-mdso"				\
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
						-i "${_lib_dst_path}"			\
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
						-n "${_so_src_path}" -;
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
			fi;
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
			pkgp_install_lib_link "${_so_src_path}" "${_so_dst_dir}" "${_lib_name}";
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
		done;
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
	fi;
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
};
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
# vim:filetype=sh