Changes to build Windows emulator under Linux/MinGW

- Linux being case-sensitve, include "windows.h" instead of "Windows.h" is important.
- Use MinGW's windres.
- No pthread needed.

(Merged from master Change Ib4ce944b)

Change-Id: I29050b0013a6f9a3f1fd72e586a77c27d559b15a
diff --git a/Makefile.android b/Makefile.android
index 0b719e0..38ad685 100644
--- a/Makefile.android
+++ b/Makefile.android
@@ -659,6 +659,8 @@
 #
 LOCAL_CFLAGS += $(SDL_CFLAGS)
 LOCAL_LDLIBS += $(SDL_LDLIBS)
+# Circular dependencies between libSDL and libSDLmain;
+# We repeat the libraries in the final link to work around it.
 LOCAL_STATIC_LIBRARIES += libSDL libSDLmain
 LOCAL_STATIC_LIBRARIES += libSDL libSDLmain
 
@@ -671,11 +673,19 @@
 # to use some weird pathnames to make this work...
 #
 ifeq ($(HOST_OS),windows)
+
+# Locate windres executable
+WINDRES := windres
+ifneq ($(USE_MINGW),)
+  # When building the Windows emulator under Linux, use the MinGW one
+  WINDRES := i586-mingw32msvc-windres
+endif
+
 INTERMEDIATE     := $(call intermediates-dir-for,EXECUTABLES,$(LOCAL_MODULE),true)
 ANDROID_ICON_OBJ := android_icon.o
 ANDROID_ICON_PATH := $(LOCAL_PATH)/images
 $(ANDROID_ICON_PATH)/$(ANDROID_ICON_OBJ): $(ANDROID_ICON_PATH)/android_icon.rc
-	windres $< -I $(ANDROID_ICON_PATH) -o $@
+	$(WINDRES) $< -I $(ANDROID_ICON_PATH) -o $@
 
 # seems to be the only way to add an object file that was not generated from
 # a C/C++/Java source file to our build system. and very unfortunately,
@@ -760,11 +770,12 @@
 
 # other flags
 LOCAL_CFLAGS += -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
-LOCAL_LDLIBS += -lm -lpthread
-
+LOCAL_LDLIBS += -lm
 
 ifeq ($(HOST_OS),windows)
     LOCAL_LDLIBS += -lwinmm -lws2_32 -liphlpapi
+else
+    LOCAL_LDLIBS += -lpthread
 endif
 
 LOCAL_LDLIBS += $(QEMU_AUDIO_LIB)
diff --git a/android/utils/mapfile.c b/android/utils/mapfile.c
index f964d38..c8ba8e5 100644
--- a/android/utils/mapfile.c
+++ b/android/utils/mapfile.c
@@ -19,7 +19,7 @@
 #include "sys/types.h"
 #include "errno.h"
 #ifdef  WIN32
-#include "Windows.h"
+#include "windows.h"
 #else   // WIN32
 #include <sys/mman.h>
 #endif  // WIN32
diff --git a/elff/elff-common.h b/elff/elff-common.h
index 922de10..8729736 100644
--- a/elff/elff-common.h
+++ b/elff/elff-common.h
@@ -23,7 +23,7 @@
 #include "memory.h"

 #include "errno.h"

 #ifdef  WIN32

-#include "Windows.h"

+#include "windows.h"

 #else   // WIN32

 #include <sys/mman.h>

 #include <sys/stat.h>