lib/Tools/install
author kleing
Mon Jun 21 10:25:57 2004 +0200 (2004-06-21)
changeset 14981 e73f8140af78
parent 11550 915c5de6480f
child 15574 b1d1b5bfc464
permissions -rwxr-xr-x
Merged in license change from Isabelle2004
     1 #!/usr/bin/env bash
     2 #
     3 # $Id$
     4 # Author: Markus Wenzel, TU Muenchen
     5 #
     6 # DESCRIPTION: install standalone Isabelle executables
     7 
     8 
     9 PRG=$(basename "$0")
    10 
    11 function usage()
    12 {
    13   echo
    14   echo "Usage: $PRG [OPTIONS]"
    15   echo
    16   echo "  Options are:"
    17   echo "    -d DISTDIR   refer to DISTDIR as Isabelle distribution"
    18   echo "                 (default ISABELLE_HOME)"
    19   echo "    -k VERSION   install KDE application icon on desktop"
    20   echo "                 (for KDE VERSION 1 or 2)"
    21   echo "    -p DIR       install standalone binaries in DIR"
    22   echo
    23   echo "  Install Isabelle executables with absolute references to the current"
    24   echo "  distribution directory."
    25   echo
    26   exit 1
    27 }
    28 
    29 function fail()
    30 {
    31   echo "$1" >&2
    32   exit 2
    33 }
    34 
    35 
    36 ## process command line
    37 
    38 # options
    39 
    40 NO_OPTS=true
    41 
    42 DISTDIR="$ISABELLE_HOME"
    43 KDE=""
    44 BINDIR=""
    45 
    46 while getopts "d:k:p:" OPT
    47 do
    48   case "$OPT" in
    49     d)
    50       DISTDIR="$OPTARG"
    51       NO_OPTS=""
    52       ;;
    53     k)
    54       KDE="$OPTARG"
    55       NO_OPTS=""
    56       ;;
    57     p)
    58       BINDIR="$OPTARG"
    59       NO_OPTS=""
    60       ;;
    61     \?)
    62       usage
    63       ;;
    64   esac
    65 done
    66 
    67 shift $(($OPTIND - 1))
    68 
    69 
    70 # args
    71 
    72 [ "$#" -ne 0 -o -n "$NO_OPTS" ] && usage
    73 
    74 
    75 ## main
    76 
    77 echo "referring to distribution at $DISTDIR"
    78 
    79 
    80 # standalone binaries
    81 
    82 #set by configure
    83 AUTO_BASH=bash
    84 
    85 case "$AUTO_BASH" in
    86   /*)
    87     BASH="$AUTO_BASH"
    88     ;;
    89   *)
    90     BASH="/usr/bin/env bash"
    91     ;;
    92 esac
    93 
    94 if [ -n "$BINDIR" ]; then
    95   mkdir -p "$BINDIR" || fail "Bad directory: $BINDIR"
    96 
    97   for NAME in isatool isabelle-process isabelle-interface
    98   do
    99     BIN="$BINDIR/$NAME"
   100     DIST="$DISTDIR/bin/$NAME"
   101     echo "installing $BIN"
   102     echo "#!$BASH" > "$BIN" || fail "Cannot write file: $BIN"
   103     echo >> "$BIN"
   104     echo "exec \"$DIST\" \"\$@\"" >> "$BIN"
   105     chmod +x "$BIN"
   106   done
   107   for NAME in Isabelle isabelle
   108   do
   109     BIN="$BINDIR/$NAME"
   110     DIST="$DISTDIR/bin/$NAME"
   111     echo "installing $BIN"
   112     cp "$DIST" "$BIN" || fail "Cannot write file: $BIN"
   113     chmod +x "$BIN"
   114   done
   115 fi
   116 
   117 
   118 # install KDE 1.x / 2.x application icon
   119 
   120 if [ -n "$KDE" ]; then
   121   if [ "$KDE" = 1 ]; then
   122     KDEHOME=~/.kde
   123     KDEDESKTOP=~/Desktop
   124     KDEAPP="$KDEDESKTOP/Isabelle.kdelnk"
   125   elif [ "$KDE" = 2 ]; then
   126     KDEHOME=~/.kde2
   127     KDEDESKTOP=~/KDesktop
   128     KDEAPP="$KDEDESKTOP/Isabelle.desktop"
   129   else
   130     fail "Unknown KDE version \"$KDE\""
   131   fi
   132   mkdir -p "$KDEDESKTOP" || fail "Bad directory: $KDEDESKTOP"
   133 
   134   KDEICONS="$KDEHOME/share/icons"
   135   mkdir -p "$KDEICONS" || fail "Bad directory: $KDEICONS"
   136   mkdir -p "$KDEICONS/mini" || fail "Bad directory: $KDEICONS/mini"
   137 
   138   [ -f "$KDEICONS/isabelle.xpm" ] || cp "$ISABELLE_HOME/lib/icons/isabelle.xpm" "$KDEICONS" || \
   139     fail "Cannot write file: $KDEICONS/isabelle.xpm"
   140   [ -f "$KDEICONS/mini/isabelle.xpm" ] || \
   141     cp "$ISABELLE_HOME/lib/icons/isabelle-mini.xpm" "$KDEICONS/mini/isabelle.xpm" || \
   142     fail "Cannot write file: $KDEICONS/mini/isabelle.xpm"
   143 
   144   echo "installing $KDEAPP"
   145   echo "# KDE Config File" > "$KDEAPP" || fail "Cannot write file: $KDEAPP"
   146   echo "[KDE Desktop Entry]" >> "$KDEAPP"
   147   echo "Type=Application" >> "$KDEAPP"
   148   echo "Exec=\"$DISTDIR/bin/isabelle-interface\" %f" >> "$KDEAPP"
   149   echo "Icon=isabelle.xpm" >> "$KDEAPP"
   150   echo "TerminalOptions=" >> "$KDEAPP"
   151   echo "Path=" >> "$KDEAPP"
   152   echo "Terminal=0" >> "$KDEAPP"
   153   echo "Name=Isabelle" >> "$KDEAPP"
   154 fi