[libgis] Win32 port



commit e7127ea74717754c48779467aca2f9a1596a99f0
Author: Andy Spencer <andy753421 gmail com>
Date:   Sat May 1 00:00:32 2010 +0000

    Win32 port
    
    - Use conditional -fPIC
      - All Win32 is PIC
    
    - Use conditional -static
      - -static on Win32 causes double DLL includes
    
    - Add "b" flag to fopen
    
    - Manually fseek when appending
      - Otherwise ftell is incorrect

 configure.ac            |    9 +++++++++
 gen-win32.sh            |    7 +++++++
 src/Makefile.am         |    7 ++++---
 src/data/Makefile.am    |    5 ++++-
 src/data/gis-http.c     |    6 +++---
 src/objects/Makefile.am |    5 ++++-
 6 files changed, 31 insertions(+), 8 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 65847f9..6aa57c8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -18,6 +18,15 @@ PKG_CHECK_MODULES(CAIRO, cairo)
 PKG_CHECK_MODULES(GTK,   gtk+-2.0 >= 2.16 gtkglext-1.0)
 PKG_CHECK_MODULES(SOUP,  libsoup-2.4 >= 2.26)
 
+# Test for Windows vs. Unix
+case "${host}" in
+	*mingw32*) WIN32="yes" ;;
+	*cygwin*)  WIN32="yes" ;;
+	*)         WIN32="no"  ;;
+esac
+AM_CONDITIONAL([WIN32],    test "$WIN32" = "yes")
+AM_CONDITIONAL([NOTWIN32], test "$WIN32" = "no")
+
 # Output 
 AC_CONFIG_FILES([
 	Makefile
diff --git a/gen-win32.sh b/gen-win32.sh
new file mode 100755
index 0000000..7106b06
--- /dev/null
+++ b/gen-win32.sh
@@ -0,0 +1,7 @@
+#!/bin/bash
+dir=$(dirname $(readlink -f $0))
+./autogen.sh \
+	"--host=i686-pc-mingw32" \
+	"--libdir=Z:$dir/src/.libs" \
+	"--includedir=Z:$dir/include" \
+	CFLAGS="-g -Werror -Wno-unused $CFLAGS"
diff --git a/src/Makefile.am b/src/Makefile.am
index 8910cd5..17c04a6 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -44,22 +44,23 @@ libgis_la_LIBADD  = $(AM_LDADD) \
 	data/libgis-data.la
 
 # Demo program
+if NOTWIN32
+AM_LDFLAGS += -static
+endif
+
 bin_PROGRAMS = gis-demo
 
 gis_demo_SOURCES  = gis-demo.c
 gis_demo_LDADD    = $(AM_LDADD) libgis.la
-gis_demo_LDFLAGS  = $(AM_LDFLAGS) -static
 
 # Test programs
 noinst_PROGRAMS = gis-test tile-test
 
 gis_test_SOURCES = gis-test.c
 gis_test_LDADD   = $(AM_LDADD) libgis.la
-gis_test_LDFLAGS = $(AM_LDFLAGS) -static
 
 tile_test_SOURCES = tile-test.c
 tile_test_LDADD   = $(AM_LDADD) libgis.la
-tile_test_LDFLAGS = $(AM_LDFLAGS) -static
 
 
 MAINTAINERCLEANFILES = Makefile.in
diff --git a/src/data/Makefile.am b/src/data/Makefile.am
index 6f2d78a..e6109ee 100644
--- a/src/data/Makefile.am
+++ b/src/data/Makefile.am
@@ -1,5 +1,8 @@
-AM_CFLAGS  = -Wall --std=gnu99 -fPIC -I$(top_srcdir)/src
+AM_CFLAGS  = -Wall --std=gnu99 -I$(top_srcdir)/src
 AM_CFLAGS += $(GLIB_CFLAGS) $(SOUP_CFLAGS)
+if NOTWIN32
+AM_CFLAGS += -fPIC
+endif
 
 gis_data_includedir = $(includedir)/gis/data
 gis_data_include_HEADERS = \
diff --git a/src/data/gis-http.c b/src/data/gis-http.c
index 613dd43..b5259e4 100644
--- a/src/data/gis-http.c
+++ b/src/data/gis-http.c
@@ -125,7 +125,6 @@ gchar *gis_http_fetch(GisHttp *http, const gchar *uri, const char *local,
 {
 	g_debug("GisHttp: fetch - %s... >> %s/%s  mode=%d",
 			uri, http->prefix, local, mode);
-
 	gchar *path = _get_cache_path(http, local);
 
 	/* Unlink the file if we're refreshing it */
@@ -141,7 +140,8 @@ gchar *gis_http_fetch(GisHttp *http, const gchar *uri, const char *local,
 		gchar *part = path;
 		if (!g_file_test(path, G_FILE_TEST_EXISTS))
 			part = g_strdup_printf("%s.part", path);
-		FILE *fp = fopen_p(part, "a");
+		FILE *fp = fopen_p(part, "ab");
+		fseek(fp, 0, SEEK_END); // "a" is broken on Windows, twice
 
 		/* Make temp data */
 		struct _CacheInfo info = {
@@ -178,6 +178,7 @@ gchar *gis_http_fetch(GisHttp *http, const gchar *uri, const char *local,
 		}
 	}
 
+
 	/* TODO: free everything.. */
 	return path;
 }
@@ -219,7 +220,6 @@ GList *gis_http_available(GisHttp *http,
 		g_free(path);
 	}
 
-
 	/* Add online files if online */
 	if (index) {
 		gchar tmp[16];
diff --git a/src/objects/Makefile.am b/src/objects/Makefile.am
index 73c68ed..5f7c256 100644
--- a/src/objects/Makefile.am
+++ b/src/objects/Makefile.am
@@ -1,5 +1,8 @@
-AM_CFLAGS  = -Wall --std=gnu99 -fPIC -I$(top_srcdir)/src
+AM_CFLAGS  = -Wall --std=gnu99 -I$(top_srcdir)/src
 AM_CFLAGS += $(GLIB_CFLAGS) $(CAIRO_CFLAGS)
+if NOTWIN32
+AM_CFLAGS += -fPIC
+endif
 
 gis_objects_includedir = $(includedir)/gis/objects
 gis_objects_include_HEADERS = \



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