Work around bug in automake

There is an issue with later automakes and path substitution that
breaks test/Makefile. See e.g. http://debbugs.gnu.org/db/14/14561.html

This patch is from the debian package and works around this by doing
the expansion in configure instead.