lib/Tools/install
author paulson
Tue, 10 Feb 2004 12:02:11 +0100
changeset 14378 69c4d5997669
parent 11550 915c5de6480f
child 14981 e73f8140af78
permissions -rwxr-xr-x
generic of_nat and of_int functions, and generalization of iszero and neg

#!/usr/bin/env bash
#
# $Id$
# Author: Markus Wenzel, TU Muenchen
# License: GPL (GNU GENERAL PUBLIC LICENSE)
#
# 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 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=""

while getopts "d:k:p:" OPT
do
  case "$OPT" in
    d)
      DISTDIR="$OPTARG"
      NO_OPTS=""
      ;;
    k)
      KDE="$OPTARG"
      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=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="$DISTDIR/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=\"$DISTDIR/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