bin/isabelle
author wenzelm
Wed, 04 Dec 1996 13:06:30 +0100
changeset 2308 641be5ad47af
parent 2292 c1c5652600f1
child 2343 2588b63b42ca
permissions -rwxr-xr-x
improved 'not found' messages;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2292
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
     1
#!/bin/bash
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
     2
#
2308
641be5ad47af improved 'not found' messages;
wenzelm
parents: 2292
diff changeset
     3
# $Id$
641be5ad47af improved 'not found' messages;
wenzelm
parents: 2292
diff changeset
     4
#
2292
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
     5
# Basic Isabelle startup script.
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
     6
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
     7
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
     8
## settings
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
     9
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    10
ISABELLE_HOME=$(dirname $(dirname $0))
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    11
. $ISABELLE_HOME/lib/scripts/getsettings
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    12
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    13
#get bash-style platform info
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    14
unset HOSTTYPE
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    15
unset OSTYPE
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    16
PLATFORM=$(bash -noprofile -c 'echo $HOSTTYPE-$OSTYPE')
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    17
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    18
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    19
## diagnostics
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    20
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    21
PRG=$(basename $0)
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    22
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    23
function usage()
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    24
{
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    25
  echo
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    26
  echo "Usage: $PRG [OPTIONS] [INPUT] [OUTPUT]"
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    27
  echo
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    28
  echo "  Options are:"
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    29
  echo "    -c           force copying of heap file"
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    30
  echo "    -e MLTEXT    pass MLTEXT to ML session"
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    31
#FIXME  echo "    -o OPTIONS   pass options to ML system"
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    32
  echo "    -q           non-interactive session"
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    33
  echo "    -r           open heap file read-only"
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    34
  echo "    -u           pass 'use\"ROOT.ML\" handle _ => exit 1; commit();'"
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    35
  echo "                 to the ML session"
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    36
  echo
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    37
  echo "  INPUT (default \"$DEFAULT_LOGIC\") and OUTPUT specify in/out heaps."
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    38
  echo "  These are either names to be searched in the Isabelle path, or actual"
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    39
  echo "  file names (containing at least one /)."
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    40
  echo "  If INPUT is \"SYSTEM\", just start the bare bones ML system."
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    41
  echo
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    42
  exit 1
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    43
}
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    44
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    45
function fail()
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    46
{
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    47
  echo "$1"
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    48
  exit 2
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    49
}
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    50
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    51
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    52
## process command line
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    53
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    54
# options
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    55
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    56
COPYDB=""
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    57
MLTEXT=""
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    58
COPYDB=""
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    59
OPTIONS=""
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    60
TERMINATE=""
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    61
READONLY=""
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    62
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    63
while getopts "ce:qru" OPT
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    64
do
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    65
  case "$OPT" in
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    66
    c)
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    67
      COPYDB=true
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    68
      ;;
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    69
    e)
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    70
      MLTEXT="$MLTEXT $OPTARG"
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    71
      ;;
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    72
    o)
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    73
      OPTIONS="$OPTIONS $OPTARG"
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    74
      ;;
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    75
    q)
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    76
      TERMINATE=true
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    77
      ;;
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    78
    r)
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    79
      READONLY=true
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    80
      ;;
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    81
    u)
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    82
      MLTEXT="$MLTEXT use\"ROOT.ML\" handle _ => exit 1; commit();"
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    83
      ;;
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    84
    \?)
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    85
      usage
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    86
      ;;
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    87
  esac
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    88
done
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    89
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    90
shift $(($OPTIND - 1))
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    91
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    92
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    93
# args
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    94
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    95
INPUT=""
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    96
OUTPUT=""
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    97
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    98
if [ $# -ge 1 ]; then
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
    99
  INPUT="$1"
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   100
  shift
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   101
fi
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   102
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   103
if [ $# -ge 1 ]; then
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   104
  OUTPUT="$1"
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   105
  shift
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   106
fi
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   107
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   108
[ $# -ne 0 ] && fail "Bad args: $*"
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   109
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   110
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   111
## check ML system
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   112
2308
641be5ad47af improved 'not found' messages;
wenzelm
parents: 2292
diff changeset
   113
[ -z "$ML_SYSTEM" ] && fail "Missing ML system settings! Unable to run Isabelle."
2292
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   114
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   115
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   116
## input heap file
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   117
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   118
[ -z "$INPUT" ] && INPUT="$DEFAULT_LOGIC"
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   119
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   120
case "$INPUT" in
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   121
  SYSTEM)
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   122
    INFILE=""
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   123
    ;;
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   124
  */*)
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   125
    INFILE="$INPUT"
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   126
    [ ! -f "$INFILE" ] && fail "Bad heap file file: \"$INFILE\""
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   127
    ;;
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   128
  *)
2308
641be5ad47af improved 'not found' messages;
wenzelm
parents: 2292
diff changeset
   129
    ISA_PATH=""
2292
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   130
    INFILE=""
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   131
    for DIR in $(echo $ISABELLE_PATH | tr : " ")
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   132
    do
2308
641be5ad47af improved 'not found' messages;
wenzelm
parents: 2292
diff changeset
   133
      ISA_PATH="$ISA_PATH $DIR/$ML_SYSTEM-$PLATFORM"
2292
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   134
      [ -z "$INFILE" -a -f $DIR/$ML_SYSTEM-$PLATFORM/$INPUT ] && INFILE=$DIR/$ML_SYSTEM-$PLATFORM/$INPUT
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   135
    done
2308
641be5ad47af improved 'not found' messages;
wenzelm
parents: 2292
diff changeset
   136
    if [ -z "$INFILE" ]; then
641be5ad47af improved 'not found' messages;
wenzelm
parents: 2292
diff changeset
   137
      echo "Unknown logic \"$INPUT\" -- no heap file found in:"
641be5ad47af improved 'not found' messages;
wenzelm
parents: 2292
diff changeset
   138
      for DIR in $ISA_PATH
641be5ad47af improved 'not found' messages;
wenzelm
parents: 2292
diff changeset
   139
      do
641be5ad47af improved 'not found' messages;
wenzelm
parents: 2292
diff changeset
   140
        echo "  $DIR"
641be5ad47af improved 'not found' messages;
wenzelm
parents: 2292
diff changeset
   141
      done
641be5ad47af improved 'not found' messages;
wenzelm
parents: 2292
diff changeset
   142
      exit 2
641be5ad47af improved 'not found' messages;
wenzelm
parents: 2292
diff changeset
   143
    fi
2292
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   144
    ;;
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   145
esac
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   146
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   147
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   148
## output heap file
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   149
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   150
case "$OUTPUT" in
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   151
  "")
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   152
    [ -z "$READONLY" -a -w "$INFILE" ] && OUTFILE="$INFILE"
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   153
    ;;
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   154
  */*)
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   155
    OUTFILE="$OUTPUT"
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   156
    ;;
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   157
  *)
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   158
    OUTDIR="$ISABELLE_OUTPUT/$ML_SYSTEM-$PLATFORM"
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   159
    mkdir -p "$OUTDIR"
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   160
    OUTFILE="$OUTDIR/$OUTPUT"
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   161
    ;;
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   162
esac
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   163
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   164
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   165
## run it!
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   166
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   167
ML_SYSTEM_BASE=$(echo $ML_SYSTEM | cut -f1 -d-)
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   168
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   169
export INFILE OUTFILE COPYDB MLTEXT OPTIONS TERMINATE
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   170
[ -f $ISABELLE_HOME/lib/scripts/run-$ML_SYSTEM ] && exec $ISABELLE_HOME/lib/scripts/run-$ML_SYSTEM
c1c5652600f1 isabelle: Basic Isabelle startup script.
wenzelm
parents:
diff changeset
   171
exec $ISABELLE_HOME/lib/scripts/run-$ML_SYSTEM_BASE