Index: extensions/gsdl-ocr/trunk/CASCADE-MAKE.sh
===================================================================
--- extensions/gsdl-ocr/trunk/CASCADE-MAKE.sh	(revision 16800)
+++ extensions/gsdl-ocr/trunk/CASCADE-MAKE.sh	(revision 16800)
@@ -0,0 +1,22 @@
+#!/bin/bash
+
+source bin/script/test-setup.bash
+source lib/cascade-lib.bash
+
+if [ ! -d "$GEXTOCR_INSTALLED" ] ; then
+  echo "Making directory \"$GEXTOCR_INSTALLED\""
+  mkdir "$GEXTOCR_INSTALLED"
+fi
+
+for d in packages ; do
+  echo "Running $d/CASCADE-MAKE.sh $*"
+
+  (cd $d ; ./CASCADE-MAKE.sh $*)
+
+  if [ $? != 0 ] ; then
+    echo "Error encountered running $d/CASCADE-COMPILE.sh"
+    exit 1
+  fi
+done
+
+
Index: extensions/gsdl-ocr/trunk/bin/script/test-setup.bash
===================================================================
--- extensions/gsdl-ocr/trunk/bin/script/test-setup.bash	(revision 16800)
+++ extensions/gsdl-ocr/trunk/bin/script/test-setup.bash	(revision 16800)
@@ -0,0 +1,8 @@
+
+
+if [ "x$GEXTOCR" = "x" ] ; then
+  echo "OCR extension environment variable GEXTOCR not set."
+  echo "Have you sourced the extension's setup file, e.g. setup.bash?"
+  exit -1
+fi
+
Index: extensions/gsdl-ocr/trunk/devel.bash
===================================================================
--- extensions/gsdl-ocr/trunk/devel.bash	(revision 16800)
+++ extensions/gsdl-ocr/trunk/devel.bash	(revision 16800)
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+if [ "x$GEXTOCR" = "x" ] ; then
+  source setup.bash
+fi
+
+if [ "x$GEXTOCR_DEVEL" = "x" ] ; then
+
+  # Set environment variable so we can tell devel.bash has been sourced
+  export GEXTOCR_DEVEL=$GEXTOCR
+
+  export PATH=$GEXTOCR/bin/:$GEXTOCR_INSTALLED/devel/bin:$PATH
+
+  export PERL5PATH=$GEXTOCR_INSTALLED/devel/lib/perl5/vendor_perl/5.8.8
+
+  echo "+Your environment is now setup for OCR (Ocropus) development"
+else
+  echo "+Your environment is already setup for OCR (Ocropus) development"
+fi
+
Index: extensions/gsdl-ocr/trunk/lib/cascade-lib.bash
===================================================================
--- extensions/gsdl-ocr/trunk/lib/cascade-lib.bash	(revision 16800)
+++ extensions/gsdl-ocr/trunk/lib/cascade-lib.bash	(revision 16800)
@@ -0,0 +1,181 @@
+
+run_untar()
+{
+  local package=$1
+  local version=$2
+  local ext=$3
+
+  tar_args="";
+
+  if [ $ext = ".tar.gz" ] ; then
+    tar_args="xvzf"
+  elif [ $ext = ".tgz" ] ; then
+    tar_args="xvzf"
+  elif [ $ext = ".tar.bz2" ] ; then
+    tar_args="xvjf"
+  elif [ $ext = ".tar.bz" ] ; then
+    tar_args="xvjf"
+  elif [ $ext = ".tar" ] ; then
+    tar_args="xvf"
+  else 
+    echo "Warning: Unrecognized extension: $ext"
+    echo "Assuming tarred, gzipped file"
+    tar_args="xvjf"
+  fi
+
+
+  echo tar $tar_args $package$version$ext 
+  tar $tar_args $package$version$ext
+
+  if [ $? != 0 ] ; then
+    echo "      Error encountered running *untar* stage of $progname"
+    exit 1
+  fi
+}
+
+opt_run_tarclean()
+{
+  local type=$1
+  local package=$2
+  local version=$3
+
+  if [ $type = "1" ] ; then
+
+    local dir=$package$version
+    if [ -d $dir ] ; then
+      echo /bin/rm -rf $dir
+      /bin/rm -rf $dir
+
+      if [ $? != 0 ] ; then
+        echo "      Error encountered running *tarclean* stage of $progname"
+        exit 1
+      fi
+    else 
+      echo "Unable to find directory $dir"
+    fi
+  fi
+}
+
+opt_run_untar()
+{
+  local force_untar=$1
+  local auto_untar=$2
+  local package=$3
+  local version=$4
+
+  local ext="";
+
+  if [ ! -z "$5" ] ; then
+    ext=$5
+  else 
+    ext=".tar.gz"
+  fi
+
+  if [ $force_untar = "1" ] ; then
+    run_untar $package $version $ext
+  elif [ $auto_config = "1" ] ; then
+    if [ -d $package$version ] ; then
+      echo "Found untarred version of $package$version$ext => no need to untar"
+    else
+      run_untar $package $version $ext
+    fi
+  fi
+}
+
+
+opt_run_configure()
+{
+  local force_config=$1
+  local auto_config=$2
+  local package=$3
+  local version=$4
+  local prefix=$5
+  local opt_args="";
+
+  if [ ! -z "$6" ] ; then
+    opt_args=$6
+  fi
+
+  if [ $force_config = "1" ] ; then
+    ( echo "[pushd $package$version]"
+      cd $package$version ; \
+      echo ./configure --prefix="$prefix" $opt_args ; \
+      ./configure --prefix="$prefix" $opt_args )
+      echo "[popd]"
+    if [ $? != 0 ] ; then
+        echo "      Error encountered running *configure* stage of $progname"
+        exit 1
+    fi
+  else
+    if [ $auto_config = "1" ] ; then
+      echo "Found top-level for ${progname%.*} => no need to run ./configure"
+    fi
+  fi
+}
+
+
+opt_run_make()
+{
+  local type=$1
+  local package=$2
+  local version=$3
+  local opt_target=""
+
+  if [ ! -z "$4" ] ; then
+    opt_target=$4
+  fi
+
+  if [ $type = "1" ] ; then
+    ( cd $package$version ; \
+      make $opt_target)
+
+    if [ $? != 0 ] ; then
+        echo "      Error encountered running *make $target* stage of $progname"
+        exit 1
+    fi
+  fi
+}
+
+
+
+force_untar=0
+auto_untar=0
+
+force_config=0
+auto_config=0
+
+compile=0
+install=0
+clean=0
+distclean=0
+tarclean=0
+
+if [ $# -gt 0 ] ; then
+  for cmd in $* ; do
+    echo $cmd
+    if   [ $cmd = "untar" ] ;     then force_untar=1
+    elif [ $cmd = "configure" ] ; then force_config=1
+    elif [ $cmd = "compile" ]   ; then compile=1
+    elif [ $cmd = "install" ]   ; then install=1  
+    elif [ $cmd = "clean" ]     ; then clean=1  
+    elif [ $cmd = "distclean" ] ; then distclean=1
+    elif [ $cmd = "tarclean" ] ;  then tarclean=1
+    fi
+  done
+else
+  # defaults
+  auto_untar=1
+  auto_config=1
+  compile=1
+  install=1
+  clean=0
+  distclean=0
+  tarclean=0
+fi
+
+if [ $auto_config = "1" ] ; then
+  if [ ! -e $package$version/Makefile ] ; then
+    force_config=1
+  fi
+fi
+
Index: extensions/gsdl-ocr/trunk/packages/CASCADE-MAKE.sh
===================================================================
--- extensions/gsdl-ocr/trunk/packages/CASCADE-MAKE.sh	(revision 16800)
+++ extensions/gsdl-ocr/trunk/packages/CASCADE-MAKE.sh	(revision 16800)
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+
+for d in devel cmdline ; do
+  echo "  Running $d/CASCADE-MAKE.sh $*"
+
+  (cd $d ; ./CASCADE-MAKE.sh $*)
+
+  if [ $? != 0 ] ; then
+    echo "  Error encountered running $d/CASCADE-COMPILE.sh"
+    exit 1
+  fi
+done
Index: extensions/gsdl-ocr/trunk/packages/cmdline/CASCADE-MAKE.sh
===================================================================
--- extensions/gsdl-ocr/trunk/packages/cmdline/CASCADE-MAKE.sh	(revision 16800)
+++ extensions/gsdl-ocr/trunk/packages/cmdline/CASCADE-MAKE.sh	(revision 16800)
@@ -0,0 +1,18 @@
+#!/bin/bash
+
+if [ ! -d "$GEXTOCR_INSTALLED/cmdline" ] ; then
+  echo "    Making directory \"$GEXTOCR_INSTALLED/cmdline\""
+  mkdir "$GEXTOCR_INSTALLED/cmdline"
+fi
+
+
+for d in LIBTIFF TESSERACT LIBPNG LIBJPEG OCROPUS ; do
+  echo "    Running CASCADE-MAKE/$d.sh $*"
+
+  ./CASCADE-MAKE/$d.sh $*
+
+  if [ $? != 0 ] ; then
+    echo "    Error encountered running CASCADE-COMPILE/$d.sh"
+    exit 1
+  fi
+done
Index: extensions/gsdl-ocr/trunk/packages/cmdline/CASCADE-MAKE/LIBJPEG.sh
===================================================================
--- extensions/gsdl-ocr/trunk/packages/cmdline/CASCADE-MAKE/LIBJPEG.sh	(revision 16800)
+++ extensions/gsdl-ocr/trunk/packages/cmdline/CASCADE-MAKE/LIBJPEG.sh	(revision 16800)
@@ -0,0 +1,24 @@
+#!/bin/bash
+
+package=jpeg
+version=-6b
+
+progname=$0
+
+source ../../bin/script/test-setup.bash
+source ../../lib/cascade-lib.bash
+
+prefix=$GEXTOCR_INSTALLED/cmdline
+
+
+opt_run_untar $force_untar $auto_untar $package $version
+opt_run_configure $force_config $auto_config $package $version "$prefix" \
+        --enable-static
+
+opt_run_make $compile   $package $version
+opt_run_make $install   $package $version "install-lib"
+opt_run_make $clean     $package $version "clean"
+opt_run_make $distclean $package $version "distclean"
+
+opt_run_tarclean $tarclean $package $version
+
Index: extensions/gsdl-ocr/trunk/packages/cmdline/CASCADE-MAKE/LIBPNG.sh
===================================================================
--- extensions/gsdl-ocr/trunk/packages/cmdline/CASCADE-MAKE/LIBPNG.sh	(revision 16800)
+++ extensions/gsdl-ocr/trunk/packages/cmdline/CASCADE-MAKE/LIBPNG.sh	(revision 16800)
@@ -0,0 +1,23 @@
+#!/bin/bash
+
+package=libpng
+version=-1.2.29
+
+progname=$0
+
+source ../../bin/script/test-setup.bash
+source ../../lib/cascade-lib.bash
+
+prefix=$GEXTOCR_INSTALLED/cmdline
+
+opt_run_untar $force_untar $auto_untar $package $version 
+opt_run_configure $force_config $auto_config $package $version "$prefix"
+
+opt_run_make $compile   $package $version
+opt_run_make $install   $package $version "install"
+opt_run_make $clean     $package $version "clean"
+opt_run_make $distclean $package $version "distclean"
+
+opt_run_tarclean $tarclean $package $version
+
+
Index: extensions/gsdl-ocr/trunk/packages/cmdline/CASCADE-MAKE/LIBTIFF.sh
===================================================================
--- extensions/gsdl-ocr/trunk/packages/cmdline/CASCADE-MAKE/LIBTIFF.sh	(revision 16800)
+++ extensions/gsdl-ocr/trunk/packages/cmdline/CASCADE-MAKE/LIBTIFF.sh	(revision 16800)
@@ -0,0 +1,23 @@
+#!/bin/bash
+
+package=tiff
+version=-3.8.2
+
+progname=$0
+
+source ../../bin/script/test-setup.bash
+source ../../lib/cascade-lib.bash
+
+prefix=$GEXTOCR_INSTALLED/cmdline
+
+opt_run_untar $force_untar $auto_untar $package $version 
+opt_run_configure $force_config $auto_config $package $version "$prefix"
+
+opt_run_make $compile   $package $version
+opt_run_make $install   $package $version "install"
+opt_run_make $clean     $package $version "clean"
+opt_run_make $distclean $package $version "distclean"
+
+opt_run_tarclean $tarclean $package $version
+
+
Index: extensions/gsdl-ocr/trunk/packages/cmdline/CASCADE-MAKE/OCROPUS.sh
===================================================================
--- extensions/gsdl-ocr/trunk/packages/cmdline/CASCADE-MAKE/OCROPUS.sh	(revision 16800)
+++ extensions/gsdl-ocr/trunk/packages/cmdline/CASCADE-MAKE/OCROPUS.sh	(revision 16800)
@@ -0,0 +1,29 @@
+#!/bin/bash
+
+package=ocropus
+version=-0.2
+
+progname=$0
+
+source ../../bin/script/test-setup.bash
+source ../../lib/cascade-lib.bash
+
+prefix=$GEXTOCR_INSTALLED/cmdline
+
+opt_run_untar $force_untar $auto_untar $package $version 
+opt_run_configure $force_config $auto_config $package $version "$prefix" \
+    "--with-tesseract=$prefix \
+     CFLAGS=-I$prefix/include \
+     CXXFLAGS=-I$prefix/include \
+     CPPFLAGS=-I$prefix/include \
+     LDFLAGS=-L$prefix/lib"
+
+
+opt_run_make $compile   $package $version
+opt_run_make $install   $package $version "install"
+opt_run_make $clean     $package $version "clean"
+opt_run_make $distclean $package $version "distclean"
+
+opt_run_tarclean $tarclean $package $version
+
+
Index: extensions/gsdl-ocr/trunk/packages/cmdline/CASCADE-MAKE/TESSERACT.sh
===================================================================
--- extensions/gsdl-ocr/trunk/packages/cmdline/CASCADE-MAKE/TESSERACT.sh	(revision 16800)
+++ extensions/gsdl-ocr/trunk/packages/cmdline/CASCADE-MAKE/TESSERACT.sh	(revision 16800)
@@ -0,0 +1,24 @@
+#!/bin/bash
+
+package=tesseract
+version=-svn
+
+progname=$0
+
+source ../../bin/script/test-setup.bash
+source ../../lib/cascade-lib.bash
+
+prefix=$GEXTOCR_INSTALLED/cmdline
+
+opt_run_untar $force_untar $auto_untar $package $version 
+opt_run_configure $force_config $auto_config $package $version "$prefix" \
+  --with-libtif=$prefix
+
+opt_run_make $compile   $package $version
+opt_run_make $install   $package $version "install"
+opt_run_make $clean     $package $version "clean"
+opt_run_make $distclean $package $version "distclean"
+
+opt_run_tarclean $tarclean $package $version
+
+
Index: extensions/gsdl-ocr/trunk/packages/devel/CASCADE-MAKE.sh
===================================================================
--- extensions/gsdl-ocr/trunk/packages/devel/CASCADE-MAKE.sh	(revision 16800)
+++ extensions/gsdl-ocr/trunk/packages/devel/CASCADE-MAKE.sh	(revision 16800)
@@ -0,0 +1,19 @@
+#!/bin/bash
+
+
+if [ ! -d "$GEXTOCR_INSTALLED/devel" ] ; then
+  echo "Making directory \"$GEXTOCR_INSTALLED/devel\""
+  mkdir "$GEXTOCR_INSTALLED/devel"
+fi
+
+
+for d in FTJAM ; do
+  echo "    Running CASCADE-MAKE/$d.sh $*"
+
+  ./CASCADE-MAKE/$d.sh $*
+
+  if [ $? != 0 ] ; then
+    echo "  Error encountered running CASCADE-COMPILE/$d.sh"
+    exit 1
+  fi
+done
Index: extensions/gsdl-ocr/trunk/packages/devel/CASCADE-MAKE/FTJAM.sh
===================================================================
--- extensions/gsdl-ocr/trunk/packages/devel/CASCADE-MAKE/FTJAM.sh	(revision 16800)
+++ extensions/gsdl-ocr/trunk/packages/devel/CASCADE-MAKE/FTJAM.sh	(revision 16800)
@@ -0,0 +1,23 @@
+#!/bin/bash
+
+package=ftjam
+version=-2.5.2
+
+progname=$0
+
+source ../../bin/script/test-setup.bash
+source ../../lib/cascade-lib.bash
+
+prefix=$GEXTOCR_INSTALLED/devel
+
+opt_run_untar $force_untar $auto_untar $package $version 
+opt_run_configure $force_config $auto_config $package $version "$prefix"
+
+opt_run_make $compile   $package $version
+opt_run_make $install   $package $version "install"
+opt_run_make $clean     $package $version "clean"
+opt_run_make $distclean $package $version "distclean"
+
+opt_run_tarclean $tarclean $package $version
+
+
Index: extensions/gsdl-ocr/trunk/setup.bash
===================================================================
--- extensions/gsdl-ocr/trunk/setup.bash	(revision 16800)
+++ extensions/gsdl-ocr/trunk/setup.bash	(revision 16800)
@@ -0,0 +1,35 @@
+
+extdesc="the Optical Character Recognition (OCR) Extension"
+
+if [ "x$GEXTOCR" = "x" ] ; then
+  export GEXTOCR=`pwd`
+  export GEXTOCR_INSTALLED=$GEXTOCR/installed
+
+  export PATH=$GEXTOCR_INSTALLED/cmdline/bin:$PATH
+
+  # Needed for running tesseract
+  export TESSDATA_PREFIX=$GEXTOCR_INSTALLED/cmdline/share/
+
+
+  if [ "x$LD_LIBRARY_PATH" = "x" ] ; then
+    export LD_LIBRARY_PATH=$GEXTOCR_INSTALLED/cmdline/lib
+  else
+    export LD_LIBRARY_PATH=$GEXTOCR_INSTALLED/cmdline/lib:$LD_LIBRARY_PATH
+  fi
+
+  if [ "x$GSDLEXTS" = "x" ] ; then
+    export GSDLEXTS=ocr
+  else 
+    export GSDLEXTS=$GSDLEXTS:ocr
+  fi
+
+
+  echo "+Your environment is now setup for $extdesc to Greenstone"
+else
+  echo "+Your environment is already setup for $extdesc to Greenstone"
+fi
+
+
+if [ -e devel.bash ] ; then
+  source devel.bash
+fi
