build: check for dlopen() in a BSD-friendly way.

From http://www.flameeyes.eu/autotools-mythbuster/autoconf/finding.html