| author | bulwahn | 
| Wed, 28 Oct 2009 12:29:02 +0100 | |
| changeset 33328 | 1d93dd8a02c9 | 
| parent 31317 | 1f5740424c69 | 
| child 39619 | 34952c2423c6 | 
| permissions | -rwxr-xr-x | 
| 10555 | 1 | #!/usr/bin/env bash | 
| 2301 | 2 | # | 
| 26215 
94d32a7cd0fb
rearrangements to make latest Poly/ML the default, not old 4.x;
 wenzelm parents: 
25123diff
changeset | 3 | # Author: Makarius | 
| 2314 | 4 | # | 
| 26215 
94d32a7cd0fb
rearrangements to make latest Poly/ML the default, not old 4.x;
 wenzelm parents: 
25123diff
changeset | 5 | # Poly/ML 5.1/5.2 startup script. | 
| 9977 | 6 | |
| 31317 
1f5740424c69
removed "compress" option from isabelle-process and isabelle usedir -- this is always enabled;
 wenzelm parents: 
31315diff
changeset | 7 | export -n INFILE OUTFILE MLTEXT TERMINATE NOWRITE | 
| 2301 | 8 | |
| 9 | ||
| 10 | ## diagnostics | |
| 11 | ||
| 2349 | 12 | function fail_out() | 
| 2301 | 13 | {
 | 
| 2349 | 14 | echo "Unable to create output heap file: \"$OUTFILE\"" >&2 | 
| 2301 | 15 | exit 2 | 
| 16 | } | |
| 17 | ||
| 10206 | 18 | function check_file() | 
| 5063 | 19 | {
 | 
| 20 | if [ ! -f "$1" ]; then | |
| 21 | echo "Unable to locate $1" >&2 | |
| 10206 | 22 | echo "Please check your ML system settings!" >&2 | 
| 5063 | 23 | exit 2 | 
| 24 | fi | |
| 25 | } | |
| 26 | ||
| 2301 | 27 | |
| 26215 
94d32a7cd0fb
rearrangements to make latest Poly/ML the default, not old 4.x;
 wenzelm parents: 
25123diff
changeset | 28 | ## compiler executables and libraries | 
| 16374 | 29 | |
| 21356 | 30 | POLY="$ML_HOME/poly" | 
| 10206 | 31 | check_file "$POLY" | 
| 2301 | 32 | |
| 26215 
94d32a7cd0fb
rearrangements to make latest Poly/ML the default, not old 4.x;
 wenzelm parents: 
25123diff
changeset | 33 | if [ "$(basename "$ML_HOME")" = bin ]; then | 
| 
94d32a7cd0fb
rearrangements to make latest Poly/ML the default, not old 4.x;
 wenzelm parents: 
25123diff
changeset | 34 | POLYLIB="$(cd "$ML_HOME"; cd "$(pwd -P)"; cd ../lib; pwd)" | 
| 16392 | 35 | else | 
| 26215 
94d32a7cd0fb
rearrangements to make latest Poly/ML the default, not old 4.x;
 wenzelm parents: 
25123diff
changeset | 36 | POLYLIB="$ML_HOME" | 
| 16392 | 37 | fi | 
| 10206 | 38 | |
| 26215 
94d32a7cd0fb
rearrangements to make latest Poly/ML the default, not old 4.x;
 wenzelm parents: 
25123diff
changeset | 39 | export LD_LIBRARY_PATH="$POLYLIB:$LD_LIBRARY_PATH" | 
| 
94d32a7cd0fb
rearrangements to make latest Poly/ML the default, not old 4.x;
 wenzelm parents: 
25123diff
changeset | 40 | export DYLD_LIBRARY_PATH="$POLYLIB:$DYLD_LIBRARY_PATH" | 
| 9765 | 41 | |
| 42 | ||
| 2301 | 43 | ## prepare databases | 
| 44 | ||
| 45 | if [ -z "$INFILE" ]; then | |
| 26215 
94d32a7cd0fb
rearrangements to make latest Poly/ML the default, not old 4.x;
 wenzelm parents: 
25123diff
changeset | 46 | INIT="" | 
| 
94d32a7cd0fb
rearrangements to make latest Poly/ML the default, not old 4.x;
 wenzelm parents: 
25123diff
changeset | 47 | EXIT="fun exit 0 = (OS.Process.exit OS.Process.success): unit | exit _ = OS.Process.exit OS.Process.failure;" | 
| 10105 | 48 | else | 
| 26215 
94d32a7cd0fb
rearrangements to make latest Poly/ML the default, not old 4.x;
 wenzelm parents: 
25123diff
changeset | 49 | check_file "$INFILE" | 
| 
94d32a7cd0fb
rearrangements to make latest Poly/ML the default, not old 4.x;
 wenzelm parents: 
25123diff
changeset | 50 | INIT="(Signal.signal (2, Signal.SIG_HANDLE (fn _ => Process.interruptConsoleProcesses ())); PolyML.SaveState.loadState \"$INFILE\" handle Fail msg => (TextIO.output (TextIO.stdErr, msg ^ \"\\n\"); OS.Process.exit OS.Process.failure));" | 
| 
94d32a7cd0fb
rearrangements to make latest Poly/ML the default, not old 4.x;
 wenzelm parents: 
25123diff
changeset | 51 | EXIT="" | 
| 2301 | 52 | fi | 
| 53 | ||
| 54 | if [ -z "$OUTFILE" ]; then | |
| 26215 
94d32a7cd0fb
rearrangements to make latest Poly/ML the default, not old 4.x;
 wenzelm parents: 
25123diff
changeset | 55 | COMMIT='fun commit () = (TextIO.output (TextIO.stdErr, "Error - Database is not opened for writing.\n"); false);' | 
| 2301 | 56 | else | 
| 31317 
1f5740424c69
removed "compress" option from isabelle-process and isabelle usedir -- this is always enabled;
 wenzelm parents: 
31315diff
changeset | 57 | COMMIT="fun commit () = (PolyML.shareCommonData PolyML.rootFunction; TextIO.output (TextIO.stdOut, \"Exporting $OUTFILE\n\"); PolyML.SaveState.saveState \"$OUTFILE\"; true);" | 
| 26215 
94d32a7cd0fb
rearrangements to make latest Poly/ML the default, not old 4.x;
 wenzelm parents: 
25123diff
changeset | 58 |   [ -f "$OUTFILE" ] && { chmod +w "$OUTFILE" || fail_out; }
 | 
| 2301 | 59 | fi | 
| 60 | ||
| 61 | ||
| 62 | ## run it! | |
| 63 | ||
| 26215 
94d32a7cd0fb
rearrangements to make latest Poly/ML the default, not old 4.x;
 wenzelm parents: 
25123diff
changeset | 64 | MLTEXT="$INIT $EXIT $COMMIT $MLTEXT" | 
| 
94d32a7cd0fb
rearrangements to make latest Poly/ML the default, not old 4.x;
 wenzelm parents: 
25123diff
changeset | 65 | MLEXIT="commit();" | 
| 
94d32a7cd0fb
rearrangements to make latest Poly/ML the default, not old 4.x;
 wenzelm parents: 
25123diff
changeset | 66 | |
| 16254 
1b2683e18fd2
DISCGARB_OPTIONS: proper treatment of specific polyml versions;
 wenzelm parents: 
15850diff
changeset | 67 | if [ -z "$TERMINATE" ]; then | 
| 
1b2683e18fd2
DISCGARB_OPTIONS: proper treatment of specific polyml versions;
 wenzelm parents: 
15850diff
changeset | 68 | FEEDER_OPTS="" | 
| 
1b2683e18fd2
DISCGARB_OPTIONS: proper treatment of specific polyml versions;
 wenzelm parents: 
15850diff
changeset | 69 | else | 
| 
1b2683e18fd2
DISCGARB_OPTIONS: proper treatment of specific polyml versions;
 wenzelm parents: 
15850diff
changeset | 70 | FEEDER_OPTS="-q" | 
| 
1b2683e18fd2
DISCGARB_OPTIONS: proper treatment of specific polyml versions;
 wenzelm parents: 
15850diff
changeset | 71 | fi | 
| 
1b2683e18fd2
DISCGARB_OPTIONS: proper treatment of specific polyml versions;
 wenzelm parents: 
15850diff
changeset | 72 | |
| 26215 
94d32a7cd0fb
rearrangements to make latest Poly/ML the default, not old 4.x;
 wenzelm parents: 
25123diff
changeset | 73 | "$ISABELLE_HOME/lib/scripts/feeder" -p -h "$MLTEXT" -t "$MLEXIT" $FEEDER_OPTS | \ | 
| 
94d32a7cd0fb
rearrangements to make latest Poly/ML the default, not old 4.x;
 wenzelm parents: 
25123diff
changeset | 74 |   { read FPID; "$POLY" -q $ML_OPTIONS; RC="$?"; kill -HUP "$FPID"; exit "$RC"; }
 | 
| 9789 | 75 | RC="$?" | 
| 2301 | 76 | |
| 4505 | 77 | [ -n "$OUTFILE" -a -f "$OUTFILE" -a -n "$NOWRITE" ] && chmod -w "$OUTFILE" | 
| 2301 | 78 | |
| 9789 | 79 | exit "$RC" |