#!/bin/bash

## Things to test:
##   the plugin builds!
##   plugin loads
##   passes vamp-plugin-tester tests
##   does not export any unnecessary symbols
##   has valid .cat and .n3

platform=linux

configure_maybe() {
    dir="$1"
    if [ ! -f "$dir/Makefile" ] ; then
	if [ -f "$dir/configure" ] ; then
	    ( cd "$dir" ; ./configure )
	fi
    fi
}

find_makefile() {
    dir="$1"
    for f in Makefile Makefile.$platform build/$platform/Makefile build/$platform/Makefile.$platform ; do
	if [ -f "$dir/$f" ]; then
	    echo $f
	    break
	fi
    done
}

for dir in $(cat .hgsub | awk '{ print $1; }') ; do
    echo
    echo "Processing: $dir"
    if configure_maybe "$dir"; then
	mfile=$(find_makefile "$dir")
	if [ -n "$mfile" ]; then
	    make -C "$dir" -f "$mfile"
	else
	    echo "Failed to find a Makefile in $dir"
	fi
    fi
done

	    
