summaryrefslogtreecommitdiffhomepage
path: root/subr/ex_setup_env.subr
blob: 8907d7eb11d2da35fcbf9af5f23d846a88f761fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
ex_setup_env() {
	local __;
	set -o noglob;
	if [ -z "${DEFAULT_BUILD_CPUS}" ]\
	&& [ -e /proc/cpuinfo ]; then
		DEFAULT_BUILD_CPUS=$(awk '/^processor/{cpus++} END{print cpus}' /proc/cpuinfo);
	fi;
	: ${ARCH:=nt64}; : ${BUILD:=debug};
	if [ "${ARCH}" = nt32 ]; then
		TARGET="i686-nt32-midipix";
	elif [ "${ARCH}" = nt64 ]; then
		TARGET="x86_64-nt64-midipix";
	else
		if [ "${BUILD}" != debug ]\
		&& [ "${BUILD}" != release ]; then
			ex_log_msg failexit "Error: unknown build type \`${BUILD}'.";
		fi;
		ex_log_msg failexit "Error: invalid architecture \`${ARCH}'.";
	fi;
	for __ in ${HOME}/midipix_build.vars ../midipix_build.vars ./vars/env.vars ./vars/build.vars; do
		[ -e ${__} ] && . ${__};
	done;
	export PATH="${PREFIX}/bin${PATH:+:${PATH}}";
	if [ ${ARG_IPV4_ONLY:-0} -eq 1 ]; then
		DEFAULT_WGET_ARGS="-4${DEFAULT_WGET_ARGS:+ ${DEFAULT_WGET_ARGS}}";
	elif [ ${ARG_IPV6_ONLY:-0} -eq 1 ]; then
		DEFAULT_WGET_ARGS="-6${DEFAULT_WGET_ARGS:+ ${DEFAULT_WGET_ARGS}}";
	fi;
	for __ in $(export | sed -e 's/^export //' -e 's/=.*$//'); do
		if ! ex_lmatch "${CLEAR_ENV_VARS_EXCEPT}" " " "${__}"; then
			unset "${__}";
		fi;
	done;
};

# vim:filetype=sh