midipix / build / midipix_build

Forked from build/midipix_build 4 years ago
Clone

Blame subr/pkg_setup_env.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) 7fe25d
pkg_setup_env() {
Lucio Andrés Illanes Albornoz (arab, vxp) 48549b
	local	_pkg_name_uc _pkg_name_parent_uc				\
Lucio Andrés Illanes Albornoz (arab, vxp) 48549b
		_vars_fname _vname _build_uc __ _log_env_vars;
Lucio Andrés Illanes Albornoz (arab, vxp) 8ee843
	_pkg_name_uc="$(echo ${PKG_NAME} | tr a-z A-Z)";
Lucio Andrés Illanes Albornoz (arab, vxp) 8ee843
	for _vars_fname in vars/${PKG_NAME}.vars; do
Lucio Andrés Illanes Albornoz (arab, vxp) 8ee843
		[ -e "${_vars_fname}" ] && . "${_vars_fname}";
Lucio Andrés Illanes Albornoz (arab, vxp) 8ee843
	done;
Lucio Andrés Illanes Albornoz (arab, vxp) 48549b
	_build_uc="$(echo ${BUILD} | tr a-z A-Z)";
Lucio Andrés Illanes Albornoz (arab, vxp) 48549b
	if [ -n "${PKG_NAME_PARENT}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 48549b
		_pkg_name_parent_uc="$(echo ${PKG_NAME_PARENT} | tr a-z A-Z)";
Lucio Andrés Illanes Albornoz (arab, vxp) 48549b
		for _vname in PREFIX ${PKG_BUILD_VARS}; do
Lucio Andrés Illanes Albornoz (arab, vxp) 48549b
			for __ in "DEFAULT_${_vname}"				\
Lucio Andrés Illanes Albornoz (arab, vxp) 48549b
				  "${BUILD_TARGET}_${_vname}"			\
Lucio Andrés Illanes Albornoz (arab, vxp) 48549b
				  "PKG_${_pkg_name_parent_uc}_${_vname}"	\
Lucio Andrés Illanes Albornoz (arab, vxp) 48549b
				  "PKG_${_pkg_name_parent_uc}_${_vname}_${_build_uc}"; do
Lucio Andrés Illanes Albornoz (arab, vxp) 70b9d4
				if [ -n "$(get_var_unsafe "${__}")" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 70b9d4
					set_var_unsafe "PKG_${_vname}" "$(get_var_unsafe ${__})";
Lucio Andrés Illanes Albornoz (arab, vxp) 70b9d4
					if ! lmatch "${_log_env_vars}" " " "${__}"; then
Lucio Andrés Illanes Albornoz (arab, vxp) 70b9d4
						_log_env_vars="${_log_env_vars:+${_log_env_vars} }${__}";
Lucio Andrés Illanes Albornoz (arab, vxp) 70b9d4
					fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 70b9d4
				fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 48549b
			done;
Lucio Andrés Illanes Albornoz (arab, vxp) 48549b
		done;
Lucio Andrés Illanes Albornoz (arab, vxp) 48549b
	fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 8ee843
	for _vname in PREFIX ${PKG_BUILD_VARS}; do
Lucio Andrés Illanes Albornoz (arab, vxp) 48549b
		for __ in "DEFAULT_${_vname}"					\
Lucio Andrés Illanes Albornoz (arab, vxp) 48549b
			  "${BUILD_TARGET}_${_vname}"				\
Lucio Andrés Illanes Albornoz (arab, vxp) 48549b
			  "PKG_${_pkg_name_uc}_${_vname}"			\
Lucio Andrés Illanes Albornoz (arab, vxp) 8ee843
			  "PKG_${_pkg_name_uc}_${_vname}_${_build_uc}"; do
Lucio Andrés Illanes Albornoz (arab, vxp) 70b9d4
			if [ -n "$(get_var_unsafe "${__}")" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 70b9d4
				set_var_unsafe "PKG_${_vname}" "$(get_var_unsafe ${__})";
Lucio Andrés Illanes Albornoz (arab, vxp) 70b9d4
				if ! lmatch "${_log_env_vars}" " " "${__}"; then
Lucio Andrés Illanes Albornoz (arab, vxp) 70b9d4
					_log_env_vars="${_log_env_vars:+${_log_env_vars} }${__}";
Lucio Andrés Illanes Albornoz (arab, vxp) 70b9d4
				fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 70b9d4
			fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 8ee843
		done;
Lucio Andrés Illanes Albornoz (arab, vxp) 8ee843
	done;
Lucio Andrés Illanes Albornoz (arab, vxp) 8ee843
	if [ -z "${PKG_URL}" -a -z "${PKG_URLS_GIT}" -a -z "${PKG_VERSION}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 8ee843
		log_msg failexit "Error: package \`${PKG_NAME}' missing in build.vars.";
Lucio Andrés Illanes Albornoz (arab, vxp) 570129
	else
Lucio Andrés Illanes Albornoz (arab, vxp) 8ee843
		[ -n "${PKG_ENV_VARS_EXTRA}" ] && set_env_vars_with_sep : "${PKG_ENV_VARS_EXTRA}";
Lucio Andrés Illanes Albornoz (arab, vxp) 8ee843
		[ -z "${PKG_FNAME}" ] && PKG_FNAME="${PKG_URL##*/}";
Lucio Andrés Illanes Albornoz (arab, vxp) b19456
		[ -z "${PKG_SUBDIR}" ] && PKG_SUBDIR="${PKG_FNAME%%.t*}";
Lucio Andrés Illanes Albornoz (arab, vxp) 8ee843
		[ -z "${PKG_TARGET}" ] && PKG_TARGET="${TARGET}";
Lucio Andrés Illanes Albornoz (arab, vxp) 8ee843
		[ -z "${MIDIPIX_BUILD_PWD}" ] && MIDIPIX_BUILD_PWD="$(pwd)";
Lucio Andrés Illanes Albornoz (arab, vxp) d5afb4
		if [ -z "${PKG_BUILD_DIR}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) d5afb4
			set_build_dir "${PKG_SUBDIR}" "${PKG_BUILD_TYPE:-native}";
Lucio Andrés Illanes Albornoz (arab, vxp) d5afb4
		fi;
Lucio Andrés Illanes Albornoz (arab, vxp) d5afb4
		if [ "${PKG_BUILD_TYPE}" = "host" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) d5afb4
			export AR="ar";
Lucio Andrés Illanes Albornoz (arab, vxp) d5afb4
			export CC="gcc";
Lucio Andrés Illanes Albornoz (arab, vxp) d5afb4
			export CXX="g++";
Lucio Andrés Illanes Albornoz (arab, vxp) d5afb4
			export RANLIB="ranlib";
Lucio Andrés Illanes Albornoz (arab, vxp) d5afb4
		else
Lucio Andrés Illanes Albornoz (arab, vxp) d5afb4
			export AR="${PKG_TARGET}-ar";
Lucio Andrés Illanes Albornoz (arab, vxp) d5afb4
			export CC="${PKG_TARGET}-gcc";
Lucio Andrés Illanes Albornoz (arab, vxp) d5afb4
			export CXX="${PKG_TARGET}-g++";
Lucio Andrés Illanes Albornoz (arab, vxp) d5afb4
			export RANLIB="${PKG_TARGET}-ranlib";
Lucio Andrés Illanes Albornoz (arab, vxp) d5afb4
		fi;
Lucio Andrés Illanes Albornoz (arab, vxp) d5afb4
		if [ "${PKG_SLIBTOOL}" != "default" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 557c73
			export LIBTOOL="${PKG_SLIBTOOL:-slibtool}";
Lucio Andrés Illanes Albornoz (arab, vxp) d5afb4
			export MAKE="make LIBTOOL=${PKG_SLIBTOOL:-slibtool}";
Lucio Andrés Illanes Albornoz (arab, vxp) d5afb4
		fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 570129
	fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 8ee843
	if [ -n "${_log_env_vars}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 70b9d4
		_log_env_vars="$(echo "${_log_env_vars}" | tr " " "\n" | sort | tr "\n" " ")";
Lucio Andrés Illanes Albornoz (arab, vxp) 8ee843
 		log_env_vars "build" ${_log_env_vars};
Lucio Andrés Illanes Albornoz (arab, vxp) 570129
	fi;
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