#!/bin/sh

if [ `id -u` != 0 ] ; then
 echo You need to be root to run $0
 exit 1
fi

if [ -z "$1" ] ; then
 cat <<EOF
$0 compiler-name 

un-registers a Common Lisp compiler to the 
Common-Lisp-Controller system.
EOF
    exit 1
fi


FILE="/usr/lib/common-lisp/bin/$1.sh"

if [ ! -f "$FILE" ] ; then
  cat <<EOF
$0: No implementation of the name $1 is registered 
Cannot find the file $FILE

Maybe you already removed it?
EOF
  exit 0
fi
if [ ! -r "$FILE" ] ; then
  cat <<EOF
$0: No implementation of the name $1 is registered 
Cannot read the file $FILE

Maybe you already removed it?
EOF
  exit 0
fi

#uninstall the defsystem
sh "$FILE" remove-defsystem || echo De-installation defsystem failed  

# Just remove the damn subtree

(cd / ; rm -rf "/usr/lib/common-lisp/${1}/" ; true )

cat <<EOF
$0: Compiler $1 uninstalled
EOF
