lib/scripts/run-polyml
author kleing
Tue, 06 May 2003 12:29:49 +0200
changeset 13965 46ad7fd03a38
parent 13002 e844d0ee15d5
child 14981 e73f8140af78
permissions -rwxr-xr-x
use -Smax with poly 4.1.3 for maximum database space (see poly release notes)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10555
2323ec838401 /usr/bin/env bash;
wenzelm
parents: 10206
diff changeset
     1
#!/usr/bin/env bash
2301
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
     2
#
2314
67bf78c7c725 replaced cat by ucat;
wenzelm
parents: 2301
diff changeset
     3
# $Id$
9789
wenzelm
parents: 9765
diff changeset
     4
# Author: Markus Wenzel, TU Muenchen
wenzelm
parents: 9765
diff changeset
     5
# License: GPL (GNU GENERAL PUBLIC LICENSE)
2314
67bf78c7c725 replaced cat by ucat;
wenzelm
parents: 2301
diff changeset
     6
#
2301
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
     7
# Poly/ML startup script.
9977
32955afeb835 unexport exports;
wenzelm
parents: 9789
diff changeset
     8
10105
f9be78009930 added COPYDB argument;
wenzelm
parents: 9997
diff changeset
     9
export -n INFILE OUTFILE COPYDB COMPRESS MLTEXT TERMINATE NOWRITE
2301
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    10
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    11
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    12
## diagnostics
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    13
2349
e9475a7be4ad various fixes;
wenzelm
parents: 2314
diff changeset
    14
function fail_out()
2301
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    15
{
2349
e9475a7be4ad various fixes;
wenzelm
parents: 2314
diff changeset
    16
  echo "Unable to create output heap file: \"$OUTFILE\"" >&2
2301
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    17
  exit 2
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    18
}
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    19
10206
d48a2e324abf accomodate Poly/ML 4.0;
wenzelm
parents: 10105
diff changeset
    20
function check_file()
5063
d45ec8d00ab0 check_mlhome_file;
wenzelm
parents: 4505
diff changeset
    21
{
d45ec8d00ab0 check_mlhome_file;
wenzelm
parents: 4505
diff changeset
    22
  if [ ! -f "$1" ]; then
d45ec8d00ab0 check_mlhome_file;
wenzelm
parents: 4505
diff changeset
    23
    echo "Unable to locate $1" >&2
10206
d48a2e324abf accomodate Poly/ML 4.0;
wenzelm
parents: 10105
diff changeset
    24
    echo "Please check your ML system settings!" >&2
5063
d45ec8d00ab0 check_mlhome_file;
wenzelm
parents: 4505
diff changeset
    25
    exit 2
d45ec8d00ab0 check_mlhome_file;
wenzelm
parents: 4505
diff changeset
    26
  fi
d45ec8d00ab0 check_mlhome_file;
wenzelm
parents: 4505
diff changeset
    27
}
d45ec8d00ab0 check_mlhome_file;
wenzelm
parents: 4505
diff changeset
    28
2301
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    29
2400
4b08766bc9d1 added symbolinput filter;
wenzelm
parents: 2389
diff changeset
    30
## Poly/ML programs
2301
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    31
10206
d48a2e324abf accomodate Poly/ML 4.0;
wenzelm
parents: 10105
diff changeset
    32
ML_DBASE_PREFIX=""
9789
wenzelm
parents: 9765
diff changeset
    33
POLY="$ML_HOME/poly"
10206
d48a2e324abf accomodate Poly/ML 4.0;
wenzelm
parents: 10105
diff changeset
    34
check_file "$POLY"
2301
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    35
9765
46def28153d6 improved exit function for polyml-4.0;
wenzelm
parents: 8821
diff changeset
    36
case "$ML_SYSTEM" in
46def28153d6 improved exit function for polyml-4.0;
wenzelm
parents: 8821
diff changeset
    37
  polyml-4.*)
10206
d48a2e324abf accomodate Poly/ML 4.0;
wenzelm
parents: 10105
diff changeset
    38
    if [ -z "$ML_DBASE" ]; then
d48a2e324abf accomodate Poly/ML 4.0;
wenzelm
parents: 10105
diff changeset
    39
      if [ -z "$COPYDB" ]; then
d48a2e324abf accomodate Poly/ML 4.0;
wenzelm
parents: 10105
diff changeset
    40
        ML_DBASE_PREFIX="$ML_HOME/"
d48a2e324abf accomodate Poly/ML 4.0;
wenzelm
parents: 10105
diff changeset
    41
        ML_DBASE="ML_dbase"
d48a2e324abf accomodate Poly/ML 4.0;
wenzelm
parents: 10105
diff changeset
    42
      else
d48a2e324abf accomodate Poly/ML 4.0;
wenzelm
parents: 10105
diff changeset
    43
        ML_DBASE="$ML_HOME/ML_dbase"
d48a2e324abf accomodate Poly/ML 4.0;
wenzelm
parents: 10105
diff changeset
    44
      fi
d48a2e324abf accomodate Poly/ML 4.0;
wenzelm
parents: 10105
diff changeset
    45
      POLYPATH="$ML_HOME"
d48a2e324abf accomodate Poly/ML 4.0;
wenzelm
parents: 10105
diff changeset
    46
    else
d48a2e324abf accomodate Poly/ML 4.0;
wenzelm
parents: 10105
diff changeset
    47
      POLYPATH=$(dirname "$ML_DBASE")
d48a2e324abf accomodate Poly/ML 4.0;
wenzelm
parents: 10105
diff changeset
    48
    fi
d48a2e324abf accomodate Poly/ML 4.0;
wenzelm
parents: 10105
diff changeset
    49
    export POLYPATH
d48a2e324abf accomodate Poly/ML 4.0;
wenzelm
parents: 10105
diff changeset
    50
d48a2e324abf accomodate Poly/ML 4.0;
wenzelm
parents: 10105
diff changeset
    51
    DISCGARB="$POLY"
d48a2e324abf accomodate Poly/ML 4.0;
wenzelm
parents: 10105
diff changeset
    52
    DISCGARB_OPTIONS="-d -c"
d48a2e324abf accomodate Poly/ML 4.0;
wenzelm
parents: 10105
diff changeset
    53
9765
46def28153d6 improved exit function for polyml-4.0;
wenzelm
parents: 8821
diff changeset
    54
    EXIT="fun exit 0 = (OS.Process.exit OS.Process.success): unit | exit _ = OS.Process.exit OS.Process.failure;"
46def28153d6 improved exit function for polyml-4.0;
wenzelm
parents: 8821
diff changeset
    55
    ;;
46def28153d6 improved exit function for polyml-4.0;
wenzelm
parents: 8821
diff changeset
    56
  *)
10206
d48a2e324abf accomodate Poly/ML 4.0;
wenzelm
parents: 10105
diff changeset
    57
    if [ -z "$ML_DBASE" ]; then
d48a2e324abf accomodate Poly/ML 4.0;
wenzelm
parents: 10105
diff changeset
    58
      ML_DBASE="$ML_HOME/ML_dbase"
d48a2e324abf accomodate Poly/ML 4.0;
wenzelm
parents: 10105
diff changeset
    59
    fi
d48a2e324abf accomodate Poly/ML 4.0;
wenzelm
parents: 10105
diff changeset
    60
d48a2e324abf accomodate Poly/ML 4.0;
wenzelm
parents: 10105
diff changeset
    61
    DISCGARB="$ML_HOME/discgarb"
d48a2e324abf accomodate Poly/ML 4.0;
wenzelm
parents: 10105
diff changeset
    62
    DISCGARB_OPTIONS="-c"
d48a2e324abf accomodate Poly/ML 4.0;
wenzelm
parents: 10105
diff changeset
    63
    check_file "$DISCGARB"
d48a2e324abf accomodate Poly/ML 4.0;
wenzelm
parents: 10105
diff changeset
    64
9765
46def28153d6 improved exit function for polyml-4.0;
wenzelm
parents: 8821
diff changeset
    65
    EXIT="val exit = PolyML.exit;"
46def28153d6 improved exit function for polyml-4.0;
wenzelm
parents: 8821
diff changeset
    66
    ;;
46def28153d6 improved exit function for polyml-4.0;
wenzelm
parents: 8821
diff changeset
    67
esac
46def28153d6 improved exit function for polyml-4.0;
wenzelm
parents: 8821
diff changeset
    68
46def28153d6 improved exit function for polyml-4.0;
wenzelm
parents: 8821
diff changeset
    69
2301
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    70
## prepare databases
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    71
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    72
if [ -z "$INFILE" ]; then
10206
d48a2e324abf accomodate Poly/ML 4.0;
wenzelm
parents: 10105
diff changeset
    73
  check_file "$ML_DBASE_PREFIX$ML_DBASE"
d48a2e324abf accomodate Poly/ML 4.0;
wenzelm
parents: 10105
diff changeset
    74
  INFILE="$ML_DBASE"
9765
46def28153d6 improved exit function for polyml-4.0;
wenzelm
parents: 8821
diff changeset
    75
  MLTEXT="val use = PolyML.use; $EXIT $MLTEXT"
13965
46ad7fd03a38 use -Smax with poly 4.1.3 for maximum database space (see poly release notes)
kleing
parents: 13002
diff changeset
    76
  [ "$ML_SYSTEM" = polyml-4.1.3 ] && \
46ad7fd03a38 use -Smax with poly 4.1.3 for maximum database space (see poly release notes)
kleing
parents: 13002
diff changeset
    77
    DISCGARB_OPTIONS="$DISCGARB_OPTIONS -Smax"
12810
76f3dd2f151a cover polyml-4.1.2;
wenzelm
parents: 12111
diff changeset
    78
  [ "$ML_SYSTEM" = polyml-4.1.1 -o "$ML_SYSTEM" = polyml-4.1.2 ] && \
13002
e844d0ee15d5 option -S 180;
wenzelm
parents: 12810
diff changeset
    79
    DISCGARB_OPTIONS="$DISCGARB_OPTIONS -S 180"
10105
f9be78009930 added COPYDB argument;
wenzelm
parents: 9997
diff changeset
    80
else
f9be78009930 added COPYDB argument;
wenzelm
parents: 9997
diff changeset
    81
  COPYDB=true
2301
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    82
fi
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    83
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    84
if [ -z "$OUTFILE" ]; then
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    85
  DB="$INFILE"
2349
e9475a7be4ad various fixes;
wenzelm
parents: 2314
diff changeset
    86
  ML_OPTIONS="-r $ML_OPTIONS"  
e9475a7be4ad various fixes;
wenzelm
parents: 2314
diff changeset
    87
elif [ "$INFILE" -ef "$OUTFILE" ]; then
2301
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    88
  DB="$INFILE"
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    89
elif [ -n "$COPYDB" ]; then
2936
bd33e7aae062 fixed { ... } shell syntax to accomodate bash 2.x;
wenzelm
parents: 2605
diff changeset
    90
  [ -f "$OUTFILE" ] && { rm -f "$OUTFILE" || fail_out; }
2548
b5d19d99a58d 'rm -f' instead of 'cp -f';
wenzelm
parents: 2400
diff changeset
    91
  cp "$INFILE" "$OUTFILE" || fail_out
2349
e9475a7be4ad various fixes;
wenzelm
parents: 2314
diff changeset
    92
  chmod +w "$OUTFILE" || fail_out
2301
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    93
  DB="$OUTFILE"
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    94
else
2936
bd33e7aae062 fixed { ... } shell syntax to accomodate bash 2.x;
wenzelm
parents: 2605
diff changeset
    95
  [ -f "$OUTFILE" ] && { rm -f "$OUTFILE" || fail_out; }
9789
wenzelm
parents: 9765
diff changeset
    96
  echo "PolyML.make_database \"$OUTFILE\"; PolyML.quit();" | "$POLY" -r "$INFILE"
2301
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    97
  [ -f "$OUTFILE" ] || fail_out
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    98
  DB="$OUTFILE"
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
    99
fi
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
   100
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
   101
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
   102
## run it!
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
   103
4505
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4333
diff changeset
   104
if [ -z "$TERMINATE" ]; then
12111
d942348d8faf got rid of obsolete input filtering;
wenzelm
parents: 11485
diff changeset
   105
  FEEDER_OPTS=""
4505
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4333
diff changeset
   106
else
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4333
diff changeset
   107
  FEEDER_OPTS="-q"
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4333
diff changeset
   108
fi
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4333
diff changeset
   109
10206
d48a2e324abf accomodate Poly/ML 4.0;
wenzelm
parents: 10105
diff changeset
   110
DB_INFO=$(ls -l "$DB" 2>/dev/null)
2349
e9475a7be4ad various fixes;
wenzelm
parents: 2314
diff changeset
   111
9789
wenzelm
parents: 9765
diff changeset
   112
"$ISABELLE_HOME/lib/scripts/feeder" -p -h "$MLTEXT" $FEEDER_OPTS | \
wenzelm
parents: 9765
diff changeset
   113
  { read FPID; "$POLY" $ML_OPTIONS "$DB"; RC="$?"; kill -HUP "$FPID"; exit "$RC"; }
wenzelm
parents: 9765
diff changeset
   114
RC="$?"
2301
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
   115
13965
46ad7fd03a38 use -Smax with poly 4.1.3 for maximum database space (see poly release notes)
kleing
parents: 13002
diff changeset
   116
10206
d48a2e324abf accomodate Poly/ML 4.0;
wenzelm
parents: 10105
diff changeset
   117
NEW_DB_INFO=$(ls -l "$DB" 2>/dev/null)
d48a2e324abf accomodate Poly/ML 4.0;
wenzelm
parents: 10105
diff changeset
   118
[ -n "$OUTFILE" -a -n "$COMPRESS" -a "$DB_INFO" != "$NEW_DB_INFO" ] && \
d48a2e324abf accomodate Poly/ML 4.0;
wenzelm
parents: 10105
diff changeset
   119
  "$DISCGARB" $DISCGARB_OPTIONS "$OUTFILE"
4505
4a2c872b6513 use feeder to pipe into ML;
wenzelm
parents: 4333
diff changeset
   120
[ -n "$OUTFILE" -a -f "$OUTFILE" -a -n "$NOWRITE" ] && chmod -w "$OUTFILE"
2301
c72f4f7236b6 run-polyml: Poly/ML startup script.
wenzelm
parents:
diff changeset
   121
9789
wenzelm
parents: 9765
diff changeset
   122
exit "$RC"