lib/Tools/install
author wenzelm
Tue Apr 08 15:47:12 2008 +0200 (2008-04-08)
changeset 26577 50f47cc2af72
parent 16653 c12c2f411f77
child 28504 7ad7d7d6df47
permissions -rwxr-xr-x
removed obsolete AUTO_BASH feature;
wenzelm@10555
     1
#!/usr/bin/env bash
wenzelm@5362
     2
#
wenzelm@5362
     3
# $Id$
wenzelm@9788
     4
# Author: Markus Wenzel, TU Muenchen
wenzelm@5362
     5
#
wenzelm@6417
     6
# DESCRIPTION: install standalone Isabelle executables
wenzelm@5362
     7
wenzelm@5362
     8
wenzelm@9788
     9
PRG=$(basename "$0")
wenzelm@5362
    10
wenzelm@5362
    11
function usage()
wenzelm@5362
    12
{
wenzelm@5362
    13
  echo
wenzelm@6417
    14
  echo "Usage: $PRG [OPTIONS]"
wenzelm@5362
    15
  echo
wenzelm@5403
    16
  echo "  Options are:"
wenzelm@7887
    17
  echo "    -d DISTDIR   refer to DISTDIR as Isabelle distribution"
wenzelm@7887
    18
  echo "                 (default ISABELLE_HOME)"
wenzelm@6417
    19
  echo "    -p DIR       install standalone binaries in DIR"
wenzelm@5403
    20
  echo
wenzelm@6417
    21
  echo "  Install Isabelle executables with absolute references to the current"
wenzelm@6417
    22
  echo "  distribution directory."
wenzelm@5362
    23
  echo
wenzelm@5362
    24
  exit 1
wenzelm@5362
    25
}
wenzelm@5362
    26
wenzelm@5362
    27
function fail()
wenzelm@5362
    28
{
wenzelm@5362
    29
  echo "$1" >&2
wenzelm@5362
    30
  exit 2
wenzelm@5362
    31
}
wenzelm@5362
    32
wenzelm@5362
    33
wenzelm@5403
    34
## process command line
wenzelm@5403
    35
wenzelm@5403
    36
# options
wenzelm@5403
    37
wenzelm@6450
    38
NO_OPTS=true
wenzelm@6450
    39
wenzelm@5403
    40
DISTDIR="$ISABELLE_HOME"
wenzelm@6417
    41
BINDIR=""
wenzelm@5362
    42
wenzelm@16653
    43
while getopts "d:p:" OPT
wenzelm@5403
    44
do
wenzelm@15856
    45
  NO_OPTS=""
wenzelm@5403
    46
  case "$OPT" in
wenzelm@5404
    47
    d)
wenzelm@5403
    48
      DISTDIR="$OPTARG"
wenzelm@5403
    49
      ;;
wenzelm@6417
    50
    p)
wenzelm@6417
    51
      BINDIR="$OPTARG"
aspinall@15733
    52
      ;;
wenzelm@5403
    53
    \?)
wenzelm@5403
    54
      usage
wenzelm@5403
    55
      ;;
wenzelm@5403
    56
  esac
wenzelm@5403
    57
done
wenzelm@5362
    58
wenzelm@5403
    59
shift $(($OPTIND - 1))
wenzelm@5403
    60
wenzelm@5403
    61
wenzelm@5403
    62
# args
wenzelm@5403
    63
wenzelm@9788
    64
[ "$#" -ne 0 -o -n "$NO_OPTS" ] && usage
wenzelm@5362
    65
wenzelm@15848
    66
wenzelm@5362
    67
## main
wenzelm@5362
    68
wenzelm@6459
    69
echo "referring to distribution at $DISTDIR"
wenzelm@6417
    70
wenzelm@6417
    71
wenzelm@6417
    72
# standalone binaries
wenzelm@5362
    73
wenzelm@6417
    74
if [ -n "$BINDIR" ]; then
wenzelm@6417
    75
  mkdir -p "$BINDIR" || fail "Bad directory: $BINDIR"
wenzelm@6417
    76
wenzelm@11550
    77
  for NAME in isatool isabelle-process isabelle-interface
wenzelm@6417
    78
  do
wenzelm@6417
    79
    BIN="$BINDIR/$NAME"
wenzelm@15856
    80
    DIST="$DISTDIR/bin/$NAME"
wenzelm@6417
    81
    echo "installing $BIN"
wenzelm@15848
    82
    rm -f "$BIN"
wenzelm@26577
    83
    echo "#!/usr/bin/env bash" > "$BIN" || fail "Cannot write file: $BIN"
wenzelm@9788
    84
    echo >> "$BIN"
wenzelm@9788
    85
    echo "exec \"$DIST\" \"\$@\"" >> "$BIN"
wenzelm@9788
    86
    chmod +x "$BIN"
wenzelm@6417
    87
  done
wenzelm@11550
    88
  for NAME in Isabelle isabelle
wenzelm@11550
    89
  do
wenzelm@11550
    90
    BIN="$BINDIR/$NAME"
wenzelm@11550
    91
    echo "installing $BIN"
wenzelm@15848
    92
    rm -f "$BIN"
wenzelm@15856
    93
    cp "$ISABELLE_HOME/bin/$NAME" "$BIN" || fail "Cannot write file: $BIN"
wenzelm@11550
    94
    chmod +x "$BIN"
wenzelm@11550
    95
  done
wenzelm@6417
    96
fi