#!/bin/sh
#
# Copyright (C) 2005-2006 Anders Logg.
# Licensed under the GNU GPL Version 2.
#
# 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

FORMFILES=`find . -name '*.form'`

TOPDIR=`pwd`

for FORMFILE in $FORMFILES; do

    echo "--- Compiling $FORMFILE ---"

    DIRNAME=`dirname $FORMFILE`
    FILENAME=`echo $FORMFILE | sed s#$DIRNAME/##`

    cd $DIRNAME
    ffc $FILENAME
    cd $TOPDIR

done
