From 598bc078a34ab3704eae7b278b32716bb1c81163 Mon Sep 17 00:00:00 2001 From: cedric Date: Mon, 5 Dec 2011 13:57:10 +0000 Subject: [PATCH] eina: improve system header detection. git-svn-id: http://svn.enlightenment.org/svn/e/trunk/eina@65900 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- configure.ac | 22 +++++++++++++++++++--- src/lib/Makefile.am | 9 +++++++-- src/lib/eina_file.c | 33 +++++++++++++++++++++++++++++---- src/lib/eina_simple_xml_parser.c | 4 +++- 4 files changed, 58 insertions(+), 10 deletions(-) diff --git a/configure.ac b/configure.ac index 31e2996..126f1d0 100644 --- a/configure.ac +++ b/configure.ac @@ -355,10 +355,9 @@ AM_CONDITIONAL([BUILD_TILER_EXAMPLE], [test "x${build_tiler_example}" = "xyes"]) ### Checks for header files AC_HEADER_ASSERT -AC_HEADER_DIRENT AC_HEADER_TIME EFL_CHECK_PATH_MAX -AC_CHECK_HEADERS([unistd.h libgen.h inttypes.h stdint.h sys/types.h siginfo.h]) +AC_CHECK_HEADERS([unistd.h libgen.h inttypes.h stdint.h sys/types.h siginfo.h strings.h sys/mman.h]) if test "x${ac_cv_header_inttypes_h}" = "xyes" ; then EINA_CONFIGURE_HAVE_INTTYPES_H="#define EINA_HAVE_INTTYPES_H" @@ -372,6 +371,14 @@ if test "x${ac_cv_header_inttypes_h}" = "xyes" ; then fi AC_SUBST([EINA_CONFIGURE_HAVE_STDINT_H]) +if test "x${ac_cv_header_strings_h}" = "xyes" ; then + AC_DEFINE([HAVE_STRINGS_H], [1], [Define to 1 if you have the header file.]) +fi + +if test "x${ac_cv_header_sys_mman_h}" = "xyes" ; then + AC_DEFINE([HAVE_MMAN_H], [1], [Define to 1 if you have the header file.]) +fi + ### Checks for types AC_CHECK_SIZEOF([wchar_t]) @@ -384,8 +391,17 @@ AC_CHECK_TYPES([siginfo_t], [], [], #endif ]]) -### Checks for structures +### Check if dirent.h is usable +AC_CHECK_TYPES([struct dirent], [have_dirent="yes"], [have_dirent="no"], + [[#include + ]]) + +if test "x${have_dirent_h}" = "xyes" ; then + EINA_CONFIGURE_HAVE_DIRENT_H="#define EINA_HAVE_DIRENT_H" + AC_DEFINE([HAVE_DIRENT_H], [1], [Define to 1 if you have a valid header file.]) +fi +AC_SUBST([EINA_CONFIGURE_HAVE_DIRENT_H]) ### Checks for compiler characteristics AC_C_CONST diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am index 0537a61..1d89257 100644 --- a/src/lib/Makefile.am +++ b/src/lib/Makefile.am @@ -130,12 +130,17 @@ eina_amalgamation.c: $(base_sources) Makefile @echo "#include " >> eina_amalgamation.c @echo "#include " >> eina_amalgamation.c @echo "#include " >> eina_amalgamation.c - @echo "#include " >> eina_amalgamation.c + @echo "#ifdef HAVE_DLOPEN" >> eina_amalgamation.c + @echo "# include " >> eina_amalgamation.c + @echo "#endif" >> eina_amalgamation.c @echo "#include " >> eina_amalgamation.c - @echo "#include " >> eina_amalgamation.c + @echo "#ifdef HAVE_DIRENT_H" >> eina_amalgamation.c + @echo "# include " >> eina_amalgamation.c + @echo "#endif" >> eina_amalgamation.c @echo "#include " >> eina_amalgamation.c @echo "#include " >> eina_amalgamation.c @echo "#include " >> eina_amalgamation.c + @echo "#include " >> eina_amalgamation.c @echo "#ifdef HAVE_EVIL" >> eina_amalgamation.c @echo "# include " >> eina_amalgamation.c diff --git a/src/lib/eina_file.c b/src/lib/eina_file.c index 84b9e78..bc0632c 100644 --- a/src/lib/eina_file.c +++ b/src/lib/eina_file.c @@ -40,11 +40,15 @@ void *alloca (size_t); #include #include -#include +#ifdef HAVE_DIRENT_H +# include +#endif #include #include #include -#include +#ifdef HAVE_MMAN_H +# include +#endif #include #define PATH_DELIM '/' @@ -60,6 +64,7 @@ void *alloca (size_t); #include "eina_list.h" #include "eina_lock.h" #include "eina_mmap.h" +#include "eina_log.h" #ifdef HAVE_ESCAPE_H # include @@ -95,9 +100,8 @@ void *alloca (size_t); #define EINA_SMALL_PAGE 4096 # define EINA_HUGE_PAGE 16 * 1024 * 1024 +#ifdef HAVE_DIRENT_H typedef struct _Eina_File_Iterator Eina_File_Iterator; -typedef struct _Eina_File_Map Eina_File_Map; - struct _Eina_File_Iterator { Eina_Iterator iterator; @@ -107,6 +111,7 @@ struct _Eina_File_Iterator char dir[1]; }; +#endif struct _Eina_File { @@ -134,6 +139,7 @@ struct _Eina_File Eina_Bool delete_me : 1; }; +typedef struct _Eina_File_Map Eina_File_Map; struct _Eina_File_Map { void *map; @@ -156,6 +162,7 @@ static int _eina_file_log_dom = -1; * The code and description of the issue can be found at : * http://womble.decadent.org.uk/readdir_r-advisory.html */ +#ifdef HAVE_DIRENT_H static long _eina_name_max(DIR *dirp) { @@ -390,6 +397,7 @@ _eina_file_stat_ls_iterator_next(Eina_File_Direct_Iterator *it, void **data) return EINA_TRUE; } +#endif static void _eina_file_real_close(Eina_File *file) @@ -738,6 +746,7 @@ eina_file_split(char *path) EAPI Eina_Iterator * eina_file_ls(const char *dir) { +#ifdef HAVE_DIRENT_H Eina_File_Iterator *it; size_t length; @@ -773,11 +782,16 @@ eina_file_ls(const char *dir) it->iterator.free = FUNC_ITERATOR_FREE(_eina_file_ls_iterator_free); return &it->iterator; +#else + (void) dir; + return NULL; +#endif } EAPI Eina_Iterator * eina_file_direct_ls(const char *dir) { +#ifdef HAVE_DIRENT_H Eina_File_Direct_Iterator *it; size_t length; @@ -825,11 +839,16 @@ eina_file_direct_ls(const char *dir) it->iterator.free = FUNC_ITERATOR_FREE(_eina_file_direct_ls_iterator_free); return &it->iterator; +#else + (void) dir; + return NULL; +#endif } EAPI Eina_Iterator * eina_file_stat_ls(const char *dir) { +#ifdef HAVE_DIRENT_H Eina_File_Direct_Iterator *it; size_t length; @@ -877,6 +896,10 @@ eina_file_stat_ls(const char *dir) it->iterator.free = FUNC_ITERATOR_FREE(_eina_file_direct_ls_iterator_free); return &it->iterator; +#else + (void) dir; + return NULL; +#endif } EAPI Eina_File * @@ -887,7 +910,9 @@ eina_file_open(const char *path, Eina_Bool shared) char *filename; struct stat file_stat; int fd = -1; +#ifdef HAVE_EXECVP int flags; +#endif EINA_SAFETY_ON_NULL_RETURN_VAL(path, NULL); diff --git a/src/lib/eina_simple_xml_parser.c b/src/lib/eina_simple_xml_parser.c index 91f6e87..6a8c96b 100644 --- a/src/lib/eina_simple_xml_parser.c +++ b/src/lib/eina_simple_xml_parser.c @@ -38,7 +38,9 @@ extern "C" void *alloca (size_t); #endif -#include +#ifdef HAVE_STRINGS_H +# include +#endif #include #include -- 2.7.4