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