lib/scripts/run-polyml-4.9.1
author wenzelm
Thu, 12 Oct 2006 14:26:16 +0200
changeset 20993 214843edd729
parent 20760 f8281cbf37a5
child 20994 6f2995b4c867
permissions -rwxr-xr-x
set DYLD_LIBRARY_PATH (for Darwin);
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
20993
214843edd729 set DYLD_LIBRARY_PATH (for Darwin);
wenzelm
parents: 20760
diff changeset
    39
20759
wenzelm
parents: 20750
diff changeset
    40
export LD_LIBRARY_PATH="$POLYLIB:$LD_LIBRARY_PATH"
20993
214843edd729 set DYLD_LIBRARY_PATH (for Darwin);
wenzelm
parents: 20760
diff changeset
    41
export DYLD_LIBRARY_PATH="$POLYLIB:$DYLD_LIBRARY_PATH"
20747
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    42
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
## prepare databases
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    45
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    46
if [ -z "$INFILE" ]; then
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    47
  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
    48
else
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    49
  check_file "$INFILE"
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    50
  POLY="$INFILE"
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    51
  EXIT=""
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    52
fi
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    53
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    54
if [ -z "$OUTFILE" ]; then
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    55
  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
    56
else
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    57
  if [ -z "$COMPRESS" ]; then
20760
f8281cbf37a5 tuned messages;
wenzelm
parents: 20759
diff changeset
    58
    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
    59
  else
20760
f8281cbf37a5 tuned messages;
wenzelm
parents: 20759
diff changeset
    60
    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
    61
  fi
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    62
  [ -f "$OUTFILE" ] && { chmod +w "$OUTFILE" || fail_out; }
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    63
  rm -f "${OUTFILE}.o" || fail_out
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    64
fi
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    65
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
## run it!
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    68
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    69
MLTEXT="PolyML.Compiler.printInAlphabeticalOrder := false; $EXIT $COMMIT $MLTEXT"
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    70
MLEXIT="commit();"
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    71
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    72
if [ -z "$TERMINATE" ]; then
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    73
  FEEDER_OPTS=""
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    74
else
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    75
  FEEDER_OPTS="-q"
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    76
fi
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    77
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    78
"$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
    79
  { read FPID; "$POLY" $ML_OPTIONS; RC="$?"; kill -HUP "$FPID"; exit "$RC"; }
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    80
RC="$?"
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    81
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    82
if [ -n "$OUTFILE" ]; then
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    83
  if [ -e "${OUTFILE}.o" ]; then
20759
wenzelm
parents: 20750
diff changeset
    84
    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
    85
    rm -f "${OUTFILE}.o"
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
  [ -f "$OUTFILE" -a -n "$NOWRITE" ] && chmod -w "$OUTFILE"
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    88
fi
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    89
32ee2489fedf Poly/ML startup script (for 4.9.1);
wenzelm
parents:
diff changeset
    90
exit "$RC"