src/Pure/mk
author berghofe
Wed Oct 31 19:37:04 2001 +0100 (2001-10-31)
changeset 11998 b14e7686ce84
parent 11391 e8638d07fdee
child 14981 e73f8140af78
permissions -rwxr-xr-x
- enter_thmx -> enter_thms
- improved naming of theorems: enter_thms now takes functions pre_name and post_name
as arguments
wenzelm@11391
     1
#!/usr/bin/env bash
wenzelm@2339
     2
#
wenzelm@2339
     3
# $Id$
wenzelm@9789
     4
# Author: Markus Wenzel, TU Muenchen
wenzelm@9789
     5
# License: GPL (GNU GENERAL PUBLIC LICENSE)
wenzelm@2339
     6
#
wenzelm@2339
     7
# mk - build Pure Isabelle.
wenzelm@2339
     8
#
wenzelm@10102
     9
# Requires proper Isabelle settings environment (cf. IsaMakefile).
wenzelm@2339
    10
wenzelm@2339
    11
wenzelm@2339
    12
## diagnostics
wenzelm@2339
    13
wenzelm@3774
    14
function usage()
wenzelm@3774
    15
{
wenzelm@3774
    16
  echo
wenzelm@3774
    17
  echo "Usage: $PRG [OPTIONS]"
wenzelm@3774
    18
  echo
wenzelm@3774
    19
  echo "  Make Pure Isabelle."
wenzelm@3774
    20
  echo
wenzelm@10102
    21
  echo "    -C           tell ML system to copy output image"
wenzelm@10102
    22
  echo "    -r           prepare RAW image only"
wenzelm@3774
    23
  echo
wenzelm@3774
    24
  exit 1
wenzelm@3774
    25
}
wenzelm@3774
    26
wenzelm@2339
    27
function fail()
wenzelm@2339
    28
{
wenzelm@2339
    29
  echo "$1" >&2
wenzelm@2339
    30
  exit 2
wenzelm@2339
    31
}
wenzelm@2339
    32
wenzelm@2339
    33
wenzelm@3774
    34
## process command line
wenzelm@3774
    35
wenzelm@3774
    36
# options
wenzelm@3774
    37
wenzelm@10102
    38
COPY=""
wenzelm@3774
    39
RAW=""
wenzelm@3774
    40
wenzelm@10102
    41
while getopts "Cr" OPT
wenzelm@3774
    42
do
wenzelm@3774
    43
  case "$OPT" in
wenzelm@10102
    44
    C)
wenzelm@10102
    45
      COPY="-C"
wenzelm@10102
    46
      ;;
wenzelm@3774
    47
    r)
wenzelm@3774
    48
      RAW=true
wenzelm@3774
    49
      ;;
wenzelm@3774
    50
    \?)
wenzelm@3774
    51
      usage
wenzelm@3774
    52
      ;;
wenzelm@3774
    53
  esac
wenzelm@3774
    54
done
wenzelm@3774
    55
wenzelm@3774
    56
shift $(($OPTIND - 1))
wenzelm@3774
    57
wenzelm@3774
    58
wenzelm@3774
    59
# args
wenzelm@3774
    60
wenzelm@9789
    61
[ "$#" -ne 0 ] && usage
wenzelm@3774
    62
wenzelm@3774
    63
wenzelm@2339
    64
## main
wenzelm@2339
    65
wenzelm@4442
    66
# get compatibility file
wenzelm@4442
    67
wenzelm@9789
    68
ML_SYSTEM_BASE=$(echo "$ML_SYSTEM" | cut -f1 -d-)
wenzelm@3056
    69
[ -z "$ML_SYSTEM" ] && \
wenzelm@6186
    70
  fail "Missing ML system settings! Probably not run via 'isatool make'."
wenzelm@2339
    71
wenzelm@2339
    72
COMPAT=""
wenzelm@2339
    73
[ -f "ML-Systems/$ML_SYSTEM_BASE.ML" ] && COMPAT="ML-Systems/$ML_SYSTEM_BASE.ML"
wenzelm@2339
    74
[ -f "ML-Systems/$ML_SYSTEM.ML" ] && COMPAT="ML-Systems/$ML_SYSTEM.ML"
wenzelm@2339
    75
[ -z "$COMPAT" ] && fail "Missing compatibility file for ML system \"$ML_SYSTEM\"!"
wenzelm@2339
    76
wenzelm@4442
    77
wenzelm@4442
    78
# prepare log dir
wenzelm@4442
    79
wenzelm@4442
    80
LOGDIR="$ISABELLE_OUTPUT/log"
wenzelm@4442
    81
mkdir -p "$LOGDIR"
wenzelm@4442
    82
wenzelm@4442
    83
wenzelm@4442
    84
# run isabelle
wenzelm@4442
    85
wenzelm@4442
    86
SECONDS=0
wenzelm@4442
    87
wenzelm@3774
    88
if [ -z "$RAW" ]; then
wenzelm@4442
    89
  ITEM="Pure"
wenzelm@7277
    90
  echo "Building $ITEM ..."
wenzelm@4442
    91
  LOG="$LOGDIR/$ITEM"
wenzelm@4442
    92
wenzelm@10102
    93
  "$ISABELLE" $COPY \
wenzelm@3774
    94
    -e "val ml_system = \"$ML_SYSTEM\";" \
wenzelm@4495
    95
    -e "(use\"$COMPAT\"; use\"ROOT.ML\") handle _ => exit 1;" \
wenzelm@10900
    96
    -f -c -q -w RAW_ML_SYSTEM Pure > "$LOG" 2>&1
wenzelm@9789
    97
  RC="$?"
wenzelm@3774
    98
else
wenzelm@4442
    99
  ITEM="RAW"
wenzelm@7277
   100
  echo "Building $ITEM ..."
wenzelm@4442
   101
  LOG="$LOGDIR/$ITEM"
wenzelm@4442
   102
wenzelm@10102
   103
  "$ISABELLE" $COPY \
wenzelm@3774
   104
    -e "val ml_system = \"$ML_SYSTEM\";" \
wenzelm@10900
   105
    -e "use\"$COMPAT\" handle _ => exit 1;" \
wenzelm@9789
   106
    -q -w RAW_ML_SYSTEM RAW > "$LOG" 2>&1
wenzelm@9789
   107
  RC="$?"
wenzelm@3774
   108
fi
wenzelm@4442
   109
wenzelm@9789
   110
ELAPSED=$("$ISABELLE_HOME/lib/scripts/showtime" "$SECONDS")
wenzelm@4442
   111
wenzelm@4442
   112
wenzelm@4442
   113
# exit status
wenzelm@4442
   114
wenzelm@9789
   115
if [ "$RC" -eq 0 ]; then
wenzelm@7277
   116
  echo "Finished $ITEM ($ELAPSED elapsed time)"
wenzelm@4442
   117
  gzip --force "$LOG"
wenzelm@4442
   118
else
wenzelm@7263
   119
  echo "$ITEM FAILED"
wenzelm@4442
   120
  echo "(see also $LOG)"
wenzelm@9789
   121
  echo; tail "$LOG"; echo
wenzelm@4442
   122
fi
wenzelm@4442
   123
wenzelm@9789
   124
exit "$RC"