Mac build fixes.

This gets us pretty close. There are a few problems with libraries we depend
on (system/core/liblog and external/icu4c) that I have workarounds for, and
a problem with gtest that I haven't yet worked around that prevents us from
linking any of the tests. But this at least gives us a Mac dex2oat binary.

Change-Id: Iac39a6c2963c3d37ab2165d7d1a70e303ba22c45
diff --git a/build/Android.common.mk b/build/Android.common.mk
index 9e05a1c..671ed59 100644
--- a/build/Android.common.mk
+++ b/build/Android.common.mk
@@ -68,7 +68,13 @@
 ART_TARGET_NON_DEBUG_CFLAGS := $(art_non_debug_cflags)
 
 # TODO: move -fkeep-inline-functions to art_debug_cflags when target gcc > 4.4
-ART_HOST_DEBUG_CFLAGS := $(art_debug_cflags) -fkeep-inline-functions
+ART_HOST_DEBUG_CFLAGS := $(art_debug_cflags)
+
+ifneq ($(HOST_OS),linux)
+  # Some Mac OS pthread header files are broken with -fkeep-inline-functions.
+  ART_HOST_DEBUG_CFLAGS := $(filter-out -fkeep-inline-functions,)
+endif
+
 ART_TARGET_DEBUG_CFLAGS := $(art_debug_cflags)
 
 DEX2OAT_SRC_FILES := \
diff --git a/build/Android.libart.mk b/build/Android.libart.mk
index 6b4377b..bdd5514 100644
--- a/build/Android.libart.mk
+++ b/build/Android.libart.mk
@@ -74,7 +74,10 @@
   else # host
     LOCAL_STATIC_LIBRARIES += libcutils
     LOCAL_SHARED_LIBRARIES += libz-host
-    LOCAL_LDLIBS := -ldl -lpthread -lrt
+    LOCAL_LDLIBS := -ldl -lpthread
+    ifeq ($(HOST_OS),linux)
+      LOCAL_LDLIBS += -lrt
+    endif
   endif
   LOCAL_STATIC_LIBRARIES += libdex
   ifeq ($$(art_target_or_host),target)
diff --git a/build/Android.libarttest.mk b/build/Android.libarttest.mk
index 86927c3..16bbcad 100644
--- a/build/Android.libarttest.mk
+++ b/build/Android.libarttest.mk
@@ -42,7 +42,10 @@
     include $(BUILD_SHARED_LIBRARY)
   else # host
     LOCAL_CFLAGS := $(ART_HOST_CFLAGS) $(ART_HOST_DEBUG_CFLAGS)
-    LOCAL_LDLIBS := -ldl -lrt -lpthread
+    LOCAL_LDLIBS := -ldl -lpthread
+    ifeq ($(HOST_OS),linux)
+      LOCAL_LDLIBS += -lrt
+    endif
     include $(BUILD_HOST_SHARED_LIBRARY)
   endif
 endef