lib/Tools/install
author wenzelm
Sun Apr 06 16:59:41 2014 +0200 (2014-04-06)
changeset 56439 95e2656b3b23
parent 52116 abf9fcfa65cf
child 62588 cd266473b81b
permissions -rwxr-xr-x
renamed "isabelle-process" to "isabelle_process", with shell function to avoid dynamic path lookups;
wenzelm@10555
     1
#!/usr/bin/env bash
wenzelm@5362
     2
#
wenzelm@9788
     3
# Author: Markus Wenzel, TU Muenchen
wenzelm@5362
     4
#
wenzelm@6417
     5
# DESCRIPTION: install standalone Isabelle executables
wenzelm@5362
     6
wenzelm@5362
     7
wenzelm@9788
     8
PRG=$(basename "$0")
wenzelm@5362
     9
wenzelm@5362
    10
function usage()
wenzelm@5362
    11
{
wenzelm@5362
    12
  echo
wenzelm@50132
    13
  echo "Usage: isabelle $PRG [OPTIONS] BINDIR"
wenzelm@5362
    14
  echo
wenzelm@5403
    15
  echo "  Options are:"
wenzelm@7887
    16
  echo "    -d DISTDIR   refer to DISTDIR as Isabelle distribution"
wenzelm@7887
    17
  echo "                 (default ISABELLE_HOME)"
wenzelm@5403
    18
  echo
wenzelm@50132
    19
  echo "  Install Isabelle executables with absolute references to the"
wenzelm@6417
    20
  echo "  distribution directory."
wenzelm@5362
    21
  echo
wenzelm@5362
    22
  exit 1
wenzelm@5362
    23
}
wenzelm@5362
    24
wenzelm@5362
    25
function fail()
wenzelm@5362
    26
{
wenzelm@5362
    27
  echo "$1" >&2
wenzelm@5362
    28
  exit 2
wenzelm@5362
    29
}
wenzelm@5362
    30
wenzelm@5362
    31
wenzelm@5403
    32
## process command line
wenzelm@5403
    33
wenzelm@5403
    34
# options
wenzelm@5403
    35
wenzelm@5403
    36
DISTDIR="$ISABELLE_HOME"
wenzelm@6417
    37
BINDIR=""
wenzelm@5362
    38
wenzelm@50132
    39
while getopts "d:" OPT
wenzelm@5403
    40
do
wenzelm@5403
    41
  case "$OPT" in
wenzelm@5404
    42
    d)
wenzelm@5403
    43
      DISTDIR="$OPTARG"
wenzelm@5403
    44
      ;;
wenzelm@5403
    45
    \?)
wenzelm@5403
    46
      usage
wenzelm@5403
    47
      ;;
wenzelm@5403
    48
  esac
wenzelm@5403
    49
done
wenzelm@5362
    50
wenzelm@5403
    51
shift $(($OPTIND - 1))
wenzelm@5403
    52
wenzelm@5403
    53
wenzelm@5403
    54
# args
wenzelm@5403
    55
wenzelm@50132
    56
[ "$#" -ge 1 ] && { BINDIR="$1"; shift; }
wenzelm@50132
    57
[ "$#" -ne 0 -o -z "$BINDIR" ] && usage
wenzelm@5362
    58
wenzelm@15848
    59
wenzelm@5362
    60
## main
wenzelm@5362
    61
wenzelm@50132
    62
echo "referring to distribution at \"$DISTDIR\""
wenzelm@6417
    63
wenzelm@50132
    64
mkdir -p "$BINDIR" || fail "Bad directory: \"$BINDIR\""
wenzelm@6417
    65
wenzelm@56439
    66
for NAME in isabelle isabelle_process isabelle_scala_script
wenzelm@50132
    67
do
wenzelm@50132
    68
  BIN="$BINDIR/$NAME"
wenzelm@50132
    69
  DIST="$DISTDIR/bin/$NAME"
wenzelm@50132
    70
  echo "installing $BIN"
wenzelm@50132
    71
  rm -f "$BIN"
wenzelm@50132
    72
  echo "#!/usr/bin/env bash" > "$BIN" || fail "Cannot write file: $BIN"
wenzelm@50132
    73
  echo >> "$BIN"
wenzelm@50132
    74
  echo "exec \"$DIST\" \"\$@\"" >> "$BIN"
wenzelm@50132
    75
  chmod +x "$BIN"
wenzelm@50132
    76
done
wenzelm@50132
    77