Merge "Compile libcurl for the host."
diff --git a/Android.mk b/Android.mk
index 13f1787..d338b96 100644
--- a/Android.mk
+++ b/Android.mk
@@ -40,6 +40,24 @@
 #########################
 # Build the libcurl shared library
 
+libcurl_shared_libs := libcrypto libssl libz
+
+include $(CLEAR_VARS)
+include $(LOCAL_PATH)/lib/Makefile.inc
+
+LOCAL_SRC_FILES := $(addprefix lib/,$(CSOURCES))
+LOCAL_C_INCLUDES := $(curl_includes)
+LOCAL_CFLAGS := \
+    $(curl_CFLAGS) \
+    -D_GNU_SOURCE=1
+LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include
+
+LOCAL_MODULE:= libcurl-host
+LOCAL_MODULE_TAGS := optional
+LOCAL_SHARED_LIBRARIES := $(libcurl_shared_libs:=-host)
+
+include $(BUILD_HOST_SHARED_LIBRARY)
+
 include $(CLEAR_VARS)
 include $(LOCAL_PATH)/lib/Makefile.inc
 
@@ -50,7 +68,7 @@
 
 LOCAL_MODULE:= libcurl
 LOCAL_MODULE_TAGS := optional
-LOCAL_SHARED_LIBRARIES := libcrypto libssl libz
+LOCAL_SHARED_LIBRARIES := $(libcurl_shared_libs)
 
 include $(BUILD_SHARED_LIBRARY)
 
diff --git a/lib/cookie.c b/lib/cookie.c
index 94f2a8b..ea717a6 100644
--- a/lib/cookie.c
+++ b/lib/cookie.c
@@ -79,7 +79,6 @@
     13-Jun-1988 03:04:55 GMT; domain=.fidelity.com; path=/; secure
 ****/
 
-
 #include "curl_setup.h"
 
 #if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_COOKIES)
diff --git a/lib/curl_config.h b/lib/curl_config.h
index 88124ff..434cf9b 100644
--- a/lib/curl_config.h
+++ b/lib/curl_config.h
@@ -125,7 +125,10 @@
 #define HAVE_BORINGSSL 1
 
 /* Define to 1 if you have the clock_gettime function and monotonic timer. */
+#ifndef __APPLE__
+/* CLOCK_MONOTONIC is not defined in mac when building for the host. */
 #define HAVE_CLOCK_GETTIME_MONOTONIC 1
+#endif
 
 /* Define to 1 if you have the closesocket function. */
 /* #undef HAVE_CLOSESOCKET */
@@ -435,10 +438,14 @@
 #define HAVE_MEMORY_H 1
 
 /* Define to 1 if you have the memrchr function or macro. */
+#ifndef __APPLE__
 #define HAVE_MEMRCHR 1
+#endif
 
 /* Define to 1 if you have the MSG_NOSIGNAL flag. */
+#ifndef __APPLE__
 #define HAVE_MSG_NOSIGNAL 1
+#endif
 
 /* Define to 1 if you have the <netdb.h> header file. */
 #define HAVE_NETDB_H 1
@@ -839,7 +846,7 @@
 #define RETSIGTYPE void
 
 /* Define to the type qualifier of arg 5 for select. */
-#define SELECT_QUAL_ARG5 
+#define SELECT_QUAL_ARG5
 
 /* Define to the type of arg 1 for select. */
 #define SELECT_TYPE_ARG1 int
diff --git a/lib/warnless.c b/lib/warnless.c
index 8d4bbdf..9482b44 100644
--- a/lib/warnless.c
+++ b/lib/warnless.c
@@ -22,6 +22,7 @@
 
 #include "curl_setup.h"
 #include "stdint.h"
+#include "limits.h"
 
 #if defined(__INTEL_COMPILER) && defined(__unix__)