summaryrefslogtreecommitdiffhomepage
path: root/build.sh
blob: e49310444a5b3754096dbb1e07b6acb444abf298 (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
37
38
39
40
41
42
43
#!/bin/sh

{
unset AR ARFLAGS CC CFLAGS CXX CXXFLAGS LD LDFLAGS;
. ./build.vars; . ./build.subr;
check_prereqs git make sed tar wget;
log_msg info "Build started by ${USER}@$(hostname).";
#trap
(set -o errexit; mkdir -p "${PREFIX}" "${WORKDIR}");
BUILD_NFINI=${BUILD_NSKIP:=${BUILD_NFAIL:=${_nbuild:=0}}};
for BUILD_LVL in 0 1 2; do
	for BUILD_SCRIPT_FNAME in ${BUILD_LVL}[0-9][0-9].*.build; do
		if [ -n "${DEBUG_SCRIPT}" ]\
		&& [ "x${DEBUG_SCRIPT}" != "x${BUILD_SCRIPT_FNAME}" ]; then
			continue;
		elif [ ! -f "${BUILD_SCRIPT_FNAME}" ]; then
			continue;
		else
			unset BUILD_SCRIPT_RC; : $((_nbuild+=1));
			log_msg info "Invoking build script \`${BUILD_SCRIPT_FNAME}'";
			(set -o errexit -- $(split "." "${BUILD_SCRIPT_FNAME%.build}");	\
			 SCRIPT_FNAME="${BUILD_SCRIPT_FNAME}"; _pwd="$(pwd)";		\
			 cd "${WORKDIR}"; . "${_pwd}/build.subr";		\
			 . "${_pwd}/${BUILD_SCRIPT_FNAME}");
			case ${BUILD_SCRIPT_RC:=${?}} in
			0) log_msg succ "Finished build script \`${BUILD_SCRIPT_FNAME}'.";
				: $((BUILD_NFINI+=1)); continue; ;;
			212) log_msg info "Skipped build script \`${BUILD_SCRIPT_FNAME}' (already built.)";
				: $((BUILD_NSKIP+=1)); BUILD_SCRIPT_RC=0; continue; ;;
			*) log_msg fail "Build failed in build script \`${BUILD_SCRIPT_FNAME}' (last return code ${BUILD_SCRIPT_RC}.).";
				: $((BUILD_NFAIL+=1)); break; ;;
			esac;
		fi;
	done;
	if [ ${BUILD_SCRIPT_RC:-0} != 0 ]; then
		break;
	fi;
done;
log_msg info "${BUILD_NFINI} finished, ${BUILD_NSKIP} skipped, and ${BUILD_NFAIL} failed builds in ${_nbuild} build script(s).";
exit ${BUILD_SCRIPT_RC};
} 2>&1 | tee build.log;

# vim:filetype=sh