#!/bin/sh

MANDIR="/usr/share/man/man1 /usr/man/man1"
BINDIR=/usr/bin

EAGLEDIR=`pwd`

echo=echo
test "$1" = "-q" && echo=false

if test "`basename $0`" = "install"; then
   $echo "Starting EAGLE Installation"
   $echo ""

   $echo -n "installing link to binary in $BINDIR..."
   if ! ln -f -s $EAGLEDIR/bin/eagle $BINDIR; then exit 1; fi
   $echo "done."

   $echo -n "installing man page "
   for i in $MANDIR; do
       if test -d $i; then
          $echo -n "in $i..."
          cp man/eagle.1 $i
          break
          fi
       done
   $echo "done."

   $echo ""
   # this line shall always be displayed!
   echo "EAGLE Installation finished"
else
   $echo "Starting EAGLE Uninstallation"
   $echo ""

   $echo -n "deleting link to binary from $BINDIR..."
   if ! rm -f $BINDIR/eagle; then exit 1; fi
   $echo "done."

   $echo -n "deleting man page "
   for i in $MANDIR; do
       if test -a $i/eagle.1; then
          $echo -n "from $i..."
          rm -f $i/eagle.1
          break
          fi
       done
   $echo "done."

   $echo ""
   $echo "EAGLE Uninstallation finished"
   fi
true
