lib/Tools/install
author wenzelm
Sat Dec 20 11:39:27 2008 +0100 (2008-12-20)
changeset 29143 72c960b2b83e
parent 28915 0642cbb60c98
child 50132 180d086c30dd
permissions -rwxr-xr-x
removed Ids;
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@28650
    13
  echo "Usage: isabelle $PRG [OPTIONS]"
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@6417
    18
  echo "    -p DIR       install standalone binaries in DIR"
wenzelm@5403
    19
  echo
wenzelm@6417
    20
  echo "  Install Isabelle executables with absolute references to the current"
wenzelm@6417
    21
  echo "  distribution directory."
wenzelm@5362
    22
  echo
wenzelm@5362
    23
  exit 1
wenzelm@5362
    24
}
wenzelm@5362
    25
wenzelm@5362
    26
function fail()
wenzelm@5362
    27
{
wenzelm@5362
    28
  echo "$1" >&2
wenzelm@5362
    29
  exit 2
wenzelm@5362
    30
}
wenzelm@5362
    31
wenzelm@5362
    32
wenzelm@5403
    33
## process command line
wenzelm@5403
    34
wenzelm@5403
    35
# options
wenzelm@5403
    36
wenzelm@6450
    37
NO_OPTS=true
wenzelm@6450
    38
wenzelm@5403
    39
DISTDIR="$ISABELLE_HOME"
wenzelm@6417
    40
BINDIR=""
wenzelm@5362
    41
wenzelm@16653
    42
while getopts "d:p:" OPT
wenzelm@5403
    43
do
wenzelm@15856
    44
  NO_OPTS=""
wenzelm@5403
    45
  case "$OPT" in
wenzelm@5404
    46
    d)
wenzelm@5403
    47
      DISTDIR="$OPTARG"
wenzelm@5403
    48
      ;;
wenzelm@6417
    49
    p)
wenzelm@6417
    50
      BINDIR="$OPTARG"
aspinall@15733
    51
      ;;
wenzelm@5403
    52
    \?)
wenzelm@5403
    53
      usage
wenzelm@5403
    54
      ;;
wenzelm@5403
    55
  esac
wenzelm@5403
    56
done
wenzelm@5362
    57
wenzelm@5403
    58
shift $(($OPTIND - 1))
wenzelm@5403
    59
wenzelm@5403
    60
wenzelm@5403
    61
# args
wenzelm@5403
    62
wenzelm@9788
    63
[ "$#" -ne 0 -o -n "$NO_OPTS" ] && usage
wenzelm@5362
    64
wenzelm@15848
    65
wenzelm@5362
    66
## main
wenzelm@5362
    67
wenzelm@6459
    68
echo "referring to distribution at $DISTDIR"
wenzelm@6417
    69
wenzelm@6417
    70
wenzelm@6417
    71
# standalone binaries
wenzelm@5362
    72
wenzelm@6417
    73
if [ -n "$BINDIR" ]; then
wenzelm@6417
    74
  mkdir -p "$BINDIR" || fail "Bad directory: $BINDIR"
wenzelm@6417
    75
wenzelm@28915
    76
  for NAME in isabelle isabelle-process
wenzelm@6417
    77
  do
wenzelm@6417
    78
    BIN="$BINDIR/$NAME"
wenzelm@15856
    79
    DIST="$DISTDIR/bin/$NAME"
wenzelm@6417
    80
    echo "installing $BIN"
wenzelm@15848
    81
    rm -f "$BIN"
wenzelm@26577
    82
    echo "#!/usr/bin/env bash" > "$BIN" || fail "Cannot write file: $BIN"
wenzelm@9788
    83
    echo >> "$BIN"
wenzelm@9788
    84
    echo "exec \"$DIST\" \"\$@\"" >> "$BIN"
wenzelm@9788
    85
    chmod +x "$BIN"
wenzelm@6417
    86
  done
wenzelm@6417
    87
fi