lib/Tools/install
author wenzelm
Mon Apr 19 17:53:38 1999 +0200 (1999-04-19)
changeset 6450 990e6e2dee26
parent 6417 39941b906910
child 6459 1d13a86bfa6c
permissions -rwxr-xr-x
improved usage;
wenzelm@5362
     1
#!/bin/bash
wenzelm@5362
     2
#
wenzelm@5362
     3
# $Id$
wenzelm@5362
     4
#
wenzelm@6417
     5
# DESCRIPTION: install standalone Isabelle executables
wenzelm@5362
     6
wenzelm@5362
     7
wenzelm@5362
     8
PRG=$(basename $0)
wenzelm@5362
     9
wenzelm@5362
    10
function usage()
wenzelm@5362
    11
{
wenzelm@5362
    12
  echo
wenzelm@6417
    13
  echo "Usage: $PRG [OPTIONS]"
wenzelm@5362
    14
  echo
wenzelm@5403
    15
  echo "  Options are:"
wenzelm@5403
    16
  echo "    -d DISTDIR   use DISTDIR as Isabelle distribution (default ISABELLE_HOME)"
wenzelm@6417
    17
  echo "    -k           install KDE application icon on Desktop"
wenzelm@6417
    18
  echo "    -p DIR       install standalone binaries in DIR"
wenzelm@5403
    19
  echo
wenzelm@6417
    20
  echo "  Install Isabelle executables with absolute references to the current"
wenzelm@6417
    21
  echo "  distribution directory."
wenzelm@5362
    22
  echo
wenzelm@5362
    23
  exit 1
wenzelm@5362
    24
}
wenzelm@5362
    25
wenzelm@5362
    26
function fail()
wenzelm@5362
    27
{
wenzelm@5362
    28
  echo "$1" >&2
wenzelm@5362
    29
  exit 2
wenzelm@5362
    30
}
wenzelm@5362
    31
wenzelm@5362
    32
wenzelm@5403
    33
## process command line
wenzelm@5403
    34
wenzelm@5403
    35
# options
wenzelm@5403
    36
wenzelm@6450
    37
NO_OPTS=true
wenzelm@6450
    38
wenzelm@5403
    39
DISTDIR="$ISABELLE_HOME"
wenzelm@6417
    40
KDE=""
wenzelm@6417
    41
BINDIR=""
wenzelm@5362
    42
wenzelm@6417
    43
while getopts "d:kp:" OPT
wenzelm@5403
    44
do
wenzelm@5403
    45
  case "$OPT" in
wenzelm@5404
    46
    d)
wenzelm@5403
    47
      DISTDIR="$OPTARG"
wenzelm@6450
    48
      NO_OPTS=""
wenzelm@5403
    49
      ;;
wenzelm@6417
    50
    k)
wenzelm@6417
    51
      KDE=true
wenzelm@6450
    52
      NO_OPTS=""
wenzelm@6417
    53
      ;;
wenzelm@6417
    54
    p)
wenzelm@6417
    55
      BINDIR="$OPTARG"
wenzelm@6450
    56
      NO_OPTS=""
wenzelm@6417
    57
      ;;
wenzelm@5403
    58
    \?)
wenzelm@5403
    59
      usage
wenzelm@5403
    60
      ;;
wenzelm@5403
    61
  esac
wenzelm@5403
    62
done
wenzelm@5362
    63
wenzelm@5403
    64
shift $(($OPTIND - 1))
wenzelm@5403
    65
wenzelm@5403
    66
wenzelm@5403
    67
# args
wenzelm@5403
    68
wenzelm@6450
    69
[ $# -ne 0 -o -n "$NO_OPTS" ] && usage
wenzelm@5362
    70
wenzelm@5362
    71
wenzelm@5362
    72
## main
wenzelm@5362
    73
wenzelm@6417
    74
echo "distribution at $DISTDIR"
wenzelm@6417
    75
wenzelm@6417
    76
wenzelm@6417
    77
# standalone binaries
wenzelm@5362
    78
wenzelm@6082
    79
#set by configure
wenzelm@6082
    80
AUTO_BASH=/bin/bash
wenzelm@5362
    81
wenzelm@6417
    82
if [ -n "$BINDIR" ]; then
wenzelm@6417
    83
  mkdir -p "$BINDIR" || fail "Bad directory: $BINDIR"
wenzelm@6417
    84
wenzelm@6417
    85
  for NAME in isatool isabelle Isabelle
wenzelm@6417
    86
  do
wenzelm@6417
    87
    BIN="$BINDIR/$NAME"
wenzelm@6417
    88
    DIST="$DISTDIR/bin/$NAME"
wenzelm@6417
    89
    echo "installing $BIN"
wenzelm@6417
    90
    echo "#!$AUTO_BASH" >$BIN || fail "Cannot write file: $BIN"
wenzelm@6417
    91
    echo >>$BIN
wenzelm@6417
    92
    echo "exec $DIST \"\$@\"" >>$BIN
wenzelm@6417
    93
    chmod +x $BIN
wenzelm@6417
    94
  done
wenzelm@6417
    95
fi
wenzelm@6417
    96
wenzelm@6417
    97
wenzelm@6417
    98
# install KDE application icon
wenzelm@5403
    99
wenzelm@6417
   100
KDEHOME=~/.kde
wenzelm@6417
   101
KDEAPP=~/Desktop/Isabelle.kdelnk
wenzelm@6417
   102
wenzelm@6417
   103
if [ "$KDE" = true ]; then
wenzelm@6417
   104
  mkdir -p $KDEHOME/share/icons || fail "Bad directory: $KDEHOME/share/icons"
wenzelm@6417
   105
wenzelm@6417
   106
  ICON=$KDEHOME/share/icons/isabelle.xpm
wenzelm@6417
   107
  [ -f $ICON ] || cp $DISTDIR/lib/logo/isabelle-tiny.xpm $ICON || fail "Cannot write file: $ICON"
wenzelm@6417
   108
wenzelm@6417
   109
  echo "installing $KDEAPP"
wenzelm@6417
   110
  echo "# KDE Config File" >$KDEAPP || fail "Cannot write file: $KDEAPP"
wenzelm@6417
   111
  echo "[KDE Desktop Entry]" >>$KDEAPP
wenzelm@6417
   112
  echo "Type=Application" >>$KDEAPP
wenzelm@6417
   113
  echo "Exec=$DISTDIR/bin/Isabelle" >>$KDEAPP
wenzelm@6417
   114
  echo "Icon=isabelle.xpm" >>$KDEAPP
wenzelm@6417
   115
  echo "TerminalOptions=" >>$KDEAPP
wenzelm@6417
   116
  echo "Path=" >>$KDEAPP
wenzelm@6417
   117
  echo "Terminal=0" >>$KDEAPP
wenzelm@6417
   118
  echo "Name=Isabelle" >>$KDEAPP
wenzelm@6417
   119
wenzelm@6417
   120
  type -p kfmclient >/dev/null && kfmclient refreshDesktop
wenzelm@6417
   121
fi