lib/Tools/install
author skalberg
Fri Mar 04 15:07:34 2005 +0100 (2005-03-04)
changeset 15574 b1d1b5bfc464
parent 14981 e73f8140af78
child 15733 75b9219980d3
permissions -rwxr-xr-x
Removed practically all references to Library.foldr.
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@11125
    19
  echo "    -k VERSION   install KDE application icon on desktop"
wenzelm@11125
    20
  echo "                 (for KDE VERSION 1 or 2)"
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@11125
    46
while getopts "d:k:p:" 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@11125
    54
      KDE="$OPTARG"
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
skalberg@15574
    83
AUTO_BASH=/bin/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@11550
    97
  for NAME in isatool isabelle-process isabelle-interface
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@11550
   107
  for NAME in Isabelle isabelle
wenzelm@11550
   108
  do
wenzelm@11550
   109
    BIN="$BINDIR/$NAME"
wenzelm@11550
   110
    DIST="$DISTDIR/bin/$NAME"
wenzelm@11550
   111
    echo "installing $BIN"
wenzelm@11550
   112
    cp "$DIST" "$BIN" || fail "Cannot write file: $BIN"
wenzelm@11550
   113
    chmod +x "$BIN"
wenzelm@11550
   114
  done
wenzelm@6417
   115
fi
wenzelm@6417
   116
wenzelm@6417
   117
wenzelm@11125
   118
# install KDE 1.x / 2.x application icon
wenzelm@5403
   119
wenzelm@11125
   120
if [ -n "$KDE" ]; then
wenzelm@11125
   121
  if [ "$KDE" = 1 ]; then
wenzelm@11125
   122
    KDEHOME=~/.kde
wenzelm@11125
   123
    KDEDESKTOP=~/Desktop
wenzelm@11125
   124
    KDEAPP="$KDEDESKTOP/Isabelle.kdelnk"
wenzelm@11125
   125
  elif [ "$KDE" = 2 ]; then
wenzelm@11125
   126
    KDEHOME=~/.kde2
wenzelm@11125
   127
    KDEDESKTOP=~/KDesktop
wenzelm@11125
   128
    KDEAPP="$KDEDESKTOP/Isabelle.desktop"
wenzelm@11125
   129
  else
wenzelm@11125
   130
    fail "Unknown KDE version \"$KDE\""
wenzelm@11125
   131
  fi
wenzelm@11127
   132
  mkdir -p "$KDEDESKTOP" || fail "Bad directory: $KDEDESKTOP"
wenzelm@6417
   133
wenzelm@11125
   134
  KDEICONS="$KDEHOME/share/icons"
wenzelm@9788
   135
  mkdir -p "$KDEICONS" || fail "Bad directory: $KDEICONS"
wenzelm@9788
   136
  mkdir -p "$KDEICONS/mini" || fail "Bad directory: $KDEICONS/mini"
wenzelm@6417
   137
wenzelm@9788
   138
  [ -f "$KDEICONS/isabelle.xpm" ] || cp "$ISABELLE_HOME/lib/icons/isabelle.xpm" "$KDEICONS" || \
wenzelm@6545
   139
    fail "Cannot write file: $KDEICONS/isabelle.xpm"
wenzelm@9788
   140
  [ -f "$KDEICONS/mini/isabelle.xpm" ] || \
wenzelm@9788
   141
    cp "$ISABELLE_HOME/lib/icons/isabelle-mini.xpm" "$KDEICONS/mini/isabelle.xpm" || \
wenzelm@6545
   142
    fail "Cannot write file: $KDEICONS/mini/isabelle.xpm"
wenzelm@6417
   143
wenzelm@6417
   144
  echo "installing $KDEAPP"
wenzelm@9788
   145
  echo "# KDE Config File" > "$KDEAPP" || fail "Cannot write file: $KDEAPP"
wenzelm@9788
   146
  echo "[KDE Desktop Entry]" >> "$KDEAPP"
wenzelm@9788
   147
  echo "Type=Application" >> "$KDEAPP"
wenzelm@11550
   148
  echo "Exec=\"$DISTDIR/bin/isabelle-interface\" %f" >> "$KDEAPP"
wenzelm@9788
   149
  echo "Icon=isabelle.xpm" >> "$KDEAPP"
wenzelm@9788
   150
  echo "TerminalOptions=" >> "$KDEAPP"
wenzelm@9788
   151
  echo "Path=" >> "$KDEAPP"
wenzelm@9788
   152
  echo "Terminal=0" >> "$KDEAPP"
wenzelm@9788
   153
  echo "Name=Isabelle" >> "$KDEAPP"
wenzelm@6417
   154
fi