lib/Tools/install
author wenzelm
Sun, 20 Jan 2013 13:59:13 +0100
changeset 50990 11996ea98bbe
parent 50132 180d086c30dd
child 52116 abf9fcfa65cf
permissions -rwxr-xr-x
tuned;

#!/usr/bin/env bash
#
# Author: Markus Wenzel, TU Muenchen
#
# DESCRIPTION: install standalone Isabelle executables


PRG=$(basename "$0")

function usage()
{
  echo
  echo "Usage: isabelle $PRG [OPTIONS] BINDIR"
  echo
  echo "  Options are:"
  echo "    -d DISTDIR   refer to DISTDIR as Isabelle distribution"
  echo "                 (default ISABELLE_HOME)"
  echo
  echo "  Install Isabelle executables with absolute references to the"
  echo "  distribution directory."
  echo
  exit 1
}

function fail()
{
  echo "$1" >&2
  exit 2
}


## process command line

# options

DISTDIR="$ISABELLE_HOME"
BINDIR=""

while getopts "d:" OPT
do
  case "$OPT" in
    d)
      DISTDIR="$OPTARG"
      ;;
    \?)
      usage
      ;;
  esac
done

shift $(($OPTIND - 1))


# args

[ "$#" -ge 1 ] && { BINDIR="$1"; shift; }
[ "$#" -ne 0 -o -z "$BINDIR" ] && usage


## main

echo "referring to distribution at \"$DISTDIR\""

mkdir -p "$BINDIR" || fail "Bad directory: \"$BINDIR\""

for NAME in isabelle isabelle-process
do
  BIN="$BINDIR/$NAME"
  DIST="$DISTDIR/bin/$NAME"
  echo "installing $BIN"
  rm -f "$BIN"
  echo "#!/usr/bin/env bash" > "$BIN" || fail "Cannot write file: $BIN"
  echo >> "$BIN"
  echo "exec \"$DIST\" \"\$@\"" >> "$BIN"
  chmod +x "$BIN"
done