lib/scripts/run-polyml-5.0
author wenzelm
Mon, 16 Feb 2009 21:23:33 +0100
changeset 29758 7a3b5bbed313
parent 29145 b1c6f4563df7
child 31315 3c7b40548a84
permissions -rwxr-xr-x
removed rudiments of glossary;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
21653
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
     1
#!/usr/bin/env bash
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
     2
#
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
     3
# Author: Makarius
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
     4
#
26213
3a190cb91c6c tuned comment;
wenzelm
parents: 25124
diff changeset
     5
# Poly/ML 5.0 startup script.
21653
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
     6
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
     7
export -n INFILE OUTFILE COPYDB COMPRESS MLTEXT TERMINATE NOWRITE
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
     8
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
     9
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
    10
## diagnostics
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
    11
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
    12
function fail_out()
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
    13
{
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
    14
  echo "Unable to create output heap file: \"$OUTFILE\"" >&2
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
    15
  exit 2
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
    16
}
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
    17
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
    18
function check_file()
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
    19
{
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
    20
  if [ ! -f "$1" ]; then
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
    21
    echo "Unable to locate $1" >&2
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
    22
    echo "Please check your ML system settings!" >&2
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
    23
    exit 2
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
    24
  fi
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
    25
}
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
    26
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
    27
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
    28
## compiler executables and libraries
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
    29
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
    30
POLY="$ML_HOME/poly"
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
    31
check_file "$POLY"
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
    32
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
    33
if [ "$(basename "$ML_HOME")" = bin ]; then
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
    34
  POLYLIB="$(cd "$ML_HOME"; cd "$(pwd -P)"; cd ../lib; pwd)"
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
    35
else
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
    36
  POLYLIB="$ML_HOME"
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
    37
fi
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
    38
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
    39
export LD_LIBRARY_PATH="$POLYLIB:$LD_LIBRARY_PATH"
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
    40
export DYLD_LIBRARY_PATH="$POLYLIB:$DYLD_LIBRARY_PATH"
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
    41
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
    42
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
    43
## prepare databases
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
    44
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
    45
if [ -z "$INFILE" ]; then
21713
85722dc0fc81 more careful evaluation of ML text, prevents spurious output;
wenzelm
parents: 21711
diff changeset
    46
  PRG="$POLY"
21653
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
    47
  EXIT="fun exit 0 = (OS.Process.exit OS.Process.success): unit | exit _ = OS.Process.exit OS.Process.failure;"
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
    48
else
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
    49
  check_file "$INFILE"
21713
85722dc0fc81 more careful evaluation of ML text, prevents spurious output;
wenzelm
parents: 21711
diff changeset
    50
  PRG="$INFILE"
21653
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
    51
  EXIT=""
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
    52
fi
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
    53
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
    54
if [ -z "$OUTFILE" ]; then
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
    55
  COMMIT='fun commit () = (TextIO.output (TextIO.stdErr, "Error - Database is not opened for writing.\n"); false);'
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
    56
else
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
    57
  if [ -z "$COMPRESS" ]; then
24296
3479a9fe73e0 removed signal setup from root function to on-entry hook;
wenzelm
parents: 22253
diff changeset
    58
    COMMIT="fun commit () = (TextIO.output (TextIO.stdOut, \"Exporting $OUTFILE\n\"); PolyML.export (\"$OUTFILE\", PolyML.rootFunction); true);"
21653
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
    59
  else
24296
3479a9fe73e0 removed signal setup from root function to on-entry hook;
wenzelm
parents: 22253
diff changeset
    60
    COMMIT="fun commit () = (PolyML.shareCommonData PolyML.rootFunction; TextIO.output (TextIO.stdOut, \"Exporting $OUTFILE\n\"); PolyML.export (\"$OUTFILE\", PolyML.rootFunction); true);"
21653
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
    61
  fi
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
    62
  [ -f "$OUTFILE" ] && { chmod +w "$OUTFILE" || fail_out; }
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
    63
  rm -f "${OUTFILE}.o" || fail_out
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
    64
fi
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
    65
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
    66
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
    67
## run it!
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
    68
25124
a7dd8d3bf969 maintain PolyML.Compiler.printInAlphabeticalOrder in polyml.ML;
wenzelm
parents: 24480
diff changeset
    69
MLTEXT="$EXIT $COMMIT $MLTEXT"
21653
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
    70
MLEXIT="commit();"
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
    71
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
    72
if [ -z "$TERMINATE" ]; then
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
    73
  FEEDER_OPTS=""
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
    74
else
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
    75
  FEEDER_OPTS="-q"
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
    76
fi
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
    77
26375
234f10289d97 back to feeder -- Isabelle ML setup no longer evaluates command line;
wenzelm
parents: 26213
diff changeset
    78
"$ISABELLE_HOME/lib/scripts/feeder" -p -h "$MLTEXT" -t "$MLEXIT" $FEEDER_OPTS | \
234f10289d97 back to feeder -- Isabelle ML setup no longer evaluates command line;
wenzelm
parents: 26213
diff changeset
    79
  { read FPID; "$PRG" -q $ML_OPTIONS; RC="$?"; kill -HUP "$FPID"; exit "$RC"; }
21653
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
    80
RC="$?"
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
    81
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
    82
if [ -n "$OUTFILE" ]; then
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
    83
  if [ -e "${OUTFILE}.o" ]; then
24480
97c0ef49fa8f renamed POLYML_LINK_OPTIONS to POLY_LINK_OPTIONS;
wenzelm
parents: 24479
diff changeset
    84
    cc -o "$OUTFILE" "${OUTFILE}.o" -L"$POLYLIB" -lpolymain -lpolyml $POLY_LINK_OPTIONS || fail_out
21653
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
    85
    rm -f "${OUTFILE}.o"
21711
dfac729d3066 root function: restore default interrupt handler;
wenzelm
parents: 21653
diff changeset
    86
    [ -e "${OUTFILE}.exe" ] && mv "${OUTFILE}.exe" "$OUTFILE"
21653
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
    87
  fi
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
    88
  [ -f "$OUTFILE" -a -n "$NOWRITE" ] && chmod -w "$OUTFILE"
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
    89
fi
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
    90
219924615db6 setup for polyml-5.0;
wenzelm
parents:
diff changeset
    91
exit "$RC"