#!/bin/bash
# 2008, 2011, 2013 Etersoft www.etersoft.ru
# Author: Vitaly Lipatov <lav@etersoft.ru>
# Public domain


__check_string()
{
	local LOGFILE="$1"
	shift
	local NC="$@"
	grep -- "$NC" $LOGFILE && warning "'$NC' problem exists in the build output"
}

check_log()
{
	local LOGFILE i RES
	echo
	echo "-------------------------------------------------------"
	LOGFILE=$1
	echog "Check log $LOGFILE for..."

	# obsoleted
	if grep -q 'ld: warning: libstdc++\.so\.5, needed by [^ ]\+, may conflict with libstdc++\.so\.6' $LOGFILE ; then
		echog "Error found: libstdc++.so.5/6 conflicts. Check the log."
		return 1
	fi

	if grep -q 'will always overflow destination buffer' $LOGFILE ; then
		echog "Error found: will always overflow destination buffer. Check the log."
		return 1
	fi

	local i
	for i in	"python-strict" \
			"command not found" \
			"-march=athlon -mtune=athlon-xp" \
			"WARNING:"; do
		__check_string $LOGFILE "$i"
	done

	return 0
}
