Conan_Kudo / build / midipix_build

Forked from build/midipix_build 4 years ago
Clone

Blame subr/pkg_install.subr

Lucio Andrés Illanes Albornoz (arab, vxp) 570129
#
Lucio Andrés Illanes Albornoz (arab, vxp) 802215
# set -o errexit -o noglob are assumed.
Lucio Andrés Illanes Albornoz (arab, vxp) 570129
#
Lucio Andrés Illanes Albornoz (arab, vxp) 570129
Lucio Andrés Illanes Albornoz (arab, vxp) f539a4
pkgp_install_clean_lib() {
Lucio Andrés Illanes Albornoz (arab, vxp) 802215
	local __;
Lucio Andrés Illanes Albornoz (arab, vxp) 570129
	if [ -d ${PKG_PREFIX}/lib ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 570129
		for __ in $(find ${PKG_PREFIX}/lib -type f -name \*.la); do
Lucio Andrés Illanes Albornoz (arab, vxp) bd97b6
			build_fileop rm ${__};
Lucio Andrés Illanes Albornoz (arab, vxp) 570129
		done;
Lucio Andrés Illanes Albornoz (arab, vxp) 570129
	fi;
Lucio Andrés Illanes Albornoz (arab, vxp) f539a4
};
Lucio Andrés Illanes Albornoz (arab, vxp) f539a4
Lucio Andrés Illanes Albornoz (arab, vxp) 48fd14
pkgp_install_lib_link() {
Lucio Andrés Illanes Albornoz (arab, vxp) 48fd14
	local _so_path="${1}" _so_dir="${2}" _lib_name="${3}"				\
Lucio Andrés Illanes Albornoz (arab, vxp) 48fd14
		_lib_link_tgt _lib_link_path;
Lucio Andrés Illanes Albornoz (arab, vxp) 48fd14
	_lib_link_tgt="$(find "${_so_dir}"						\
Lucio Andrés Illanes Albornoz (arab, vxp) 48fd14
			-name "${_lib_name%%.*}.*.lib.a"				|\
Lucio Andrés Illanes Albornoz (arab, vxp) 48fd14
			sort | tail -1)";
Lucio Andrés Illanes Albornoz (arab, vxp) 48fd14
	if [ -n "${_lib_link_tgt}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 48fd14
		_lib_link_path="${_so_path%.so*}.lib.a";
Lucio Andrés Illanes Albornoz (arab, vxp) 48fd14
		build_fileop rm "${_lib_link_path}";
Lucio Andrés Illanes Albornoz (arab, vxp) 48fd14
		build_fileop ln_symbolic "${_lib_link_tgt}"				\
Lucio Andrés Illanes Albornoz (arab, vxp) 48fd14
			"${_lib_link_path}";
Lucio Andrés Illanes Albornoz (arab, vxp) 48fd14
	fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 48fd14
};
Lucio Andrés Illanes Albornoz (arab, vxp) 48fd14
Lucio Andrés Illanes Albornoz (arab, vxp) 48fd14
pkgp_install_libs() {
Lucio Andrés Illanes Albornoz (arab, vxp) 48fd14
	local _so_src_path _so_dst_path _so_dst_dir					\
Lucio Andrés Illanes Albornoz (arab, vxp) 48fd14
		_lib_src_path _lib_name _lib_dst_path;
Lucio Andrés Illanes Albornoz (arab, vxp) 570129
	if [ "${PKG_BUILD_TYPE}" != "host" ]						\
Lucio Andrés Illanes Albornoz (arab, vxp) 570129
	&& test_cmd perk								\
Lucio Andrés Illanes Albornoz (arab, vxp) 1f97e6
	&& test_cmd ${PKG_TARGET}-mdso; then
Lucio Andrés Illanes Albornoz (arab, vxp) 48fd14
		for _so_src_path in							\
Lucio Andrés Illanes Albornoz (arab, vxp) 1f97e6
			$(find	\(  -name "*.so"					\
Lucio Andrés Illanes Albornoz (arab, vxp) 763688
				-or -name "*.so.[0-9]*"					\
Lucio Andrés Illanes Albornoz (arab, vxp) 763688
				-or -name "*.so.[0-9]*.[0-9]*"				\
Lucio Andrés Illanes Albornoz (arab, vxp) 763688
				-or -name "*.so.[0-9]*.[0-9]*.[0-9]*" \) -print);
Lucio Andrés Illanes Albornoz (arab, vxp) 48fd14
		do	_so_src_path="${_so_src_path#./}";
Lucio Andrés Illanes Albornoz (arab, vxp) 48fd14
			if [ "$(readlink -f "${_so_src_path}")" = "/dev/null" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 48fd14
				continue;
Lucio Andrés Illanes Albornoz (arab, vxp) 48fd14
			else	case "${_so_src_path}" in
Lucio Andrés Illanes Albornoz (arab, vxp) 48fd14
				*.so)	_lib_src_path="${_so_src_path%%.so}.lib.a"; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) 48fd14
				*.so.*)	_lib_src_path="${_so_src_path%%.so.*}.${_so_src_path##*.so.}.lib.a"; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) 48fd14
				esac;
Lucio Andrés Illanes Albornoz (arab, vxp) 48fd14
				_lib_name="$(basename "${_lib_src_path}")";
Lucio Andrés Illanes Albornoz (arab, vxp) 48fd14
				_so_dst_path="$(find "${PKG_PREFIX}/lib"		\
Lucio Andrés Illanes Albornoz (arab, vxp) 48fd14
						-name "$(basename "${_so_src_path}")"	\
Lucio Andrés Illanes Albornoz (arab, vxp) 48fd14
						-size "$(stat -c %s "${_so_src_path}")c")";
Lucio Andrés Illanes Albornoz (arab, vxp) 48fd14
				_so_dst_dir="${_so_dst_path%/*}";
Lucio Andrés Illanes Albornoz (arab, vxp) 48fd14
			fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 48fd14
			if [ -z "${_so_dst_path}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 570129
				continue;
Lucio Andrés Illanes Albornoz (arab, vxp) 48fd14
			elif [ ! -L "${_lib_src_path}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 48fd14
				_lib_dst_path="${_so_dst_dir}/${_lib_name}";
Lucio Andrés Illanes Albornoz (arab, vxp) 48fd14
				perk -e "${_so_src_path}"				|\
Lucio Andrés Illanes Albornoz (arab, vxp) 48fd14
					"${PKG_TARGET}-mdso"				\
Lucio Andrés Illanes Albornoz (arab, vxp) 48fd14
						-i "${_lib_src_path}"			\
Lucio Andrés Illanes Albornoz (arab, vxp) 48fd14
						-n "${_so_src_path}" -;
Lucio Andrés Illanes Albornoz (arab, vxp) 48fd14
				build_fileop rm "${_lib_dst_path}";
Lucio Andrés Illanes Albornoz (arab, vxp) 48fd14
				build_fileop cp "${_lib_src_path}" "${_lib_dst_path}";
Lucio Andrés Illanes Albornoz (arab, vxp) 570129
			fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 48fd14
			pkgp_install_lib_link "${_so_dst_path}" "${_so_dst_dir}" "${_lib_name}";
Lucio Andrés Illanes Albornoz (arab, vxp) 570129
		done;
Lucio Andrés Illanes Albornoz (arab, vxp) 570129
	fi;
Lucio Andrés Illanes Albornoz (arab, vxp) f539a4
};
Lucio Andrés Illanes Albornoz (arab, vxp) f539a4
Lucio Andrés Illanes Albornoz (arab, vxp) b47485
pkgp_install_pkgconfig() {
Lucio Andrés Illanes Albornoz (arab, vxp) b47485
	local __;
Lucio Andrés Illanes Albornoz (arab, vxp) b47485
	for __ in $(find "${WORKDIR}/${PKG_BUILD_DIR}" -name \*.pc); do 
Lucio Andrés Illanes Albornoz (arab, vxp) b47485
		if grep -Eq '^libdir=[^$]+$' "${__}"; then
Lucio Andrés Illanes Albornoz (arab, vxp) 3ac274
			sed -i	-e '/^libdir=[^$]\+$/s/^libdir=\(.\+\)$/libdir=${exec_prefix}\1/'	\
Lucio Andrés Illanes Albornoz (arab, vxp) 48fd14
				-e '/^exec_prefix=$/s/^.*$/exec_prefix=${prefix}/'	\
Lucio Andrés Illanes Albornoz (arab, vxp) b47485
					"${__}";
Lucio Andrés Illanes Albornoz (arab, vxp) b47485
		fi;
Lucio Andrés Illanes Albornoz (arab, vxp) b47485
	done;
Lucio Andrés Illanes Albornoz (arab, vxp) b47485
};
Lucio Andrés Illanes Albornoz (arab, vxp) b47485
Lucio Andrés Illanes Albornoz (arab, vxp) f539a4
pkg_install() {
Lucio Andrés Illanes Albornoz (arab, vxp) b47485
	pkgp_install_pkgconfig;
Lucio Andrés Illanes Albornoz (arab, vxp) f539a4
	if [ ${PKG_NO_MAKE_INSTALL:-0} -eq 0 ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) b47485
		run_cmd_unsplit make							\
Lucio Andrés Illanes Albornoz (arab, vxp) b47485
			${PKG_MAKEFLAGS_INSTALL}					\
Lucio Andrés Illanes Albornoz (arab, vxp) b47485
			${PKG_MAKEFLAGS_INSTALL_EXTRA}					\
Lucio Andrés Illanes Albornoz (arab, vxp) b47485
			AR=${AR} CC=${CC} RANLIB=${RANLIB}				\
Lucio Andrés Illanes Albornoz (arab, vxp) f539a4
			"${PKG_CFLAGS_INSTALL:+CFLAGS=${PKG_CFLAGS_INSTALL}}"				\
Lucio Andrés Illanes Albornoz (arab, vxp) f539a4
			"${PKG_CFLAGS_INSTALL_EXTRA:+CFLAGS+=${PKG_CFLAGS_INSTALL_EXTRA}}"		\
Lucio Andrés Illanes Albornoz (arab, vxp) f539a4
			"${PKG_LDFLAGS_INSTALL:+LDFLAGS=${PKG_LDFLAGS_INSTALL}}"			\
Lucio Andrés Illanes Albornoz (arab, vxp) f539a4
			"${PKG_LDFLAGS_INSTALL_EXTRA:+LDFLAGS+=${PKG_LDFLAGS_INSTALL_EXTRA}}"		\
Lucio Andrés Illanes Albornoz (arab, vxp) f539a4
			"${PKG_RANLIB_INSTALL:+RANLIB=${PKG_RANLIB_INSTALL}}"				\
Lucio Andrés Illanes Albornoz (arab, vxp) f539a4
			${PKG_INSTALL_TARGET:=install};
Lucio Andrés Illanes Albornoz (arab, vxp) f539a4
		if [ -n "${PKG_PREFIX_EXTRA}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) b47485
			run_cmd_unsplit make						\
Lucio Andrés Illanes Albornoz (arab, vxp) b47485
				${PKG_MAKEFLAGS_INSTALL}				\
Lucio Andrés Illanes Albornoz (arab, vxp) b47485
				${PKG_MAKEFLAGS_INSTALL_EXTRA}				\
Lucio Andrés Illanes Albornoz (arab, vxp) b47485
				AR=${AR} CC=${CC} RANLIB=${RANLIB}			\
Lucio Andrés Illanes Albornoz (arab, vxp) f539a4
				"${PKG_CFLAGS_INSTALL:+CFLAGS=${PKG_CFLAGS_INSTALL}}"			\
Lucio Andrés Illanes Albornoz (arab, vxp) f539a4
				"${PKG_CFLAGS_INSTALL_EXTRA:+CFLAGS+=${PKG_CFLAGS_INSTALL_EXTRA}}"	\
Lucio Andrés Illanes Albornoz (arab, vxp) f539a4
				"${PKG_LDFLAGS_INSTALL:+LDFLAGS=${PKG_LDFLAGS_INSTALL}}"		\
Lucio Andrés Illanes Albornoz (arab, vxp) f539a4
				"${PKG_LDFLAGS_INSTALL_EXTRA:+LDFLAGS+=${PKG_LDFLAGS_INSTALL_EXTRA}}"	\
Lucio Andrés Illanes Albornoz (arab, vxp) f539a4
				"${PKG_RANLIB_INSTALL:+RANLIB=${PKG_RANLIB_INSTALL}}"			\
Lucio Andrés Illanes Albornoz (arab, vxp) b47485
				${PKG_INSTALL_TARGET_EXTRA:=install}			\
Lucio Andrés Illanes Albornoz (arab, vxp) f539a4
				DESTDIR=${PKG_PREFIX_EXTRA};
Lucio Andrés Illanes Albornoz (arab, vxp) f539a4
		fi;
Lucio Andrés Illanes Albornoz (arab, vxp) f539a4
	fi;
Lucio Andrés Illanes Albornoz (arab, vxp) f539a4
	pkgp_install_clean_lib;
Lucio Andrés Illanes Albornoz (arab, vxp) bd6eba
	if [ -n "${PKG_INSTALL_FILES}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) bd97b6
		(install_files -v ${PKG_PREFIX} ${PKG_INSTALL_FILES});
Lucio Andrés Illanes Albornoz (arab, vxp) bd6eba
	fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 48fd14
	pkgp_install_libs;
Lucio Andrés Illanes Albornoz (arab, vxp) b47485
	pkgp_install_pkgconfig;
Lucio Andrés Illanes Albornoz (arab, vxp) 570129
};
Lucio Andrés Illanes Albornoz (arab, vxp) 570129
Lucio Andrés Illanes Albornoz (arab, vxp) 570129
# vim:filetype=sh