#!/usr/bin/env bash
#
# $Id$
# Author: Markus Wenzel, TU Muenchen
#
# 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 " -a RDISTDIR refer to RDISTDIR as Isabelle distribution"
echo " in installed files, for packaging scripts"
echo " (default to same value as -d)"
echo " -k VERSION install KDE application icon on desktop"
echo " (for KDE VERSION 1 or 2)"
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=""
RDISTDIR=""
while getopts "d:k:p:a:" OPT
do
case "$OPT" in
d)
DISTDIR="$OPTARG"
NO_OPTS=""
;;
k)
KDE="$OPTARG"
NO_OPTS=""
;;
p)
BINDIR="$OPTARG"
NO_OPTS=""
;;
a)
RDISTDIR="$OPTARG"
NO_OPTS=""
;;
\?)
usage
;;
esac
done
shift $(($OPTIND - 1))
# args
[ "$#" -ne 0 -o -n "$NO_OPTS" ] && usage
if [ -z "$RDISTDIR" ]; then
RDISTDIR=$DISTDIR
fi
## main
echo "referring to distribution at $DISTDIR"
# standalone binaries
#set by configure
AUTO_BASH=/bin/bash
case "$AUTO_BASH" in
/*)
BASH="$AUTO_BASH"
;;
*)
BASH="/usr/bin/env bash"
;;
esac
if [ -n "$BINDIR" ]; then
mkdir -p "$BINDIR" || fail "Bad directory: $BINDIR"
for NAME in isatool isabelle-process isabelle-interface
do
BIN="$BINDIR/$NAME"
DIST="$RDISTDIR/bin/$NAME"
echo "installing $BIN"
echo "#!$BASH" > "$BIN" || fail "Cannot write file: $BIN"
echo >> "$BIN"
echo "exec \"$DIST\" \"\$@\"" >> "$BIN"
chmod +x "$BIN"
done
for NAME in Isabelle isabelle
do
BIN="$BINDIR/$NAME"
DIST="$DISTDIR/bin/$NAME"
echo "installing $BIN"
cp "$DIST" "$BIN" || fail "Cannot write file: $BIN"
chmod +x "$BIN"
done
fi
# install KDE 1.x / 2.x application icon
if [ -n "$KDE" ]; then
if [ "$KDE" = 1 ]; then
KDEHOME=~/.kde
KDEDESKTOP=~/Desktop
KDEAPP="$KDEDESKTOP/Isabelle.kdelnk"
elif [ "$KDE" = 2 ]; then
KDEHOME=~/.kde2
KDEDESKTOP=~/KDesktop
KDEAPP="$KDEDESKTOP/Isabelle.desktop"
else
fail "Unknown KDE version \"$KDE\""
fi
mkdir -p "$KDEDESKTOP" || fail "Bad directory: $KDEDESKTOP"
KDEICONS="$KDEHOME/share/icons"
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=\"$RDISTDIR/bin/isabelle-interface\" %f" >> "$KDEAPP"
echo "Icon=isabelle.xpm" >> "$KDEAPP"
echo "TerminalOptions=" >> "$KDEAPP"
echo "Path=" >> "$KDEAPP"
echo "Terminal=0" >> "$KDEAPP"
echo "Name=Isabelle" >> "$KDEAPP"
fi