build: make libdl optional
On modern libcs, libdl is either an empty library that persists for compatibility purposes (the library functions that used to live there having moved into libc), or it doesn't exist at all. For compatibility with the latter, while still supporting e.g. old glibc that does require linking libdl, make the libdl dependency optional, and assume that if it's absent libc provides the functions we need.