#!/bin/sh

no_errors=0

# Rowan
#if [ `hostname` = "rowan" ]; then
#  make=/usr/local/bin/make
#fi

make=/usr/local/bin/make

# BSDI
if [ `uname` = "BSD/OS" ]; then
  make=gmake
fi

handle_error ()
{
  echo ""; echo "ERROR $0 found error in $1"; echo ""
  printf "\7"
  no_errors=`echo $no_errors+1 | bc`
  err_modules="$err_modules $1"
} # handle_error () 

for module in `ls -dF ?? | grep / | cut -f1 -d/`
do
  cd $module
  $make || handle_error $module
  cd ..
done

if [ $no_errors != "0" ]; then
  printf "There were errors in the following modules:\n\t$err_modules\n"
else
  echo ""; echo "$0 finished with no errors."
fi
