Admin/build
author wenzelm
Sat Aug 16 13:32:23 2008 +0200 (2008-08-16)
changeset 27915 42581956d75b
parent 27904 343696007eca
child 27978 9fb6cfaa5da5
permissions -rwxr-xr-x
more robust handling of directory layout variants;
     1 #!/usr/bin/env bash
     2 #
     3 # $Id$
     4 #
     5 # Administrative build for Isabelle source distribution.
     6 
     7 ## global environment
     8 
     9 #paranoia setting for sunbroy
    10 PATH="/usr/local/dist/DIR/j2sdk1.5.0/bin:$PATH"
    11 
    12 PATH="/home/scala/scala/bin:$PATH"
    13 
    14 
    15 ## directory layout
    16 
    17 ISABELLE_DIR="$(cd "$(dirname "$0")"; cd "$(pwd -P)"; cd ..; pwd)"
    18 
    19 if [ -d "$ISABELLE_DIR/Distribution" ]; then
    20   ISATOOL="$ISABELLE_DIR/Distribution/bin/isatool"
    21   ISABELLE_LIB="$ISABELLE_DIR/Distribution/lib"
    22   ISABELLE_SRC="$ISABELLE_DIR"
    23   ISABELLE_DOC_SRC="$ISABELLE_DIR/Doc"
    24 else
    25   ISATOOL="$ISABELLE_DIR/bin/isatool"
    26   ISABELLE_LIB="$ISABELLE_DIR/lib"
    27   ISABELLE_SRC="$ISABELLE_DIR/src"
    28   ISABELLE_DOC_SRC="$ISABELLE_DIR/doc-src"
    29 fi
    30 
    31 
    32 ## diagnostics
    33 
    34 PRG="$(basename "$0")"
    35 
    36 function usage()
    37 {
    38   cat <<EOF
    39 
    40 Usage: $PRG [MODULES]
    41 
    42   Produce Isabelle distribution modules from current repository sources.
    43   The MODULES list may contain any of the following:
    44 
    45     all             all modules below
    46     browser         graph browser (requires jdk)
    47     doc             documentation (requires latex and rail)
    48     jars            JVM components (requires jdk and scala)
    49 
    50 EOF
    51   exit 1
    52 }
    53 
    54 function fail()
    55 {
    56   echo "$1" >&2
    57   exit 2
    58 }
    59 
    60 
    61 ## process command line
    62 
    63 [ "$#" -eq 0 ] && usage
    64 
    65 MODULES="$@"; shift "$#"
    66 
    67 
    68 ## modules
    69 
    70 function build_all ()
    71 {
    72   build_doc
    73   build_browser
    74   build_jars
    75 }
    76 
    77 
    78 function build_browser ()
    79 {
    80   echo "###"
    81   echo "### Building graph browser ..."
    82   echo "###"
    83 
    84   cd "$ISABELLE_LIB/browser"
    85   make clean all || fail "Failed to build graph browser!"
    86 }
    87 
    88 
    89 function build_doc ()
    90 {
    91   echo "###"
    92   echo "### Building documentation ..."
    93   echo "###"
    94 
    95   cd "$ISABELLE_DOC_SRC"
    96   for DOC in $(cat Dirs)
    97   do
    98     pushd "$DOC" >/dev/null
    99     make clean dvi || fail "DVI document for $DOC failed!"
   100     make clean pdf || fail "PDF document for $DOC failed!"
   101     popd >/dev/null
   102   done
   103 }
   104 
   105 
   106 function build_jars ()
   107 {
   108   echo "###"
   109   echo "### Building JVM components ..."
   110   echo "###"
   111 
   112   pushd "$ISABELLE_SRC/Pure" >/dev/null
   113   "$ISATOOL" make jar || fail "Failed to build Pure.jar!"
   114   popd >/dev/null
   115 
   116   pushd "$ISABELLE_LIB/classes" >/dev/null
   117   ./mk
   118   [ -f isabelle.jar ] || fail "Failed to build Isabelle process wrapper!"
   119   popd >/dev/null
   120 
   121   if [ -d "$HOME/lib/jedit/current" ]; then
   122     type -p scalac >/dev/null || fail "Scala compiler unavailable"
   123     pushd "$ISABELLE_LIB/jedit/plugin" >/dev/null
   124     ./mk
   125     [ -f ../isabelle.jar ] || fail "Failed to build jEdit plugin!"
   126     popd >/dev/null
   127   else
   128     echo "Warning: skipping jedit plugin"
   129   fi
   130 }
   131 
   132 
   133 ## main
   134 
   135 for MODULE in $MODULES
   136 do
   137   case $MODULE in
   138     all) build_all;;
   139     browser) build_browser;;
   140     doc) build_doc;;
   141     jars) build_jars;;
   142     *) fail "Bad module $MODULE"
   143   esac
   144 done