lib/scripts/run-polyml-4.9.1
author wenzelm
Thu, 28 Sep 2006 15:30:03 +0200
changeset 20760 f8281cbf37a5
parent 20759 1cd271a4fb12
child 20993 214843edd729
permissions -rwxr-xr-x
tuned messages;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
20747
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
     1
#!/usr/bin/env bash
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
     2
#
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
     3
# $Id$
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
     4
# Author: Makarius
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
     5
#
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
     6
# Poly/ML startup script (for 4.9.1)
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
     7
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
     8
export -n INFILE OUTFILE COPYDB COMPRESS MLTEXT TERMINATE NOWRITE
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
     9
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    10
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    11
## diagnostics
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    12
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    13
function fail_out()
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    14
{
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    15
  echo "Unable to create output heap file: \"$OUTFILE\"" >&2
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    16
  exit 2
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    17
}
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    18
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    19
function check_file()
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    20
{
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    21
  if [ ! -f "$1" ]; then
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    22
    echo "Unable to locate $1" >&2
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    23
    echo "Please check your ML system settings!" >&2
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    24
    exit 2
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    25
  fi
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    26
}
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    27
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    28
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    29
## compiler executables and libraries
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    30
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    31
POLY="$ML_HOME/poly"
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    32
check_file "$POLY"
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    33
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    34
if [ "$(basename "$ML_HOME")" = bin ]; then
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    35
  POLYLIB="$(cd "$ML_HOME"; cd "$(pwd -P)"; cd ../lib; pwd)"
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    36
else
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    37
  POLYLIB="$ML_HOME"
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    38
fi
20759
wenzelm
parents: 20750
diff changeset
    39
export LD_LIBRARY_PATH="$POLYLIB:$LD_LIBRARY_PATH"
20747
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    40
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    41
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    42
## prepare databases
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    43
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    44
if [ -z "$INFILE" ]; then
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    45
  EXIT="fun exit 0 = (OS.Process.exit OS.Process.success): unit | exit _ = OS.Process.exit OS.Process.failure;"
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    46
else
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    47
  check_file "$INFILE"
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    48
  POLY="$INFILE"
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    49
  EXIT=""
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    50
fi
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    51
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    52
if [ -z "$OUTFILE" ]; then
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    53
  COMMIT='fun commit () = (TextIO.output (TextIO.stdErr, "Error - Database is not opened for writing.\n"); false);'
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    54
else
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    55
  if [ -z "$COMPRESS" ]; then
20760
f8281cbf37a5 tuned messages;
wenzelm
parents: 20759
diff changeset
    56
    COMMIT="fun commit () = (TextIO.output (TextIO.stdOut, \"Exporting $OUTFILE\n\"); PolyML.export (\"$OUTFILE\", PolyML.rootFunction); true);"
20747
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    57
  else
20760
f8281cbf37a5 tuned messages;
wenzelm
parents: 20759
diff changeset
    58
    COMMIT="fun commit () = (PolyML.shareCommonData PolyML.rootFunction; TextIO.output (TextIO.stdOut, \"Exporting $OUTFILE\n\"); PolyML.export (\"$OUTFILE\", PolyML.rootFunction); true);"
20747
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    59
  fi
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    60
  [ -f "$OUTFILE" ] && { chmod +w "$OUTFILE" || fail_out; }
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    61
  rm -f "${OUTFILE}.o" || fail_out
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    62
fi
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    63
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    64
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    65
## run it!
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    66
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    67
MLTEXT="PolyML.Compiler.printInAlphabeticalOrder := false; $EXIT $COMMIT $MLTEXT"
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    68
MLEXIT="commit();"
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    69
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    70
if [ -z "$TERMINATE" ]; then
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    71
  FEEDER_OPTS=""
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    72
else
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    73
  FEEDER_OPTS="-q"
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    74
fi
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    75
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    76
"$ISABELLE_HOME/lib/scripts/feeder" -p -h "$MLTEXT" -t "$MLEXIT" $FEEDER_OPTS | \
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    77
  { read FPID; "$POLY" $ML_OPTIONS; RC="$?"; kill -HUP "$FPID"; exit "$RC"; }
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    78
RC="$?"
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    79
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    80
if [ -n "$OUTFILE" ]; then
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    81
  if [ -e "${OUTFILE}.o" ]; then
20759
wenzelm
parents: 20750
diff changeset
    82
    cc -o "$OUTFILE" "${OUTFILE}.o" -L "$POLYLIB" -lpolymain -lpolyml -lstdc++ || fail_out
20747
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    83
    rm -f "${OUTFILE}.o"
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    84
  fi
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    85
  [ -f "$OUTFILE" -a -n "$NOWRITE" ] && chmod -w "$OUTFILE"
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    86
fi
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    87
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    88
exit "$RC"