lib/Tools/install
author wenzelm
Sat Sep 08 20:00:31 2001 +0200 (2001-09-08)
changeset 11550 915c5de6480f
parent 11127 e43723fff70c
child 14981 e73f8140af78
permissions -rwxr-xr-x
smart selection of isabelle-process versus isabelle-interface;
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@11125
    20
  echo "    -k VERSION   install KDE application icon on desktop"
wenzelm@11125
    21
  echo "                 (for KDE VERSION 1 or 2)"
wenzelm@6417
    22
  echo "    -p DIR       install standalone binaries in DIR"
wenzelm@5403
    23
  echo
wenzelm@6417
    24
  echo "  Install Isabelle executables with absolute references to the current"
wenzelm@6417
    25
  echo "  distribution directory."
wenzelm@5362
    26
  echo
wenzelm@5362
    27
  exit 1
wenzelm@5362
    28
}
wenzelm@5362
    29
wenzelm@5362
    30
function fail()
wenzelm@5362
    31
{
wenzelm@5362
    32
  echo "$1" >&2
wenzelm@5362
    33
  exit 2
wenzelm@5362
    34
}
wenzelm@5362
    35
wenzelm@5362
    36
wenzelm@5403
    37
## process command line
wenzelm@5403
    38
wenzelm@5403
    39
# options
wenzelm@5403
    40
wenzelm@6450
    41
NO_OPTS=true
wenzelm@6450
    42
wenzelm@5403
    43
DISTDIR="$ISABELLE_HOME"
wenzelm@6417
    44
KDE=""
wenzelm@6417
    45
BINDIR=""
wenzelm@5362
    46
wenzelm@11125
    47
while getopts "d:k:p:" OPT
wenzelm@5403
    48
do
wenzelm@5403
    49
  case "$OPT" in
wenzelm@5404
    50
    d)
wenzelm@5403
    51
      DISTDIR="$OPTARG"
wenzelm@6450
    52
      NO_OPTS=""
wenzelm@5403
    53
      ;;
wenzelm@6417
    54
    k)
wenzelm@11125
    55
      KDE="$OPTARG"
wenzelm@6450
    56
      NO_OPTS=""
wenzelm@6417
    57
      ;;
wenzelm@6417
    58
    p)
wenzelm@6417
    59
      BINDIR="$OPTARG"
wenzelm@6450
    60
      NO_OPTS=""
wenzelm@6417
    61
      ;;
wenzelm@5403
    62
    \?)
wenzelm@5403
    63
      usage
wenzelm@5403
    64
      ;;
wenzelm@5403
    65
  esac
wenzelm@5403
    66
done
wenzelm@5362
    67
wenzelm@5403
    68
shift $(($OPTIND - 1))
wenzelm@5403
    69
wenzelm@5403
    70
wenzelm@5403
    71
# args
wenzelm@5403
    72
wenzelm@9788
    73
[ "$#" -ne 0 -o -n "$NO_OPTS" ] && usage
wenzelm@5362
    74
wenzelm@5362
    75
wenzelm@5362
    76
## main
wenzelm@5362
    77
wenzelm@6459
    78
echo "referring to distribution at $DISTDIR"
wenzelm@6417
    79
wenzelm@6417
    80
wenzelm@6417
    81
# standalone binaries
wenzelm@5362
    82
wenzelm@6082
    83
#set by configure
wenzelm@10555
    84
AUTO_BASH=bash
wenzelm@10555
    85
wenzelm@10555
    86
case "$AUTO_BASH" in
wenzelm@10555
    87
  /*)
wenzelm@10555
    88
    BASH="$AUTO_BASH"
wenzelm@10555
    89
    ;;
wenzelm@10555
    90
  *)
wenzelm@10555
    91
    BASH="/usr/bin/env bash"
wenzelm@10555
    92
    ;;
wenzelm@10555
    93
esac
wenzelm@5362
    94
wenzelm@6417
    95
if [ -n "$BINDIR" ]; then
wenzelm@6417
    96
  mkdir -p "$BINDIR" || fail "Bad directory: $BINDIR"
wenzelm@6417
    97
wenzelm@11550
    98
  for NAME in isatool isabelle-process isabelle-interface
wenzelm@6417
    99
  do
wenzelm@6417
   100
    BIN="$BINDIR/$NAME"
wenzelm@6417
   101
    DIST="$DISTDIR/bin/$NAME"
wenzelm@6417
   102
    echo "installing $BIN"
wenzelm@10555
   103
    echo "#!$BASH" > "$BIN" || fail "Cannot write file: $BIN"
wenzelm@9788
   104
    echo >> "$BIN"
wenzelm@9788
   105
    echo "exec \"$DIST\" \"\$@\"" >> "$BIN"
wenzelm@9788
   106
    chmod +x "$BIN"
wenzelm@6417
   107
  done
wenzelm@11550
   108
  for NAME in Isabelle isabelle
wenzelm@11550
   109
  do
wenzelm@11550
   110
    BIN="$BINDIR/$NAME"
wenzelm@11550
   111
    DIST="$DISTDIR/bin/$NAME"
wenzelm@11550
   112
    echo "installing $BIN"
wenzelm@11550
   113
    cp "$DIST" "$BIN" || fail "Cannot write file: $BIN"
wenzelm@11550
   114
    chmod +x "$BIN"
wenzelm@11550
   115
  done
wenzelm@6417
   116
fi
wenzelm@6417
   117
wenzelm@6417
   118
wenzelm@11125
   119
# install KDE 1.x / 2.x application icon
wenzelm@5403
   120
wenzelm@11125
   121
if [ -n "$KDE" ]; then
wenzelm@11125
   122
  if [ "$KDE" = 1 ]; then
wenzelm@11125
   123
    KDEHOME=~/.kde
wenzelm@11125
   124
    KDEDESKTOP=~/Desktop
wenzelm@11125
   125
    KDEAPP="$KDEDESKTOP/Isabelle.kdelnk"
wenzelm@11125
   126
  elif [ "$KDE" = 2 ]; then
wenzelm@11125
   127
    KDEHOME=~/.kde2
wenzelm@11125
   128
    KDEDESKTOP=~/KDesktop
wenzelm@11125
   129
    KDEAPP="$KDEDESKTOP/Isabelle.desktop"
wenzelm@11125
   130
  else
wenzelm@11125
   131
    fail "Unknown KDE version \"$KDE\""
wenzelm@11125
   132
  fi
wenzelm@11127
   133
  mkdir -p "$KDEDESKTOP" || fail "Bad directory: $KDEDESKTOP"
wenzelm@6417
   134
wenzelm@11125
   135
  KDEICONS="$KDEHOME/share/icons"
wenzelm@9788
   136
  mkdir -p "$KDEICONS" || fail "Bad directory: $KDEICONS"
wenzelm@9788
   137
  mkdir -p "$KDEICONS/mini" || fail "Bad directory: $KDEICONS/mini"
wenzelm@6417
   138
wenzelm@9788
   139
  [ -f "$KDEICONS/isabelle.xpm" ] || cp "$ISABELLE_HOME/lib/icons/isabelle.xpm" "$KDEICONS" || \
wenzelm@6545
   140
    fail "Cannot write file: $KDEICONS/isabelle.xpm"
wenzelm@9788
   141
  [ -f "$KDEICONS/mini/isabelle.xpm" ] || \
wenzelm@9788
   142
    cp "$ISABELLE_HOME/lib/icons/isabelle-mini.xpm" "$KDEICONS/mini/isabelle.xpm" || \
wenzelm@6545
   143
    fail "Cannot write file: $KDEICONS/mini/isabelle.xpm"
wenzelm@6417
   144
wenzelm@6417
   145
  echo "installing $KDEAPP"
wenzelm@9788
   146
  echo "# KDE Config File" > "$KDEAPP" || fail "Cannot write file: $KDEAPP"
wenzelm@9788
   147
  echo "[KDE Desktop Entry]" >> "$KDEAPP"
wenzelm@9788
   148
  echo "Type=Application" >> "$KDEAPP"
wenzelm@11550
   149
  echo "Exec=\"$DISTDIR/bin/isabelle-interface\" %f" >> "$KDEAPP"
wenzelm@9788
   150
  echo "Icon=isabelle.xpm" >> "$KDEAPP"
wenzelm@9788
   151
  echo "TerminalOptions=" >> "$KDEAPP"
wenzelm@9788
   152
  echo "Path=" >> "$KDEAPP"
wenzelm@9788
   153
  echo "Terminal=0" >> "$KDEAPP"
wenzelm@9788
   154
  echo "Name=Isabelle" >> "$KDEAPP"
wenzelm@6417
   155
fi