Index: raster/Makefile
===================================================================
--- raster/Makefile	(revision 36202)
+++ raster/Makefile	(working copy)
@@ -40,7 +40,6 @@
 	r.kappa \
 	r.lake \
 	r.le \
-	r.li \
 	r.los \
 	r.mapcalc \
 	r.median \
@@ -128,7 +127,7 @@
 
 include $(MODULE_TOPDIR)/include/Make/Platform.make
 
-ifneq ($(MINGW),)
+ifeq ($(MINGW),)
     SUBDIRS += r.li
 endif
 
Index: lib/g3d/g3dcache.c
===================================================================
--- lib/g3d/g3dcache.c	(revision 36213)
+++ lib/g3d/g3dcache.c	(working copy)
@@ -121,7 +121,7 @@
 	return 0;
     }
 
-    index = *((int *)(xdr + nBytes));
+    index = *((int *)((unsigned char *)xdr + nBytes));
     map->index[index] = -pos - 2;
 
     map->cachePosLast--;
Index: lib/gis/spawn.c
===================================================================
--- lib/gis/spawn.c	(revision 36202)
+++ lib/gis/spawn.c	(working copy)
@@ -204,7 +204,7 @@
 
 #ifdef __MINGW32__
 
-static int do_redirects(struct redirect *redirects, int num_redirects)
+static void do_redirects(struct redirect *redirects, int num_redirects)
 {
     if (num_redirects > 0)
 	G_fatal_error
Index: lib/gis/Makefile
===================================================================
--- lib/gis/Makefile	(revision 36202)
+++ lib/gis/Makefile	(working copy)
@@ -1,5 +1,7 @@
 MODULE_TOPDIR = ../..
 
+NOFILTEROUT=1
+
 GDAL_LINK = $(USE_GDAL)
 GDAL_DYNAMIC = 1
 
@@ -10,6 +12,9 @@
 
 LIB_OBJS := $(subst .c,.o,$(wildcard *.c))
 LIB_OBJS := $(filter-out fmode.o dllmain.o,$(LIB_OBJS))
+ifneq ($(MINGW),)
+LIB_OBJS += dllmain.o
+endif
 
 include $(MODULE_TOPDIR)/include/Make/Lib.make
 include $(MODULE_TOPDIR)/include/Make/Doxygen.make
@@ -40,7 +45,7 @@
 
 endif
 
-default: $(DLLMAIN_OBJ) lib $(FMODE_OBJ) $(DATAFILES) $(COLORFILES) $(ETC)/colors.desc $(ETC)/element_list
+default: lib $(FMODE_OBJ) $(DATAFILES) $(COLORFILES) $(ETC)/colors.desc $(ETC)/element_list
 
 $(ETC)/colors:
 	$(MKDIR) $@
Index: lib/gis/gdal.c
===================================================================
--- lib/gis/gdal.c	(revision 36202)
+++ lib/gis/gdal.c	(working copy)
@@ -19,6 +19,8 @@
 # ifdef _WIN32
 #  include <windows.h>
 # endif
+# undef CPL_STDCALL
+# define CPL_STDCALL
 #endif
 
 static void CPL_STDCALL (*pGDALAllRegister)(void);
@@ -77,6 +79,8 @@
 	"libgdal.so",
 # endif
 # ifdef _WIN32
+  "gdal16.dll",
+  "gdal15.dll",
 	"gdal11.dll",
 	"gdal.1.0.dll",
 	"gdal.dll",
Index: include/Make/Lib.make
===================================================================
--- include/Make/Lib.make	(revision 36202)
+++ include/Make/Lib.make	(working copy)
@@ -11,6 +11,11 @@
 LIB_OBJS = $(subst .c,.o,$(wildcard *.c))
 endif
 
+ifndef NOFILTEROUT
+LIB_OBJS := $(filter-out fmode.o,$(LIB_OBJS))
+LIB_OBJS := $(filter-out dllmain.o,$(LIB_OBJS))
+endif
+
 ARCH_LIB_OBJS := $(foreach obj,$(LIB_OBJS),$(OBJDIR)/$(obj))
 
 STLIB_NAME = $(LIB_NAME)
Index: include/Make/Shlib.make
===================================================================
--- include/Make/Shlib.make	(revision 36202)
+++ include/Make/Shlib.make	(working copy)
@@ -4,8 +4,10 @@
 
 # Object that calls _setfmode(_O_BINARY) which must be linked to each DLL on Windows
 ifdef MINGW
+ifneq ($(SHLIB_NAME),$(DATETIME_LIBNAME))
   DLLMAIN_OBJ = $(MODULE_TOPDIR)/lib/gis/$(OBJDIR)/dllmain.o
 endif
+endif
 
 CFLAGS += $(SHLIB_CFLAGS) $(NLS_CFLAGS)
 LDFLAGS += $(SHLIB_LDFLAGS)

