[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[E-devel] fixes for compilation of eet with MinGW




Hey

here are 2 patches for the compilation of eet and its tests with MinGW. It seems to work on my box. I can't commit right now.

Vincent
? dali.edj
? eet_test.diff
? menufondg.jpg
? out.eet
Index: Makefile
===================================================================
RCS file: /var/cvs/e/e17/test/orig/eet/Makefile,v
retrieving revision 1.2
diff -u -r1.2 Makefile
--- Makefile	28 Oct 2006 08:23:28 -0000	1.2
+++ Makefile	1 Jan 2007 12:27:04 -0000
@@ -8,18 +8,17 @@
 eet_OBJS = $(eet_SRCS:.c=.o)
 eet: $(eet_OBJS)
 	$(RM) $@
-	$(CC) $(LIBS) $(CFLAGS) $(LDFLAGS) $(eet_OBJS) -o $@
+	$(CC) $(eet_OBJS) $(LIBS) $(LDFLAGS) -o $@
 
 eet_bench_SRCS = eet_bench_main.c
 eet_bench_OBJS = $(eet_bench_SRCS:.c=.o)
 eet_bench: $(eet_bench_OBJS)
 	$(RM) $@
-	$(CC) $(LIBS) $(CFLAGS) $(LDFLAGS) $(eet_bench_OBJS) -o $@
+	$(CC) $(eet_bench_OBJS) $(LIBS) $(LDFLAGS) -o $@
 
 ############################################################################
 #### boilerplate
 .c.o:
-	$(CC) $(FALGS) $(CFLAGS) -c $< -o $@
+	$(CC) $(FLAGS) $(CFLAGS) -c $< -o $@
 clean::
 	rm -rf $(BINS) *.o *~
-	
? eet.diff
Index: INSTALL
===================================================================
RCS file: /var/cvs/e/e17/libs/eet/INSTALL,v
retrieving revision 1.2
diff -u -r1.2 INSTALL
--- INSTALL	2 Dec 2002 23:39:25 -0000	1.2
+++ INSTALL	1 Jan 2007 13:51:48 -0000
@@ -12,3 +12,8 @@
     make install
 
 NOTE: You MUST make install Eet for it to run properly.
+
+NOTE: for compilation with MinGW, fnmatch.h is probably missing.
+      That file can be found here:
+http://www.koders.com/c/fid2B518462CB1EED3D4E31E271DB83CD1582F6EEBE.aspx
+      It should be installed in the mingw include directory.
Index: configure.in
===================================================================
RCS file: /var/cvs/e/e17/libs/eet/configure.in,v
retrieving revision 1.68
diff -u -r1.68 configure.in
--- configure.in	4 Dec 2006 12:14:17 -0000	1.68
+++ configure.in	1 Jan 2007 13:51:48 -0000
@@ -21,6 +21,7 @@
 
 AC_CHECK_HEADERS(netinet/in.h)
 
+winsock_libs=""
 case "$host_os" in
 	mingw|mingw32)
 		winsock_libs="-lwsock32"
@@ -29,15 +30,19 @@
 
 AC_SUBST(winsock_libs)
 
-AC_CHECK_HEADER(fnmatch.h,, AC_MSG_ERROR([Cannot find fnmatch.h. Make sure your CFLAGS environment variable contains include lines for the location of this file]))
+AC_CHECK_HEADER(fnmatch.h,, AC_MSG_ERROR([Cannot find fnmatch.h. Make sure your CFLAGS environment variable contains include lines for the location of this file. MinGW users: see the INSTALL file]))
 
+fnmatch_libs=""
 AC_CHECK_FUNCS(fnmatch, res=yes, res=no)
 if test "x$res" = "xno"; then
-	AC_CHECK_LIB(fnmatch, fnmatch, res=yes, res=no)
+	AC_CHECK_LIB(fnmatch, fnmatch, res=yes fnmatch_libs="-lfnmatch", res=no)
+dnl Test for compilation with MinGW.
+dnl fnmatch function is in the libiberty library
 	if test "x$res" = "xno"; then
-		AC_MSG_ERROR([Cannot find fnmatch() in neither libc nor libfnmatch])
-	else
-		fnmatch_libs="-lfnmatch"
+		AC_CHECK_LIB(iberty, fnmatch, res=yes fnmatch_libs="-liberty", res=no)
+	fi
+	if test "x$res" = "xno"; then
+		AC_MSG_ERROR([Cannot find fnmatch() in neither libc nor libfnmatch, nor libiberty])
 	fi
 fi
 
Index: eet-config.in
===================================================================
RCS file: /var/cvs/e/e17/libs/eet/eet-config.in,v
retrieving revision 1.7
diff -u -r1.7 eet-config.in
--- eet-config.in	11 Jun 2006 22:37:23 -0000	1.7
+++ eet-config.in	1 Jan 2007 13:51:48 -0000
@@ -46,7 +46,7 @@
       ;;
     --libs)
       libdirs=-L@libdir@
-      echo $libdirs -leet -lz -ljpeg
+      echo $libdirs -leet -lz -ljpeg @fnmatch_libs@ @winsock_libs@
       ;;
     *)
       echo "${usage}" 1>&2
Index: src/lib/Eet.h
===================================================================
RCS file: /var/cvs/e/e17/libs/eet/src/lib/Eet.h,v
retrieving revision 1.37
diff -u -r1.37 Eet.h
--- src/lib/Eet.h	17 Dec 2006 11:00:45 -0000	1.37
+++ src/lib/Eet.h	1 Jan 2007 13:51:50 -0000
@@ -7,7 +7,7 @@
 #undef EAPI
 #endif
 #ifdef WIN32
-# ifdef BUILDING_DLL
+# ifdef DLL_EXPORT
 #  define EAPI __declspec(dllexport)
 # else
 #  define EAPI __declspec(dllimport)
Index: src/lib/eet_lib.c
===================================================================
RCS file: /var/cvs/e/e17/libs/eet/src/lib/eet_lib.c,v
retrieving revision 1.72
diff -u -r1.72 eet_lib.c
--- src/lib/eet_lib.c	16 Oct 2006 15:02:11 -0000	1.72
+++ src/lib/eet_lib.c	1 Jan 2007 13:51:51 -0000
@@ -3,7 +3,9 @@
  */
 
 #include <sys/types.h>
+#ifndef _WIN32
 #include <sys/mman.h>
+#endif
 
 #include "Eet.h"
 #include "Eet_private.h"
@@ -12,6 +14,22 @@
 #undef HAVE_REALPATH
 #endif
 
+#ifdef _WIN32
+
+#ifndef F_SETFD
+#define F_SETFD 2
+#endif
+
+#ifndef PROT_READ
+#define PROT_READ 1
+#endif
+
+#ifndef FD_CLOEXEC
+#define FD_CLOEXEC 1
+#endif
+
+#endif
+
 #define EET_MAGIC_FILE                  0x1ee7ff00
 #define EET_MAGIC_FILE_HEADER           0x1ee7ff01
 
@@ -471,6 +489,9 @@
 {
    Eet_File	*ef;
    struct stat	file_stat;
+#ifdef _WIN32
+   HANDLE       h;
+#endif
    
    if (!file)
      return NULL;
@@ -558,7 +579,15 @@
    if (eet_test_close(!ef->fp, ef))
      return NULL;
 
+#ifndef _WIN32
    fcntl(fileno(ef->fp), F_SETFD, FD_CLOEXEC);
+#else
+   /* FIXME: check if that code is needed / correct */
+   h = (HANDLE) _get_osfhandle (fileno(ef->fp));
+   if (h == (HANDLE) -1)
+     return NULL;
+   SetHandleInformation (h, HANDLE_FLAG_INHERIT, 0);
+#endif
    /* if we opened for read or read-write */
    if ((mode == EET_FILE_MODE_READ) || (mode == EET_FILE_MODE_READ_WRITE))
      {
@@ -568,10 +597,29 @@
 	int			num_entries;
 	int			byte_entries;
 	int			i;
+#ifdef _WIN32
+	HANDLE                  fm;
+#endif
+
 
 	ef->data_size = file_stat.st_size;
+#ifndef _WIN32
 	ef->data = mmap(NULL, ef->data_size, PROT_READ,
 			MAP_SHARED, fileno(ef->fp), 0);
+#else
+	fm = CreateFileMapping((HANDLE) _get_osfhandle (fileno(ef->fp)),
+			       NULL,
+			       PAGE_READONLY,
+			       0,
+			       0,
+			       NULL);
+	ef->data = MapViewOfFile(fm,
+				 FILE_MAP_READ,
+				 0,
+				 0,
+				 ef->data_size);
+	CloseHandle(fm);
+#endif
 
 	if (eet_test_close((ef->data == (void *)-1) || (ef->data == NULL), ef))
 	  return NULL;
@@ -825,7 +873,11 @@
 	  }
 	free(ef->header);
      }
+#ifndef _WIN32
    if (ef->data) munmap(ef->data, ef->data_size);
+#else
+   if (ef->data) UnmapViewOfFile (ef->data);
+#endif
    if (ef->fp) fclose(ef->fp);
 
    /* zero out ram for struct - caution tactic against stale memory use */