Don't include static system libraries

Only link libraries statically if they're not in a system directory and we
detect that they exist. Otherwise system libraries should all be linked
dynamically as usual