Fix up-to-date check for intermediate dependencies.

In a dependency chain with static libraries b and c (a->b->c), changing something in c didn't trigger a rebuild of b, but only of c and a.