]> Pileus Git - grits/commitdiff
Win32 port
authorAndy Spencer <andy753421@gmail.com>
Sat, 1 May 2010 00:00:32 +0000 (00:00 +0000)
committerAndy Spencer <andy753421@gmail.com>
Sat, 1 May 2010 01:23:48 +0000 (01:23 +0000)
- 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
gen-win32.sh [new file with mode: 0755]
src/Makefile.am
src/data/Makefile.am
src/data/gis-http.c
src/objects/Makefile.am

index 65847f990f31cc192a2e0b3f1b7158528ae5aadc..6aa57c8e9e1d5e348afd1d8d176d790d1ff8275a 100644 (file)
@@ -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 (executable)
index 0000000..7106b06
--- /dev/null
@@ -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"
index 8910cd5c04f99f42a392b101ea141d2537075404..17c04a603b300a3fc615e724ce83e2646802d71b 100644 (file)
@@ -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
index 6f2d78a525303f1af39b150c9121a297b7d0cf8d..e6109eed67b3f874c4fb6687f17dcbd9a415fc01 100644 (file)
@@ -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 = \
index 613dd439fa7ce38f7c55486415cf5a1a8cc8d15a..b5259e47108e15a92f0f95b44c24d4b19828a873 100644 (file)
@@ -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];
index 73c68edc5414e38b1255e2899c873c1f53b44e5e..5f7c256ce67e6e9a1025add992cbf6788b3ebd14 100644 (file)
@@ -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 = \