* configure.ac: Check whether struct dirent has a d_type field

* src/dir.c (dir_contents_file_exists_p): Use the autoconf macro
HAVE_STRUCT_DIRENT_D_TYPE rather than relying on the GNU libc-
specific _DIRENT_HAVE_D_TYPE.
* lib/glob.c: Set HAVE_D_TYPE if HAVE_STRUCT_DIRENT_D_TYPE.
diff --git a/configure.ac b/configure.ac
index da1e17d..a1f2555 100644
--- a/configure.ac
+++ b/configure.ac
@@ -164,6 +164,9 @@
 AC_FUNC_STRCOLL
 AC_FUNC_CLOSEDIR_VOID
 
+# dir.c and our glob.c use dirent.d_type if available
+AC_STRUCT_DIRENT_D_TYPE
+
 # See if the user wants to add (or not) GNU Guile support
 AC_ARG_WITH([guile], [AS_HELP_STRING([--with-guile],
             [Support GNU Guile for embedded scripting])])
diff --git a/lib/glob.c b/lib/glob.c
index f221a53..adad16f 100644
--- a/lib/glob.c
+++ b/lib/glob.c
@@ -117,7 +117,7 @@
 
 /* When used in the GNU libc the symbol _DIRENT_HAVE_D_TYPE is available
    if the `d_type' member for `struct dirent' is available.  */
-#ifdef _DIRENT_HAVE_D_TYPE
+#if defined(_DIRENT_HAVE_D_TYPE) || defined(HAVE_STRUCT_DIRENT_D_TYPE)
 # define HAVE_D_TYPE	1
 #endif
 
diff --git a/src/dir.c b/src/dir.c
index efa35f6..b867f95 100644
--- a/src/dir.c
+++ b/src/dir.c
@@ -732,7 +732,7 @@
 #else
           df->name = strcache_add_len (d->d_name, len);
 #endif
-#ifdef _DIRENT_HAVE_D_TYPE
+#ifdef HAVE_STRUCT_DIRENT_D_TYPE
           df->type = d->d_type;
 #endif
           df->length = len;
@@ -1245,7 +1245,7 @@
 #ifdef _DIRENT_HAVE_D_NAMLEN
           d->d_namlen = len - 1;
 #endif
-#ifdef _DIRENT_HAVE_D_TYPE
+#ifdef HAVE_STRUCT_DIRENT_D_TYPE
           d->d_type = df->type;
 #endif
           memcpy (d->d_name, df->name, len);