src/Pure/mk
author wenzelm
Sun, 15 Oct 2000 19:50:35 +0200
changeset 10220 2a726de6e124
parent 10102 3c21a2e616e7
child 10900 7268a5f425f8
permissions -rwxr-xr-x
proper symbol markup with \isamath, \isatext; support sub/super scripts:

#!/bin/bash
#
# $Id$
# Author: Markus Wenzel, TU Muenchen
# License: GPL (GNU GENERAL PUBLIC LICENSE)
#
# mk - build Pure Isabelle.
#
# Requires proper Isabelle settings environment (cf. IsaMakefile).


## diagnostics

function usage()
{
  echo
  echo "Usage: $PRG [OPTIONS]"
  echo
  echo "  Make Pure Isabelle."
  echo
  echo "    -C           tell ML system to copy output image"
  echo "    -r           prepare RAW image only"
  echo
  exit 1
}

function fail()
{
  echo "$1" >&2
  exit 2
}


## process command line

# options

COPY=""
RAW=""

while getopts "Cr" OPT
do
  case "$OPT" in
    C)
      COPY="-C"
      ;;
    r)
      RAW=true
      ;;
    \?)
      usage
      ;;
  esac
done

shift $(($OPTIND - 1))


# args

[ "$#" -ne 0 ] && usage


## main

# get compatibility file

ML_SYSTEM_BASE=$(echo "$ML_SYSTEM" | cut -f1 -d-)
[ -z "$ML_SYSTEM" ] && \
  fail "Missing ML system settings! Probably not run via 'isatool make'."

COMPAT=""
[ -f "ML-Systems/$ML_SYSTEM_BASE.ML" ] && COMPAT="ML-Systems/$ML_SYSTEM_BASE.ML"
[ -f "ML-Systems/$ML_SYSTEM.ML" ] && COMPAT="ML-Systems/$ML_SYSTEM.ML"
[ -z "$COMPAT" ] && fail "Missing compatibility file for ML system \"$ML_SYSTEM\"!"


# prepare log dir

LOGDIR="$ISABELLE_OUTPUT/log"
mkdir -p "$LOGDIR"


# run isabelle

SECONDS=0

if [ -z "$RAW" ]; then
  ITEM="Pure"
  echo "Building $ITEM ..."
  LOG="$LOGDIR/$ITEM"

  "$ISABELLE" $COPY \
    -e "val ml_system = \"$ML_SYSTEM\";" \
    -e "(use\"$COMPAT\"; use\"ROOT.ML\") handle _ => exit 1;" \
    -c -q -w RAW_ML_SYSTEM Pure > "$LOG" 2>&1
  RC="$?"
else
  ITEM="RAW"
  echo "Building $ITEM ..."
  LOG="$LOGDIR/$ITEM"

  "$ISABELLE" $COPY \
    -e "val ml_system = \"$ML_SYSTEM\";" \
    -e "use\"$COMPAT\" handle _ => exit 1;;" \
    -q -w RAW_ML_SYSTEM RAW > "$LOG" 2>&1
  RC="$?"
fi

ELAPSED=$("$ISABELLE_HOME/lib/scripts/showtime" "$SECONDS")


# exit status

if [ "$RC" -eq 0 ]; then
  echo "Finished $ITEM ($ELAPSED elapsed time)"
  gzip --force "$LOG"
else
  echo "$ITEM FAILED"
  echo "(see also $LOG)"
  echo; tail "$LOG"; echo
fi

exit "$RC"