diff --git a/configure b/configure
index 28757869b5526498e1c06392033b1ad451d38232..c9c04e3fedafc45338a47aef8b7da81465178a5e 100755
--- a/configure
+++ b/configure
@@ -7215,6 +7215,7 @@ done
 
 
 
+
 
 
 for ac_header in \
@@ -7231,6 +7232,7 @@ for ac_header in \
 	capi20.h \
 	curses.h \
 	direct.h \
+	dirent.h \
 	dlfcn.h \
 	elf.h \
 	float.h \
@@ -17204,6 +17206,7 @@ esac
 
 
 
+
 
 
 for ac_func in \
@@ -17249,6 +17252,7 @@ for ac_func in \
 	prctl \
 	pread \
 	pwrite \
+	readdir \
 	readlink \
 	rfork \
 	sched_yield \
diff --git a/configure.ac b/configure.ac
index 52f5752a933ffd9440b4e73c5be9ee21195b54f7..a7783f2dec5f0c3eba5a5a5033a032bcdcd732a5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -237,6 +237,7 @@ AC_CHECK_HEADERS(\
 	capi20.h \
 	curses.h \
 	direct.h \
+	dirent.h \
 	dlfcn.h \
 	elf.h \
 	float.h \
@@ -1401,6 +1402,7 @@ AC_CHECK_FUNCS(\
 	prctl \
 	pread \
 	pwrite \
+	readdir \
 	readlink \
 	rfork \
 	sched_yield \
diff --git a/dlls/crypt32/rootstore.c b/dlls/crypt32/rootstore.c
index b1bbe9f80f903b52925a9c1fd67131e37dd324f5..22bfd19d34e0af37cdc413a85c7ae5b3bb6024d6 100644
--- a/dlls/crypt32/rootstore.c
+++ b/dlls/crypt32/rootstore.c
@@ -22,7 +22,9 @@
 #ifdef HAVE_SYS_STAT_H
 #include <sys/stat.h>
 #endif
+#ifdef HAVE_DIRENT_H
 #include <dirent.h>
+#endif
 #include <fcntl.h>
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
@@ -313,6 +315,7 @@ static BOOL import_certs_from_path(LPCSTR path, HCERTSTORE store,
  */
 static BOOL import_certs_from_dir(LPCSTR path, HCERTSTORE store)
 {
+#ifdef HAVE_READDIR
     BOOL ret = FALSE;
     DIR *dir;
 
@@ -341,6 +344,10 @@ static BOOL import_certs_from_dir(LPCSTR path, HCERTSTORE store)
         }
     }
     return ret;
+#else
+    FIXME("not implemented without readdir available\n");
+    return FALSE;
+#endif
 }
 
 /* Opens path, which may be a file or a directory, and imports any certificates
diff --git a/include/config.h.in b/include/config.h.in
index 49ed198d6672fce243e268897383abed9dbef965..3566a9453f795a153d60a9ce8d24c1034e2d7291 100644
--- a/include/config.h.in
+++ b/include/config.h.in
@@ -65,6 +65,9 @@
 /* Define to 1 if you have the <direct.h> header file. */
 #undef HAVE_DIRECT_H
 
+/* Define to 1 if you have the <dirent.h> header file. */
+#undef HAVE_DIRENT_H
+
 /* Define to 1 if you have the <DiskArbitration/DiskArbitration.h> header
    file. */
 #undef HAVE_DISKARBITRATION_DISKARBITRATION_H
@@ -570,6 +573,9 @@
 /* Define to 1 if you have the `pwrite' function. */
 #undef HAVE_PWRITE
 
+/* Define to 1 if you have the `readdir' function. */
+#undef HAVE_READDIR
+
 /* Define to 1 if you have the `readlink' function. */
 #undef HAVE_READLINK