use better strategy to check the need for --no-as-needed link flag.

Copied from https://github.com/plone/Installers-UnifiedInstaller copy of z3c.recipe.staticlxml.