#! /bin/sh
# Simple shell script to run the Xbae examples
#
# It also sets the required environment variables to run
# the example programs properly
#

cd `dirname $0`
SRCDIR=`pwd`/../src


# Now cycle through the list of directories and example programs
if [ -s "$1" ]; then
    dirlist="$*"
else
    dirlist="*"
fi

for i in $dirlist
do
    if [ -d $i -a -f $i/Makefile ]
    then
    	echo "running tests in: $i" 
	cd $i
        EXAMPLES=`grep "noinst_PROGRAMS =" <Makefile | sed -e "s/noinst_PROGRAMS =//" | grep -v '$(EXEEXT)' | grep -v "^#"`
	for j in $EXAMPLES
	  do
	  echo " $j"
	  ../../libtool --mode=execute ./$j
	  done
	cd ..
    fi
done

echo "Finished!"
