use ldd and Config to determine libc in places where ldd is available

This patch changes the libc guessing game to use ldd on platforms that I am at least pretty sure that support it.  It should be more reliable.  I tested this on Linux, FreeBSD, NetBSD, OpenBSD and Solaris.