#!/bin/sh
#
# Copyright 1990,91,92,93,94  by Thomas Roell, Germany.
# Copyright 1993,94           by X Inside Inc, USA.
# All Rights Reserved.
#

## begin shared

unset SCOMPAT

XACCELHOME=
XARCH=
XOS=
XLIB=/usr/lib/X11
XBIN=/usr/bin/X11

if [ -x /bin/uname ]
then
	implementation="`/bin/uname -s`"
	release="`/bin/uname -r`"
else
	implementation="`/usr/bin/uname -s`"
	release="`/usr/bin/uname -r`"
fi

case "$implementation" in
"SINIX-D" | "SINIX-Z" )
	XARCH=SVR4
	XOS=SINIX
	;;

"SunOS" )
	XARCH=SVR4
	XOS=SOLARIS
	XLIB=/usr/openwin/lib
	XBIN=/usr/openwin/bin
	;;

"Linux" )
	XARCH=LINUX
	XOS=LINUX
	;;

"FreeBSD" )
	XARCH=FreeBSD
	XOS=FreeBSD
	;;

"BSD/386" )
	XARCH=BSDI
	XOS=BSDI
	XLIB=/usr/X11/lib/X11
	XBIN=/usr/X11/bin
	;;

*)
	case "$release" in
	"4.2" | "4.2MP" )
		XARCH=SVR4
		XOS=SVR4.2
		XLIB=/usr/X/lib
		XBIN=/usr/X/bin
		;;

	"4.0" | "4.1" )
		XARCH=SVR4
		XOS=SVR4
		;;

	"3.2" )
		if [ -f /etc/perms/rts ]
		then	
		        XARCH=SCO
			XOS=SCO
		else
		        XARCH=ISC
			XOS=ISC
		fi
		;;
	esac
	;;
esac

if [ -d /usr/X386/lib/X11 ]
then
	XLIB=/usr/X386/lib/X11
	XBIN=/usr/X386/bin
fi

if [ "x$XARCH" = "$XARCH" ]
then
	echo "Unkown Architecture"
	exit -1
fi

XACCELHOME=$XLIB/AcceleratedX

export XACCELHOME XARCH XBIN XLIB XOS

## end shared

if [ ! -d $XACCELHOME/arch/$XARCH ]
then
	echo "Support for $XARCH not installed"
	exit -2
fi

##
## Execute XOS dependent uninstall script first, and then the XARCH dependent
## one. Those will uninstall device drivers and similar things.
##
if [ -f $XACCELHOME/arch/$XARCH/$XOS/Uninstall.sh ]
then
	cd $XACCELHOME/arch/$XARCH/$XOS
	/bin/sh ./Uninstall.sh
fi

if [ -f $XACCELHOME/arch/$XARCH/Uninstall.sh ]
then
	cd $XACCELHOME/arch/$XARCH
	/bin/sh ./Uninstall.sh
fi

##
## Remove the Xaccel & Xsetup scripts from $XBIN, and restore the old
## X-Server.
##

rm $XBIN/Xaccel >/dev/null 2>&1
rm $XBIN/Xsetup >/dev/null 2>&1

##
## Restore the old X server
##

/bin/rm -f $XBIN/X >/dev/null 2>&1

if [ -x $XBIN/X.$XOS ]
then
	/bin/mv $XBIN/X.$XOS $XBIN/X
fi

exit 0