#!/bin/sh

# compileforms
#
# Recompile all ffc forms (use when FFC has been updated)
#
# This script should be run from the top level directory.
                                                                                                    
# Simple test to see where we are
# FIXME: Does not work when typing ./scripts/...
CHECK=`echo $0 | cut -d'/' -f1`
if [ "$CHECK" != "scripts" ]; then
        echo "This script must be run from the top level directory."
        exit 1
fi

cd src/modules

FORMS=`find . -name '*.form'`
for f in $FORMS; do
	MODULE=`echo $f | cut -d'/' -f2`
	# Temporarily skip Navier-Stokes to speed up testing
	if [ $MODULE != "navierstokes" ]; then
    		FORMFILE=`echo $f | cut -d'/' -f4`
		cd $MODULE/dolfin
		ffc $FORMFILE
		cd ../../
	fi
done
