Index: third_party/WebKit/WebCore/dom/SelectElement.cpp
===================================================================
--- third_party/WebKit/WebCore/dom/SelectElement.cpp	(revision 63601)
+++ third_party/WebKit/WebCore/dom/SelectElement.cpp	(working copy)
@@ -53,7 +53,7 @@
 #if PLATFORM(MAC) || (PLATFORM(CHROMIUM) && OS(DARWIN))
 #define ARROW_KEYS_POP_MENU 1
 #define SPACE_OR_RETURN_POP_MENU 0
-#elif PLATFORM(GTK) || (PLATFORM(CHROMIUM) && OS(LINUX))
+#elif PLATFORM(GTK) || (PLATFORM(CHROMIUM) && (OS(LINUX) || OS(FREEBSD)))
 #define ARROW_KEYS_POP_MENU 0
 #define SPACE_OR_RETURN_POP_MENU 1
 #else
Index: third_party/WebKit/WebCore/page/EventHandler.cpp
===================================================================
--- third_party/WebKit/WebCore/page/EventHandler.cpp	(revision 63601)
+++ third_party/WebKit/WebCore/page/EventHandler.cpp	(working copy)
@@ -1890,7 +1890,7 @@
     return swallowEvent;
 }
 
-#if !PLATFORM(GTK) && !(PLATFORM(CHROMIUM) && OS(LINUX))
+#if !PLATFORM(GTK) && !(PLATFORM(CHROMIUM) && (OS(LINUX) || OS(FREEBSD)))
 bool EventHandler::shouldTurnVerticalTicksIntoHorizontal(const HitTestResult&) const
 {
     return false;
Index: third_party/WebKit/WebCore/page/chromium/EventHandlerChromium.cpp
===================================================================
--- third_party/WebKit/WebCore/page/chromium/EventHandlerChromium.cpp	(revision 63601)
+++ third_party/WebKit/WebCore/page/chromium/EventHandlerChromium.cpp	(working copy)
@@ -154,7 +154,7 @@
 #endif
 }
 
-#if OS(LINUX)
+#if OS(LINUX) || OS(FREEBSD)
 // GTK+ must scroll horizontally if the mouse pointer is on top of the
 // horizontal scrollbar while scrolling with the wheel.
 // This code comes from gtk/EventHandlerGtk.cpp.
Index: third_party/WebKit/WebCore/platform/chromium/ChromiumBridge.h
===================================================================
--- third_party/WebKit/WebCore/platform/chromium/ChromiumBridge.h	(revision 63601)
+++ third_party/WebKit/WebCore/platform/chromium/ChromiumBridge.h	(working copy)
@@ -141,7 +141,7 @@
 #if OS(WINDOWS)
         static bool ensureFontLoaded(HFONT font);
 #endif
-#if OS(LINUX)
+#if OS(LINUX) || OS(FREEBSD)
         static void getRenderStyleForStrike(const char* family, int sizeAndStyle, FontRenderStyle* result);
         static String getFontFamilyForCharacters(const UChar*, size_t numCharacters);
 #endif
Index: third_party/WebKit/WebCore/platform/graphics/chromium/FontCustomPlatformData.cpp
===================================================================
--- third_party/WebKit/WebCore/platform/graphics/chromium/FontCustomPlatformData.cpp	(revision 63601)
+++ third_party/WebKit/WebCore/platform/graphics/chromium/FontCustomPlatformData.cpp	(working copy)
@@ -36,7 +36,7 @@
 #include "Base64.h"
 #include "ChromiumBridge.h"
 #include "OpenTypeUtilities.h"
-#elif OS(LINUX)
+#elif OS(LINUX) || OS(FREEBSD)
 #include "SkStream.h"
 #endif
 
@@ -47,7 +47,7 @@
 
 #if OS(WINDOWS)
 #include <objbase.h>
-#elif OS(LINUX)
+#elif OS(LINUX) || OS(FREEBSD)
 #include <cstring>
 #endif
 
@@ -58,7 +58,7 @@
 #if OS(WINDOWS)
     if (m_fontReference)
         RemoveFontMemResourceEx(m_fontReference);
-#elif OS(LINUX)
+#elif OS(LINUX) || OS(FREEBSD)
     if (m_fontReference)
         m_fontReference->unref();
 #endif
@@ -99,7 +99,7 @@
 
     HFONT hfont = CreateFontIndirect(&logFont);
     return FontPlatformData(hfont, size);
-#elif OS(LINUX)
+#elif OS(LINUX) || OS(FREEBSD)
     ASSERT(m_fontReference);
     return FontPlatformData(m_fontReference, "", size, bold && !m_fontReference->isBold(), italic && !m_fontReference->isItalic());
 #else
@@ -123,7 +123,7 @@
 }
 #endif
 
-#if OS(LINUX)
+#if OS(LINUX) || OS(FREEBSD)
 class RemoteFontStream : public SkStream {
 public:
     explicit RemoteFontStream(PassRefPtr<SharedBuffer> buffer)
@@ -189,7 +189,7 @@
     if (!fontReference)
         return 0;
     return new FontCustomPlatformData(fontReference, fontName);
-#elif OS(LINUX)
+#elif OS(LINUX) || OS(FREEBSD)
     RemoteFontStream* stream = new RemoteFontStream(buffer);
     SkTypeface* typeface = SkTypeface::CreateFromStream(stream);
     if (!typeface)
Index: third_party/WebKit/WebCore/platform/graphics/chromium/FontPlatformData.h
===================================================================
--- third_party/WebKit/WebCore/platform/graphics/chromium/FontPlatformData.h	(revision 63601)
+++ third_party/WebKit/WebCore/platform/graphics/chromium/FontPlatformData.h	(working copy)
@@ -33,7 +33,7 @@
 
 #if OS(WINDOWS)
 #include "FontPlatformDataChromiumWin.h"
-#elif OS(LINUX)
+#elif OS(LINUX) || OS(FREEBSD)
 #include "FontPlatformDataLinux.h"
 #endif
 
Index: third_party/WebKit/WebCore/platform/graphics/chromium/FontCustomPlatformData.h
===================================================================
--- third_party/WebKit/WebCore/platform/graphics/chromium/FontCustomPlatformData.h	(revision 63601)
+++ third_party/WebKit/WebCore/platform/graphics/chromium/FontCustomPlatformData.h	(working copy)
@@ -38,7 +38,7 @@
 #if OS(WINDOWS)
 #include "PlatformString.h"
 #include <windows.h>
-#elif OS(LINUX)
+#elif OS(LINUX) || OS(FREEBSD)
 #include "SkTypeface.h"
 #endif
 
@@ -53,7 +53,7 @@
         : m_fontReference(fontReference)
         , m_name(name)
     {}
-#elif OS(LINUX)
+#elif OS(LINUX) || OS(FREEBSD)
     explicit FontCustomPlatformData(SkTypeface* typeface)
         : m_fontReference(typeface)
     {}
@@ -67,7 +67,7 @@
 #if OS(WINDOWS)
     HANDLE m_fontReference;
     String m_name;
-#elif OS(LINUX)
+#elif OS(LINUX) || OS(FREEBSD)
     SkTypeface* m_fontReference;
 #endif
 };
Index: third_party/WebKit/WebCore/platform/graphics/skia/PlatformContextSkia.cpp
===================================================================
--- third_party/WebKit/WebCore/platform/graphics/skia/PlatformContextSkia.cpp	(revision 63601)
+++ third_party/WebKit/WebCore/platform/graphics/skia/PlatformContextSkia.cpp	(working copy)
@@ -89,7 +89,7 @@
     // color to produce a new output color.
     SkColor applyAlpha(SkColor) const;
 
-#if OS(LINUX) || OS(WINDOWS)
+#if OS(LINUX) || OS(FREEBSD) || OS(WINDOWS)
     // If non-empty, the current State is clipped to this image.
     SkBitmap m_imageBufferClip;
     // If m_imageBufferClip is non-empty, this is the region the image is clipped to.
@@ -146,7 +146,7 @@
     , m_lineJoin(other.m_lineJoin)
     , m_dash(other.m_dash)
     , m_textDrawingMode(other.m_textDrawingMode)
-#if OS(LINUX) || OS(WINDOWS)
+#if OS(LINUX) || OS(FREEBSD) || OS(WINDOWS)
     , m_imageBufferClip(other.m_imageBufferClip)
     , m_clip(other.m_clip)
 #endif
@@ -232,7 +232,7 @@
     m_stateStack.append(m_state->cloneInheritedProperties());
     m_state = &m_stateStack.last();
 
-#if OS(LINUX) || OS(WINDOWS)
+#if OS(LINUX) || OS(FREEBSD) || OS(WINDOWS)
     // The clip image only needs to be applied once. Reset the image so that we
     // don't attempt to clip multiple times.
     m_state->m_imageBufferClip.reset();
@@ -242,7 +242,7 @@
     canvas()->save();
 }
 
-#if OS(LINUX) || OS(WINDOWS)
+#if OS(LINUX) || OS(FREEBSD) || OS(WINDOWS)
 void PlatformContextSkia::beginLayerClippedToImage(const WebCore::FloatRect& rect,
                                                    const WebCore::ImageBuffer* imageBuffer)
 {
@@ -290,7 +290,7 @@
 
 void PlatformContextSkia::restore()
 {
-#if OS(LINUX) || OS(WINDOWS)
+#if OS(LINUX) || OS(FREEBSD) || OS(WINDOWS)
     if (!m_state->m_imageBufferClip.empty()) {
         applyClipFromImage(m_state->m_clip, m_state->m_imageBufferClip);
         canvas()->restore();
@@ -614,7 +614,7 @@
     return !m_imageResamplingHintSrcSize.isEmpty() && !m_imageResamplingHintDstSize.isEmpty();
 }
 
-#if OS(LINUX) || OS(WINDOWS)
+#if OS(LINUX) || OS(FREEBSD) || OS(WINDOWS)
 void PlatformContextSkia::applyClipFromImage(const WebCore::FloatRect& rect, const SkBitmap& imageBuffer)
 {
     // NOTE: this assumes the image mask contains opaque black for the portions that are to be shown, as such we
Index: third_party/WebKit/WebCore/platform/graphics/skia/PlatformContextSkia.h
===================================================================
--- third_party/WebKit/WebCore/platform/graphics/skia/PlatformContextSkia.h	(revision 63601)
+++ third_party/WebKit/WebCore/platform/graphics/skia/PlatformContextSkia.h	(working copy)
@@ -88,7 +88,7 @@
     // |rect|. This layer is implicitly restored when the next restore is
     // invoked.
     // NOTE: |imageBuffer| may be deleted before the |restore| is invoked.
-#if OS(LINUX) || OS(WINDOWS)
+#if OS(LINUX) || OS(FREEBSD) || OS(WINDOWS)
     void beginLayerClippedToImage(const WebCore::FloatRect&,
                                   const WebCore::ImageBuffer*);
 #endif
@@ -176,7 +176,7 @@
     bool hasImageResamplingHint() const;
 
 private:
-#if OS(LINUX) || OS(WINDOWS)
+#if OS(LINUX) || OS(FREEBSD) || OS(WINDOWS)
     // Used when restoring and the state has an image clip. Only shows the pixels in
     // m_canvas that are also in imageBuffer.
     void applyClipFromImage(const WebCore::FloatRect&, const SkBitmap&);
Index: third_party/WebKit/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp
===================================================================
--- third_party/WebKit/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp	(revision 63601)
+++ third_party/WebKit/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp	(working copy)
@@ -432,7 +432,7 @@
     if (paintingDisabled())
         return;
 
-#if OS(LINUX) || OS(WINDOWS)
+#if OS(LINUX) || OS(FREEBSD) || OS(WINDOWS)
     platformContext()->beginLayerClippedToImage(rect, imageBuffer);
 #endif
 }
Index: third_party/WebKit/WebCore/platform/Scrollbar.cpp
===================================================================
--- third_party/WebKit/WebCore/platform/Scrollbar.cpp	(revision 63601)
+++ third_party/WebKit/WebCore/platform/Scrollbar.cpp	(working copy)
@@ -40,7 +40,7 @@
 
 using namespace std;
 
-#if PLATFORM(CHROMIUM) && OS(LINUX)
+#if PLATFORM(CHROMIUM) && (OS(LINUX) || OS(FREEBSD))
 // The position of the scrollbar thumb affects the appearance of the steppers, so
 // when the thumb moves, we have to invalidate them for painting.
 #define THUMB_POSITION_AFFECTS_BUTTONS
Index: third_party/WebKit/WebCore/bindings/js/JSInspectorFrontendHostCustom.cpp
===================================================================
--- third_party/WebKit/WebCore/bindings/js/JSInspectorFrontendHostCustom.cpp	(revision 63601)
+++ third_party/WebKit/WebCore/bindings/js/JSInspectorFrontendHostCustom.cpp	(working copy)
@@ -57,6 +57,8 @@
     DEFINE_STATIC_LOCAL(const String, platform, ("windows"));
 #elif OS(LINUX)
     DEFINE_STATIC_LOCAL(const String, platform, ("linux"));
+#elif OS(FREEBSD)
+    DEFINE_STATIC_LOCAL(const String, platform, ("freebsd"));
 #else
     DEFINE_STATIC_LOCAL(const String, platform, ("unknown"));
 #endif
Index: third_party/WebKit/WebCore/bindings/v8/custom/V8InspectorFrontendHostCustom.cpp
===================================================================
--- third_party/WebKit/WebCore/bindings/v8/custom/V8InspectorFrontendHostCustom.cpp	(revision 63601)
+++ third_party/WebKit/WebCore/bindings/v8/custom/V8InspectorFrontendHostCustom.cpp	(working copy)
@@ -46,6 +46,8 @@
     return v8String("mac");
 #elif defined(OS_LINUX)
     return v8String("linux");
+#elif defined(OS_FREEBSD)
+    return v8String("freebsd");
 #elif defined(OS_WIN)
     return v8String("windows");
 #else
Index: third_party/WebKit/WebCore/loader/CachedFont.cpp
===================================================================
--- third_party/WebKit/WebCore/loader/CachedFont.cpp	(revision 63601)
+++ third_party/WebKit/WebCore/loader/CachedFont.cpp	(working copy)
@@ -27,7 +27,7 @@
 #include "config.h"
 #include "CachedFont.h"
 
-#if PLATFORM(CG) || PLATFORM(QT) || PLATFORM(GTK) || (PLATFORM(CHROMIUM) && (OS(WINDOWS) || OS(LINUX))) || PLATFORM(HAIKU) || OS(WINCE) || PLATFORM(ANDROID)
+#if PLATFORM(CG) || PLATFORM(QT) || PLATFORM(GTK) || (PLATFORM(CHROMIUM) && (OS(WINDOWS) || OS(LINUX) || OS(FREEBSD))) || PLATFORM(HAIKU) || OS(WINCE) || PLATFORM(ANDROID)
 #define STORE_FONT_CUSTOM_PLATFORM_DATA
 #endif
 
Index: third_party/WebKit/WebKit/chromium/src/WebGraphicsContext3DDefaultImpl.cpp
===================================================================
--- third_party/WebKit/WebKit/chromium/src/WebGraphicsContext3DDefaultImpl.cpp	(revision 63601)
+++ third_party/WebKit/WebKit/chromium/src/WebGraphicsContext3DDefaultImpl.cpp	(working copy)
@@ -39,7 +39,7 @@
 
 #include "NotImplemented.h"
 
-#if OS(LINUX)
+#if OS(LINUX) || OS(FREEBSD)
 #include <dlfcn.h>
 #endif
 
@@ -54,7 +54,7 @@
 
 bool WebGraphicsContext3DDefaultImpl::s_initializedGLEW = false;
 
-#if OS(LINUX)
+#if OS(LINUX) || OS(FREEBSD)
 WebGraphicsContext3DDefaultImpl::GLConnection* WebGraphicsContext3DDefaultImpl::s_gl = 0;
 
 WebGraphicsContext3DDefaultImpl::GLConnection* WebGraphicsContext3DDefaultImpl::GLConnection::create()
@@ -107,7 +107,7 @@
     dlclose(m_libGL);
 }
 
-#endif // OS(LINUX)
+#endif // OS(LINUX) || OS(FREEBSD)
 
 WebGraphicsContext3DDefaultImpl::VertexAttribPointerState::VertexAttribPointerState()
     : enabled(false)
@@ -142,7 +142,7 @@
     , m_pbuffer(0)
     , m_contextObj(0)
     , m_renderOutput(0)
-#elif OS(LINUX)
+#elif OS(LINUX) || OS(FREEBSD)
     , m_contextObj(0)
     , m_pbuffer(0)
 #else
@@ -183,7 +183,7 @@
         CGLDestroyPBuffer(m_pbuffer);
         if (m_renderOutput)
             delete[] m_renderOutput;
-#elif OS(LINUX)
+#elif OS(LINUX) || OS(FREEBSD)
         s_gl->makeCurrent(0, 0);
         s_gl->destroyContext(m_contextObj);
         s_gl->destroyPbuffer(m_pbuffer);
@@ -316,7 +316,7 @@
     }
     m_pbuffer = pbuffer;
     m_contextObj = context;
-#elif OS(LINUX)
+#elif OS(LINUX) || OS(FREEBSD)
     if (!s_gl) {
         s_gl = GLConnection::create();
         if (!s_gl)
@@ -431,7 +431,7 @@
     if (CGLGetCurrentContext() != m_contextObj)
         if (CGLSetCurrentContext(m_contextObj) == kCGLNoError)
             return true;
-#elif OS(LINUX)
+#elif OS(LINUX) || OS(FREEBSD)
     if (s_gl->getCurrentContext() != m_contextObj)
         if (s_gl->makeCurrent(m_pbuffer, m_contextObj))
             return true;
Index: third_party/WebKit/WebKit/chromium/src/ChromiumBridge.cpp
===================================================================
--- third_party/WebKit/WebKit/chromium/src/ChromiumBridge.cpp	(revision 63601)
+++ third_party/WebKit/WebKit/chromium/src/ChromiumBridge.cpp	(working copy)
@@ -64,7 +64,7 @@
 #include "WebThemeEngine.h"
 #endif
 
-#if OS(LINUX)
+#if OS(LINUX) || OS(FREEBSD)
 #include "WebFontInfo.h"
 #include "WebFontRenderStyle.h"
 #endif
@@ -420,7 +420,7 @@
 }
 #endif
 
-#if OS(LINUX)
+#if OS(LINUX) || OS(FREEBSD)
 String ChromiumBridge::getFontFamilyForCharacters(const UChar* characters, size_t numCharacters)
 {
     if (webKitClient()->sandboxSupport())
Index: third_party/WebKit/WebKit/chromium/src/WebFrameImpl.cpp
===================================================================
--- third_party/WebKit/WebKit/chromium/src/WebFrameImpl.cpp	(revision 63601)
+++ third_party/WebKit/WebKit/chromium/src/WebFrameImpl.cpp	(working copy)
@@ -151,7 +151,7 @@
 #include "LocalCurrentGraphicsContext.h"
 #endif
 
-#if OS(LINUX)
+#if OS(LINUX) || OS(FREEBSD)
 #include <gdk/gdk.h>
 #endif
 
@@ -298,7 +298,7 @@
         float scale = m_printedPageWidth / pageRect.width();
 
         ctx.save();
-#if OS(LINUX)
+#if OS(LINUX) || OS(FREEBSD)
         ctx.scale(WebCore::FloatSize(scale, scale));
 #endif
         ctx.translate(static_cast<float>(-pageRect.x()),
Index: third_party/WebKit/WebKit/chromium/src/WebGraphicsContext3DDefaultImpl.h
===================================================================
--- third_party/WebKit/WebKit/chromium/src/WebGraphicsContext3DDefaultImpl.h	(revision 63601)
+++ third_party/WebKit/WebKit/chromium/src/WebGraphicsContext3DDefaultImpl.h	(working copy)
@@ -52,7 +52,7 @@
 #define FLIP_FRAMEBUFFER_VERTICALLY
 #endif
 
-#if OS(LINUX)
+#if OS(LINUX) || OS(FREEBSD)
 #include "GL/glxew.h"
 #endif
 
@@ -332,7 +332,7 @@
     CGLPBufferObj m_pbuffer;
     CGLContextObj m_contextObj;
     unsigned char* m_renderOutput;
-#elif OS(LINUX)
+#elif OS(LINUX) || OS(FREEBSD)
     GLXContext m_contextObj;
     GLXPbuffer m_pbuffer;
 
Index: third_party/WebKit/WebKit/chromium/src/WebViewImpl.cpp
===================================================================
--- third_party/WebKit/WebKit/chromium/src/WebViewImpl.cpp	(revision 63601)
+++ third_party/WebKit/WebKit/chromium/src/WebViewImpl.cpp	(working copy)
@@ -115,7 +115,7 @@
 #if OS(WINDOWS)
 #include "RenderThemeChromiumWin.h"
 #else
-#if OS(LINUX)
+#if OS(LINUX) || OS(FREEBSD)
 #include "RenderThemeChromiumLinux.h"
 #endif
 #include "RenderTheme.h"
@@ -402,7 +402,7 @@
         || (event.button == WebMouseEvent::ButtonLeft
             && event.modifiers & WebMouseEvent::ControlKey))
         mouseContextMenu(event);
-#elif OS(LINUX)
+#elif OS(LINUX) || OS(FREEBSD)
     if (event.button == WebMouseEvent::ButtonRight)
         mouseContextMenu(event);
 #endif
@@ -441,7 +441,7 @@
     if (!mainFrameImpl() || !mainFrameImpl()->frameView())
         return;
 
-#if OS(LINUX)
+#if OS(LINUX) || OS(FREEBSD)
     // If the event was a middle click, attempt to copy text into the focused
     // frame. We execute this before we let the page have a go at the event
     // because the page may change what is focused during in its event handler.
@@ -525,11 +525,11 @@
     if (!handler)
         return keyEventDefault(event);
 
-#if OS(WINDOWS) || OS(LINUX)
+#if OS(WINDOWS) || OS(LINUX) || OS(FREEBSD)
     const WebInputEvent::Type contextMenuTriggeringEventType =
 #if OS(WINDOWS)
         WebInputEvent::KeyUp;
-#elif OS(LINUX)
+#elif OS(LINUX) || OS(FREEBSD)
         WebInputEvent::RawKeyDown;
 #endif
 
@@ -673,7 +673,7 @@
 }
 #endif
 
-#if OS(WINDOWS) || OS(LINUX)
+#if OS(WINDOWS) || OS(LINUX) || OS(FREEBSD)
 // Mac has no way to open a context menu based on a keyboard event.
 bool WebViewImpl::sendContextMenuEvent(const WebKeyboardEvent& event)
 {
@@ -1875,7 +1875,7 @@
 void WebViewImpl::setScrollbarColors(unsigned inactiveColor,
                                      unsigned activeColor,
                                      unsigned trackColor) {
-#if OS(LINUX)
+#if OS(LINUX) || OS(FREEBSD)
     PlatformThemeChromiumGtk::setScrollbarColors(inactiveColor,
                                                  activeColor,
                                                  trackColor);
@@ -1886,7 +1886,7 @@
                                      unsigned activeForegroundColor,
                                      unsigned inactiveBackgroundColor,
                                      unsigned inactiveForegroundColor) {
-#if OS(LINUX)
+#if OS(LINUX) || OS(FREEBSD)
     RenderThemeChromiumLinux::setSelectionColors(activeBackgroundColor,
                                                  activeForegroundColor,
                                                  inactiveBackgroundColor,
Index: tools/gyp/test/additional-targets/src/dir1/actions.gyp
===================================================================
--- tools/gyp/test/additional-targets/src/dir1/actions.gyp	(revision 837)
+++ tools/gyp/test/additional-targets/src/dir1/actions.gyp	(working copy)
@@ -47,7 +47,7 @@
     },
   ],
   'conditions': [
-    ['OS=="linux"', {
+    ['OS=="linux" or OS=="freebsd"', {
       'target_defaults': {
         'cflags': ['-fPIC'],
       },
Index: tools/gyp/test/library/src/library.gyp
===================================================================
--- tools/gyp/test/library/src/library.gyp	(revision 837)
+++ tools/gyp/test/library/src/library.gyp	(working copy)
@@ -48,7 +48,7 @@
     },
   ],
   'conditions': [
-    ['OS=="linux"', {
+    ['OS=="linux" or OS=="freebsd"', {
       'target_defaults': {
         # Support 64-bit shared libs (also works fine for 32-bit).
         'cflags': ['-fPIC'],
Index: tools/gyp/pylib/gyp/generator/make.py
===================================================================
--- tools/gyp/pylib/gyp/generator/make.py	(revision 837)
+++ tools/gyp/pylib/gyp/generator/make.py	(working copy)
@@ -34,7 +34,7 @@
 generator_default_variables = {
   'EXECUTABLE_PREFIX': '',
   'EXECUTABLE_SUFFIX': '',
-  'OS': 'linux',
+  'OS': 'freebsd',
   'STATIC_LIB_PREFIX': 'lib',
   'SHARED_LIB_PREFIX': 'lib',
   'STATIC_LIB_SUFFIX': '.a',
@@ -106,7 +106,7 @@
 #   export LINK="$(CXX)"
 #
 # This will allow make to invoke N linker processes as specified in -jN.
-LINK ?= flock $(builddir)/linker.lock $(CXX)
+LINK ?= $(CXX)
 
 # We want to use GNU ar's T option if available because it's much faster.
 # We try to archive and link a file to see ar and ld support this feature.
@@ -147,13 +147,13 @@
   ARFLAGS.target := $(call detect_arflags,target)
 endif
 
-CC.host ?= gcc
-CFLAGS.host ?=
-CXX.host ?= g++
-CXXFLAGS.host ?=
-LINK.host ?= g++
-LDFLAGS.host ?=
-AR.host ?= ar
+CC.host ?= $(CC)
+CFLAGS.host ?= $(CFLAGS)
+CXX.host ?= $(CXX)
+CXXFLAGS.host ?= $(CXXFLAGS)
+LINK.host ?= $(LINK)
+LDFLAGS.host ?= $(LDFLAGS)
+AR.host ?= $(AR)
 # See the description for ARFLAGS.target.
 -include $(obj).host/arflags/arflags.mk
 # Temporarily disabled -- see ARFLAGS.target.
@@ -195,7 +195,7 @@
 # We remove slashes and replace spaces with new lines;
 # remove blank lines;
 # delete the first line and append a colon to the remaining lines.
-sed -e 's|\\||' -e 's| |\n|g' $(depfile).raw |\
+sed -e 's|\\||' -e 'y| |\n|' $(depfile).raw |\
   grep -v '^$$'                              |\
   sed -e 1d -e 's|$$|:|'                      \
     >> $(depfile)
@@ -895,12 +895,12 @@
 # CFLAGS et al overrides must be target-local.
 # See "Target-specific Variable Values" in the GNU Make manual.""")
       self.WriteLn("$(OBJS): TOOLSET := $(TOOLSET)")
-      self.WriteLn("$(OBJS): GYP_CFLAGS := $(CFLAGS_$(BUILDTYPE)) "
-                   "$(CFLAGS_C_$(BUILDTYPE)) "
-                   "$(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE))")
-      self.WriteLn("$(OBJS): GYP_CXXFLAGS := $(CFLAGS_$(BUILDTYPE)) "
-                   "$(CFLAGS_CC_$(BUILDTYPE)) "
-                   "$(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE))")
+      self.WriteLn("$(OBJS): GYP_CFLAGS := $(INCS_$(BUILDTYPE)) "
+                   "$(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) "
+                   "$(DEFS_$(BUILDTYPE))")
+      self.WriteLn("$(OBJS): GYP_CXXFLAGS := $(INCS_$(BUILDTYPE)) "
+                   "$(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) "
+                   "$(DEFS_$(BUILDTYPE))")
 
     self.WriteLn()
 
Index: tools/gyp/pylib/gyp/__init__.py
===================================================================
--- tools/gyp/pylib/gyp/__init__.py     (revision 856)
+++ tools/gyp/pylib/gyp/__init__.py     (working copy)
@@ -315,6 +315,7 @@
                            'cygwin':   'msvs',
                            'freebsd7': 'make',
                            'freebsd8': 'make',
+                           'freebsd9': 'make',
                            'linux2':   'make',
                            'openbsd4': 'make',
                            'sunos5':   'make',}[sys.platform] ]
Index: third_party/hunspell/hunspell.gyp
===================================================================
--- third_party/hunspell/hunspell.gyp	(revision 50872)
+++ third_party/hunspell/hunspell.gyp	(working copy)
@@ -63,11 +63,12 @@
         ],
       },
       'conditions': [
-        ['OS=="linux"', {
+        ['OS=="linux" or OS=="freebsd"', {
           'cflags': [
             '-Wno-unused-value',
             '-Wno-unused-variable',
             '-Wno-write-strings',
+            '-Wno-parentheses',
           ],
         }],
       ],
Index: third_party/icu/public/common/unicode/umachine.h
===================================================================
--- third_party/icu/public/common/unicode/umachine.h	(revision 51076)
+++ third_party/icu/public/common/unicode/umachine.h	(working copy)
@@ -49,6 +49,8 @@
 #   include "unicode/pmac.h"
 #elif defined(__linux__)
 #   include "unicode/plinux.h"
+#elif defined(__FreeBSD__)
+#   include "unicode/pfreebsd.h"
 #else
 #   include "unicode/platform.h"
 #endif
Index: third_party/icu/public/common/unicode/pfreebsd.h
===================================================================
--- third_party/icu/public/common/unicode/pfreebsd.h	(revision 0)
+++ third_party/icu/public/common/unicode/pfreebsd.h	(revision 0)
@@ -0,0 +1,313 @@
+/*
+******************************************************************************
+*
+*   Copyright (C) 1997-2007, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+*
+******************************************************************************
+*
+*  FILE NAME : platform.h
+*
+*   Date        Name        Description
+*   05/13/98    nos         Creation (content moved here from ptypes.h).
+*   03/02/99    stephen     Added AS400 support.
+*   03/30/99    stephen     Added Linux support.
+*   04/13/99    stephen     Reworked for autoconf.
+******************************************************************************
+*/
+
+/**
+ * \file 
+ * \brief Basic types for the platform 
+ */
+
+/* Define the platform we're on. */
+#ifndef U_BSD
+#define U_BSD
+#endif
+
+/* Define whether inttypes.h is available */
+#ifndef U_HAVE_INTTYPES_H
+#define U_HAVE_INTTYPES_H 1
+#endif
+
+/*
+ * Define what support for C++ streams is available.
+ *     If U_IOSTREAM_SOURCE is set to 199711, then <iostream> is available
+ * (1997711 is the date the ISO/IEC C++ FDIS was published), and then
+ * one should qualify streams using the std namespace in ICU header
+ * files.
+ *     If U_IOSTREAM_SOURCE is set to 198506, then <iostream.h> is
+ * available instead (198506 is the date when Stroustrup published
+ * "An Extensible I/O Facility for C++" at the summer USENIX conference).
+ *     If U_IOSTREAM_SOURCE is 0, then C++ streams are not available and
+ * support for them will be silently suppressed in ICU.
+ *
+ */
+
+#ifndef U_IOSTREAM_SOURCE
+#define U_IOSTREAM_SOURCE 199711
+#endif
+
+/* Determines whether specific types are available */
+#ifndef U_HAVE_INT8_T
+#define U_HAVE_INT8_T 1
+#endif
+
+#ifndef U_HAVE_UINT8_T
+#define U_HAVE_UINT8_T 1
+#endif
+
+#ifndef U_HAVE_INT16_T
+#define U_HAVE_INT16_T 1
+#endif
+
+#ifndef U_HAVE_UINT16_T
+#define U_HAVE_UINT16_T 1
+#endif
+
+#ifndef U_HAVE_INT32_T
+#define U_HAVE_INT32_T 1
+#endif
+
+#ifndef U_HAVE_UINT32_T
+#define U_HAVE_UINT32_T 1
+#endif
+
+#ifndef U_HAVE_INT64_T
+#define U_HAVE_INT64_T 1
+#endif
+
+#ifndef U_HAVE_UINT64_T
+#define U_HAVE_UINT64_T 1
+#endif
+
+/*===========================================================================*/
+/* Generic data types                                                        */
+/*===========================================================================*/
+
+#include <sys/types.h>
+
+/* If your platform does not have the <inttypes.h> header, you may
+   need to edit the typedefs below. */
+#if U_HAVE_INTTYPES_H
+
+/* autoconf 2.13 sometimes can't properly find the data types in <inttypes.h> */
+/* os/390 needs <inttypes.h>, but it doesn't have int8_t, and it sometimes */
+/* doesn't have uint8_t depending on the OS version. */
+/* So we have this work around. */
+#ifdef OS390
+/* The features header is needed to get (u)int64_t sometimes. */
+#include <features.h>
+#if ! U_HAVE_INT8_T
+typedef signed char int8_t;
+#endif
+#if !defined(__uint8_t)
+#define __uint8_t 1
+typedef unsigned char uint8_t;
+#endif
+#endif /* OS390 */
+
+#include <inttypes.h>
+
+#else /* U_HAVE_INTTYPES_H */
+
+#if ! U_HAVE_INT8_T
+typedef signed char int8_t;
+#endif
+
+#if ! U_HAVE_UINT8_T
+typedef unsigned char uint8_t;
+#endif
+
+#if ! U_HAVE_INT16_T
+typedef signed short int16_t;
+#endif
+
+#if ! U_HAVE_UINT16_T
+typedef unsigned short uint16_t;
+#endif
+
+#if ! U_HAVE_INT32_T
+typedef signed int int32_t;
+#endif
+
+#if ! U_HAVE_UINT32_T
+typedef unsigned int uint32_t;
+#endif
+
+#if ! U_HAVE_INT64_T
+    typedef signed long long int64_t;
+/* else we may not have a 64-bit type */
+#endif
+
+#if ! U_HAVE_UINT64_T
+    typedef unsigned long long uint64_t;
+/* else we may not have a 64-bit type */
+#endif
+
+#endif
+
+/*===========================================================================*/
+/* Compiler and environment features                                         */
+/*===========================================================================*/
+
+/* Define whether namespace is supported */
+#ifndef U_HAVE_NAMESPACE
+#define U_HAVE_NAMESPACE 1
+#endif
+
+/* Determines the endianness of the platform
+   It's done this way in case multiple architectures are being built at once.
+   For example, Darwin supports fat binaries, which can be both PPC and x86 based. */
+#if defined(BYTE_ORDER) && defined(BIG_ENDIAN)
+#define U_IS_BIG_ENDIAN (BYTE_ORDER == BIG_ENDIAN)
+#else
+#define U_IS_BIG_ENDIAN 0
+#endif
+
+/* 1 or 0 to enable or disable threads.  If undefined, default is: enable threads. */
+#define ICU_USE_THREADS 1
+
+/* On strong memory model CPUs (e.g. x86 CPUs), we use a safe & quick double check lock. */
+#if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
+#define UMTX_STRONG_MEMORY_MODEL 1
+#endif
+
+#ifndef U_DEBUG
+#define U_DEBUG 0
+#endif
+
+#ifndef U_RELEASE
+#define U_RELEASE 1
+#endif
+
+/* Determine whether to disable renaming or not. This overrides the
+   setting in umachine.h which is for all platforms. */
+#ifndef U_DISABLE_RENAMING
+#define U_DISABLE_RENAMING 0
+#endif
+
+/* Determine whether to override new and delete. */
+#ifndef U_OVERRIDE_CXX_ALLOCATION
+#define U_OVERRIDE_CXX_ALLOCATION 1
+#endif
+/* Determine whether to override placement new and delete for STL. */
+#ifndef U_HAVE_PLACEMENT_NEW
+#define U_HAVE_PLACEMENT_NEW 1
+#endif
+
+/* Determine whether to enable tracing. */
+#ifndef U_ENABLE_TRACING
+#define U_ENABLE_TRACING 0
+#endif
+
+/* Do we allow ICU users to use the draft APIs by default? */
+#ifndef U_DEFAULT_SHOW_DRAFT
+#define U_DEFAULT_SHOW_DRAFT 1
+#endif
+
+/* Define the library suffix in a C syntax. */
+#define U_HAVE_LIB_SUFFIX 0
+#define U_LIB_SUFFIX_C_NAME 
+#define U_LIB_SUFFIX_C_NAME_STRING ""
+
+/*===========================================================================*/
+/* Character data types                                                      */
+/*===========================================================================*/
+
+#if ((defined(OS390) && (!defined(__CHARSET_LIB) || !__CHARSET_LIB))) || defined(OS400)
+#   define U_CHARSET_FAMILY 1
+#endif
+
+/*===========================================================================*/
+/* Information about wchar support                                           */
+/*===========================================================================*/
+
+#define U_HAVE_WCHAR_H      1
+#define U_SIZEOF_WCHAR_T    4
+
+#define U_HAVE_WCSCPY       1
+
+/**
+ * \def U_DECLARE_UTF16
+ * Do not use this macro. Use the UNICODE_STRING or U_STRING_DECL macros
+ * instead.
+ * @internal
+ */
+#if 1 || defined(U_CHECK_UTF16_STRING)
+#if (defined(__xlC__) && defined(__IBM_UTF_LITERAL) && U_SIZEOF_WCHAR_T != 2) \
+    || (defined(__HP_aCC) && __HP_aCC >= 035000) \
+    || (defined(__HP_cc) && __HP_cc >= 111106)
+#define U_DECLARE_UTF16(string) u ## string
+#elif (defined(__SUNPRO_CC) && __SUNPRO_CC >= 0x550)
+/* || (defined(__SUNPRO_C) && __SUNPRO_C >= 0x580) */
+/* Sun's C compiler has issues with this notation, and it's unreliable. */
+#define U_DECLARE_UTF16(string) U ## string
+#elif U_SIZEOF_WCHAR_T == 2 \
+    && (U_CHARSET_FAMILY == 0 || ((defined(OS390) || defined(OS400)) && defined(__UCS2__)))
+#define U_DECLARE_UTF16(string) L ## string
+#endif
+#endif
+
+/*===========================================================================*/
+/* Information about POSIX support                                           */
+/*===========================================================================*/
+
+#define U_HAVE_NL_LANGINFO_CODESET  1
+#define U_NL_LANGINFO_CODESET       CODESET
+
+#if 1
+#define U_TZSET         tzset
+#endif
+#if 0
+#define U_TIMEZONE      
+#endif
+#if 1
+#define U_TZNAME        tzname
+#endif
+
+#define U_HAVE_MMAP     1
+#define U_HAVE_POPEN    1
+
+/*===========================================================================*/
+/* Symbol import-export control                                              */
+/*===========================================================================*/
+
+#if 1
+#define U_EXPORT __attribute__((visibility("default")))
+/*#elif defined(__HP_aCC) || defined(__HP_cc)
+#define U_EXPORT __declspec(dllexport)*/
+#else
+#define U_EXPORT
+#endif
+
+/* U_CALLCONV is releated to U_EXPORT2 */
+#define U_EXPORT2
+
+/* cygwin needs to export/import data */
+#ifdef U_CYGWIN
+#define U_IMPORT __declspec(dllimport)
+#else
+#define U_IMPORT 
+#endif
+
+/*===========================================================================*/
+/* Code alignment and C function inlining                                    */
+/*===========================================================================*/
+
+#ifndef U_INLINE
+#   ifdef __cplusplus
+#       define U_INLINE inline
+#   else
+#       define U_INLINE inline
+#   endif
+#endif
+
+#define U_ALIGN_CODE(n) 
+
+/*===========================================================================*/
+/* Programs used by ICU code                                                 */
+/*===========================================================================*/
+
+#define U_MAKE  "/usr/local/bin/gmake"
Index: third_party/icu/icu.gyp
===================================================================
--- third_party/icu/icu.gyp	(revision 51076)
+++ third_party/icu/icu.gyp	(working copy)
@@ -42,7 +42,7 @@
         }, {  # else: OS != "win"
           'sources!': ['icudt42.dll'],
         }],
-        [ 'OS != "linux" or chromeos == 1', {
+        [ '(OS != "linux" and OS != "freebsd") or chromeos == 1', {
           'sources!': ['linux/icudt42l_dat.s'],
         }],
         [ 'OS != "mac"', {
@@ -215,7 +215,7 @@
         ],
       },
       'conditions': [
-        [ 'OS=="linux"', {
+        [ 'OS=="linux" or OS=="freebsd"', {
           # Since ICU wants to internally use its own deprecated APIs, don't
           # complain about it.
           'cflags': [
@@ -403,7 +403,7 @@
             'source/stubdata/stubdata.c',
           ],
         }],
-        [ 'OS == "linux"', {
+        [ 'OS == "linux" or OS=="freebsd"', {
           'cflags': [
             # TODO(port): fix ICU to not depend on this flag.
             '-fno-strict-aliasing',
Index: third_party/libjingle/source/talk/base/httpcommon.cc
===================================================================
--- third_party/libjingle/source/talk/base/httpcommon.cc	(revision 24)
+++ third_party/libjingle/source/talk/base/httpcommon.cc	(working copy)
@@ -399,7 +399,7 @@
     gmt = non_gmt + kTimeZoneOffsets[zindex] * 60 * 60;
   }
   // TODO: Android should support timezone, see b/2441195
-#if defined(OSX) || defined(ANDROID)
+#if defined(OSX) || defined(ANDROID) || defined(BSD)
   tm *tm_for_timezone = localtime((time_t *)&gmt);
   *seconds = gmt + tm_for_timezone->tm_gmtoff;
 #else
Index: third_party/libjingle/source/talk/base/unixfilesystem.cc
===================================================================
--- third_party/libjingle/source/talk/base/unixfilesystem.cc	(revision 24)
+++ third_party/libjingle/source/talk/base/unixfilesystem.cc	(working copy)
@@ -490,7 +490,7 @@
 
 Pathname UnixFilesystem::GetCurrentDirectory() {
   Pathname cwd;
-#if defined(LINUX) || defined(OSX)
+#if defined(LINUX) || defined(OSX) || defined(BSD)
   // Both Linux and Mac supported malloc()'ing the string themselves, although
   // that is not required by POSIX.
   char *path = getcwd(NULL, 0);
@@ -508,7 +508,7 @@
   }
   cwd.SetFolder(std::string(path));
 
-#if defined(LINUX) || defined(OSX)
+#if defined(LINUX) || defined(OSX) || defined(BSD)
   free(path);
 #endif
   return cwd;
Index: third_party/libjingle/source/talk/base/physicalsocketserver.cc
===================================================================
--- third_party/libjingle/source/talk/base/physicalsocketserver.cc	(revision 24)
+++ third_party/libjingle/source/talk/base/physicalsocketserver.cc	(working copy)
@@ -487,7 +487,7 @@
         *slevel = IPPROTO_IP;
         *sopt = IP_DONTFRAGMENT;
         break;
-#elif defined(OSX)
+#elif defined(OSX) || defined(BSD)
         LOG(LS_WARNING) << "Socket::OPT_DONTFRAGMENT not supported.";
         return -1;
 #elif defined(POSIX)
Index: third_party/ppapi/ppapi.gyp
===================================================================
--- third_party/ppapi/ppapi.gyp	(revision 165)
+++ third_party/ppapi/ppapi.gyp	(working copy)
@@ -144,7 +144,7 @@
             },
           },
         }],
-        ['OS=="linux"', {
+        ['OS=="linux" or OS=="freebsd"', {
           'cflags': ['-Wextra', '-pedantic'],
         }],
         ['OS=="mac"', {
@@ -172,7 +172,7 @@
         ['OS=="win"', {
           'msvs_guid': '057E7FA0-83C0-11DF-8395-0800200C9A66',
         }],
-        ['OS=="linux"', {
+        ['OS=="linux" or OS=="freebsd"', {
           'cflags': ['-Wextra', '-pedantic'],
         }],
         ['OS=="mac"', {
Index: native_client/src/shared/platform/platform.gyp
===================================================================
--- native_client/src/shared/platform/platform.gyp	(revision 2697)
+++ native_client/src/shared/platform/platform.gyp	(working copy)
@@ -59,7 +59,7 @@
       'time.h',
     ],
     'conditions': [
-      ['OS=="linux"', {
+      ['OS=="linux" or OS=="freebsd"', {
         'platform_sources': [
           'linux/condition_variable.cc',
           'linux/lock.cc',
Index: native_client/src/trusted/service_runtime/service_runtime.gyp
===================================================================
--- native_client/src/trusted/service_runtime/service_runtime.gyp	(revision 2697)
+++ native_client/src/trusted/service_runtime/service_runtime.gyp	(working copy)
@@ -31,7 +31,7 @@
 {
   'variables': {
     'conditions': [
-      ['OS=="linux"', {
+      ['OS=="linux" or OS=="freebsd"', {
         'syscall_handler': [
           'linux/nacl_syscall_impl.c'
         ],
Index: native_client/build/common.gypi
===================================================================
--- native_client/build/common.gypi	(revision 2697)
+++ native_client/build/common.gypi	(working copy)
@@ -383,7 +383,7 @@
     },
   },
   'conditions': [
-    ['OS=="linux"', {
+    ['OS=="linux" or OS=="freebsd"', {
       'target_defaults': {
         # Enable -Werror by default, but put it in a variable so it can
         # be disabled in ~/.gyp/include.gypi on the valgrind builders.
