Conditionally include dirent.h and dlfcn.h

If you do not have a filesystem or do not support dav or
dynamic loading, the corresponding header files need not
be included (some environments might not have them).
Merge pull request #431 from jhnwkmn/reduce-includes

Conditionally include dirent.h and dlfcn.h