midipix / build / midipix_build

Forked from build/midipix_build 4 years ago
Clone
Blob Blame History Raw
#
# set -o errexit -o noglob are assumed.
#

pkg_setup_env() {
	if [ -z "${PKG_URL}" ]\
	&& [ -z "${PKG_URLS_GIT}" ]\
	&& [ -z "${PKG_VERSION}" ]\
	&& ! test_cmd "pkg_${PKG_NAME}_all"; then
		log_msg failexit "Error: package \`${PKG_NAME}' missing in build.vars.";
	elif [ "${PKG_DISABLED:-0}" -eq 1 ]; then
		log_msg vnfo "Skipping disabled package \`${PKG_NAME}.'";
		exit 0;
	else
		[ -z "${MIDIPIX_BUILD_PWD}" ] && MIDIPIX_BUILD_PWD="$(pwd)";
		[ -n "${PKG_ENV_VARS_EXTRA}" ] && set_env_vars_with_sep : "${PKG_ENV_VARS_EXTRA}";
		[ -z "${PKG_FNAME}" ] && PKG_FNAME="${PKG_URL##*/}";
		[ -z "${PKG_TARGET}" ] && PKG_TARGET="${TARGET}";
		case "${PKG_BASE_DIR}" in
		?*)	;;
		*)	PKG_BASE_DIR="${WORKDIR}/${PKG_NAME}-${PKG_BUILD_TYPE:-native}-${PKG_TARGET}";
			if [ -n "${ARG_RESTART}" ]\
			&& [ -z "${ARG_RESTART_AT}" ]; then
				build_fileop rm "${PKG_BASE_DIR}";
			fi; ;;
		esac;
		case "${PKG_BUILD_TYPE}" in
		host)	export AR="ar";
			export CC="gcc";
			export CXX="g++";
			export RANLIB="ranlib";
			export MAKE="make LIBTOOL=${PKG_SLIBTOOL:-slibtool}";
			export LIBTOOL="${PKG_SLIBTOOL:-slibtool}"; ;;
		*)	export AR="${PKG_TARGET}-ar";
			export CC="${PKG_TARGET}-gcc";
			export CXX="${PKG_TARGET}-g++";
			export RANLIB="${PKG_TARGET}-ranlib";
			export MAKE="make LIBTOOL=${PKG_SLIBTOOL:-slibtool}";
			export LIBTOOL="${PKG_SLIBTOOL:-slibtool}"; ;;
		esac;
		case "${PKG_SUBDIR}" in
		?*)	;;
		*)	case "${PKG_URLS_GIT}" in
			?*)	PKG_SUBDIR="${PKG_URLS_GIT%%=*}"; ;;
			*)	case "${PKG_FNAME}" in
				*.t*)	PKG_SUBDIR="${PKG_FNAME%%.t*}"; ;;
				*)	PKG_SUBDIR="${PKG_NAME}"; ;;
				esac; ;;
			esac; ;;
		esac;
	fi;
	if [ -n "${PKG_ENV_VARS}" ]; then
		PKG_ENV_VARS="$(echo "${PKG_ENV_VARS}" | tr " " "\n" | sort | tr "\n" " ")";
		log_env_vars "build" ${PKG_ENV_VARS};
	fi;
};

# vim:filetype=sh