#!/bin/sh

### Exit immediately if a command exits with a non-zero status
set -e

### Get temporary directory and change to it
tmpdir=$(mktemp --directory)
cd $tmpdir

### Copy all distributed exemples here
cp /usr/share/doc/librsb-dev/examples/* .

### Compile them
echo "***** Compiling the sources..."
./make.sh

### Run the examples
echo "***** Running the examples..."
for s in *.c *.F90 ; do
  p=$(basename $(basename $s .c) .F90)
  echo "===== $p"
  ./$p
done

### Do cleanup
cd ..
rm -rf $tempdir
