Fixes to link with petsc 3.1 when other petsc versions are present.