Admin/build
author haftmann
Wed, 15 Jul 2009 10:11:13 +0200
changeset 32073 0a83608e21f1
parent 31831 92993da74973
child 34282 549969a7f582
permissions -rwxr-xr-x
additional preprocessor rule

#!/usr/bin/env bash
#
# Administrative build for Isabelle source distribution.

## global environment

#paranoia setting for sunbroy
PATH="/usr/local/dist/DIR/j2sdk1.5.0/bin:$PATH"

PATH="/home/scala/current/bin:$PATH"
if [ -z "$SCALA_HOME" ]; then
  export SCALA_HOME="$(dirname "$(dirname "$(type -p scalac)")")"
fi


## directory layout

ISABELLE_HOME="$(cd "$(dirname "$0")"; cd "$(pwd -P)"; cd ..; pwd)"
ISABELLE_TOOL="$ISABELLE_HOME/bin/isabelle"


## diagnostics

PRG="$(basename "$0")"

function usage()
{
  cat <<EOF

Usage: $PRG [MODULES]

  Produce Isabelle distribution modules from current repository sources.
  The MODULES list may contain any of the following:

    all             all modules below
    browser         graph browser (requires jdk)
    doc             documentation (requires latex and rail)
    jars            Scala/JVM components (requires scala)

EOF
  exit 1
}

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


## process command line

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

MODULES="$@"; shift "$#"


## modules

function build_all ()
{
  build_doc
  build_browser
  build_jars
}


function build_browser ()
{
  echo "###"
  echo "### Building graph browser ..."
  echo "###"

  cd "$ISABELLE_HOME/lib/browser"
  make clean all || fail "Failed to build graph browser!"
}


function build_doc ()
{
  echo "###"
  echo "### Building documentation ..."
  echo "###"

  cd "$ISABELLE_HOME/doc-src"
  for DOC in $(cat Dirs)
  do
    pushd "$DOC" >/dev/null
    make clean dvi || fail "DVI document for $DOC failed!"
    make clean pdf || fail "PDF document for $DOC failed!"
    popd >/dev/null
  done
}


function build_jars ()
{
  echo "###"
  echo "### Building Scala/JVM components ..."
  echo "###"

  [ -z "$SCALA_HOME" ] && fail "Scala unavailable: unknown SCALA_HOME"

  pushd "$ISABELLE_HOME/src/Pure" >/dev/null
  "$ISABELLE_TOOL" make jars || fail "Failed to build isabelle-scala.jar"
  popd >/dev/null
}


## main

for MODULE in $MODULES
do
  case $MODULE in
    all) build_all;;
    browser) build_browser;;
    doc) build_doc;;
    jars) build_jars;;
    *) fail "Bad module $MODULE"
  esac
done