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