Fix build when dirent.h is not available

This commit is contained in:
Jakub Adam 2019-06-04 21:31:43 +02:00
parent f850de85ab
commit 49ce76a8cf
3 changed files with 9 additions and 4 deletions

View File

@ -370,6 +370,9 @@ AC_SUBST(PSL_TESTFILE)
AC_FUNC_ALLOCA AC_FUNC_ALLOCA
AC_CHECK_FUNCS([strndup clock_gettime fmemopen nl_langinfo]) AC_CHECK_FUNCS([strndup clock_gettime fmemopen nl_langinfo])
# check for dirent.h
AC_HEADER_DIRENT
# Override the template file name of the generated .pc file, so that there # Override the template file name of the generated .pc file, so that there
# is no need to rename the template file when the API version changes. # is no need to rename the template file when the API version changes.
AC_CONFIG_FILES([Makefile AC_CONFIG_FILES([Makefile

View File

@ -40,7 +40,6 @@
#include <fcntl.h> #include <fcntl.h>
#include <errno.h> #include <errno.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <dirent.h>
#if defined (_MSC_VER) && ! defined (ssize_t) #if defined (_MSC_VER) && ! defined (ssize_t)
#include <basetsd.h> #include <basetsd.h>
@ -49,7 +48,9 @@ typedef SSIZE_T ssize_t;
#include "fuzzer.h" #include "fuzzer.h"
#if defined (TEST_RUN) && defined (HAVE_FMEMOPEN) #if defined (TEST_RUN) && defined (HAVE_FMEMOPEN) && defined (HAVE_DIRENT_H)
#include <dirent.h>
static void test_all_from(const char *dirname) static void test_all_from(const char *dirname)
{ {
@ -122,7 +123,7 @@ int main(int argc, char **argv)
return 0; return 0;
} }
#else /* TEST_RUN && HAVE_FMEMOPEN */ #else /* TEST_RUN && HAVE_FMEMOPEN && HAVE_DIRENT_H */
#ifndef __AFL_LOOP #ifndef __AFL_LOOP
static int __AFL_LOOP(int n) static int __AFL_LOOP(int n)
@ -158,4 +159,4 @@ int main(int argc, char **argv)
#endif #endif
} }
#endif /* TEST_RUN && HAVE_FMEMOPEN*/ #endif /* TEST_RUN && HAVE_FMEMOPEN && HAVE_DIRENT_H */

View File

@ -107,6 +107,7 @@ config.set('BUILTIN_GENERATOR_LIBIDN', enable_builtin == 'libidn')
config.set('HAVE_UNISTD_H', cc.check_header('unistd.h')) config.set('HAVE_UNISTD_H', cc.check_header('unistd.h'))
config.set('HAVE_STDINT_H', cc.check_header('stdint.h')) config.set('HAVE_STDINT_H', cc.check_header('stdint.h'))
config.set('HAVE_ALLOCA_H', cc.check_header('alloca.h')) config.set('HAVE_ALLOCA_H', cc.check_header('alloca.h'))
config.set('HAVE_DIRENT_H', cc.check_header('dirent.h'))
config.set('HAVE_ALLOCA', cc.has_function('alloca')) config.set('HAVE_ALLOCA', cc.has_function('alloca'))
config.set('HAVE_STRNDUP', cc.has_function('strndup')) config.set('HAVE_STRNDUP', cc.has_function('strndup'))
config.set('HAVE_CLOCK_GETTIME', cc.has_function('clock_gettime')) config.set('HAVE_CLOCK_GETTIME', cc.has_function('clock_gettime'))