From 0a0a7ebc372af8f85c4aec21e2300b62f1b3ffa3 Mon Sep 17 00:00:00 2001
From: pmcdona <invalid@example.com>
Date: Wed, 18 Dec 2013 10:17:25 +0800
Subject: [PATCH] Trac 53 minw update

http://libwebsockets.org/trac/libwebsockets/ticket/53
---
 CMakeLists.txt        |  4 ++++
 cross-ming.cmake      | 31 +++++++++++++++++++++++++++++++
 lib/libwebsockets.h   |  2 +-
 win32port/zlib/gzio.c |  3 ++-
 4 files changed, 38 insertions(+), 2 deletions(-)
 create mode 100644 cross-ming.cmake

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 595d9722..c591149a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -310,7 +310,11 @@ endif(UNIX)
 
 
 if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
+    if (UNIX)
 	set( CMAKE_C_FLAGS "-Wall -Werror -O4 -fvisibility=hidden ${CMAKE_C_FLAGS}" )
+    else(UNIX)
+	set( CMAKE_C_FLAGS "-Wall -O4 -fvisibility=hidden ${CMAKE_C_FLAGS}" )
+    endif(UNIX)
 endif ()
 
 source_group("Headers Private"  FILES ${HDR_PRIVATE})
diff --git a/cross-ming.cmake b/cross-ming.cmake
new file mode 100644
index 00000000..94989f23
--- /dev/null
+++ b/cross-ming.cmake
@@ -0,0 +1,31 @@
+#
+# CMake Toolchain file for crosscompiling on MingW.
+#
+# This can be used when running cmake in the following way:
+#  cd build/
+#  cmake .. -DCMAKE_TOOLCHAIN_FILE=../cross-ming.cmake
+#
+
+set(CROSS_PATH /usr/bin)
+
+# Target operating system name.
+set(CMAKE_SYSTEM_NAME Windows)
+set(BUILD_SHARED_LIBS OFF)
+
+# Name of C compiler.
+set(CMAKE_C_COMPILER "${CROSS_PATH}/x86_64-w64-mingw32-gcc")
+#set(CMAKE_CXX_COMPILER "${CROSS_PATH}/x86_64-w64-mingw32-g++")
+set(CMAKE_RC_COMPILER "${CROSS_PATH}/x86_64-w64-mingw32-windres")
+set(CMAKE_C_FLAGS "-Wno-error")
+
+# Where to look for the target environment. (More paths can be added here)
+set(CMAKE_FIND_ROOT_PATH "${CROSS_PATH}")
+
+# Adjust the default behavior of the FIND_XXX() commands:
+# search programs in the host environment only.
+set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
+
+# Search headers and libraries in the target environment only.
+set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
+set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
+
diff --git a/lib/libwebsockets.h b/lib/libwebsockets.h
index e4e8e23b..f957e54d 100644
--- a/lib/libwebsockets.h
+++ b/lib/libwebsockets.h
@@ -35,7 +35,7 @@ extern "C" {
 #include <winsock2.h>
 #include <ws2tcpip.h>
 #include <stddef.h>
-#include <BaseTsd.h>
+#include <basetsd.h>
 #include "websock-w32.h"
 
 #include "gettimeofday.h"
diff --git a/win32port/zlib/gzio.c b/win32port/zlib/gzio.c
index 26f2da1e..a57352e1 100644
--- a/win32port/zlib/gzio.c
+++ b/win32port/zlib/gzio.c
@@ -10,6 +10,7 @@
 #include <stdio.h>
 
 #include "zutil.h"
+#include "gzguts.h"
 
 #ifdef NO_DEFLATE       /* for compatiblity with old definition */
 #  define NO_GZCOMPRESS
@@ -977,7 +978,7 @@ const char * ZEXPORT gzerror (file, errnum)
     *errnum = s->z_err;
     if (*errnum == Z_OK) return (const char*)"";
 
-    m = (char*)(*errnum == Z_ERRNO ? zstrerror(errno) : s->stream.msg);
+    m = (char*)(*errnum == Z_ERRNO ? zstrerror() : s->stream.msg);
 
     if (m == NULL || *m == '\0') m = (char*)ERR_MSG(s->z_err);
 
-- 
GitLab