Lucio Andrés Illanes Albornoz (arab, vxp) 0185bc
#
Lucio Andrés Illanes Albornoz (arab, vxp) 0185bc
# set -o noglob is assumed.
Lucio Andrés Illanes Albornoz (arab, vxp) 0185bc
#
Lucio Andrés Illanes Albornoz (arab, vxp) 0185bc
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
BUILD_ARGS_SPEC="
Lucio Andrés Illanes Albornoz 0eaee4
	ARCH:arg:-a:
Lucio Andrés Illanes Albornoz 0eaee4
	ARG_AS_NEEDED:--as-needed:
Lucio Andrés Illanes Albornoz (arab, vxp) 19ab70
	ARG_CLEAN_BUILDS:arg:-C:
Lucio Andrés Illanes Albornoz (arab, vxp) cbc8e0
	ARG_DEBUG_MINIPIX:--debug-minipix:
Lucio Andrés Illanes Albornoz 0eaee4
	ARG_DIST:arg:-D:
Lucio Andrés Illanes Albornoz d279a9
	ARG_FETCH_FORCE:-F:
Lucio Andrés Illanes Albornoz (arab, vxp) cbc8e0
	ARG_PARALLEL:optarg:-P:auto
Lucio Andrés Illanes Albornoz (arab, vxp) cbc8e0
	ARG_RELAXED:-R:
Lucio Andrés Illanes Albornoz (arab, vxp) cbc8e0
	ARG_RESTART:arg:-r:
Lucio Andrés Illanes Albornoz (arab, vxp) cbc8e0
	ARG_VERBOSE:selfarg:-v:
Lucio Andrés Illanes Albornoz (arab, vxp) cbc8e0
	ARG_VERBOSE:selfarg:-vv:
Lucio Andrés Illanes Albornoz (arab, vxp) cbc8e0
	ARG_VERBOSE:selfarg:-vvv:
Lucio Andrés Illanes Albornoz f0dfe1
	ARG_VERBOSE:selfarg:-vvvv:
Lucio Andrés Illanes Albornoz 0eaee4
	BUILD:arg:-b:";
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
build_args() {
Lucio Andrés Illanes Albornoz 907bd3
	local _spec="${BUILD_ARGS_SPEC}" _spec_arg="" _found="";
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
	while [ ${#} -gt 0 ]; do
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
		if [ "${1#-}" = "${1}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
			break;
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
		fi;
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
		for _spec_arg in ${_spec}; do
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
			case "${_spec_arg}" in
Lucio Andrés Illanes Albornoz (arab, vxp) cbc8e0
			*:${1}:*)
Lucio Andrés Illanes Albornoz (arab, vxp) cbc8e0
				case "${_spec_arg#*:}" in
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
				arg:*)
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
					ex_rtl_set_var_unsafe "${_spec_arg%%:*}" "${2}"; shift; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) cbc8e0
				optarg:*)
Lucio Andrés Illanes Albornoz (arab, vxp) cbc8e0
					if [ -n "${2}" ]\
Lucio Andrés Illanes Albornoz (arab, vxp) cbc8e0
					&& [ "x${2#-}" = "x${2}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) cbc8e0
						ex_rtl_set_var_unsafe "${_spec_arg%%:*}" "${2}";
Lucio Andrés Illanes Albornoz (arab, vxp) cbc8e0
						shift;
Lucio Andrés Illanes Albornoz (arab, vxp) cbc8e0
					else
Lucio Andrés Illanes Albornoz (arab, vxp) cbc8e0
						ex_rtl_set_var_unsafe "${_spec_arg%%:*}"	\
Lucio Andrés Illanes Albornoz (arab, vxp) cbc8e0
							"${_spec_arg##*:}";
Lucio Andrés Illanes Albornoz (arab, vxp) cbc8e0
					fi; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
				selfarg:*)
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
					ex_rtl_set_var_unsafe "${_spec_arg%%:*}" "${1}"; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
				*)
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
					ex_rtl_set_var_unsafe "${_spec_arg%%:*}" 1; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
				esac; _found=1; break; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
			*)	_found=0; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
			esac;
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
		done;
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
		if [ "${_found:-0}" -eq 0 ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
			exec cat etc/build.usage;
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
		else
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
			shift;
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
		fi;
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
	done;
Lucio Andrés Illanes Albornoz f84af6
	if ex_rtl_lmatch "${ARG_DIST}" , tbz2	\
Lucio Andrés Illanes Albornoz f84af6
	|| ex_rtl_lmatch "${ARG_DIST}" , tgz	\
Lucio Andrés Illanes Albornoz f84af6
	|| ex_rtl_lmatch "${ARG_DIST}" , txz	\
Lucio Andrés Illanes Albornoz f84af6
	|| ex_rtl_lmatch "${ARG_DIST}" , zipdist; then
Lucio Andrés Illanes Albornoz f84af6
		if ! ex_rtl_lmatch "${ARG_DIST}" , minipix; then
Lucio Andrés Illanes Albornoz f84af6
			ARG_DIST="${ARG_DIST:+${ARG_DIST},}minipix";
Lucio Andrés Illanes Albornoz f84af6
		fi;
Lucio Andrés Illanes Albornoz f84af6
	fi;
Lucio Andrés Illanes Albornoz cc86a5
	case "${ARG_RESTART}" in
Lucio Andrés Illanes Albornoz cc86a5
	ALL)	ARG_RESTART_AT=ALL; ;;
Lucio Andrés Illanes Albornoz cc86a5
	LAST)	ARG_RESTART_AT=""; ;;
Lucio Andrés Illanes Albornoz cc86a5
	"")	;;
Lucio Andrés Illanes Albornoz cc86a5
	*)	if [ "${ARG_RESTART%:*}" != "${ARG_RESTART}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
			ARG_RESTART_AT="${ARG_RESTART#*:}"; ARG_RESTART="${ARG_RESTART%:*}";
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		else
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
			ARG_RESTART_AT=ALL;
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
		fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 19ab70
		ARG_RESTART="$(echo "${ARG_RESTART}" | sed "s/,/ /g")";
Lucio Andrés Illanes Albornoz cc86a5
		;;
Lucio Andrés Illanes Albornoz cc86a5
	esac;
Lucio Andrés Illanes Albornoz f0dfe1
	case "${ARG_VERBOSE}" in
Lucio Andrés Illanes Albornoz f0dfe1
	-v)	ARG_VERBOSE=1; ;;
Lucio Andrés Illanes Albornoz f0dfe1
	-vv)	ARG_VERBOSE=2; ;;
Lucio Andrés Illanes Albornoz f0dfe1
	-vvv)	ARG_VERBOSE=3; ;;
Lucio Andrés Illanes Albornoz f0dfe1
	-vvvv)	ARG_VERBOSE=4; ;;
Lucio Andrés Illanes Albornoz f0dfe1
	esac;
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
	while [ ${#} -gt 0 ]; do
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
	case "${1}" in
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	*=*)	ex_rtl_set_var_unsafe "${1%%=*}" "${1#*=}"; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) 1dfec6
	*)	BUILD_TARGETS="${BUILD_TARGETS:+${BUILD_TARGETS} }${1}"; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
	esac; shift; done;
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
};
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
# vim:filetype=sh