* fix compilation on Windows
authorcaro <caro>
Sun, 31 Aug 2008 14:05:17 +0000 (14:05 +0000)
committercaro <caro@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Sun, 31 Aug 2008 14:05:17 +0000 (14:05 +0000)
 * improve a bit autotools

git-svn-id: http://svn.enlightenment.org/svn/e/trunk/PROTO/eina@35761 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

configure.in
src/lib/Makefile.am
src/lib/eina_counter.c
src/lib/eina_file.c
src/modules/mp/chained_pool/Makefile.am
src/modules/mp/ememoa_fixed/Makefile.am
src/modules/mp/ememoa_unknown/Makefile.am
src/modules/mp/pass_through/Makefile.am

index 10d9d1c..3c31149 100644 (file)
@@ -104,6 +104,15 @@ AC_MSG_RESULT([$enable_ememoa])
 
 PKG_PROG_PKG_CONFIG
 
+# Evil library for compilation on Windows CE
+
+case "$host_os" in
+   mingw32ce* | cegcc*)
+   PKG_CHECK_MODULES([EVIL], [evil])
+   AC_DEFINE(HAVE_EVIL, 1, [Set to 1 if evil package is installed])
+   ;;
+esac
+
 # Check library for unit tests
 
 if test "x${enable_tests}" = "xyes" ; then
@@ -193,6 +202,17 @@ AC_C_BIGENDIAN
 AC_PROG_CC_STDC
 AC_C___ATTRIBUTE__
 
+EINA_CFLAGS="${COVERAGE_CFLAGS}"
+case "${host_os}" in
+   cegcc*)
+      EINA_CFLAGS="${EINA_CFLAGS=} ${EVIL_CFLAGS} -mwin32"
+   ;;
+   mingw*)
+      EINA_CFLAGS="${EINA_CFLAGS=} ${EVIL_CFLAGS}"
+   ;;
+esac
+AC_SUBST(EINA_CFLAGS)
+
 if test "x$enable_coverage" = "xyes" ; then
    CFLAGS="${DEBUG_CFLAGS}"
 fi
@@ -203,13 +223,19 @@ fi
 
 
 ### Checks for linker characteristics
+EINA_LIBS=""
 lt_enable_auto_import=""
-case "$host_os" in
+case "${host_os}" in
    mingw* | cegcc*)
       AC_DEFINE(EFL_EINA_BUILD, 1, [Define to mention that eina is built])
+      EINA_LIBS="${COVERAGE_LIBS} ${EVIL_LIBS} -lm"
       lt_enable_auto_import="-Wl,--enable-auto-import"
    ;;
+   *)
+      EINA_LIBS="${COVERAGE_LIBS} -ldl -lrt -lm"
+   ;;
 esac
+AC_SUBST(EINA_LIBS)
 AC_SUBST(lt_enable_auto_import)
 
 
index a360cb2..b4402f2 100644 (file)
@@ -5,7 +5,7 @@ AM_CPPFLAGS = \
 -DPACKAGE_BIN_DIR=\"$(bindir)\" \
 -DPACKAGE_LIB_DIR=\"$(libdir)\" \
 -DPACKAGE_DATA_DIR=\"$(datadir)/$(PACKAGE)\" \
-@COVERAGE_CFLAGS@
+@EINA_CFLAGS@
 
 lib_LTLIBRARIES = libeina.la
 
@@ -29,6 +29,8 @@ eina_convert.c \
 eina_rbtree.c \
 eina_stringshare.c
 
-libeina_la_LIBADD = -ldl -lrt @COVERAGE_LIBS@ -lm
+libeina_la_LIBADD = @EINA_LIBS@
 libeina_la_LDFLAGS = -no-undefined @lt_enable_auto_import@ -version-info @version_info@
-libeina_la_DEPENDENCIES = $(top_builddir)/config.h
+
+clean-local:
+       rm -rf *.gcno
index 55c6068..51034cb 100644 (file)
@@ -28,7 +28,7 @@
 # define WIN32_LEAN_AND_MEAN
 # include <windows.h>
 # undef WIN32_LEAN_AND_MEAN
-#endif /* _WIN2 */
+#endif /* _WIN2 */
 
 #include "eina_counter.h"
 #include "eina_inlist.h"
index 1c29283..f7c8785 100644 (file)
 # include <config.h>
 #endif
 
-#define _GNU_SOURCE
 #include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <dirent.h>
+
+#ifndef _WIN32
+# define _GNU_SOURCE
+# include <sys/types.h>
+# include <sys/stat.h>
+# include <unistd.h>
+# include <dirent.h>
+#else
+# define WIN32_LEAN_AND_MEAN
+# include <windows.h>
+# undef WIN32_LEAN_AND_MEAN
+# include <Evil.h>
+#endif /* _WIN2 */
+
 
 #ifdef HAVE_ALLOCA_H
 # include <alloca.h>
@@ -66,6 +75,7 @@ void *alloca (size_t);
 EAPI Eina_Bool
 eina_file_dir_list(const char *dir, Eina_Bool recursive, Eina_File_Dir_List_Cb cb, void *data)
 {
+#ifndef _WIN32
        struct dirent *de;
        DIR *d;
 
@@ -107,6 +117,69 @@ eina_file_dir_list(const char *dir, Eina_Bool recursive, Eina_File_Dir_List_Cb c
        }
 
        closedir(d);
+#else
+       WIN32_FIND_DATA file;
+       HANDLE          hSearch;
+       char           *new_dir;
+       TCHAR          *tdir;
+       int             length_dir;
+
+       if (!cb) return EINA_FALSE;
+       if (!dir || (*dir == '\0')) return EINA_FALSE;
+
+       length_dir = strlen(dir);
+       new_dir = (char *)alloca(length_dir + 5);
+       if (!new_dir) return EINA_FALSE;
+
+       memcpy(new_dir, dir, length_dir);
+       memcpy(new_dir + length_dir, "/*.*", 5);
+
+#ifdef UNICODE
+       tdir =  evil_char_to_wchar(new_dir);
+#else
+       tdir = new_dir;
+#endif /* ! UNICODE */
+       hSearch = FindFirstFile(tdir, &file);
+#ifdef UNICODE
+       free(tdir);
+#endif /* UNICODE */
+
+       if (hSearch == INVALID_HANDLE_VALUE) return EINA_FALSE;
+
+       do
+       {
+               char *filename;
+
+#ifdef UNICODE
+               filename = evil_wchar_to_char(file.cFileName);
+#else
+               filename = file.cFileName;
+#endif /* ! UNICODE */
+               if (!strcmp(filename, ".") || !strcmp(filename, ".."))
+                       continue;
+
+               cb(filename, dir, data);
+
+               if (recursive == EINA_TRUE) {
+                       char *path;
+
+                       path = alloca(strlen(dir) + strlen(filename) + 2);
+                       strcpy(path, dir);
+                       strcat(path, "/");
+                       strcat(path, filename);
+
+                       if (!(file.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
+                               continue ;
+
+                       eina_file_dir_list(path, recursive, cb, data);
+               }
+#ifdef UNICODE
+               free(filename);
+#endif /* UNICODE */
+
+       } while (FindNextFile(hSearch, &file));
+       FindClose(hSearch);
+#endif /* _WIN32 */
 
        return EINA_TRUE;
 }
index 24723c7..06a897e 100644 (file)
@@ -1,5 +1,4 @@
-MAINTAINERCLEANFILES = \
-Makefile.in
+MAINTAINERCLEANFILES = Makefile.in
 
 AM_CPPFLAGS = \
 -I. \
@@ -12,6 +11,9 @@ controller_LTLIBRARIES = eina_chained_mempool.la
 eina_chained_mempool_la_SOURCES = \
 eina_chained_mempool.c
 
-eina_chained_mempool_la_LIBADD       = $(top_builddir)/src/lib/libeina.la @COVERAGE_LIBS@
-eina_chained_mempool_la_LDFLAGS      = -no-undefined @lt_enable_auto_import@ -module -avoid-version
+eina_chained_mempool_la_LIBADD = $(top_builddir)/src/lib/libeina.la @COVERAGE_LIBS@
+eina_chained_mempool_la_LDFLAGS = -no-undefined @lt_enable_auto_import@ -module -avoid-version
 eina_chained_mempool_la_DEPENDENCIES = $(top_builddir)/src/lib/libeina.la
+
+clean-local:
+       rm -rf *.gcno
index 41cdf9e..3d23b6e 100644 (file)
@@ -20,3 +20,6 @@ eina_ememoa_fixed_la_LDFLAGS      = -no-undefined @lt_enable_auto_import@ -modul
 eina_ememoa_fixed_la_DEPENDENCIES = $(top_builddir)/src/lib/libeina.la
 
 endif
+
+clean-local:
+       rm -rf *.gcno
index 96b562a..5c7dcd0 100644 (file)
@@ -20,3 +20,6 @@ eina_ememoa_unknown_la_LDFLAGS      = -no-undefined @lt_enable_auto_import@ -mod
 eina_ememoa_unknown_la_DEPENDENCIES = $(top_builddir)/src/lib/libeina.la
 
 endif
+
+clean-local:
+       rm -rf *.gcno
index 24badd4..d2f6522 100644 (file)
@@ -17,3 +17,6 @@ pass_through_la_LIBADD       = $(top_builddir)/src/lib/libeina.la @COVERAGE_LIBS
 pass_through_la_LDFLAGS      = -no-undefined @lt_enable_auto_import@ -module -avoid-version
 pass_through_la_DEPENDENCIES = $(top_builddir)/src/lib/libeina.la
 
+clean-local:
+       rm -rf *.gcno
+