Use NSFoundationVersionNumber to detect Foundation

This is more reliable than checking for CFRetain to see if
CoreFoundation is linked, as CFRetain is always available, even when not
linked against CoreFoundation explicitly.