try to rearrange libs used for linking ...

If all of that fails - libgroups are required (but I think in case of
useshrplib=false we might to skip the test at all)