diff --git a/src/dynamic_load.c b/src/dynamic_load.c
index 0992ea00ef39758f102439d9703c2f80a1478b91..0af7af1a9bad541bcc42bda9ad5e1c245a011248 100644
--- a/src/dynamic_load.c
+++ b/src/dynamic_load.c
@@ -1,6 +1,6 @@
 #include "global.h"
 
-#if !defined(HAVE_DLFCN_H) || !defined(HAVE_DLSYM) || !defined(HAVE_DLOPEN)
+#if !defined(HAVE_DLSYM) || !defined(HAVE_DLOPEN)
 #undef HAVE_DLOPEN
 #endif
 
@@ -11,7 +11,10 @@
 #include "module.h"
 #include "stralloc.h"
 #include "macros.h"
+
+#ifdef HAVE_DLFCN_H
 #include <dlfcn.h>
+#endif
 
 struct module_list
 {
diff --git a/src/machine.h.in b/src/machine.h.in
index ab080e190d0bd621e458524d16327b99dd12da05..86c5517d402ee5175276b2e6a744d49ba04700c2 100644
--- a/src/machine.h.in
+++ b/src/machine.h.in
@@ -339,12 +339,12 @@
 #undef _THREAD_SAFE
 
 /* Define this if you have dlopen() */
-#define HAVE_DLOPEN
+#undef HAVE_DLOPEN
 
 /* Define this if you have dlsym() */
-#define HAVE_DLSYM
+#undef HAVE_DLSYM
 
 /* Define this if you have <dlfcn.h> */
-#define HAVE_DLFCN_H
+#undef HAVE_DLFCN_H
 
 #endif /* MACHINE_H */