lib/Tools/install
author wenzelm
Fri Jan 01 16:40:47 2016 +0100 (2016-01-01)
changeset 62028 2ecee4679f99
parent 56439 95e2656b3b23
child 62588 cd266473b81b
permissions -rwxr-xr-x
updated for release;
     1 #!/usr/bin/env bash
     2 #
     3 # Author: Markus Wenzel, TU Muenchen
     4 #
     5 # DESCRIPTION: install standalone Isabelle executables
     6 
     7 
     8 PRG=$(basename "$0")
     9 
    10 function usage()
    11 {
    12   echo
    13   echo "Usage: isabelle $PRG [OPTIONS] BINDIR"
    14   echo
    15   echo "  Options are:"
    16   echo "    -d DISTDIR   refer to DISTDIR as Isabelle distribution"
    17   echo "                 (default ISABELLE_HOME)"
    18   echo
    19   echo "  Install Isabelle executables with absolute references to the"
    20   echo "  distribution directory."
    21   echo
    22   exit 1
    23 }
    24 
    25 function fail()
    26 {
    27   echo "$1" >&2
    28   exit 2
    29 }
    30 
    31 
    32 ## process command line
    33 
    34 # options
    35 
    36 DISTDIR="$ISABELLE_HOME"
    37 BINDIR=""
    38 
    39 while getopts "d:" OPT
    40 do
    41   case "$OPT" in
    42     d)
    43       DISTDIR="$OPTARG"
    44       ;;
    45     \?)
    46       usage
    47       ;;
    48   esac
    49 done
    50 
    51 shift $(($OPTIND - 1))
    52 
    53 
    54 # args
    55 
    56 [ "$#" -ge 1 ] && { BINDIR="$1"; shift; }
    57 [ "$#" -ne 0 -o -z "$BINDIR" ] && usage
    58 
    59 
    60 ## main
    61 
    62 echo "referring to distribution at \"$DISTDIR\""
    63 
    64 mkdir -p "$BINDIR" || fail "Bad directory: \"$BINDIR\""
    65 
    66 for NAME in isabelle isabelle_process isabelle_scala_script
    67 do
    68   BIN="$BINDIR/$NAME"
    69   DIST="$DISTDIR/bin/$NAME"
    70   echo "installing $BIN"
    71   rm -f "$BIN"
    72   echo "#!/usr/bin/env bash" > "$BIN" || fail "Cannot write file: $BIN"
    73   echo >> "$BIN"
    74   echo "exec \"$DIST\" \"\$@\"" >> "$BIN"
    75   chmod +x "$BIN"
    76 done
    77