#
# gPort
#		Script for examining properties of a platform
#		Part of Generic SETUP (gSETUP)
#
# Author	Stuart Herbert
#		(stuart@gnqs.org)
#
# Copyright	(c) 1998 Stuart Herbert
#		Released under v2 of the GNU GPL


. ../../../../SETUPDir/GSetup-Scripts/GSetup-lib.sh

export GSLIB_V_HEADER=$GPORT_V_HEADER
export GSLIB_V_SHELL=$GPORT_V_SHELL
export GSLIB_V_MAKE=$GPORT_V_MAKE
export GSLIB_V_DESC=$GPORT_V_DIR
export GSLIB_V_SOURCE=$GPORT_V_SOURCE

SCRIPT_EXIT=127

echo 0 > .gslib_def_count

if [ -f ./.gslib_tests ]; then
	rm -f ./.gslib_tests
fi

if [ "$1+" != "+" ]; then
	SCRIPT_LIST="$@"
	GSLIB_QUIET=1
else
	SCRIPT_LIST="`( cd $GPORT_V_DIR ; echo *.sh )`"
	for x in $GSLIB_V_HEADER $GSLIB_V_SHELL $GSLIB_V_SOURCE ; do
		if [ -f $x ]; then
			rm -f $x
		fi
	done
fi

for x in $SCRIPT_LIST ; do
	if [ -f $GPORT_V_DIR/$x ]; then
		export GSLIB_SCRIPT="$GPORT_V_DIR/`basename $x .sh`"
		$our_shell $GPORT_V_DIR/$x
		SCRIPT_EXIT=$?

		for y in test.c test.o test ; do
			if [ -f $y ]; then
				F_WARNING "$x has left $y behind"
			fi
		done

		if [ $SCRIPT_EXIT != 0 ]; then
			rm -f .gslib_def_count
			exit $SCRIPT_EXIT
		fi
	fi
done

F_ECHO_LN
F_ECHO_SEPARATOR
F_ECHO_LN "`cat .gslib_def_count` portability tests are now complete!!!"
F_ECHO_LN "You can review the results in $GPORT_V_SHELL"
F_ECHO_SEPARATOR

rm -f .gslib_def_count
exit $SCRIPT_EXIT
