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