lib/Tools/install
author wenzelm
Thu Nov 30 20:10:29 2000 +0100 (2000-11-30)
changeset 10555 2323ec838401
parent 10504 d7f5607fbadf
child 11125 b70c3c1b499f
permissions -rwxr-xr-x
/usr/bin/env bash;
wenzelm@10555
     1
#!/usr/bin/env bash
wenzelm@5362
     2
#
wenzelm@5362
     3
# $Id$
wenzelm@9788
     4
# Author: Markus Wenzel, TU Muenchen
wenzelm@9788
     5
# License: GPL (GNU GENERAL PUBLIC LICENSE)
wenzelm@5362
     6
#
wenzelm@6417
     7
# DESCRIPTION: install standalone Isabelle executables
wenzelm@5362
     8
wenzelm@5362
     9
wenzelm@9788
    10
PRG=$(basename "$0")
wenzelm@5362
    11
wenzelm@5362
    12
function usage()
wenzelm@5362
    13
{
wenzelm@5362
    14
  echo
wenzelm@6417
    15
  echo "Usage: $PRG [OPTIONS]"
wenzelm@5362
    16
  echo
wenzelm@5403
    17
  echo "  Options are:"
wenzelm@7887
    18
  echo "    -d DISTDIR   refer to DISTDIR as Isabelle distribution"
wenzelm@7887
    19
  echo "                 (default ISABELLE_HOME)"
wenzelm@6417
    20
  echo "    -k           install KDE application icon on Desktop"
wenzelm@6417
    21
  echo "    -p DIR       install standalone binaries in DIR"
wenzelm@5403
    22
  echo
wenzelm@6417
    23
  echo "  Install Isabelle executables with absolute references to the current"
wenzelm@6417
    24
  echo "  distribution directory."
wenzelm@5362
    25
  echo
wenzelm@5362
    26
  exit 1
wenzelm@5362
    27
}
wenzelm@5362
    28
wenzelm@5362
    29
function fail()
wenzelm@5362
    30
{
wenzelm@5362
    31
  echo "$1" >&2
wenzelm@5362
    32
  exit 2
wenzelm@5362
    33
}
wenzelm@5362
    34
wenzelm@5362
    35
wenzelm@5403
    36
## process command line
wenzelm@5403
    37
wenzelm@5403
    38
# options
wenzelm@5403
    39
wenzelm@6450
    40
NO_OPTS=true
wenzelm@6450
    41
wenzelm@5403
    42
DISTDIR="$ISABELLE_HOME"
wenzelm@6417
    43
KDE=""
wenzelm@6417
    44
BINDIR=""
wenzelm@5362
    45
wenzelm@6417
    46
while getopts "d:kp:" OPT
wenzelm@5403
    47
do
wenzelm@5403
    48
  case "$OPT" in
wenzelm@5404
    49
    d)
wenzelm@5403
    50
      DISTDIR="$OPTARG"
wenzelm@6450
    51
      NO_OPTS=""
wenzelm@5403
    52
      ;;
wenzelm@6417
    53
    k)
wenzelm@6417
    54
      KDE=true
wenzelm@6450
    55
      NO_OPTS=""
wenzelm@6417
    56
      ;;
wenzelm@6417
    57
    p)
wenzelm@6417
    58
      BINDIR="$OPTARG"
wenzelm@6450
    59
      NO_OPTS=""
wenzelm@6417
    60
      ;;
wenzelm@5403
    61
    \?)
wenzelm@5403
    62
      usage
wenzelm@5403
    63
      ;;
wenzelm@5403
    64
  esac
wenzelm@5403
    65
done
wenzelm@5362
    66
wenzelm@5403
    67
shift $(($OPTIND - 1))
wenzelm@5403
    68
wenzelm@5403
    69
wenzelm@5403
    70
# args
wenzelm@5403
    71
wenzelm@9788
    72
[ "$#" -ne 0 -o -n "$NO_OPTS" ] && usage
wenzelm@5362
    73
wenzelm@5362
    74
wenzelm@5362
    75
## main
wenzelm@5362
    76
wenzelm@6459
    77
echo "referring to distribution at $DISTDIR"
wenzelm@6417
    78
wenzelm@6417
    79
wenzelm@6417
    80
# standalone binaries
wenzelm@5362
    81
wenzelm@6082
    82
#set by configure
wenzelm@10555
    83
AUTO_BASH=bash
wenzelm@10555
    84
wenzelm@10555
    85
case "$AUTO_BASH" in
wenzelm@10555
    86
  /*)
wenzelm@10555
    87
    BASH="$AUTO_BASH"
wenzelm@10555
    88
    ;;
wenzelm@10555
    89
  *)
wenzelm@10555
    90
    BASH="/usr/bin/env bash"
wenzelm@10555
    91
    ;;
wenzelm@10555
    92
esac
wenzelm@5362
    93
wenzelm@6417
    94
if [ -n "$BINDIR" ]; then
wenzelm@6417
    95
  mkdir -p "$BINDIR" || fail "Bad directory: $BINDIR"
wenzelm@6417
    96
wenzelm@6417
    97
  for NAME in isatool isabelle Isabelle
wenzelm@6417
    98
  do
wenzelm@6417
    99
    BIN="$BINDIR/$NAME"
wenzelm@6417
   100
    DIST="$DISTDIR/bin/$NAME"
wenzelm@6417
   101
    echo "installing $BIN"
wenzelm@10555
   102
    echo "#!$BASH" > "$BIN" || fail "Cannot write file: $BIN"
wenzelm@9788
   103
    echo >> "$BIN"
wenzelm@9788
   104
    echo "exec \"$DIST\" \"\$@\"" >> "$BIN"
wenzelm@9788
   105
    chmod +x "$BIN"
wenzelm@6417
   106
  done
wenzelm@6417
   107
fi
wenzelm@6417
   108
wenzelm@6417
   109
wenzelm@6417
   110
# install KDE application icon
wenzelm@5403
   111
wenzelm@6417
   112
KDEHOME=~/.kde
wenzelm@6417
   113
KDEAPP=~/Desktop/Isabelle.kdelnk
wenzelm@9788
   114
KDEICONS="$KDEHOME/share/icons"
wenzelm@6417
   115
wenzelm@6417
   116
if [ "$KDE" = true ]; then
wenzelm@9788
   117
  mkdir -p "$KDEICONS" || fail "Bad directory: $KDEICONS"
wenzelm@9788
   118
  mkdir -p "$KDEICONS/mini" || fail "Bad directory: $KDEICONS/mini"
wenzelm@6417
   119
wenzelm@9788
   120
  [ -f "$KDEICONS/isabelle.xpm" ] || cp "$ISABELLE_HOME/lib/icons/isabelle.xpm" "$KDEICONS" || \
wenzelm@6545
   121
    fail "Cannot write file: $KDEICONS/isabelle.xpm"
wenzelm@9788
   122
  [ -f "$KDEICONS/mini/isabelle.xpm" ] || \
wenzelm@9788
   123
    cp "$ISABELLE_HOME/lib/icons/isabelle-mini.xpm" "$KDEICONS/mini/isabelle.xpm" || \
wenzelm@6545
   124
    fail "Cannot write file: $KDEICONS/mini/isabelle.xpm"
wenzelm@6417
   125
wenzelm@6417
   126
  echo "installing $KDEAPP"
wenzelm@9788
   127
  echo "# KDE Config File" > "$KDEAPP" || fail "Cannot write file: $KDEAPP"
wenzelm@9788
   128
  echo "[KDE Desktop Entry]" >> "$KDEAPP"
wenzelm@9788
   129
  echo "Type=Application" >> "$KDEAPP"
wenzelm@10504
   130
  echo "Exec=\"$DISTDIR/bin/Isabelle\" %f" >> "$KDEAPP"
wenzelm@9788
   131
  echo "Icon=isabelle.xpm" >> "$KDEAPP"
wenzelm@9788
   132
  echo "TerminalOptions=" >> "$KDEAPP"
wenzelm@9788
   133
  echo "Path=" >> "$KDEAPP"
wenzelm@9788
   134
  echo "Terminal=0" >> "$KDEAPP"
wenzelm@9788
   135
  echo "Name=Isabelle" >> "$KDEAPP"
wenzelm@6417
   136
wenzelm@10555
   137
  echo
wenzelm@10030
   138
  echo "Please refresh your KDE desktop now!"
wenzelm@6417
   139
fi