meson: Only link to libdl when it is necessary
Recent FreeBSD releases add libdl to the system, which just includes a few stub functions already included in libc. Since it only exists for GNU/Linux compatibility and does nothing useful, it may be better to avoid linking to it when dlopen can be found in libc.
This commit modifies the libdl check to mimic the code in the removed configure.ac file, so libdl is only used when dlopen can't be found without using -ldl.