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 2b85d0
# set +o errexit -o noglob is assumed.
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
#
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
Lucio Andrés Illanes Albornoz 2b85d0
pkgp_install_libs_purge_la() {
Lucio Andrés Illanes Albornoz 2b85d0
	local _la_path="";
Lucio Andrés Illanes Albornoz 2b85d0
	for _la_path in $(find "${PKG_DESTDIR}" -type f -name \*.la); do
Lucio Andrés Illanes Albornoz c6d6e0
		rtl_fileop rm "${_la_path}" || return "${?}";
Lucio Andrés Illanes Albornoz 2b85d0
	done;
Lucio Andrés Illanes Albornoz (arab, vxp) 981a63
};
Lucio Andrés Illanes Albornoz (arab, vxp) 981a63
Lucio Andrés Illanes Albornoz 2b85d0
pkgp_install_libs_shared_link() {
Lucio Andrés Illanes Albornoz 2b85d0
	local _lib_name="${1}" _so_dir="${2}" _so_path="${3}" _lib_link_path="${3%.so*}.lib.a" _lib_link_tgt="";
Lucio Andrés Illanes Albornoz 2b85d0
	if _lib_link_tgt="$(find "${_so_dir}" -name "${_lib_name%%.*}.*.lib.a" | sort | tail -1)"\
Lucio Andrés Illanes Albornoz 2b85d0
	&& [ -n "${_lib_link_tgt}" ]\
Lucio Andrés Illanes Albornoz (arab, vxp) 9b2278
	&& [ "${_lib_link_tgt}" != "${_lib_link_path}" ]; then
Lucio Andrés Illanes Albornoz c6d6e0
		if ! rtl_fileop rm "${_lib_link_path}"\
Lucio Andrés Illanes Albornoz c6d6e0
		|| ! rtl_fileop ln_symbolic "$(rtl_basename "${_lib_link_tgt}")" "${_lib_link_path}"; then
Lucio Andrés Illanes Albornoz 2b85d0
			return 1;
Lucio Andrés Illanes Albornoz 2b85d0
		fi;
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 2b85d0
pkgp_install_libs_shared() {
Lucio Andrés Illanes Albornoz 2b85d0
	local _lib_dst_path="" _lib_name="" _lib_src_path="" _so_dst_dir="" _so_src_path="";
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
	if [ "${PKG_BUILD_TYPE}" != "host" ]; then
Lucio Andrés Illanes Albornoz 2b85d0
		for _so_src_path in \
Lucio Andrés Illanes Albornoz 2b85d0
			$(find	"${PKG_DESTDIR}"							  \
Lucio Andrés Illanes Albornoz (arab, vxp) 981a63
				\(  -name "*.so" -or -name "*.so.*" \) -print);
Lucio Andrés Illanes Albornoz 2b85d0
		do	if [ "$(readlink -f "${_so_path}")" != "/dev/null" ]\
Lucio Andrés Illanes Albornoz c6d6e0
			&& [ -z "$(rtl_head "[0-9.]" "${_so_src_path##*.so}")" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
				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 2b85d0
				_so_dst_dir="${_so_src_path%/*}";
Lucio Andrés Illanes Albornoz c6d6e0
				_lib_name="$(rtl_basename "${_lib_src_path}")";
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
				_lib_dst_path="${_so_dst_dir}/${_lib_name}";
Lucio Andrés Illanes Albornoz 2b85d0
				if [ ! -L "${_lib_src_path}" ]\
Lucio Andrés Illanes Albornoz 2b85d0
				&& [ ! -e "${_lib_dst_path}" ]; then
Lucio Andrés Illanes Albornoz c6d6e0
					(rtl_fileop cd "$(rtl_dirname "${_so_src_path}")" 	&&\
Lucio Andrés Illanes Albornoz c6d6e0
					perk -e "$(rtl_basename "${_so_src_path}")"			 |\
Lucio Andrés Illanes Albornoz 2b85d0
						"${PKG_TARGET}-mdso"					  \
Lucio Andrés Illanes Albornoz c6d6e0
							-i "$(rtl_basename "${_lib_dst_path}")"	  \
Lucio Andrés Illanes Albornoz c6d6e0
							-n "$(rtl_basename "${_so_src_path}")" -) || return "${?}";
Lucio Andrés Illanes Albornoz 2b85d0
				fi;
Lucio Andrés Illanes Albornoz 2b85d0
				pkgp_install_libs_shared_link "${_lib_name}" "${_so_dst_dir}" "${_so_src_path}" || return "${?}";
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
			fi;
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 2b85d0
pkg_install_libs() {
Lucio Andrés Illanes Albornoz 2b85d0
	if ! pkgp_install_libs_purge_la\
Lucio Andrés Illanes Albornoz 2b85d0
	|| ! pkgp_install_libs_shared; then
Lucio Andrés Illanes Albornoz 2b85d0
		return 1;
Lucio Andrés Illanes Albornoz 2b85d0
	fi;
Lucio Andrés Illanes Albornoz 2b85d0
};
Lucio Andrés Illanes Albornoz 2b85d0
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
# vim:filetype=sh