#!/bin/sh
# $OpenBSD: DEINSTALL,v 1.1.1.1 2001/07/13 18:53:55 pvalchev Exp $
#
# grace de-installation

set -e
PATH=/bin:/usr/bin:/sbin:/usr/sbin
PREFIX=${PKG_PREFIX:-/usr/local}

NO_X11=`echo "$1" | sed -e "s/.*-no_x11/no_x11/"`

LINKS="$PREFIX/bin/grace \
	$PREFIX/bin/gracebat \
	$PREFIX/include/grace_np.h \
	$PREFIX/lib/libgrace_np.a \
	$PREFIX/man/man1/grace.1 \
	$PREFIX/man/man1/gracebat.1 \
	$PREFIX/man/man1/grconvert.1"

if [ ! $NO_X11 == "no_x11" ]; then
    LINKS="$LINKS $PREFIX/bin/xmgrace \
           $PREFIX/man/man1/xmgrace.1"
fi

for LINK in $LINKS; do
    if [ -L $LINK ]; then
        rm -f $LINK
    else
        echo
        echo "+---------------"
        echo "| Did not delete $LINK, not a link to a $1"
        echo "| file. Please have a look at the file."
        echo "+---------------"
        echo
        ERROR=1
    fi
done

if [ ! $ERROR ]; then
    echo
    echo "+---------------"
    echo "| All links to $1 files are deleted."
    echo "+---------------"
    echo
fi

exit 0
