Check if dirent.d_type is available in the configure script.

Add a check in the configure script to check if the dirent struct has a d_type
member, since that's not available on all systems.
This commit is contained in:
Kyle Brenneman 2019-04-26 11:06:59 -06:00
parent 0e0060fba5
commit 58c8c4a402
2 changed files with 17 additions and 0 deletions

View file

@ -296,6 +296,21 @@ AS_IF([test "x$HAVE_RTLD_NOLOAD" = "xyes"],
[AC_DEFINE([HAVE_RTLD_NOLOAD], 1,
[Define to 1 if the compiler supports RTLD_NOLOAD.])])
AC_MSG_CHECKING([for dirent.d_type])
AC_COMPILE_IFELSE([AC_LANG_SOURCE([
#include <dirent.h>
void foo(struct dirent *ent)
{
(void) ent->d_type;
}
])],
[HAVE_DIRENT_DTYPE=yes],[HAVE_DIRENT_DTYPE=no])
AC_MSG_RESULT($HAVE_DIRENT_DTYPE)
AS_IF([test "x$HAVE_DIRENT_DTYPE" = "xyes"],
[AC_DEFINE([HAVE_DIRENT_DTYPE], 1,
[Define to 1 if struct dirent has a d_type member.])])
# See if the linker supports the --no-undefined flag.
AX_CHECK_LINK_FLAG([-Xlinker --no-undefined],
[AC_SUBST([LINKER_FLAG_NO_UNDEFINED], ["-Xlinker --no-undefined"])],

View file

@ -73,10 +73,12 @@ void LoadVendors(void)
static int ScandirFilter(const struct dirent *ent)
{
#if defined(HAVE_DIRENT_DTYPE)
// Ignore the entry if we know that it's not a regular file or symlink.
if (ent->d_type != DT_REG && ent->d_type != DT_LNK && ent->d_type != DT_UNKNOWN) {
return 0;
}
#endif
// Otherwise, select any JSON files.
if (fnmatch("*.json", ent->d_name, 0) == 0) {