build: fix race condition in test deps

Declare proper transitive dependencies when building with an in-tree
copy of libgtest so that `make` knows when to build what.

A nice side effect is that it no longer runs libgtest's configure script
on every invocation of `make check`. Should speed up the edit/build/test
cycle a bit.

Newer versions of automake are more aggressive when it comes to
parallelizing builds and that becomes apparent when executing
`make -j<n> check` with n >= 2: the test suite build failed spuriously
because `make` tried to compile the test runner and run libgtest's
configure script at the same time.