lib/Tools/install
author wenzelm
Tue Apr 26 20:41:37 2005 +0200 (2005-04-26)
changeset 15856 674ff97ce0ef
parent 15848 3001067227af
child 16653 c12c2f411f77
permissions -rwxr-xr-x
removed -a option;
fixed -d option to do what -a was trying;
tuned;
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@15856
    46
while getopts "d:k:p:" OPT
wenzelm@5403
    47
do
wenzelm@15856
    48
  NO_OPTS=""
wenzelm@5403
    49
  case "$OPT" in
wenzelm@5404
    50
    d)
wenzelm@5403
    51
      DISTDIR="$OPTARG"
wenzelm@5403
    52
      ;;
wenzelm@6417
    53
    k)
wenzelm@11125
    54
      KDE="$OPTARG"
wenzelm@6417
    55
      ;;
wenzelm@6417
    56
    p)
wenzelm@6417
    57
      BINDIR="$OPTARG"
aspinall@15733
    58
      ;;
wenzelm@5403
    59
    \?)
wenzelm@5403
    60
      usage
wenzelm@5403
    61
      ;;
wenzelm@5403
    62
  esac
wenzelm@5403
    63
done
wenzelm@5362
    64
wenzelm@5403
    65
shift $(($OPTIND - 1))
wenzelm@5403
    66
wenzelm@5403
    67
wenzelm@5403
    68
# args
wenzelm@5403
    69
wenzelm@9788
    70
[ "$#" -ne 0 -o -n "$NO_OPTS" ] && usage
wenzelm@5362
    71
wenzelm@15848
    72
wenzelm@5362
    73
## main
wenzelm@5362
    74
wenzelm@6459
    75
echo "referring to distribution at $DISTDIR"
wenzelm@6417
    76
wenzelm@6417
    77
wenzelm@6417
    78
# standalone binaries
wenzelm@5362
    79
wenzelm@6082
    80
#set by configure
wenzelm@15848
    81
AUTO_BASH=bash
wenzelm@10555
    82
wenzelm@10555
    83
case "$AUTO_BASH" in
wenzelm@10555
    84
  /*)
wenzelm@10555
    85
    BASH="$AUTO_BASH"
wenzelm@10555
    86
    ;;
wenzelm@10555
    87
  *)
wenzelm@10555
    88
    BASH="/usr/bin/env bash"
wenzelm@10555
    89
    ;;
wenzelm@10555
    90
esac
wenzelm@5362
    91
wenzelm@6417
    92
if [ -n "$BINDIR" ]; then
wenzelm@6417
    93
  mkdir -p "$BINDIR" || fail "Bad directory: $BINDIR"
wenzelm@6417
    94
wenzelm@11550
    95
  for NAME in isatool isabelle-process isabelle-interface
wenzelm@6417
    96
  do
wenzelm@6417
    97
    BIN="$BINDIR/$NAME"
wenzelm@15856
    98
    DIST="$DISTDIR/bin/$NAME"
wenzelm@6417
    99
    echo "installing $BIN"
wenzelm@15848
   100
    rm -f "$BIN"
wenzelm@10555
   101
    echo "#!$BASH" > "$BIN" || fail "Cannot write file: $BIN"
wenzelm@9788
   102
    echo >> "$BIN"
wenzelm@9788
   103
    echo "exec \"$DIST\" \"\$@\"" >> "$BIN"
wenzelm@9788
   104
    chmod +x "$BIN"
wenzelm@6417
   105
  done
wenzelm@11550
   106
  for NAME in Isabelle isabelle
wenzelm@11550
   107
  do
wenzelm@11550
   108
    BIN="$BINDIR/$NAME"
wenzelm@11550
   109
    echo "installing $BIN"
wenzelm@15848
   110
    rm -f "$BIN"
wenzelm@15856
   111
    cp "$ISABELLE_HOME/bin/$NAME" "$BIN" || fail "Cannot write file: $BIN"
wenzelm@11550
   112
    chmod +x "$BIN"
wenzelm@11550
   113
  done
wenzelm@6417
   114
fi
wenzelm@6417
   115
wenzelm@6417
   116
wenzelm@11125
   117
# install KDE 1.x / 2.x application icon
wenzelm@5403
   118
wenzelm@11125
   119
if [ -n "$KDE" ]; then
wenzelm@11125
   120
  if [ "$KDE" = 1 ]; then
wenzelm@11125
   121
    KDEHOME=~/.kde
wenzelm@11125
   122
    KDEDESKTOP=~/Desktop
wenzelm@11125
   123
    KDEAPP="$KDEDESKTOP/Isabelle.kdelnk"
wenzelm@11125
   124
  elif [ "$KDE" = 2 ]; then
wenzelm@11125
   125
    KDEHOME=~/.kde2
wenzelm@11125
   126
    KDEDESKTOP=~/KDesktop
wenzelm@11125
   127
    KDEAPP="$KDEDESKTOP/Isabelle.desktop"
wenzelm@11125
   128
  else
wenzelm@11125
   129
    fail "Unknown KDE version \"$KDE\""
wenzelm@11125
   130
  fi
wenzelm@11127
   131
  mkdir -p "$KDEDESKTOP" || fail "Bad directory: $KDEDESKTOP"
wenzelm@6417
   132
wenzelm@11125
   133
  KDEICONS="$KDEHOME/share/icons"
wenzelm@9788
   134
  mkdir -p "$KDEICONS" || fail "Bad directory: $KDEICONS"
wenzelm@9788
   135
  mkdir -p "$KDEICONS/mini" || fail "Bad directory: $KDEICONS/mini"
wenzelm@6417
   136
wenzelm@9788
   137
  [ -f "$KDEICONS/isabelle.xpm" ] || cp "$ISABELLE_HOME/lib/icons/isabelle.xpm" "$KDEICONS" || \
wenzelm@6545
   138
    fail "Cannot write file: $KDEICONS/isabelle.xpm"
wenzelm@9788
   139
  [ -f "$KDEICONS/mini/isabelle.xpm" ] || \
wenzelm@9788
   140
    cp "$ISABELLE_HOME/lib/icons/isabelle-mini.xpm" "$KDEICONS/mini/isabelle.xpm" || \
wenzelm@6545
   141
    fail "Cannot write file: $KDEICONS/mini/isabelle.xpm"
wenzelm@6417
   142
wenzelm@6417
   143
  echo "installing $KDEAPP"
wenzelm@9788
   144
  echo "# KDE Config File" > "$KDEAPP" || fail "Cannot write file: $KDEAPP"
wenzelm@9788
   145
  echo "[KDE Desktop Entry]" >> "$KDEAPP"
wenzelm@9788
   146
  echo "Type=Application" >> "$KDEAPP"
wenzelm@15856
   147
  echo "Exec=\"$DISTDIR/bin/isabelle-interface\" %f" >> "$KDEAPP"
wenzelm@9788
   148
  echo "Icon=isabelle.xpm" >> "$KDEAPP"
wenzelm@9788
   149
  echo "TerminalOptions=" >> "$KDEAPP"
wenzelm@9788
   150
  echo "Path=" >> "$KDEAPP"
wenzelm@9788
   151
  echo "Terminal=0" >> "$KDEAPP"
wenzelm@9788
   152
  echo "Name=Isabelle" >> "$KDEAPP"
wenzelm@6417
   153
fi