#!/bin/bash
#
# $Id$
#
# DESCRIPTION: install standalone Isabelle executables
PRG=$(basename $0)
function usage()
{
echo
echo "Usage: $PRG [OPTIONS]"
echo
echo " Options are:"
echo " -d DISTDIR refer to DISTDIR as Isabelle distribution"
echo " (default ISABELLE_HOME)"
echo " -k install KDE application icon on Desktop"
echo " -p DIR install standalone binaries in DIR"
echo
echo " Install Isabelle executables with absolute references to the current"
echo " distribution directory."
echo
exit 1
}
function fail()
{
echo "$1" >&2
exit 2
}
## process command line
# options
NO_OPTS=true
DISTDIR="$ISABELLE_HOME"
KDE=""
BINDIR=""
while getopts "d:kp:" OPT
do
case "$OPT" in
d)
DISTDIR="$OPTARG"
NO_OPTS=""
;;
k)
KDE=true
NO_OPTS=""
;;
p)
BINDIR="$OPTARG"
NO_OPTS=""
;;
\?)
usage
;;
esac
done
shift $(($OPTIND - 1))
# args
[ $# -ne 0 -o -n "$NO_OPTS" ] && usage
## main
echo "referring to distribution at $DISTDIR"
# standalone binaries
#set by configure
AUTO_BASH=/bin/bash
if [ -n "$BINDIR" ]; then
mkdir -p "$BINDIR" || fail "Bad directory: $BINDIR"
for NAME in isatool isabelle Isabelle
do
BIN="$BINDIR/$NAME"
DIST="$DISTDIR/bin/$NAME"
echo "installing $BIN"
echo "#!$AUTO_BASH" >$BIN || fail "Cannot write file: $BIN"
echo >>$BIN
echo "exec $DIST \"\$@\"" >>$BIN
chmod +x $BIN
done
fi
# install KDE application icon
KDEHOME=~/.kde
KDEAPP=~/Desktop/Isabelle.kdelnk
KDEICONS=$KDEHOME/share/icons
if [ "$KDE" = true ]; then
mkdir -p $KDEICONS || fail "Bad directory: $KDEICONS"
mkdir -p $KDEICONS/mini || fail "Bad directory: $KDEICONS/mini"
[ -f $KDEICONS/isabelle.xpm ] || cp $ISABELLE_HOME/lib/icons/isabelle.xpm $KDEICONS || \
fail "Cannot write file: $KDEICONS/isabelle.xpm"
[ -f $KDEICONS/mini/isabelle.xpm ] || \
cp $ISABELLE_HOME/lib/icons/isabelle-mini.xpm $KDEICONS/mini/isabelle.xpm || \
fail "Cannot write file: $KDEICONS/mini/isabelle.xpm"
echo "installing $KDEAPP"
echo "# KDE Config File" >$KDEAPP || fail "Cannot write file: $KDEAPP"
echo "[KDE Desktop Entry]" >>$KDEAPP
echo "Type=Application" >>$KDEAPP
echo "Exec=$DISTDIR/bin/Isabelle" >>$KDEAPP
echo "Icon=isabelle.xpm" >>$KDEAPP
echo "TerminalOptions=" >>$KDEAPP
echo "Path=" >>$KDEAPP
echo "Terminal=0" >>$KDEAPP
echo "Name=Isabelle" >>$KDEAPP
type -p kfmclient >/dev/null && kfmclient refreshDesktop
fi