Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
BUILD_ARGS_SPEC="
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
	ARG_IPV4_ONLY:-4
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
	ARG_IPV6_ONLY:-6
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
	ARCH:arg:-a
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
	BUILD:arg:-b
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
	ARG_CLEAN:-c
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
	ARG_DEBUG_MINIPIX:--debug-minipix
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
	ARG_OFFLINE:-N
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
	ARG_RELAXED:-R
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
	ARG_RESTART:arg:-r
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
	ARG_TARBALL:selfarg:-t
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
	ARG_TARBALL:selfarg:-t.bz2
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
	ARG_TARBALL:selfarg:-t.gz
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
	ARG_TARBALL:selfarg:-t.xz
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	ARG_VERBOSE:selfarg:-v
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	ARG_VERBOSE:selfarg:-vv
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	ARG_VERBOSE:selfarg:-vvv
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
	ARG_XTRACE:-x";
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
build_args() {
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
	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) f6a5cb
			*:${1})	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) 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 (arab, vxp) f6a5cb
	if [ -n "${ARG_TARBALL}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
		if [ "${ARG_TARBALL#-t.}" != "${ARG_TARBALL}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
			TARBALL_SUFFIX="${ARG_TARBALL#-t.}";
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
		else
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
			TARBALL_SUFFIX=xz;
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
		fi;
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
	fi;
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	case "${ARG_VERBOSE}" in
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	-v)	ARG_VERBOSE=1; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	-vv)	ARG_VERBOSE=2; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	-vvv)	ARG_VERBOSE=3; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	esac;
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	if [ "${ARG_XTRACE:-0}" -eq 1 ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		ARG_VERBOSE=2;
Lucio Andrés Illanes Albornoz (arab, vxp) 648b81
	fi;
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
	if [ -n "${ARG_RESTART}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
		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) ec19f0
		ARG_RESTART="$(echo ${ARG_RESTART} | sed "s/,/ /g")";
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
	fi;
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) f6a5cb
	*)	BUILD_TARGETS_META="${BUILD_TARGETS_META:+${BUILD_TARGETS_META} }${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