src/Pure/mk
author wenzelm
Mon, 09 Nov 1998 15:42:08 +0100
changeset 5840 e2d2b896c717
parent 4495 8648ba842d14
child 6186 72abe86d9418
permissions -rwxr-xr-x
Object logic specific operations.

#!/bin/bash
#
# $Id$
#
# mk - build Pure Isabelle.
#
# Assumes to be called via Isabelle make utility (cf. IsaMakefile).


## diagnostics

function usage()
{
  echo
  echo "Usage: $PRG [OPTIONS]"
  echo
  echo "  Make Pure Isabelle."
  echo
  echo "    -r           just prepare RAW image"
  echo
  exit 1
}

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


## process command line

# options

RAW=""

while getopts "r" OPT
do
  case "$OPT" in
    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 -n "Building $ITEM ... "
  LOG="$LOGDIR/$ITEM"

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

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

RC=$?

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


# exit status

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

exit $RC