#!/bin/sh

#	@(#)checkinstall	13.2 (RC International) 91/03/07
# -------------------------------------------------------------
# |         RESTRICTED RIGHTS LEGEND                          |
# | Use, duplication, or disclosure by the Government is      |
# | subject to restrictions as set forth in subparagraph      |
# | (c)(1)(ii) of the Rights in Technical Data and Computer   |
# | Software Clause at DFARS 252.227-7013.                    |
# |         MIPS Computer Systems, Inc.                       |
# |         928 Arques Avenue                                 |
# |         Sunnyvale, CA 94086                               |
# -------------------------------------------------------------
#
# test installation 

#set -x

PATH=/bin:/usr/bin:/usr/ucb:
export PATH

PKG="`echo $1 | awk '{ FS = "/"; print $(NF-1) }'`"
DRIVER=${DRIVER=$COMP_HOST_ROOT/usr/bin/$PKG}
PKGDIR=${PKGDIR=$COMP_HOST_ROOT/usr/lib/cmplrs/$PKG}
case $PKG in
	   cc*) SAMPLE=${SAMPLE=hello.c} ;;
	   pc*) SAMPLE=${SAMPLE=hello.p} ;;
	  f77*) SAMPLE=${SAMPLE=hello.f} ;;
	  pl1*) SAMPLE=${SAMPLE=hello.pl1} ;;
	cobol*) SAMPLE=${SAMPLE=hello.cob} ;;
	  ada*) SAMPLE=${SAMPLE=hello.a} ;;
	     *) echo "Wrong path given to checkinstall"; exit 1 ;;
esac
 
echo "Compiling and linking test program..."
cd /tmp 
$DRIVER $PKGDIR/$SAMPLE -o hello 2> /dev/null
status=$?
case $status in
	0) echo "Executing test program..."
	   echo ""
	   ./hello 2> /dev/null
	   status=$?
	   case $status in
		0)  echo "" 
		    echo "The compiler installation completed."
		    rm -fr /tmp/hello;;
		*)  echo "The compiler is not installed correctly, check"
		    echo "the installation instructions and try again."
		    rm -fr /tmp/hello
	   	    exit 1;;
	   esac;;
	*) echo "The compiler is not installed correctly, check"
   	   echo "the installation instructions and try again."
	   rm -fr /tmp/hello
	   exit 1;;
esac
