add stuff needed for linux builds
diff --git a/.gitignore b/.gitignore
index 6e42d49..8266006 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,6 @@
 buildtools
 base
+build/util/LASTCHANGE
 build/config
 build/toolchain
 out
diff --git a/DEPS b/DEPS
index 385252b..5a8d843 100644
--- a/DEPS
+++ b/DEPS
@@ -1,8 +1,17 @@
 vars = {
   'chromium_git': 'https://chromium.googlesource.com',
+  # Three lines of non-changing comments so that
+  # the commit queue can handle CLs rolling build tools
+  # and whatever else without interference from each other.
+  'buildtools_revision': '3b302fef93f7cc58d9b8168466905237484b2772',
+  # Three lines of non-changing comments so that
+  # the commit queue can handle CLs rolling build tools
+  # and whatever else without interference from each other.
 }
 
 deps = {
+  'gn/buildtools':
+    Var('chromium_git') + '/chromium/buildtools.git' '@' + Var('buildtools_revision'),
   'gn/base':
     Var('chromium_git') + '/chromium/src/base.git@6ec23b2',
   'gn/build/config':
diff --git a/build/gn_helpers.py b/build/gn_helpers.py
new file mode 100644
index 0000000..3b0647d
--- /dev/null
+++ b/build/gn_helpers.py
@@ -0,0 +1,39 @@
+# Copyright 2014 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Helper functions useful when writing scripts that are run from GN's
+exec_script function."""
+
+class GNException(Exception):
+  pass
+
+
+def ToGNString(value, allow_dicts = True):
+  """Prints the given value to stdout.
+
+  allow_dicts indicates if this function will allow converting dictionaries
+  to GN scopes. This is only possible at the top level, you can't nest a
+  GN scope in a list, so this should be set to False for recursive calls."""
+  if isinstance(value, str):
+    if value.find('\n') >= 0:
+      raise GNException("Trying to print a string with a newline in it.")
+    return '"' + value.replace('"', '\\"') + '"'
+
+  if isinstance(value, list):
+    return '[ %s ]' % ', '.join(ToGNString(v) for v in value)
+
+  if isinstance(value, dict):
+    if not allow_dicts:
+      raise GNException("Attempting to recursively print a dictionary.")
+    result = ""
+    for key in value:
+      if not isinstance(key, str):
+        raise GNException("Dictionary key is not a string.")
+      result += "%s = %s\n" % (key, ToGNString(value[key], False))
+    return result
+
+  if isinstance(value, int):
+    return str(value)
+
+  raise GNException("Unsupported type when printing to GN.")
diff --git a/build/gypi_to_gn.py b/build/gypi_to_gn.py
new file mode 100644
index 0000000..a107f94
--- /dev/null
+++ b/build/gypi_to_gn.py
@@ -0,0 +1,167 @@
+# Copyright 2014 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Converts a given gypi file to a python scope and writes the result to stdout.
+
+It is assumed that the file contains a toplevel dictionary, and this script
+will return that dictionary as a GN "scope" (see example below). This script
+does not know anything about GYP and it will not expand variables or execute
+conditions.
+
+It will strip conditions blocks.
+
+A variables block at the top level will be flattened so that the variables
+appear in the root dictionary. This way they can be returned to the GN code.
+
+Say your_file.gypi looked like this:
+  {
+     'sources': [ 'a.cc', 'b.cc' ],
+     'defines': [ 'ENABLE_DOOM_MELON' ],
+  }
+
+You would call it like this:
+  gypi_values = exec_script("//build/gypi_to_gn.py",
+                            [ rebase_path("your_file.gypi") ],
+                            "scope",
+                            [ "your_file.gypi" ])
+
+Notes:
+ - The rebase_path call converts the gypi file from being relative to the
+   current build file to being system absolute for calling the script, which
+   will have a different current directory than this file.
+
+ - The "scope" parameter tells GN to interpret the result as a series of GN
+   variable assignments.
+
+ - The last file argument to exec_script tells GN that the given file is a
+   dependency of the build so Ninja can automatically re-run GN if the file
+   changes.
+
+Read the values into a target like this:
+  component("mycomponent") {
+    sources = gypi_values.sources
+    defines = gypi_values.defines
+  }
+
+Sometimes your .gypi file will include paths relative to a different
+directory than the current .gn file. In this case, you can rebase them to
+be relative to the current directory.
+  sources = rebase_path(gypi_values.sources, ".",
+                        "//path/gypi/input/values/are/relative/to")
+
+This script will tolerate a 'variables' in the toplevel dictionary or not. If
+the toplevel dictionary just contains one item called 'variables', it will be
+collapsed away and the result will be the contents of that dictinoary. Some
+.gypi files are written with or without this, depending on how they expect to
+be embedded into a .gyp file.
+
+This script also has the ability to replace certain substrings in the input.
+Generally this is used to emulate GYP variable expansion. If you passed the
+argument "--replace=<(foo)=bar" then all instances of "<(foo)" in strings in
+the input will be replaced with "bar":
+
+  gypi_values = exec_script("//build/gypi_to_gn.py",
+                            [ rebase_path("your_file.gypi"),
+                              "--replace=<(foo)=bar"],
+                            "scope",
+                            [ "your_file.gypi" ])
+
+"""
+
+import gn_helpers
+from optparse import OptionParser
+import sys
+
+def LoadPythonDictionary(path):
+  file_string = open(path).read()
+  try:
+    file_data = eval(file_string, {'__builtins__': None}, None)
+  except SyntaxError, e:
+    e.filename = path
+    raise
+  except Exception, e:
+    raise Exception("Unexpected error while reading %s: %s" % (path, str(e)))
+
+  assert isinstance(file_data, dict), "%s does not eval to a dictionary" % path
+
+  # Flatten any variables to the top level.
+  if 'variables' in file_data:
+    file_data.update(file_data['variables'])
+    del file_data['variables']
+
+  # Strip any conditions.
+  if 'conditions' in file_data:
+    del file_data['conditions']
+  if 'target_conditions' in file_data:
+    del file_data['target_conditions']
+
+  # Strip targets in the toplevel, since some files define these and we can't
+  # slurp them in.
+  if 'targets' in file_data:
+    del file_data['targets']
+
+  return file_data
+
+
+def ReplaceSubstrings(values, search_for, replace_with):
+  """Recursively replaces substrings in a value.
+
+  Replaces all substrings of the "search_for" with "repace_with" for all
+  strings occurring in "values". This is done by recursively iterating into
+  lists as well as the keys and values of dictionaries."""
+  if isinstance(values, str):
+    return values.replace(search_for, replace_with)
+
+  if isinstance(values, list):
+    return [ReplaceSubstrings(v, search_for, replace_with) for v in values]
+
+  if isinstance(values, dict):
+    # For dictionaries, do the search for both the key and values.
+    result = {}
+    for key, value in values.items():
+      new_key = ReplaceSubstrings(key, search_for, replace_with)
+      new_value = ReplaceSubstrings(value, search_for, replace_with)
+      result[new_key] = new_value
+    return result
+
+  # Assume everything else is unchanged.
+  return values
+
+def main():
+  parser = OptionParser()
+  parser.add_option("-r", "--replace", action="append",
+    help="Replaces substrings. If passed a=b, replaces all substrs a with b.")
+  (options, args) = parser.parse_args()
+
+  if len(args) != 1:
+    raise Exception("Need one argument which is the .gypi file to read.")
+
+  data = LoadPythonDictionary(args[0])
+  if options.replace:
+    # Do replacements for all specified patterns.
+    for replace in options.replace:
+      split = replace.split('=')
+      # Allow "foo=" to replace with nothing.
+      if len(split) == 1:
+        split.append('')
+      assert len(split) == 2, "Replacement must be of the form 'key=value'."
+      data = ReplaceSubstrings(data, split[0], split[1])
+
+  # Sometimes .gypi files use the GYP syntax with percents at the end of the
+  # variable name (to indicate not to overwrite a previously-defined value):
+  #   'foo%': 'bar',
+  # Convert these to regular variables.
+  for key in data:
+    if len(key) > 1 and key[len(key) - 1] == '%':
+      data[key[:-1]] = data[key]
+      del data[key]
+
+  print gn_helpers.ToGNString(data)
+
+if __name__ == '__main__':
+  try:
+    main()
+  except Exception, e:
+    print str(e)
+    sys.exit(1)
diff --git a/build/linux/bin/eu-strip b/build/linux/bin/eu-strip
new file mode 100755
index 0000000..7f93eec
--- /dev/null
+++ b/build/linux/bin/eu-strip
Binary files differ
diff --git a/build/linux/bin/eu-strip.sha1 b/build/linux/bin/eu-strip.sha1
new file mode 100644
index 0000000..43f290a
--- /dev/null
+++ b/build/linux/bin/eu-strip.sha1
@@ -0,0 +1 @@
+0a9b8f68615ce388b65201e6d22da7a9cf2e729c
\ No newline at end of file
diff --git a/build/linux/chrome_linux.croc b/build/linux/chrome_linux.croc
new file mode 100644
index 0000000..f400306
--- /dev/null
+++ b/build/linux/chrome_linux.croc
@@ -0,0 +1,29 @@
+# -*- python -*-
+# Crocodile config file for Chromium linux
+
+# TODO(jhawkins): We'll need to add a chromeos.croc once we get a coverage bot
+# for that platform.
+
+{
+  # List of rules, applied in order
+  'rules' : [
+    # Specify inclusions before exclusions, since rules are in order.
+
+    # Don't include non-Linux platform dirs
+    {
+      'regexp' : '.*/(chromeos|views)/',
+      'include' : 0,
+    },
+    # Don't include chromeos, windows, or mac specific files
+    {
+      'regexp' : '.*(_|/)(chromeos|mac|win|views)(\\.|_)',
+      'include' : 0,
+    },
+
+    # Groups
+    {
+      'regexp' : '.*_test_linux\\.',
+      'group' : 'test',
+    },
+  ],
+}
diff --git a/build/linux/dump_app_syms b/build/linux/dump_app_syms
new file mode 100755
index 0000000..cbeb676
--- /dev/null
+++ b/build/linux/dump_app_syms
@@ -0,0 +1,36 @@
+#!/bin/sh
+
+# Copyright (c) 2010 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+#
+# Helper script to run dump_syms on Chrome Linux executables and strip
+# them if needed.
+
+set -e
+
+usage() {
+  echo -n "$0 <dump_syms_exe> <strip_binary> " >&2
+  echo "<binary_with_symbols> <symbols_output>" >&2
+}
+
+
+if [ $# -ne 4 ]; then
+  usage
+  exit 1
+fi
+
+SCRIPTDIR="$(readlink -f "$(dirname "$0")")"
+DUMPSYMS="$1"
+STRIP_BINARY="$2"
+INFILE="$3"
+OUTFILE="$4"
+
+# Dump the symbols from the given binary.
+if [ ! -e "$OUTFILE" -o "$INFILE" -nt "$OUTFILE" ]; then
+  "$DUMPSYMS" -r "$INFILE" > "$OUTFILE"
+fi
+
+if [ "$STRIP_BINARY" != "0" ]; then
+  strip "$INFILE"
+fi
diff --git a/build/linux/install-arm-sysroot.py b/build/linux/install-arm-sysroot.py
new file mode 100755
index 0000000..495fc75
--- /dev/null
+++ b/build/linux/install-arm-sysroot.py
@@ -0,0 +1,12 @@
+#!/usr/bin/env python
+# Copyright (c) 2012 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import sys
+
+msg = '''\
+ERROR: This script has merged with install-debian.wheezy.sysroot.py.
+Please use that instead (with --arch=arm).
+'''
+sys.stderr.write(msg)
diff --git a/build/linux/install-chromeos-fonts.py b/build/linux/install-chromeos-fonts.py
new file mode 100755
index 0000000..a24adc9
--- /dev/null
+++ b/build/linux/install-chromeos-fonts.py
@@ -0,0 +1,73 @@
+#!/usr/bin/env python
+# Copyright 2013 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# Script to install the Chrome OS fonts on Linux.
+# This script can be run manually (as root), but is also run as part
+# install-build-deps.sh.
+
+import os
+import shutil
+import subprocess
+import sys
+
+# Taken from the media-fonts/notofonts ebuild in chromiumos-overlay.
+VERSION = '20140815'
+URL = ('https://commondatastorage.googleapis.com/chromeos-localmirror/'
+       'distfiles/notofonts-%s.tar.bz2') % (VERSION)
+FONTS_DIR = '/usr/local/share/fonts'
+
+def main(args):
+  if not sys.platform.startswith('linux'):
+    print "Error: %s must be run on Linux." % __file__
+    return 1
+
+  if os.getuid() != 0:
+    print "Error: %s must be run as root." % __file__
+    return 1
+
+  if not os.path.isdir(FONTS_DIR):
+    print "Error: Destination directory does not exist: %s" % FONTS_DIR
+    return 1
+
+  dest_dir = os.path.join(FONTS_DIR, 'chromeos')
+
+  stamp = os.path.join(dest_dir, ".stamp02")
+  if os.path.exists(stamp):
+    with open(stamp) as s:
+      if s.read() == URL:
+        print "Chrome OS fonts already up-to-date in %s." % dest_dir
+        return 0
+
+  if os.path.isdir(dest_dir):
+    shutil.rmtree(dest_dir)
+  os.mkdir(dest_dir)
+  os.chmod(dest_dir, 0755)
+
+  print "Installing Chrome OS fonts to %s." % dest_dir
+  tarball = os.path.join(dest_dir, os.path.basename(URL))
+  subprocess.check_call(['curl', '-L', URL, '-o', tarball])
+  subprocess.check_call(['tar', '--no-same-owner', '--no-same-permissions',
+                         '-xf', tarball, '-C', dest_dir])
+  os.remove(tarball)
+
+  readme = os.path.join(dest_dir, "README")
+  with open(readme, 'w') as s:
+    s.write("This directory and its contents are auto-generated.\n")
+    s.write("It may be deleted and recreated. Do not modify.\n")
+    s.write("Script: %s\n" % __file__)
+
+  with open(stamp, 'w') as s:
+    s.write(URL)
+
+  for base, dirs, files in os.walk(dest_dir):
+    for dir in dirs:
+      os.chmod(os.path.join(base, dir), 0755)
+    for file in files:
+      os.chmod(os.path.join(base, file), 0644)
+
+  return 0
+
+if __name__ == '__main__':
+  sys.exit(main(sys.argv[1:]))
diff --git a/build/linux/pkg-config-wrapper b/build/linux/pkg-config-wrapper
new file mode 100755
index 0000000..b759564
--- /dev/null
+++ b/build/linux/pkg-config-wrapper
@@ -0,0 +1,59 @@
+#!/bin/bash
+# Copyright (c) 2012 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# This program wraps around pkg-config to generate the correct include and
+# library paths when cross-compiling using a sysroot.
+# The assumption is that the sysroot contains the .pc files in usr/lib/pkgconfig
+# and usr/share/pkgconfig (relative to the sysroot) and that they output paths
+# relative to some parent path of the sysroot.
+# This assumption is valid for a range of sysroots, in particular: a
+# LSB-compliant root filesystem mounted at the sysroot, and a board build
+# directory of a Chromium OS chroot.
+# Additional directories containing .pc files may be specified by setting
+# the PKG_CONFIG_PATH environment variable- these will be prepended to the
+# generated paths.
+
+root="$1"
+shift
+target_arch="$1"
+shift
+libpath="$1"
+shift
+
+if [ -z "$root" -o -z "$target_arch" ]
+then
+  echo "usage: $0 /path/to/sysroot target_arch libdir [pkg-config-arguments] package" >&2
+  exit 1
+fi
+
+if [ "$target_arch" = "x64" ]
+then
+  : ${libpath:="lib64"}
+else
+  : ${libpath:="lib"}
+fi
+
+rewrite=`dirname $0`/rewrite_dirs.py
+package=${!#}
+
+config_path=$root/usr/$libpath/pkgconfig:$root/usr/share/pkgconfig
+
+# prepend any paths specified by the environment
+if [ -n "$PKG_CONFIG_PATH" ]
+then
+  config_path="$PKG_CONFIG_PATH:$config_path"
+fi
+
+set -e
+# Some sysroots, like the Chromium OS ones, may generate paths that are not
+# relative to the sysroot. For example,
+# /path/to/chroot/build/x86-generic/usr/lib/pkgconfig/pkg.pc may have all paths
+# relative to /path/to/chroot (i.e. prefix=/build/x86-generic/usr) instead of
+# relative to /path/to/chroot/build/x86-generic (i.e prefix=/usr).
+# To support this correctly, it's necessary to extract the prefix to strip from
+# pkg-config's |prefix| variable.
+prefix=`PKG_CONFIG_PATH=$config_path pkg-config --variable=prefix "$package" | sed -e 's|/usr$||'`
+result=`PKG_CONFIG_PATH=$config_path pkg-config "$@"`
+echo "$result"| $rewrite --sysroot "$root" --strip-prefix "$prefix"
diff --git a/build/linux/rewrite_dirs.py b/build/linux/rewrite_dirs.py
new file mode 100755
index 0000000..30f22f0
--- /dev/null
+++ b/build/linux/rewrite_dirs.py
@@ -0,0 +1,71 @@
+#!/usr/bin/env python
+# Copyright (c) 2011 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Rewrites paths in -I, -L and other option to be relative to a sysroot."""
+
+import sys
+import os
+import optparse
+
+REWRITE_PREFIX = ['-I',
+                  '-idirafter',
+                  '-imacros',
+                  '-imultilib',
+                  '-include',
+                  '-iprefix',
+                  '-iquote',
+                  '-isystem',
+                  '-L']
+
+def RewritePath(path, opts):
+  """Rewrites a path by stripping the prefix and prepending the sysroot."""
+  sysroot = opts.sysroot
+  prefix = opts.strip_prefix
+  if os.path.isabs(path) and not path.startswith(sysroot):
+    if path.startswith(prefix):
+      path = path[len(prefix):]
+    path = path.lstrip('/')
+    return os.path.join(sysroot, path)
+  else:
+    return path
+
+
+def RewriteLine(line, opts):
+  """Rewrites all the paths in recognized options."""
+  args = line.split()
+  count = len(args)
+  i = 0
+  while i < count:
+    for prefix in REWRITE_PREFIX:
+      # The option can be either in the form "-I /path/to/dir" or
+      # "-I/path/to/dir" so handle both.
+      if args[i] == prefix:
+        i += 1
+        try:
+          args[i] = RewritePath(args[i], opts)
+        except IndexError:
+          sys.stderr.write('Missing argument following %s\n' % prefix)
+          break
+      elif args[i].startswith(prefix):
+        args[i] = prefix + RewritePath(args[i][len(prefix):], opts)
+    i += 1
+
+  return ' '.join(args)
+
+
+def main(argv):
+  parser = optparse.OptionParser()
+  parser.add_option('-s', '--sysroot', default='/', help='sysroot to prepend')
+  parser.add_option('-p', '--strip-prefix', default='', help='prefix to strip')
+  opts, args = parser.parse_args(argv[1:])
+
+  for line in sys.stdin.readlines():
+    line = RewriteLine(line.strip(), opts)
+    print line
+  return 0
+
+
+if __name__ == '__main__':
+  sys.exit(main(sys.argv))
diff --git a/build/linux/sysroot_ld_path.sh b/build/linux/sysroot_ld_path.sh
new file mode 100755
index 0000000..4b8bf73
--- /dev/null
+++ b/build/linux/sysroot_ld_path.sh
@@ -0,0 +1,100 @@
+#!/bin/sh
+# Copyright (c) 2013 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# Reads etc/ld.so.conf and/or etc/ld.so.conf.d/*.conf and returns the
+# appropriate linker flags.
+#
+#  sysroot_ld_path.sh /abspath/to/sysroot
+#
+
+log_error_and_exit() {
+  echo $0: $@
+  exit 1
+}
+
+process_entry() {
+  if [ -z "$1" ] || [ -z "$2" ]; then
+    log_error_and_exit "bad arguments to process_entry()"
+  fi
+  local root="$1"
+  local localpath="$2"
+
+  echo $localpath | grep -qs '^/'
+  if [ $? -ne 0 ]; then
+    log_error_and_exit $localpath does not start with /
+  fi
+  local entry="$root$localpath"
+  echo -L$entry
+  echo -Wl,-rpath-link=$entry
+}
+
+process_ld_so_conf() {
+  if [ -z "$1" ] || [ -z "$2" ]; then
+    log_error_and_exit "bad arguments to process_ld_so_conf()"
+  fi
+  local root="$1"
+  local ld_so_conf="$2"
+
+  # ld.so.conf may include relative include paths. pushd is a bashism.
+  local saved_pwd=$(pwd)
+  cd $(dirname "$ld_so_conf")
+
+  cat "$ld_so_conf" | \
+    while read ENTRY; do
+      echo "$ENTRY" | grep -qs ^include
+      if [ $? -eq 0 ]; then
+        local included_files=$(echo "$ENTRY" | sed 's/^include //')
+        echo "$included_files" | grep -qs ^/
+        if [ $? -eq 0 ]; then
+          if ls $root$included_files >/dev/null 2>&1 ; then
+            for inc_file in $root$included_files; do
+              process_ld_so_conf "$root" "$inc_file"
+            done
+          fi
+        else
+          if ls $(pwd)/$included_files >/dev/null 2>&1 ; then
+            for inc_file in $(pwd)/$included_files; do
+              process_ld_so_conf "$root" "$inc_file"
+            done
+          fi
+        fi
+        continue
+      fi
+
+      echo "$ENTRY" | grep -qs ^/
+      if [ $? -eq 0 ]; then
+        process_entry "$root" "$ENTRY"
+      fi
+    done
+
+  # popd is a bashism
+  cd "$saved_pwd"
+}
+
+# Main
+
+if [ $# -ne 1 ]; then
+  echo Usage $0 /abspath/to/sysroot
+  exit 1
+fi
+
+echo $1 | grep -qs ' '
+if [ $? -eq 0 ]; then
+  log_error_and_exit $1 contains whitespace.
+fi
+
+LD_SO_CONF="$1/etc/ld.so.conf"
+LD_SO_CONF_D="$1/etc/ld.so.conf.d"
+
+if [ -e "$LD_SO_CONF" ]; then
+  process_ld_so_conf "$1" "$LD_SO_CONF" | xargs echo
+elif [ -e "$LD_SO_CONF_D" ]; then
+  find "$LD_SO_CONF_D" -maxdepth 1 -name '*.conf' -print -quit > /dev/null
+  if [ $? -eq 0 ]; then
+    for entry in $LD_SO_CONF_D/*.conf; do
+      process_ld_so_conf "$1" "$entry"
+    done | xargs echo
+  fi
+fi
diff --git a/build/linux/system.gyp b/build/linux/system.gyp
new file mode 100644
index 0000000..5333798
--- /dev/null
+++ b/build/linux/system.gyp
@@ -0,0 +1,1221 @@
+# Copyright (c) 2012 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+{
+  'variables': {
+    'conditions': [
+      ['sysroot!=""', {
+        'pkg-config': '<(chroot_cmd) ./pkg-config-wrapper "<(sysroot)" "<(target_arch)" "<(system_libdir)"',
+      }, {
+        'pkg-config': 'pkg-config',
+      }],
+    ],
+
+    # If any of the linux_link_FOO below are set to 1, then the corresponding
+    # target will be linked against the FOO library (either dynamically or
+    # statically, depending on the pkg-config files), as opposed to loading the
+    # FOO library dynamically with dlopen.
+    'linux_link_libgps%': 0,
+    'linux_link_libpci%': 0,
+    'linux_link_libspeechd%': 0,
+    'linux_link_libbrlapi%': 0,
+
+    # Used below for the various libraries. In this scope for sharing with GN.
+    'libbrlapi_functions': [
+      'brlapi_getHandleSize',
+      'brlapi_error_location',
+      'brlapi_strerror',
+      'brlapi__acceptKeys',
+      'brlapi__openConnection',
+      'brlapi__closeConnection',
+      'brlapi__getDisplaySize',
+      'brlapi__enterTtyModeWithPath',
+      'brlapi__leaveTtyMode',
+      'brlapi__writeDots',
+      'brlapi__readKey',
+    ],
+    'libgio_functions': [
+      'g_settings_new',
+      'g_settings_get_child',
+      'g_settings_get_string',
+      'g_settings_get_boolean',
+      'g_settings_get_int',
+      'g_settings_get_strv',
+      'g_settings_list_schemas',
+    ],
+    'libpci_functions': [
+      'pci_alloc',
+      'pci_init',
+      'pci_cleanup',
+      'pci_scan_bus',
+      'pci_fill_info',
+      'pci_lookup_name',
+    ],
+    'libudev_functions': [
+      'udev_device_get_action',
+      'udev_device_get_devnode',
+      'udev_device_get_parent',
+      'udev_device_get_parent_with_subsystem_devtype',
+      'udev_device_get_property_value',
+      'udev_device_get_subsystem',
+      'udev_device_get_sysattr_value',
+      'udev_device_get_sysname',
+      'udev_device_get_syspath',
+      'udev_device_new_from_devnum',
+      'udev_device_new_from_subsystem_sysname',
+      'udev_device_new_from_syspath',
+      'udev_device_unref',
+      'udev_enumerate_add_match_subsystem',
+      'udev_enumerate_get_list_entry',
+      'udev_enumerate_new',
+      'udev_enumerate_scan_devices',
+      'udev_enumerate_unref',
+      'udev_list_entry_get_next',
+      'udev_list_entry_get_name',
+      'udev_monitor_enable_receiving',
+      'udev_monitor_filter_add_match_subsystem_devtype',
+      'udev_monitor_get_fd',
+      'udev_monitor_new_from_netlink',
+      'udev_monitor_receive_device',
+      'udev_monitor_unref',
+      'udev_new',
+      'udev_set_log_fn',
+      'udev_set_log_priority',
+      'udev_unref',
+    ],
+  },
+  'conditions': [
+    [ 'chromeos==0 and use_ozone==0', {
+      # Hide GTK and related dependencies for Chrome OS and Ozone, so they won't get
+      # added back to Chrome OS and Ozone. Don't try to use GTK on Chrome OS and Ozone.
+      'targets': [
+        {
+          'target_name': 'atk',
+          'type': 'none',
+          'conditions': [
+            ['_toolset=="target"', {
+              'direct_dependent_settings': {
+                'cflags': [
+                  '<!@(<(pkg-config) --cflags atk)',
+                ],
+                'defines': [
+                  'ATK_LIB_DIR="<!@(<(pkg-config) --variable=libdir atk)"',
+                ],
+              },
+              'link_settings': {
+                'ldflags': [
+                  '<!@(<(pkg-config) --libs-only-L --libs-only-other atk)',
+                ],
+                'libraries': [
+                  '<!@(<(pkg-config) --libs-only-l atk)',
+                ],
+              },
+            }],
+          ],
+        },
+        {
+          'target_name': 'gdk',
+          'type': 'none',
+          'conditions': [
+            ['_toolset=="target"', {
+              'direct_dependent_settings': {
+                'cflags': [
+                  '<!@(<(pkg-config) --cflags gdk-2.0)',
+                ],
+              },
+              'link_settings': {
+                'ldflags': [
+                  '<!@(<(pkg-config) --libs-only-L --libs-only-other gdk-2.0)',
+                ],
+                'libraries': [
+                  '<!@(<(pkg-config) --libs-only-l gdk-2.0)',
+                ],
+              },
+            }],
+          ],
+        },
+        {
+          'target_name': 'gtk',
+          'type': 'none',
+          'toolsets': ['host', 'target'],
+          'variables': {
+            # gtk requires gmodule, but it does not list it as a dependency
+            # in some misconfigured systems.
+            'gtk_packages': 'gmodule-2.0 gtk+-2.0 gthread-2.0',
+          },
+          'conditions': [
+            ['_toolset=="target"', {
+              'all_dependent_settings': {
+                'cflags': [
+                  '<!@(<(pkg-config) --cflags <(gtk_packages))',
+                ],
+              },
+              'link_settings': {
+                'ldflags': [
+                  '<!@(<(pkg-config) --libs-only-L --libs-only-other <(gtk_packages))',
+                ],
+                'libraries': [
+                  '<!@(<(pkg-config) --libs-only-l <(gtk_packages))',
+                ],
+              },
+            }, {
+              'all_dependent_settings': {
+                'cflags': [
+                  '<!@(pkg-config --cflags <(gtk_packages))',
+                ],
+              },
+              'link_settings': {
+                'ldflags': [
+                  '<!@(pkg-config --libs-only-L --libs-only-other <(gtk_packages))',
+                ],
+                'libraries': [
+                  '<!@(pkg-config --libs-only-l <(gtk_packages))',
+                ],
+              },
+            }],
+          ],
+        },
+        {
+          'target_name': 'gtkprint',
+          'type': 'none',
+          'conditions': [
+            ['_toolset=="target"', {
+              'direct_dependent_settings': {
+                'cflags': [
+                  '<!@(<(pkg-config) --cflags gtk+-unix-print-2.0)',
+                ],
+              },
+              'link_settings': {
+                'ldflags': [
+                  '<!@(<(pkg-config) --libs-only-L --libs-only-other gtk+-unix-print-2.0)',
+                ],
+                'libraries': [
+                  '<!@(<(pkg-config) --libs-only-l gtk+-unix-print-2.0)',
+                ],
+              },
+            }],
+          ],
+        },
+      ],  # targets
+    }],
+    [ 'use_x11==1 or ozone_platform_ozonex==1', {
+      # Hide X11 and related dependencies when use_x11=0
+      'targets': [
+        {
+          'target_name': 'x11',
+          'type': 'none',
+          'toolsets': ['host', 'target'],
+          'conditions': [
+            ['_toolset=="target"', {
+              'direct_dependent_settings': {
+                'cflags': [
+                  '<!@(<(pkg-config) --cflags x11)',
+                ],
+              },
+              'link_settings': {
+                'ldflags': [
+                  '<!@(<(pkg-config) --libs-only-L --libs-only-other x11 xi)',
+                ],
+                'libraries': [
+                  '<!@(<(pkg-config) --libs-only-l x11 xi)',
+                ],
+              },
+            }, {
+              'direct_dependent_settings': {
+                'cflags': [
+                  '<!@(pkg-config --cflags x11)',
+                ],
+              },
+              'link_settings': {
+                'ldflags': [
+                  '<!@(pkg-config --libs-only-L --libs-only-other x11 xi)',
+                ],
+                'libraries': [
+                  '<!@(pkg-config --libs-only-l x11 xi)',
+                ],
+              },
+            }],
+          ],
+        },
+        {
+          'target_name': 'xcursor',
+          'type': 'none',
+          'direct_dependent_settings': {
+            'cflags': [
+              '<!@(<(pkg-config) --cflags xcursor)',
+            ],
+          },
+          'link_settings': {
+            'ldflags': [
+              '<!@(<(pkg-config) --libs-only-L --libs-only-other xcursor)',
+            ],
+            'libraries': [
+              '<!@(<(pkg-config) --libs-only-l xcursor)',
+            ],
+          },
+        },
+        {
+          'target_name': 'xcomposite',
+          'type': 'none',
+          'direct_dependent_settings': {
+            'cflags': [
+              '<!@(<(pkg-config) --cflags xcomposite)',
+            ],
+          },
+          'link_settings': {
+            'ldflags': [
+              '<!@(<(pkg-config) --libs-only-L --libs-only-other xcomposite)',
+            ],
+            'libraries': [
+              '<!@(<(pkg-config) --libs-only-l xcomposite)',
+            ],
+          },
+        },
+        {
+          'target_name': 'xdamage',
+          'type': 'none',
+          'direct_dependent_settings': {
+            'cflags': [
+              '<!@(<(pkg-config) --cflags xdamage)',
+            ],
+          },
+          'link_settings': {
+            'ldflags': [
+              '<!@(<(pkg-config) --libs-only-L --libs-only-other xdamage)',
+            ],
+            'libraries': [
+              '<!@(<(pkg-config) --libs-only-l xdamage)',
+            ],
+          },
+        },
+        {
+          'target_name': 'xext',
+          'type': 'none',
+          'direct_dependent_settings': {
+            'cflags': [
+              '<!@(<(pkg-config) --cflags xext)',
+            ],
+          },
+          'link_settings': {
+            'ldflags': [
+              '<!@(<(pkg-config) --libs-only-L --libs-only-other xext)',
+            ],
+            'libraries': [
+              '<!@(<(pkg-config) --libs-only-l xext)',
+            ],
+          },
+        },
+        {
+          'target_name': 'xfixes',
+          'type': 'none',
+          'direct_dependent_settings': {
+            'cflags': [
+              '<!@(<(pkg-config) --cflags xfixes)',
+            ],
+          },
+          'link_settings': {
+            'ldflags': [
+              '<!@(<(pkg-config) --libs-only-L --libs-only-other xfixes)',
+            ],
+            'libraries': [
+              '<!@(<(pkg-config) --libs-only-l xfixes)',
+            ],
+          },
+        },
+        {
+          'target_name': 'xi',
+          'type': 'none',
+          'direct_dependent_settings': {
+            'cflags': [
+              '<!@(<(pkg-config) --cflags xi)',
+            ],
+          },
+          'link_settings': {
+            'ldflags': [
+              '<!@(<(pkg-config) --libs-only-L --libs-only-other xi)',
+            ],
+            'libraries': [
+              '<!@(<(pkg-config) --libs-only-l xi)',
+            ],
+          },
+        },
+        {
+          'target_name': 'xrandr',
+          'type': 'none',
+          'toolsets': ['host', 'target'],
+          'conditions': [
+            ['_toolset=="target"', {
+              'direct_dependent_settings': {
+                'cflags': [
+                  '<!@(<(pkg-config) --cflags xrandr)',
+                ],
+              },
+              'link_settings': {
+                'ldflags': [
+                  '<!@(<(pkg-config) --libs-only-L --libs-only-other xrandr)',
+                ],
+                'libraries': [
+                  '<!@(<(pkg-config) --libs-only-l xrandr)',
+                ],
+              },
+            }, {
+              'direct_dependent_settings': {
+                'cflags': [
+                  '<!@(pkg-config --cflags xrandr)',
+                ],
+              },
+              'link_settings': {
+                'ldflags': [
+                  '<!@(pkg-config --libs-only-L --libs-only-other xrandr)',
+                ],
+                'libraries': [
+                  '<!@(pkg-config --libs-only-l xrandr)',
+                ],
+              },
+            }],
+          ],
+        },
+        {
+          'target_name': 'xrender',
+          'type': 'none',
+          'direct_dependent_settings': {
+            'cflags': [
+              '<!@(<(pkg-config) --cflags xrender)',
+            ],
+          },
+          'link_settings': {
+            'ldflags': [
+              '<!@(<(pkg-config) --libs-only-L --libs-only-other xrender)',
+            ],
+            'libraries': [
+              '<!@(<(pkg-config) --libs-only-l xrender)',
+            ],
+          },
+        },
+        {
+          'target_name': 'xtst',
+          'type': 'none',
+          'toolsets': ['host', 'target'],
+          'conditions': [
+            ['_toolset=="target"', {
+              'direct_dependent_settings': {
+                'cflags': [
+                  '<!@(<(pkg-config) --cflags xtst)',
+                ],
+              },
+              'link_settings': {
+                'ldflags': [
+                  '<!@(<(pkg-config) --libs-only-L --libs-only-other xtst)',
+                ],
+                'libraries': [
+                  '<!@(<(pkg-config) --libs-only-l xtst)',
+                ],
+              },
+            }, {
+              'direct_dependent_settings': {
+                'cflags': [
+                  '<!@(pkg-config --cflags xtst)',
+                ],
+              },
+              'link_settings': {
+                'ldflags': [
+                  '<!@(pkg-config --libs-only-L --libs-only-other xtst)',
+                ],
+                'libraries': [
+                  '<!@(pkg-config --libs-only-l xtst)',
+                ],
+              },
+            }]
+          ]
+        }
+      ],  # targets
+    }],
+    ['use_x11==1 and chromeos==0', {
+      'targets': [
+        {
+          'target_name': 'xscrnsaver',
+          'type': 'none',
+          'direct_dependent_settings': {
+            'cflags': [
+              '<!@(<(pkg-config) --cflags xscrnsaver)',
+            ],
+          },
+          'link_settings': {
+            'ldflags': [
+              '<!@(<(pkg-config) --libs-only-L --libs-only-other xscrnsaver)',
+            ],
+            'libraries': [
+              '<!@(<(pkg-config) --libs-only-l xscrnsaver)',
+            ],
+          },
+        },
+      ],  # targets
+    }],
+    ['use_evdev_gestures==1', {
+      'targets': [
+        {
+          'target_name': 'libevdev-cros',
+          'type': 'none',
+          'direct_dependent_settings': {
+            'cflags': [
+              '<!@(<(pkg-config) --cflags libevdev-cros)'
+            ],
+          },
+          'link_settings': {
+            'ldflags': [
+              '<!@(<(pkg-config) --libs-only-L --libs-only-other libevdev-cros)',
+            ],
+            'libraries': [
+              '<!@(<(pkg-config) --libs-only-l libevdev-cros)',
+            ],
+          },
+        },
+        {
+          'target_name': 'libgestures',
+          'type': 'none',
+          'direct_dependent_settings': {
+            'cflags': [
+              '<!@(<(pkg-config) --cflags libgestures)'
+            ],
+          },
+          'link_settings': {
+            'ldflags': [
+              '<!@(<(pkg-config) --libs-only-L --libs-only-other libgestures)',
+            ],
+            'libraries': [
+              '<!@(<(pkg-config) --libs-only-l libgestures)',
+            ],
+          },
+        },
+      ],
+    }],
+    ['use_xkbcommon==1', {
+      'targets': [
+        {
+          'target_name': 'xkbcommon',
+          'type': 'none',
+          'direct_dependent_settings': {
+            'cflags': [
+              '<!@(<(pkg-config) --cflags xkbcommon)'
+            ],
+          },
+          'link_settings': {
+            'ldflags': [
+              '<!@(<(pkg-config) --libs-only-L --libs-only-other xkbcommon)',
+            ],
+            'libraries': [
+              '<!@(<(pkg-config) --libs-only-l xkbcommon)',
+            ],
+          },
+        },
+      ],
+    }],
+    ['ozone_platform_gbm==1', {
+      'targets': [
+        {
+          'target_name': 'gbm',
+          'type': 'none',
+          'direct_dependent_settings': {
+            'cflags': [
+              '<!@(<(pkg-config) --cflags gbm)',
+            ],
+          },
+          'link_settings': {
+            'ldflags': [
+              '<!@(<(pkg-config) --libs-only-L --libs-only-other gbm)',
+            ],
+            'libraries': [
+              '<!@(<(pkg-config) --libs-only-l gbm)',
+            ],
+          },
+        },
+      ],
+    }],
+    ['ozone_platform_dri==1 or ozone_platform_drm==1 or ozone_platform_gbm==1', {
+      'targets': [
+        {
+          'target_name': 'libdrm',
+          'type': 'none',
+          'direct_dependent_settings': {
+            'cflags': [
+              '<!@(<(pkg-config) --cflags libdrm)',
+            ],
+          },
+          'link_settings': {
+            'libraries': [
+              '<!@(<(pkg-config) --libs-only-l libdrm)',
+            ],
+          },
+        },
+      ],
+    }],
+    ['use_udev==1', {
+      'targets': [
+        {
+          'target_name': 'udev',
+          'type': 'static_library',
+          'conditions': [
+            ['_toolset=="target"', {
+              'include_dirs': [
+                '../..',
+              ],
+              'hard_dependency': 1,
+              'actions': [
+                {
+                  'variables': {
+                    'output_h': '<(SHARED_INTERMEDIATE_DIR)/library_loaders/libudev0.h',
+                    'output_cc': '<(INTERMEDIATE_DIR)/libudev0_loader.cc',
+                    'generator': '../../tools/generate_library_loader/generate_library_loader.py',
+                  },
+                  'action_name': 'generate_libudev0_loader',
+                  'inputs': [
+                    '<(generator)',
+                  ],
+                  'outputs': [
+                    '<(output_h)',
+                    '<(output_cc)',
+                  ],
+                  'action': ['python',
+                             '<(generator)',
+                             '--name', 'LibUdev0Loader',
+                             '--output-h', '<(output_h)',
+                             '--output-cc', '<(output_cc)',
+                             '--header', '"third_party/libudev/libudev0.h"',
+                             '--link-directly=0',
+                             '<@(libudev_functions)',
+                  ],
+                  'message': 'Generating libudev0 library loader',
+                  'process_outputs_as_sources': 1,
+                },
+                {
+                  'variables': {
+                    'output_h': '<(SHARED_INTERMEDIATE_DIR)/library_loaders/libudev1.h',
+                    'output_cc': '<(INTERMEDIATE_DIR)/libudev1_loader.cc',
+                    'generator': '../../tools/generate_library_loader/generate_library_loader.py',
+                  },
+                  'action_name': 'generate_libudev1_loader',
+                  'inputs': [
+                    '<(generator)',
+                  ],
+                  'outputs': [
+                    '<(output_h)',
+                    '<(output_cc)',
+                  ],
+                  'action': ['python',
+                             '<(generator)',
+                             '--name', 'LibUdev1Loader',
+                             '--output-h', '<(output_h)',
+                             '--output-cc', '<(output_cc)',
+                             '--header', '"third_party/libudev/libudev1.h"',
+                             '--link-directly=0',
+                             '<@(libudev_functions)',
+                  ],
+                  'message': 'Generating libudev1 library loader',
+                  'process_outputs_as_sources': 1,
+                },
+              ],
+            }],
+          ],
+        },
+      ],
+    }],
+    ['use_libpci==1', {
+      'targets': [
+        {
+          'target_name': 'libpci',
+          'type': 'static_library',
+          'cflags': [
+            '<!@(<(pkg-config) --cflags libpci)',
+          ],
+          'direct_dependent_settings': {
+            'include_dirs': [
+              '<(SHARED_INTERMEDIATE_DIR)',
+            ],
+            'conditions': [
+              ['linux_link_libpci==1', {
+                'link_settings': {
+                  'ldflags': [
+                    '<!@(<(pkg-config) --libs-only-L --libs-only-other libpci)',
+                  ],
+                  'libraries': [
+                    '<!@(<(pkg-config) --libs-only-l libpci)',
+                  ],
+                }
+              }],
+            ],
+          },
+          'include_dirs': [
+            '../..',
+          ],
+          'hard_dependency': 1,
+          'actions': [
+            {
+              'variables': {
+                'output_h': '<(SHARED_INTERMEDIATE_DIR)/library_loaders/libpci.h',
+                'output_cc': '<(INTERMEDIATE_DIR)/libpci_loader.cc',
+                'generator': '../../tools/generate_library_loader/generate_library_loader.py',
+              },
+              'action_name': 'generate_libpci_loader',
+              'inputs': [
+                '<(generator)',
+              ],
+              'outputs': [
+                '<(output_h)',
+                '<(output_cc)',
+              ],
+              'action': ['python',
+                         '<(generator)',
+                         '--name', 'LibPciLoader',
+                         '--output-h', '<(output_h)',
+                         '--output-cc', '<(output_cc)',
+                         '--header', '<pci/pci.h>',
+                         # TODO(phajdan.jr): Report problem to pciutils project
+                         # and get it fixed so that we don't need --use-extern-c.
+                         '--use-extern-c',
+                         '--link-directly=<(linux_link_libpci)',
+                         '<@(libpci_functions)',
+              ],
+              'message': 'Generating libpci library loader',
+              'process_outputs_as_sources': 1,
+            },
+          ],
+        },
+      ],
+    }],
+  ],  # conditions
+  'targets': [
+    {
+      'target_name': 'dbus',
+      'type': 'none',
+      'direct_dependent_settings': {
+        'cflags': [
+          '<!@(<(pkg-config) --cflags dbus-1)',
+        ],
+      },
+      'link_settings': {
+        'ldflags': [
+          '<!@(<(pkg-config) --libs-only-L --libs-only-other dbus-1)',
+        ],
+        'libraries': [
+          '<!@(<(pkg-config) --libs-only-l dbus-1)',
+        ],
+      },
+    },
+    {
+      'target_name': 'fontconfig',
+      'type': 'none',
+      'conditions': [
+        ['_toolset=="target"', {
+          'conditions': [
+            ['use_system_fontconfig==1', {
+              'direct_dependent_settings': {
+                'cflags': [
+                  '<!@(<(pkg-config) --cflags fontconfig)',
+                ],
+              },
+              'link_settings': {
+                'ldflags': [
+                  '<!@(<(pkg-config) --libs-only-L --libs-only-other fontconfig)',
+                ],
+                'libraries': [
+                  '<!@(<(pkg-config) --libs-only-l fontconfig)',
+                ],
+              },
+            }, {  # use_system_fontconfig==0
+              'dependencies': [
+                '../../third_party/fontconfig/fontconfig.gyp:fontconfig',
+              ],
+              'export_dependent_settings' : [
+                '../../third_party/fontconfig/fontconfig.gyp:fontconfig',
+              ],
+            }],
+          ],
+        }],
+      ],
+    },
+    {
+      'target_name': 'freetype2',
+      'type': 'none',
+      'conditions': [
+        ['_toolset=="target"', {
+          'direct_dependent_settings': {
+            'cflags': [
+              '<!@(<(pkg-config) --cflags freetype2)',
+            ],
+          },
+          'link_settings': {
+            'ldflags': [
+              '<!@(<(pkg-config) --libs-only-L --libs-only-other freetype2)',
+            ],
+            'libraries': [
+              '<!@(<(pkg-config) --libs-only-l freetype2)',
+            ],
+          },
+        }],
+      ],
+    },
+    {
+      'target_name': 'gconf',
+      'type': 'none',
+      'conditions': [
+        ['use_gconf==1 and _toolset=="target"', {
+          'direct_dependent_settings': {
+            'cflags': [
+              '<!@(<(pkg-config) --cflags gconf-2.0)',
+            ],
+            'defines': [
+              'USE_GCONF',
+            ],
+          },
+          'link_settings': {
+            'ldflags': [
+              '<!@(<(pkg-config) --libs-only-L --libs-only-other gconf-2.0)',
+            ],
+            'libraries': [
+              '<!@(<(pkg-config) --libs-only-l gconf-2.0)',
+            ],
+          },
+        }],
+      ],
+    },
+    {
+      'target_name': 'gio',
+      'type': 'static_library',
+      'conditions': [
+        ['use_gio==1 and _toolset=="target"', {
+          'cflags': [
+            '<!@(<(pkg-config) --cflags gio-2.0)',
+          ],
+          'variables': {
+            'gio_warning_define': [
+              # glib >=2.40 deprecate g_settings_list_schemas in favor of
+              # g_settings_schema_source_list_schemas. This function is not
+              # available on earlier versions that we still need to support
+              # (specifically, 2.32), so disable the warning.
+              # TODO(mgiuca): Remove this suppression (and variable) when we
+              # drop support for Ubuntu 13.10 (saucy) and earlier. Update the
+              # code to use g_settings_schema_source_list_schemas instead.
+              'GLIB_DISABLE_DEPRECATION_WARNINGS',
+            ],
+          },
+          'defines': [
+            '<(gio_warning_define)',
+          ],
+          'direct_dependent_settings': {
+            'cflags': [
+              '<!@(<(pkg-config) --cflags gio-2.0)',
+            ],
+            'defines': [
+              'USE_GIO',
+              '<(gio_warning_define)',
+            ],
+            'include_dirs': [
+              '<(SHARED_INTERMEDIATE_DIR)',
+            ],
+          },
+          'include_dirs': [
+            '../..',
+          ],
+          'link_settings': {
+            'ldflags': [
+              '<!@(<(pkg-config) --libs-only-L --libs-only-other gio-2.0)',
+            ],
+            'libraries': [
+              '<!@(<(pkg-config) --libs-only-l gio-2.0)',
+            ],
+            'conditions': [
+              ['linux_link_gsettings==0 and OS=="linux"', {
+                'libraries': [
+                  '-ldl',
+                ],
+              }],
+            ],
+          },
+          'hard_dependency': 1,
+          'actions': [
+            {
+              'variables': {
+                'output_h': '<(SHARED_INTERMEDIATE_DIR)/library_loaders/libgio.h',
+                'output_cc': '<(INTERMEDIATE_DIR)/libgio_loader.cc',
+                'generator': '../../tools/generate_library_loader/generate_library_loader.py',
+              },
+              'action_name': 'generate_libgio_loader',
+              'inputs': [
+                '<(generator)',
+              ],
+              'outputs': [
+                '<(output_h)',
+                '<(output_cc)',
+              ],
+              'action': ['python',
+                         '<(generator)',
+                         '--name', 'LibGioLoader',
+                         '--output-h', '<(output_h)',
+                         '--output-cc', '<(output_cc)',
+                         '--header', '<gio/gio.h>',
+                         '--link-directly=<(linux_link_gsettings)',
+                         '<@(libgio_functions)',
+              ],
+              'message': 'Generating libgio library loader',
+              'process_outputs_as_sources': 1,
+            },
+          ],
+        }],
+      ],
+    },
+    {
+      'target_name': 'glib',
+      'type': 'none',
+      'toolsets': ['host', 'target'],
+      'variables': {
+        'glib_packages': 'glib-2.0 gmodule-2.0 gobject-2.0 gthread-2.0',
+      },
+      'conditions': [
+        ['_toolset=="target"', {
+          'direct_dependent_settings': {
+            'cflags': [
+              '<!@(<(pkg-config) --cflags <(glib_packages))',
+            ],
+          },
+          'link_settings': {
+            'ldflags': [
+              '<!@(<(pkg-config) --libs-only-L --libs-only-other <(glib_packages))',
+            ],
+            'libraries': [
+              '<!@(<(pkg-config) --libs-only-l <(glib_packages))',
+            ],
+          },
+        }, {
+          'direct_dependent_settings': {
+            'cflags': [
+              '<!@(pkg-config --cflags <(glib_packages))',
+            ],
+          },
+          'link_settings': {
+            'ldflags': [
+              '<!@(pkg-config --libs-only-L --libs-only-other <(glib_packages))',
+            ],
+            'libraries': [
+              '<!@(pkg-config --libs-only-l <(glib_packages))',
+            ],
+          },
+        }],
+      ],
+    },
+    {
+      'target_name': 'gnome_keyring',
+      'type': 'none',
+      'conditions': [
+        ['use_gnome_keyring==1', {
+          'direct_dependent_settings': {
+            'cflags': [
+              '<!@(<(pkg-config) --cflags gnome-keyring-1)',
+            ],
+            'defines': [
+              'USE_GNOME_KEYRING',
+            ],
+            'conditions': [
+              ['linux_link_gnome_keyring==0', {
+                'defines': ['DLOPEN_GNOME_KEYRING'],
+              }],
+            ],
+          },
+          'conditions': [
+            ['linux_link_gnome_keyring!=0', {
+              'link_settings': {
+                'ldflags': [
+                  '<!@(<(pkg-config) --libs-only-L --libs-only-other gnome-keyring-1)',
+                ],
+                'libraries': [
+                  '<!@(<(pkg-config) --libs-only-l gnome-keyring-1)',
+                ],
+              },
+            }, {
+              'conditions': [
+                ['OS=="linux"', {
+                 'link_settings': {
+                   'libraries': [
+                     '-ldl',
+                   ],
+                 },
+                }],
+              ],
+            }],
+          ],
+        }],
+      ],
+    },
+    {
+      # The unit tests use a few convenience functions from the GNOME
+      # Keyring library directly. We ignore linux_link_gnome_keyring and
+      # link directly in this version of the target to allow this.
+      # *** Do not use this target in the main binary! ***
+      'target_name': 'gnome_keyring_direct',
+      'type': 'none',
+      'conditions': [
+        ['use_gnome_keyring==1', {
+          'direct_dependent_settings': {
+            'cflags': [
+              '<!@(<(pkg-config) --cflags gnome-keyring-1)',
+            ],
+            'defines': [
+              'USE_GNOME_KEYRING',
+            ],
+            'conditions': [
+              ['linux_link_gnome_keyring==0', {
+                'defines': ['DLOPEN_GNOME_KEYRING'],
+              }],
+            ],
+          },
+          'link_settings': {
+            'ldflags': [
+              '<!@(<(pkg-config) --libs-only-L --libs-only-other gnome-keyring-1)',
+            ],
+            'libraries': [
+              '<!@(<(pkg-config) --libs-only-l gnome-keyring-1)',
+            ],
+          },
+        }],
+      ],
+    },
+    {
+      'target_name': 'libbrlapi',
+      'type': 'static_library',
+      'all_dependent_settings': {
+        'include_dirs': [
+          '<(SHARED_INTERMEDIATE_DIR)',
+        ],
+        'defines': [
+          'USE_BRLAPI',
+        ],
+        'conditions': [
+          ['linux_link_libbrlapi==1', {
+            'link_settings': {
+              'libraries': [
+                '-lbrlapi',
+              ],
+            }
+          }],
+        ],
+      },
+      'include_dirs': [
+        '../..',
+      ],
+      'hard_dependency': 1,
+      'actions': [
+        {
+          'variables': {
+            'output_h': '<(SHARED_INTERMEDIATE_DIR)/library_loaders/libbrlapi.h',
+            'output_cc': '<(INTERMEDIATE_DIR)/libbrlapi_loader.cc',
+            'generator': '../../tools/generate_library_loader/generate_library_loader.py',
+          },
+          'action_name': 'generate_brlapi_loader',
+          'inputs': [
+            '<(generator)',
+          ],
+          'outputs': [
+            '<(output_h)',
+            '<(output_cc)',
+          ],
+          'action': ['python',
+                     '<(generator)',
+                     '--name', 'LibBrlapiLoader',
+                     '--output-h', '<(output_h)',
+                     '--output-cc', '<(output_cc)',
+                     '--header', '<brlapi.h>',
+                     '--link-directly=<(linux_link_libbrlapi)',
+                     '<@(libbrlapi_functions)',
+          ],
+          'message': 'Generating libbrlapi library loader',
+          'process_outputs_as_sources': 1,
+        },
+      ],
+    },
+    {
+      'target_name': 'libcap',
+      'type': 'none',
+      'link_settings': {
+        'libraries': [
+          '-lcap',
+        ],
+      },
+    },
+    {
+      'target_name': 'libresolv',
+      'type': 'none',
+      'link_settings': {
+        'libraries': [
+          '-lresolv',
+        ],
+      },
+    },
+    {
+      # GN version: //third_party/speech-dispatcher
+      'target_name': 'libspeechd',
+      'type': 'static_library',
+      'direct_dependent_settings': {
+        'include_dirs': [
+          '<(SHARED_INTERMEDIATE_DIR)',
+        ],
+        'conditions': [
+          ['linux_link_libspeechd==1', {
+            'link_settings': {
+              'libraries': [
+                '-lspeechd',
+              ],
+            }
+          }],
+        ],
+      },
+      'include_dirs': [
+        '../..',
+      ],
+      'hard_dependency': 1,
+      'actions': [
+        {
+          'variables': {
+            'output_h': '<(SHARED_INTERMEDIATE_DIR)/library_loaders/libspeechd.h',
+            'output_cc': '<(INTERMEDIATE_DIR)/libspeechd_loader.cc',
+            'generator': '../../tools/generate_library_loader/generate_library_loader.py',
+
+            # speech-dispatcher >= 0.8 installs libspeechd.h into
+            # speech-dispatcher/libspeechd.h, whereas speech-dispatcher < 0.8
+            # puts libspeechd.h in the top-level include directory.
+            # Since we need to support both cases for now, we ship a copy of
+            # libspeechd.h in third_party/speech-dispatcher. If the user
+            # prefers to link against the speech-dispatcher directly, the
+            # `libspeechd_h_prefix' variable can be passed to gyp with a value
+            # such as "speech-dispatcher/" that will be prepended to
+            # "libspeechd.h" in the #include directive.
+            # TODO(phaldan.jr): Once we do not need to support
+            # speech-dispatcher < 0.8 we can get rid of all this (including
+            # third_party/speech-dispatcher) and just include
+            # speech-dispatcher/libspeechd.h unconditionally.
+            'libspeechd_h_prefix%': '',
+          },
+          'action_name': 'generate_libspeechd_loader',
+          'inputs': [
+            '<(generator)',
+          ],
+          'outputs': [
+            '<(output_h)',
+            '<(output_cc)',
+          ],
+          'action': ['python',
+                     '<(generator)',
+                     '--name', 'LibSpeechdLoader',
+                     '--output-h', '<(output_h)',
+                     '--output-cc', '<(output_cc)',
+                     '--header', '<<(libspeechd_h_prefix)libspeechd.h>',
+                     '--bundled-header',
+                     '"third_party/speech-dispatcher/libspeechd.h"',
+                     '--link-directly=<(linux_link_libspeechd)',
+                     'spd_open',
+                     'spd_say',
+                     'spd_stop',
+                     'spd_close',
+                     'spd_pause',
+                     'spd_resume',
+                     'spd_set_notification_on',
+                     'spd_set_voice_rate',
+                     'spd_set_voice_pitch',
+                     'spd_list_synthesis_voices',
+                     'spd_set_synthesis_voice',
+                     'spd_list_modules',
+                     'spd_set_output_module',
+          ],
+          'message': 'Generating libspeechd library loader',
+          'process_outputs_as_sources': 1,
+        },
+      ],
+    },
+    {
+      'target_name': 'pangocairo',
+      'type': 'none',
+      'toolsets': ['host', 'target'],
+      'conditions': [
+        ['use_pango==1 and use_cairo==1', {
+          'conditions': [
+            ['_toolset=="target"', {
+              'direct_dependent_settings': {
+                'cflags': [
+                  '<!@(<(pkg-config) --cflags pangocairo pangoft2)',
+                ],
+              },
+              'link_settings': {
+                'ldflags': [
+                  '<!@(<(pkg-config) --libs-only-L --libs-only-other pangocairo pangoft2)',
+                ],
+                'libraries': [
+                  '<!@(<(pkg-config) --libs-only-l pangocairo pangoft2)',
+                ],
+              },
+            }, {
+              'direct_dependent_settings': {
+                'cflags': [
+                  '<!@(pkg-config --cflags pangocairo pangoft2)',
+                ],
+              },
+              'link_settings': {
+                'ldflags': [
+                  '<!@(pkg-config --libs-only-L --libs-only-other pangocairo pangoft2)',
+                ],
+                'libraries': [
+                  '<!@(pkg-config --libs-only-l pangocairo pangoft2)',
+                ],
+              },
+            }],
+          ],
+        }],
+      ],
+    },
+    {
+      'target_name': 'ssl',
+      'type': 'none',
+      'conditions': [
+        ['_toolset=="target"', {
+          'conditions': [
+            ['use_openssl==1', {
+              'dependencies': [
+                '../../third_party/boringssl/boringssl.gyp:boringssl',
+              ],
+            }],
+            ['use_openssl==0', {
+              'dependencies': [
+                '../../net/third_party/nss/ssl.gyp:libssl',
+              ],
+              'direct_dependent_settings': {
+                'include_dirs+': [
+                  # We need for our local copies of the libssl3 headers to come
+                  # before other includes, as we are shadowing system headers.
+                  '<(DEPTH)/net/third_party/nss/ssl',
+                ],
+                'cflags': [
+                  '<!@(<(pkg-config) --cflags nss)',
+                ],
+              },
+              'link_settings': {
+                'ldflags': [
+                  '<!@(<(pkg-config) --libs-only-L --libs-only-other nss)',
+                ],
+                'libraries': [
+                  '<!@(<(pkg-config) --libs-only-l nss | sed -e "s/-lssl3//")',
+                ],
+              },
+            }],
+            ['use_openssl==0 and clang==1', {
+              'direct_dependent_settings': {
+                'cflags': [
+                  # There is a broken header guard in /usr/include/nss/secmod.h:
+                  # https://bugzilla.mozilla.org/show_bug.cgi?id=884072
+                  '-Wno-header-guard',
+                ],
+              },
+            }],
+          ]
+        }],
+      ],
+    },
+  ],
+}
diff --git a/build/linux/unbundle/README b/build/linux/unbundle/README
new file mode 100644
index 0000000..d1b2a96
--- /dev/null
+++ b/build/linux/unbundle/README
@@ -0,0 +1,44 @@
+This directory contains files that make it possible to use system libraries.
+
+For more info please read the following:
+
+ - https://fedoraproject.org/wiki/Packaging:No_Bundled_Libraries
+ - https://wiki.gentoo.org/wiki/Why_not_bundle_dependencies
+ - http://www.debian.org/doc/debian-policy/ch-source.html#s-embeddedfiles
+
+For more Chromium-specific context please read
+http://spot.livejournal.com/312320.html .
+
+This directory is provided in the source tree to follow above guidelines.
+It is a compromise solution which takes into account Chromium developers
+who want to avoid the perceived burden of more conditional code in gyp,
+and expectations of Open Source community, where using system-provided
+libraries is the norm.
+
+Usage:
+
+1. remove_bundled_libraries.py <preserved-directories>
+
+   For example: remove_bundled_libraries.py third_party/mesa
+
+   The script scans sources looking for third_party directories.
+   Everything that is not explicitly preserved is removed (except for
+   gyp files), and the script fails if any directory passed on command
+   line does not exist (to ensure list is kept up to date).
+
+   This is intended to be used on sources extracted from a tarball,
+   not a repository.
+
+   NOTE: by default this will not remove anything (for safety). Pass
+   --do-remove flag to actually remove files.
+
+2. replace_gyp_files.py <gyp-flags>
+
+   For example: replace_gyp_files.py -Duse_system_harfbuzz=1
+
+   The script ignores flags other than -D for convenience. This makes it
+   possible to have a variable e.g. ${myconf} with all the options, and
+   execute:
+
+   build/linux/unbundle/replace_gyp_files.py ${myconf}
+   build/gyp_chromium ${myconf}
diff --git a/build/linux/unbundle/expat.gyp b/build/linux/unbundle/expat.gyp
new file mode 100644
index 0000000..030fb85
--- /dev/null
+++ b/build/linux/unbundle/expat.gyp
@@ -0,0 +1,17 @@
+# Copyright 2013 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+{
+  'targets': [
+    {
+      'target_name': 'expat',
+      'type': 'none',
+      'link_settings': {
+        'libraries': [
+          '-lexpat',
+        ],
+      },
+    },
+  ],
+}
diff --git a/build/linux/unbundle/ffmpeg.gyp b/build/linux/unbundle/ffmpeg.gyp
new file mode 100644
index 0000000..e3c3723
--- /dev/null
+++ b/build/linux/unbundle/ffmpeg.gyp
@@ -0,0 +1,54 @@
+# Copyright 2013 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+{
+  'targets': [
+    {
+      'target_name': 'ffmpeg',
+      'type': 'none',
+      'direct_dependent_settings': {
+        'cflags': [
+          '<!@(pkg-config --cflags libavcodec libavformat libavutil)',
+
+          '<!(python <(DEPTH)/tools/compile_test/compile_test.py '
+              '--code "#define __STDC_CONSTANT_MACROS\n'
+              '#include <libavcodec/avcodec.h>\n'
+              'int test() { return AV_CODEC_ID_OPUS; }" '
+              '--on-failure -DCHROMIUM_OMIT_AV_CODEC_ID_OPUS=1)',
+
+          '<!(python <(DEPTH)/tools/compile_test/compile_test.py '
+              '--code "#define __STDC_CONSTANT_MACROS\n'
+              '#include <libavcodec/avcodec.h>\n'
+              'int test() { return AV_CODEC_ID_VP9; }" '
+              '--on-failure -DCHROMIUM_OMIT_AV_CODEC_ID_VP9=1)',
+
+          '<!(python <(DEPTH)/tools/compile_test/compile_test.py '
+              '--code "#define __STDC_CONSTANT_MACROS\n'
+              '#include <libavcodec/avcodec.h>\n'
+              'int test() { return AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL; }" '
+              '--on-failure -DCHROMIUM_OMIT_AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL=1)',
+
+          '<!(python <(DEPTH)/tools/compile_test/compile_test.py '
+              '--code "#define __STDC_CONSTANT_MACROS\n'
+              '#include <libavcodec/avcodec.h>\n'
+              'int test() { struct AVFrame frame;\n'
+              'return av_frame_get_channels(&frame); }" '
+              '--on-failure -DCHROMIUM_NO_AVFRAME_CHANNELS=1)',
+        ],
+        'defines': [
+          '__STDC_CONSTANT_MACROS',
+          'USE_SYSTEM_FFMPEG',
+        ],
+      },
+      'link_settings': {
+        'ldflags': [
+          '<!@(pkg-config --libs-only-L --libs-only-other libavcodec libavformat libavutil)',
+        ],
+        'libraries': [
+          '<!@(pkg-config --libs-only-l libavcodec libavformat libavutil)',
+        ],
+      },
+    },
+  ],
+}
diff --git a/build/linux/unbundle/flac.gyp b/build/linux/unbundle/flac.gyp
new file mode 100644
index 0000000..9e4a664
--- /dev/null
+++ b/build/linux/unbundle/flac.gyp
@@ -0,0 +1,37 @@
+# Copyright 2013 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+{
+  'targets': [
+    {
+      'target_name': 'libflac',
+      'type': 'none',
+      'variables': {
+        'headers_root_path': 'include',
+        'header_filenames': [
+          'FLAC/callback.h',
+          'FLAC/metadata.h',
+          'FLAC/assert.h',
+          'FLAC/export.h',
+          'FLAC/format.h',
+          'FLAC/stream_decoder.h',
+          'FLAC/stream_encoder.h',
+          'FLAC/ordinals.h',
+          'FLAC/all.h',
+        ],
+      },
+      'includes': [
+        '../../build/shim_headers.gypi',
+      ],
+      'link_settings': {
+        'ldflags': [
+          '<!@(pkg-config --libs-only-L --libs-only-other flac)',
+        ],
+        'libraries': [
+          '<!@(pkg-config --libs-only-l flac)',
+        ],
+      },
+    },
+  ],
+}
diff --git a/build/linux/unbundle/harfbuzz.gyp b/build/linux/unbundle/harfbuzz.gyp
new file mode 100644
index 0000000..3bc1744
--- /dev/null
+++ b/build/linux/unbundle/harfbuzz.gyp
@@ -0,0 +1,47 @@
+# Copyright 2013 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+{
+  'variables': {
+    # Check for presence of harfbuzz-icu library, use it if present.
+    'harfbuzz_libraries':
+        '<!(python <(DEPTH)/tools/compile_test/compile_test.py '
+        '--code "int main() { return 0; }" '
+        '--run-linker '
+        '--on-success "harfbuzz harfbuzz-icu" '
+        '--on-failure "harfbuzz" '
+        '-- -lharfbuzz-icu)',
+  },
+  'targets': [
+    {
+      'target_name': 'harfbuzz-ng',
+      'type': 'none',
+      'cflags': [
+        '<!@(pkg-config --cflags <(harfbuzz_libraries))',
+      ],
+      'direct_dependent_settings': {
+        'cflags': [
+          '<!@(pkg-config --cflags <(harfbuzz_libraries))',
+        ],
+      },
+      'link_settings': {
+        'ldflags': [
+          '<!@(pkg-config --libs-only-L --libs-only-other <(harfbuzz_libraries))',
+        ],
+        'libraries': [
+          '<!@(pkg-config --libs-only-l <(harfbuzz_libraries))',
+        ],
+      },
+      'variables': {
+        'headers_root_path': 'src',
+        'header_filenames': [
+          'hb.h',
+        ],
+      },
+      'includes': [
+        '../../build/shim_headers.gypi',
+      ],
+    },
+  ],
+}
diff --git a/build/linux/unbundle/icu.gyp b/build/linux/unbundle/icu.gyp
new file mode 100644
index 0000000..16c36df
--- /dev/null
+++ b/build/linux/unbundle/icu.gyp
@@ -0,0 +1,248 @@
+# Copyright 2013 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+{
+  'targets': [
+    {
+      'target_name': 'icudata',
+      'type': 'none',
+      'direct_dependent_settings': {
+        'cflags': [
+          '<!@(pkg-config --cflags icu-uc)',
+        ],
+        'defines': [
+          'U_USING_ICU_NAMESPACE=0',
+        ],
+      },
+      'link_settings': {
+        'ldflags': [
+          '<!@(pkg-config --libs-only-L --libs-only-other icu-uc)',
+        ],
+        'libraries': [
+          '<!@(pkg-config --libs-only-l icu-uc)',
+        ],
+      },
+    },
+    {
+      'target_name': 'icui18n',
+      'type': 'none',
+      'toolsets': ['host', 'target'],
+      'direct_dependent_settings': {
+        'cflags': [
+          '<!@(pkg-config --cflags icu-i18n)',
+        ],
+        'defines': [
+          'U_USING_ICU_NAMESPACE=0',
+        ],
+      },
+      'link_settings': {
+        'ldflags': [
+          '<!@(pkg-config --libs-only-L --libs-only-other icu-i18n)',
+        ],
+        'libraries': [
+          '<!@(pkg-config --libs-only-l icu-i18n)',
+        ],
+      },
+      'variables': {
+        'headers_root_path': 'source/i18n',
+        'header_filenames': [
+          # This list can easily be updated using the command below:
+          # find third_party/icu/source/i18n/unicode -iname '*.h' \
+          # -printf "'%p',\n" | \
+          # sed -e 's|third_party/icu/source/i18n/||' | sort -u
+          'unicode/basictz.h',
+          'unicode/bmsearch.h',
+          'unicode/bms.h',
+          'unicode/calendar.h',
+          'unicode/choicfmt.h',
+          'unicode/coleitr.h',
+          'unicode/colldata.h',
+          'unicode/coll.h',
+          'unicode/curramt.h',
+          'unicode/currpinf.h',
+          'unicode/currunit.h',
+          'unicode/datefmt.h',
+          'unicode/dcfmtsym.h',
+          'unicode/decimfmt.h',
+          'unicode/dtfmtsym.h',
+          'unicode/dtitvfmt.h',
+          'unicode/dtitvinf.h',
+          'unicode/dtptngen.h',
+          'unicode/dtrule.h',
+          'unicode/fieldpos.h',
+          'unicode/fmtable.h',
+          'unicode/format.h',
+          'unicode/fpositer.h',
+          'unicode/gregocal.h',
+          'unicode/locdspnm.h',
+          'unicode/measfmt.h',
+          'unicode/measunit.h',
+          'unicode/measure.h',
+          'unicode/msgfmt.h',
+          'unicode/numfmt.h',
+          'unicode/numsys.h',
+          'unicode/plurfmt.h',
+          'unicode/plurrule.h',
+          'unicode/rbnf.h',
+          'unicode/rbtz.h',
+          'unicode/regex.h',
+          'unicode/search.h',
+          'unicode/selfmt.h',
+          'unicode/simpletz.h',
+          'unicode/smpdtfmt.h',
+          'unicode/sortkey.h',
+          'unicode/stsearch.h',
+          'unicode/tblcoll.h',
+          'unicode/timezone.h',
+          'unicode/tmunit.h',
+          'unicode/tmutamt.h',
+          'unicode/tmutfmt.h',
+          'unicode/translit.h',
+          'unicode/tzrule.h',
+          'unicode/tztrans.h',
+          'unicode/ucal.h',
+          'unicode/ucoleitr.h',
+          'unicode/ucol.h',
+          'unicode/ucsdet.h',
+          'unicode/ucurr.h',
+          'unicode/udat.h',
+          'unicode/udatpg.h',
+          'unicode/uldnames.h',
+          'unicode/ulocdata.h',
+          'unicode/umsg.h',
+          'unicode/unirepl.h',
+          'unicode/unum.h',
+          'unicode/uregex.h',
+          'unicode/usearch.h',
+          'unicode/uspoof.h',
+          'unicode/utmscale.h',
+          'unicode/utrans.h',
+          'unicode/vtzone.h',
+        ],
+      },
+      'includes': [
+        '../../build/shim_headers.gypi',
+      ],
+    },
+    {
+      'target_name': 'icuuc',
+      'type': 'none',
+      'toolsets': ['host', 'target'],
+      'direct_dependent_settings': {
+        'cflags': [
+          '<!@(pkg-config --cflags icu-uc)',
+        ],
+        'defines': [
+          'U_USING_ICU_NAMESPACE=0',
+        ],
+      },
+      'link_settings': {
+        'ldflags': [
+          '<!@(pkg-config --libs-only-L --libs-only-other icu-uc)',
+        ],
+        'libraries': [
+          '<!@(pkg-config --libs-only-l icu-uc)',
+        ],
+      },
+      'variables': {
+        'headers_root_path': 'source/common',
+        'header_filenames': [
+          # This list can easily be updated using the command below:
+          # find third_party/icu/source/common/unicode -iname '*.h' \
+          # -printf "'%p',\n" | \
+          # sed -e 's|third_party/icu/source/common/||' | sort -u
+          'unicode/brkiter.h',
+          'unicode/bytestream.h',
+          'unicode/caniter.h',
+          'unicode/chariter.h',
+          'unicode/dbbi.h',
+          'unicode/docmain.h',
+          'unicode/dtintrv.h',
+          'unicode/errorcode.h',
+          'unicode/icudataver.h',
+          'unicode/icuplug.h',
+          'unicode/idna.h',
+          'unicode/localpointer.h',
+          'unicode/locid.h',
+          'unicode/normalizer2.h',
+          'unicode/normlzr.h',
+          'unicode/pandroid.h',
+          'unicode/parseerr.h',
+          'unicode/parsepos.h',
+          'unicode/pfreebsd.h',
+          'unicode/plinux.h',
+          'unicode/pmac.h',
+          'unicode/popenbsd.h',
+          'unicode/ppalmos.h',
+          'unicode/ptypes.h',
+          'unicode/putil.h',
+          'unicode/pwin32.h',
+          'unicode/rbbi.h',
+          'unicode/rep.h',
+          'unicode/resbund.h',
+          'unicode/schriter.h',
+          'unicode/std_string.h',
+          'unicode/strenum.h',
+          'unicode/stringpiece.h',
+          'unicode/symtable.h',
+          'unicode/ubidi.h',
+          'unicode/ubrk.h',
+          'unicode/ucasemap.h',
+          'unicode/ucat.h',
+          'unicode/uchar.h',
+          'unicode/uchriter.h',
+          'unicode/uclean.h',
+          'unicode/ucnv_cb.h',
+          'unicode/ucnv_err.h',
+          'unicode/ucnv.h',
+          'unicode/ucnvsel.h',
+          'unicode/uconfig.h',
+          'unicode/udata.h',
+          'unicode/udeprctd.h',
+          'unicode/udraft.h',
+          'unicode/uenum.h',
+          'unicode/uidna.h',
+          'unicode/uintrnal.h',
+          'unicode/uiter.h',
+          'unicode/uloc.h',
+          'unicode/umachine.h',
+          'unicode/umisc.h',
+          'unicode/unifilt.h',
+          'unicode/unifunct.h',
+          'unicode/unimatch.h',
+          'unicode/uniset.h',
+          'unicode/unistr.h',
+          'unicode/unorm2.h',
+          'unicode/unorm.h',
+          'unicode/uobject.h',
+          'unicode/uobslete.h',
+          'unicode/urename.h',
+          'unicode/urep.h',
+          'unicode/ures.h',
+          'unicode/uscript.h',
+          'unicode/uset.h',
+          'unicode/usetiter.h',
+          'unicode/ushape.h',
+          'unicode/usprep.h',
+          'unicode/ustring.h',
+          'unicode/usystem.h',
+          'unicode/utext.h',
+          'unicode/utf16.h',
+          'unicode/utf32.h',
+          'unicode/utf8.h',
+          'unicode/utf.h',
+          'unicode/utf_old.h',
+          'unicode/utrace.h',
+          'unicode/utypeinfo.h',
+          'unicode/utypes.h',
+          'unicode/uvernum.h',
+          'unicode/uversion.h',
+        ],
+      },
+      'includes': [
+        '../../build/shim_headers.gypi',
+      ],
+    },
+  ],
+}
diff --git a/build/linux/unbundle/jsoncpp.gyp b/build/linux/unbundle/jsoncpp.gyp
new file mode 100644
index 0000000..c397f64
--- /dev/null
+++ b/build/linux/unbundle/jsoncpp.gyp
@@ -0,0 +1,39 @@
+# Copyright 2013 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+{
+  'targets': [
+    {
+      'target_name': 'jsoncpp',
+      'type': 'none',
+      'variables': {
+        'headers_root_path': 'source/include',
+        'header_filenames': [
+          'json/assertions.h',
+          'json/autolink.h',
+          'json/config.h',
+          'json/features.h',
+          'json/forwards.h',
+          'json/json.h',
+          'json/reader.h',
+          'json/value.h',
+          'json/writer.h',
+        ],
+      },
+      'includes': [
+        '../../build/shim_headers.gypi',
+      ],
+      'direct_dependent_settings': {
+        'include_dirs': [
+          '/usr/include/jsoncpp',
+        ],
+      },
+      'link_settings': {
+        'libraries': [
+          '-ljsoncpp',
+        ],
+      },
+    }
+  ],
+}
diff --git a/build/linux/unbundle/libXNVCtrl.gyp b/build/linux/unbundle/libXNVCtrl.gyp
new file mode 100644
index 0000000..f076bdb
--- /dev/null
+++ b/build/linux/unbundle/libXNVCtrl.gyp
@@ -0,0 +1,35 @@
+# Copyright 2014 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+{
+  'targets': [
+    {
+      'target_name': 'libXNVCtrl',
+      'type': 'none',
+      'variables': {
+        'headers_root_path': '.',
+        'header_filenames': [
+          'NVCtrlLib.h',
+          'NVCtrl.h',
+        ],
+      },
+      'includes': [
+        '../../build/shim_headers.gypi',
+      ],
+      'direct_dependent_settings': {
+        'cflags': [
+            '<!@(pkg-config --cflags libXNVCtrl)',
+        ],
+      },
+      'link_settings': {
+        'ldflags': [
+          '<!@(pkg-config --libs-only-L --libs-only-other libXNVCtrl)',
+        ],
+        'libraries': [
+          '<!@(pkg-config --libs-only-l libXNVCtrl)',
+        ],
+      },
+    }
+  ],
+}
diff --git a/build/linux/unbundle/libevent.gyp b/build/linux/unbundle/libevent.gyp
new file mode 100644
index 0000000..99d7435
--- /dev/null
+++ b/build/linux/unbundle/libevent.gyp
@@ -0,0 +1,27 @@
+# Copyright 2013 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+{
+  'targets': [
+    {
+      'target_name': 'libevent',
+      'type': 'none',
+      'toolsets': ['host', 'target'],
+      'variables': {
+        'headers_root_path': '.',
+        'header_filenames': [
+          'event.h',
+        ],
+      },
+      'includes': [
+        '../../build/shim_headers.gypi',
+      ],
+      'link_settings': {
+        'libraries': [
+          '-levent',
+        ],
+      },
+    }
+  ],
+}
diff --git a/build/linux/unbundle/libjpeg.gyp b/build/linux/unbundle/libjpeg.gyp
new file mode 100644
index 0000000..f56e7aa
--- /dev/null
+++ b/build/linux/unbundle/libjpeg.gyp
@@ -0,0 +1,29 @@
+# Copyright 2013 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+{
+  'targets': [
+    {
+      'target_name': 'libjpeg',
+      'type': 'none',
+      'direct_dependent_settings': {
+        'defines': [
+          'USE_SYSTEM_LIBJPEG',
+        ],
+        'conditions': [
+          ['os_bsd==1', {
+            'include_dirs': [
+              '/usr/local/include',
+            ],
+          }],
+        ],
+      },
+      'link_settings': {
+        'libraries': [
+          '-ljpeg',
+        ],
+      },
+    }
+  ],
+}
diff --git a/build/linux/unbundle/libpng.gyp b/build/linux/unbundle/libpng.gyp
new file mode 100644
index 0000000..d6933fc
--- /dev/null
+++ b/build/linux/unbundle/libpng.gyp
@@ -0,0 +1,38 @@
+# Copyright 2013 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+{
+  'targets': [
+    {
+      'target_name': 'libpng',
+      'type': 'none',
+      'dependencies': [
+        '../zlib/zlib.gyp:zlib',
+      ],
+      'direct_dependent_settings': {
+        'cflags': [
+          '<!@(pkg-config --cflags libpng)',
+        ],
+      },
+      'link_settings': {
+        'ldflags': [
+          '<!@(pkg-config --libs-only-L --libs-only-other libpng)',
+        ],
+        'libraries': [
+          '<!@(pkg-config --libs-only-l libpng)',
+        ],
+      },
+      'variables': {
+        'headers_root_path': '.',
+        'header_filenames': [
+          'png.h',
+          'pngconf.h',
+        ],
+      },
+      'includes': [
+        '../../build/shim_headers.gypi',
+      ],
+    },
+  ],
+}
diff --git a/build/linux/unbundle/libusb.gyp b/build/linux/unbundle/libusb.gyp
new file mode 100644
index 0000000..1c18033
--- /dev/null
+++ b/build/linux/unbundle/libusb.gyp
@@ -0,0 +1,34 @@
+# Copyright 2013 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+{
+  'targets': [
+    {
+      'target_name': 'libusb',
+      'type': 'none',
+      'variables': {
+        'headers_root_path': 'src/libusb',
+        'header_filenames': [
+          'libusb.h',
+        ],
+      },
+      'includes': [
+        '../../build/shim_headers.gypi',
+      ],
+      'direct_dependent_settings': {
+        'cflags': [
+          '<!@(pkg-config --cflags libusb-1.0)',
+        ],
+        'link_settings': {
+          'ldflags': [
+            '<!@(pkg-config --libs-only-L --libs-only-other libusb-1.0)',
+          ],
+          'libraries': [
+            '<!@(pkg-config --libs-only-l libusb-1.0)',
+          ],
+        },
+      },
+    },
+  ],
+}
diff --git a/build/linux/unbundle/libvpx.gyp b/build/linux/unbundle/libvpx.gyp
new file mode 100644
index 0000000..cdcf6fa
--- /dev/null
+++ b/build/linux/unbundle/libvpx.gyp
@@ -0,0 +1,42 @@
+# Copyright 2013 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+{
+  'targets': [
+    {
+      'target_name': 'libvpx',
+      'type': 'none',
+      'direct_dependent_settings': {
+        'cflags': [
+          '<!@(pkg-config --cflags vpx)',
+        ],
+      },
+      'variables': {
+        'headers_root_path': 'source/libvpx',
+        'header_filenames': [
+          'vpx/vpx_codec_impl_bottom.h',
+          'vpx/vpx_image.h',
+          'vpx/vpx_decoder.h',
+          'vpx/vp8.h',
+          'vpx/vpx_codec.h',
+          'vpx/vpx_codec_impl_top.h',
+          'vpx/vp8cx.h',
+          'vpx/vpx_integer.h',
+          'vpx/vp8dx.h',
+          'vpx/vpx_encoder.h',
+        ],
+      },
+      'includes': [
+        '../../build/shim_headers.gypi',
+      ],
+      'link_settings': {
+        'ldflags': [
+          '<!@(pkg-config --libs-only-L --libs-only-other vpx)',
+        ],
+        'libraries': [
+          '<!@(pkg-config --libs-only-l vpx)',
+        ],
+      },
+    },
+  ],
+}
diff --git a/build/linux/unbundle/libwebp.gyp b/build/linux/unbundle/libwebp.gyp
new file mode 100644
index 0000000..6dbce2e
--- /dev/null
+++ b/build/linux/unbundle/libwebp.gyp
@@ -0,0 +1,28 @@
+# Copyright 2013 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+{
+  'targets': [
+    {
+      'target_name': 'libwebp',
+      'type': 'none',
+      'direct_dependent_settings': {
+        'defines': [
+          'ENABLE_WEBP',
+        ],
+      },
+      'link_settings': {
+        'libraries': [
+          # Check for presence of webpdemux library, use it if present.
+          '<!(python <(DEPTH)/tools/compile_test/compile_test.py '
+          '--code "int main() { return 0; }" '
+          '--run-linker '
+          '--on-success "-lwebp -lwebpdemux" '
+          '--on-failure "-lwebp" '
+          '-- -lwebpdemux)',
+        ],
+      },
+    }
+  ],
+}
diff --git a/build/linux/unbundle/libxml.gyp b/build/linux/unbundle/libxml.gyp
new file mode 100644
index 0000000..bc4f9fc
--- /dev/null
+++ b/build/linux/unbundle/libxml.gyp
@@ -0,0 +1,38 @@
+# Copyright 2013 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+{
+  'targets': [
+    {
+      'target_name': 'libxml',
+      'type': 'static_library',
+      'sources': [
+        'chromium/libxml_utils.h',
+        'chromium/libxml_utils.cc',
+      ],
+      'cflags': [
+        '<!@(pkg-config --cflags libxml-2.0)',
+      ],
+      'defines': [
+        'USE_SYSTEM_LIBXML',
+      ],
+      'direct_dependent_settings': {
+        'cflags': [
+          '<!@(pkg-config --cflags libxml-2.0)',
+        ],
+        'defines': [
+          'USE_SYSTEM_LIBXML',
+        ],
+      },
+      'link_settings': {
+        'ldflags': [
+          '<!@(pkg-config --libs-only-L --libs-only-other libxml-2.0)',
+        ],
+        'libraries': [
+          '<!@(pkg-config --libs-only-l libxml-2.0)',
+        ],
+      },
+    },
+  ],
+}
diff --git a/build/linux/unbundle/libxslt.gyp b/build/linux/unbundle/libxslt.gyp
new file mode 100644
index 0000000..f7f6bb9
--- /dev/null
+++ b/build/linux/unbundle/libxslt.gyp
@@ -0,0 +1,25 @@
+# Copyright 2013 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+{
+  'targets': [
+    {
+      'target_name': 'libxslt',
+      'type': 'none',
+      'direct_dependent_settings': {
+        'cflags': [
+          '<!@(pkg-config --cflags libxslt)',
+        ],
+      },
+      'link_settings': {
+        'ldflags': [
+          '<!@(pkg-config --libs-only-L --libs-only-other libxslt)',
+        ],
+        'libraries': [
+          '<!@(pkg-config --libs-only-l libxslt)',
+        ],
+      },
+    },
+  ],
+}
diff --git a/build/linux/unbundle/opus.gyp b/build/linux/unbundle/opus.gyp
new file mode 100644
index 0000000..e8c30ba
--- /dev/null
+++ b/build/linux/unbundle/opus.gyp
@@ -0,0 +1,38 @@
+# Copyright 2013 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+{
+  'targets': [
+    {
+      'target_name': 'opus',
+      'type': 'none',
+      'direct_dependent_settings': {
+        'cflags': [
+          '<!@(pkg-config --cflags opus)',
+        ],
+      },
+      'variables': {
+        'headers_root_path': 'src/include',
+        'header_filenames': [
+          'opus_custom.h',
+          'opus_defines.h',
+          'opus_multistream.h',
+          'opus_types.h',
+          'opus.h',
+        ],
+      },
+      'includes': [
+        '../../build/shim_headers.gypi',
+      ],
+      'link_settings': {
+        'ldflags': [
+          '<!@(pkg-config --libs-only-L --libs-only-other opus)',
+        ],
+        'libraries': [
+          '<!@(pkg-config --libs-only-l opus)',
+        ],
+      },
+    },
+  ],
+}
diff --git a/build/linux/unbundle/protobuf.gyp b/build/linux/unbundle/protobuf.gyp
new file mode 100644
index 0000000..7bcd992
--- /dev/null
+++ b/build/linux/unbundle/protobuf.gyp
@@ -0,0 +1,149 @@
+# Copyright 2014 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+{
+  'targets': [
+    {
+      'target_name': 'protobuf_lite',
+      'type': 'none',
+      'direct_dependent_settings': {
+        'cflags': [
+          # Use full protobuf, because vanilla protobuf doesn't have
+          # our custom patch to retain unknown fields in lite mode.
+          '<!@(pkg-config --cflags protobuf)',
+        ],
+        'defines': [
+          'USE_SYSTEM_PROTOBUF',
+
+          # This macro must be defined to suppress the use
+          # of dynamic_cast<>, which requires RTTI.
+          'GOOGLE_PROTOBUF_NO_RTTI',
+          'GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER',
+        ],
+      },
+      'link_settings': {
+        # Use full protobuf, because vanilla protobuf doesn't have
+        # our custom patch to retain unknown fields in lite mode.
+        'ldflags': [
+          '<!@(pkg-config --libs-only-L --libs-only-other protobuf)',
+        ],
+        'libraries': [
+          '<!@(pkg-config --libs-only-l protobuf)',
+        ],
+      },
+      'variables': {
+        'headers_root_path': 'src',
+        'header_filenames': [
+          # This list can easily be updated using the command below:
+          # find third_party/protobuf/src -iname '*.h' -printf "'%p',\n" | \
+          # sed -e 's|third_party/protobuf/src/||' | sort -u
+          'google/protobuf/compiler/code_generator.h',
+          'google/protobuf/compiler/command_line_interface.h',
+          'google/protobuf/compiler/cpp/cpp_enum_field.h',
+          'google/protobuf/compiler/cpp/cpp_enum.h',
+          'google/protobuf/compiler/cpp/cpp_extension.h',
+          'google/protobuf/compiler/cpp/cpp_field.h',
+          'google/protobuf/compiler/cpp/cpp_file.h',
+          'google/protobuf/compiler/cpp/cpp_generator.h',
+          'google/protobuf/compiler/cpp/cpp_helpers.h',
+          'google/protobuf/compiler/cpp/cpp_message_field.h',
+          'google/protobuf/compiler/cpp/cpp_message.h',
+          'google/protobuf/compiler/cpp/cpp_options.h',
+          'google/protobuf/compiler/cpp/cpp_primitive_field.h',
+          'google/protobuf/compiler/cpp/cpp_service.h',
+          'google/protobuf/compiler/cpp/cpp_string_field.h',
+          'google/protobuf/compiler/cpp/cpp_unittest.h',
+          'google/protobuf/compiler/importer.h',
+          'google/protobuf/compiler/java/java_doc_comment.h',
+          'google/protobuf/compiler/java/java_enum_field.h',
+          'google/protobuf/compiler/java/java_enum.h',
+          'google/protobuf/compiler/java/java_extension.h',
+          'google/protobuf/compiler/java/java_field.h',
+          'google/protobuf/compiler/java/java_file.h',
+          'google/protobuf/compiler/java/java_generator.h',
+          'google/protobuf/compiler/java/java_helpers.h',
+          'google/protobuf/compiler/java/java_message_field.h',
+          'google/protobuf/compiler/java/java_message.h',
+          'google/protobuf/compiler/java/java_primitive_field.h',
+          'google/protobuf/compiler/java/java_service.h',
+          'google/protobuf/compiler/java/java_string_field.h',
+          'google/protobuf/compiler/mock_code_generator.h',
+          'google/protobuf/compiler/package_info.h',
+          'google/protobuf/compiler/parser.h',
+          'google/protobuf/compiler/plugin.h',
+          'google/protobuf/compiler/plugin.pb.h',
+          'google/protobuf/compiler/python/python_generator.h',
+          'google/protobuf/compiler/subprocess.h',
+          'google/protobuf/compiler/zip_writer.h',
+          'google/protobuf/descriptor_database.h',
+          'google/protobuf/descriptor.h',
+          'google/protobuf/descriptor.pb.h',
+          'google/protobuf/dynamic_message.h',
+          'google/protobuf/extension_set.h',
+          'google/protobuf/generated_enum_reflection.h',
+          'google/protobuf/generated_message_reflection.h',
+          'google/protobuf/generated_message_util.h',
+          'google/protobuf/io/coded_stream.h',
+          'google/protobuf/io/coded_stream_inl.h',
+          'google/protobuf/io/gzip_stream.h',
+          'google/protobuf/io/package_info.h',
+          'google/protobuf/io/printer.h',
+          'google/protobuf/io/tokenizer.h',
+          'google/protobuf/io/zero_copy_stream.h',
+          'google/protobuf/io/zero_copy_stream_impl.h',
+          'google/protobuf/io/zero_copy_stream_impl_lite.h',
+          'google/protobuf/message.h',
+          'google/protobuf/message_lite.h',
+          'google/protobuf/package_info.h',
+          'google/protobuf/reflection_ops.h',
+          'google/protobuf/repeated_field.h',
+          'google/protobuf/service.h',
+          'google/protobuf/stubs/atomicops.h',
+          'google/protobuf/stubs/atomicops_internals_arm64_gcc.h',
+          'google/protobuf/stubs/atomicops_internals_arm_gcc.h',
+          'google/protobuf/stubs/atomicops_internals_arm_qnx.h',
+          'google/protobuf/stubs/atomicops_internals_atomicword_compat.h',
+          'google/protobuf/stubs/atomicops_internals_macosx.h',
+          'google/protobuf/stubs/atomicops_internals_mips_gcc.h',
+          'google/protobuf/stubs/atomicops_internals_pnacl.h',
+          'google/protobuf/stubs/atomicops_internals_tsan.h',
+          'google/protobuf/stubs/atomicops_internals_x86_gcc.h',
+          'google/protobuf/stubs/atomicops_internals_x86_msvc.h',
+          'google/protobuf/stubs/common.h',
+          'google/protobuf/stubs/hash.h',
+          'google/protobuf/stubs/map-util.h',
+          'google/protobuf/stubs/once.h',
+          'google/protobuf/stubs/platform_macros.h',
+          'google/protobuf/stubs/stl_util.h',
+          'google/protobuf/stubs/stringprintf.h',
+          'google/protobuf/stubs/strutil.h',
+          'google/protobuf/stubs/substitute.h',
+          'google/protobuf/stubs/template_util.h',
+          'google/protobuf/stubs/type_traits.h',
+          'google/protobuf/testing/file.h',
+          'google/protobuf/testing/googletest.h',
+          'google/protobuf/test_util.h',
+          'google/protobuf/test_util_lite.h',
+          'google/protobuf/text_format.h',
+          'google/protobuf/unknown_field_set.h',
+          'google/protobuf/wire_format.h',
+          'google/protobuf/wire_format_lite.h',
+          'google/protobuf/wire_format_lite_inl.h',
+        ],
+      },
+      'includes': [
+        '../../build/shim_headers.gypi',
+      ],
+    },
+    {
+      'target_name': 'protoc',
+      'type': 'none',
+      'toolsets': ['host', 'target'],
+    },
+    {
+      'target_name': 'py_proto',
+      'type': 'none',
+    },
+  ],
+}
diff --git a/build/linux/unbundle/re2.gyp b/build/linux/unbundle/re2.gyp
new file mode 100644
index 0000000..e2e567a
--- /dev/null
+++ b/build/linux/unbundle/re2.gyp
@@ -0,0 +1,37 @@
+# Copyright 2013 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+{
+  'targets': [
+    {
+      'target_name': 're2',
+      'type': 'none',
+      'variables': {
+        'headers_root_path': '.',
+        'header_filenames': [
+          're2/filtered_re2.h',
+          're2/re2.h',
+          're2/set.h',
+          're2/stringpiece.h',
+          're2/variadic_function.h',
+        ],
+        'shim_generator_additional_args': [
+          # Chromium copy of re2 is patched to rename POSIX to POSIX_SYNTAX
+          # because of collision issues that break the build.
+          # Upstream refuses to make changes:
+          # http://code.google.com/p/re2/issues/detail?id=73 .
+          '--define', 'POSIX=POSIX_SYNTAX',
+        ],
+      },
+      'includes': [
+        '../../build/shim_headers.gypi',
+      ],
+      'link_settings': {
+        'libraries': [
+          '-lre2',
+        ],
+      },
+    }
+  ],
+}
diff --git a/build/linux/unbundle/remove_bundled_libraries.py b/build/linux/unbundle/remove_bundled_libraries.py
new file mode 100755
index 0000000..69e76f5
--- /dev/null
+++ b/build/linux/unbundle/remove_bundled_libraries.py
@@ -0,0 +1,102 @@
+#!/usr/bin/env python
+# Copyright 2013 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""
+Removes bundled libraries to make sure they are not used.
+
+See README for more details.
+"""
+
+
+import optparse
+import os.path
+import sys
+
+
+def DoMain(argv):
+  my_dirname = os.path.abspath(os.path.dirname(__file__))
+  source_tree_root = os.path.abspath(
+    os.path.join(my_dirname, '..', '..', '..'))
+
+  if os.path.join(source_tree_root, 'build', 'linux', 'unbundle') != my_dirname:
+    print ('Sanity check failed: please run this script from ' +
+           'build/linux/unbundle directory.')
+    return 1
+
+  parser = optparse.OptionParser()
+  parser.add_option('--do-remove', action='store_true')
+
+  options, args = parser.parse_args(argv)
+
+  exclusion_used = {}
+  for exclusion in args:
+    exclusion_used[exclusion] = False
+
+  for root, dirs, files in os.walk(source_tree_root, topdown=False):
+    # Only look at paths which contain a "third_party" component
+    # (note that e.g. third_party.png doesn't count).
+    root_relpath = os.path.relpath(root, source_tree_root)
+    if 'third_party' not in root_relpath.split(os.sep):
+      continue
+
+    for f in files:
+      path = os.path.join(root, f)
+      relpath = os.path.relpath(path, source_tree_root)
+
+      excluded = False
+      for exclusion in args:
+        # Require precise exclusions. Find the right-most third_party
+        # in the relative path, and if there is more than one ignore
+        # the exclusion if it's completely contained within the part
+        # before right-most third_party path component.
+        split = relpath.rsplit(os.sep + 'third_party' + os.sep, 1)
+        if len(split) > 1 and split[0].startswith(exclusion):
+          continue
+
+        if relpath.startswith(exclusion):
+          # Multiple exclusions can match the same path. Go through all of them
+          # and mark each one as used.
+          exclusion_used[exclusion] = True
+          excluded = True
+      if excluded:
+        continue
+
+      # Deleting gyp files almost always leads to gyp failures.
+      # These files come from Chromium project, and can be replaced if needed.
+      if f.endswith('.gyp') or f.endswith('.gypi'):
+        continue
+
+      # Deleting .isolate files leads to gyp failures. They are usually
+      # not used by a distro build anyway.
+      # See http://www.chromium.org/developers/testing/isolated-testing
+      # for more info.
+      if f.endswith('.isolate'):
+        continue
+
+      if options.do_remove:
+        # Delete the file - best way to ensure it's not used during build.
+        os.remove(path)
+      else:
+        # By default just print paths that would be removed.
+        print path
+
+  exit_code = 0
+
+  # Fail if exclusion list contains stale entries - this helps keep it
+  # up to date.
+  for exclusion, used in exclusion_used.iteritems():
+    if not used:
+      print '%s does not exist' % exclusion
+      exit_code = 1
+
+  if not options.do_remove:
+    print ('To actually remove files printed above, please pass ' +
+           '--do-remove flag.')
+
+  return exit_code
+
+
+if __name__ == '__main__':
+  sys.exit(DoMain(sys.argv[1:]))
diff --git a/build/linux/unbundle/replace_gyp_files.py b/build/linux/unbundle/replace_gyp_files.py
new file mode 100755
index 0000000..d06ae41
--- /dev/null
+++ b/build/linux/unbundle/replace_gyp_files.py
@@ -0,0 +1,82 @@
+#!/usr/bin/env python
+# Copyright 2013 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""
+Replaces gyp files in tree with files from here that
+make the build use system libraries.
+"""
+
+
+import optparse
+import os.path
+import shutil
+import sys
+
+
+REPLACEMENTS = {
+  'use_system_expat': 'third_party/expat/expat.gyp',
+  'use_system_ffmpeg': 'third_party/ffmpeg/ffmpeg.gyp',
+  'use_system_flac': 'third_party/flac/flac.gyp',
+  'use_system_harfbuzz': 'third_party/harfbuzz-ng/harfbuzz.gyp',
+  'use_system_icu': 'third_party/icu/icu.gyp',
+  'use_system_jsoncpp': 'third_party/jsoncpp/jsoncpp.gyp',
+  'use_system_libevent': 'third_party/libevent/libevent.gyp',
+  'use_system_libjpeg': 'third_party/libjpeg/libjpeg.gyp',
+  'use_system_libpng': 'third_party/libpng/libpng.gyp',
+  'use_system_libusb': 'third_party/libusb/libusb.gyp',
+  'use_system_libvpx': 'third_party/libvpx/libvpx.gyp',
+  'use_system_libwebp': 'third_party/libwebp/libwebp.gyp',
+  'use_system_libxml': 'third_party/libxml/libxml.gyp',
+  'use_system_libxnvctrl' : 'third_party/libXNVCtrl/libXNVCtrl.gyp',
+  'use_system_libxslt': 'third_party/libxslt/libxslt.gyp',
+  'use_system_opus': 'third_party/opus/opus.gyp',
+  'use_system_protobuf': 'third_party/protobuf/protobuf.gyp',
+  'use_system_re2': 'third_party/re2/re2.gyp',
+  'use_system_snappy': 'third_party/snappy/snappy.gyp',
+  'use_system_speex': 'third_party/speex/speex.gyp',
+  'use_system_sqlite': 'third_party/sqlite/sqlite.gyp',
+  'use_system_v8': 'v8/tools/gyp/v8.gyp',
+  'use_system_zlib': 'third_party/zlib/zlib.gyp',
+}
+
+
+def DoMain(argv):
+  my_dirname = os.path.dirname(__file__)
+  source_tree_root = os.path.abspath(
+    os.path.join(my_dirname, '..', '..', '..'))
+
+  parser = optparse.OptionParser()
+
+  # Accept arguments in gyp command-line syntax, so that the caller can re-use
+  # command-line for this script and gyp.
+  parser.add_option('-D', dest='defines', action='append')
+
+  parser.add_option('--undo', action='store_true')
+
+  options, args = parser.parse_args(argv)
+
+  for flag, path in REPLACEMENTS.items():
+    if '%s=1' % flag not in options.defines:
+      continue
+
+    if options.undo:
+      # Restore original file, and also remove the backup.
+      # This is meant to restore the source tree to its original state.
+      os.rename(os.path.join(source_tree_root, path + '.orig'),
+                os.path.join(source_tree_root, path))
+    else:
+      # Create a backup copy for --undo.
+      shutil.copyfile(os.path.join(source_tree_root, path),
+                      os.path.join(source_tree_root, path + '.orig'))
+
+      # Copy the gyp file from directory of this script to target path.
+      shutil.copyfile(os.path.join(my_dirname, os.path.basename(path)),
+                      os.path.join(source_tree_root, path))
+
+  return 0
+
+
+if __name__ == '__main__':
+  sys.exit(DoMain(sys.argv))
diff --git a/build/linux/unbundle/snappy.gyp b/build/linux/unbundle/snappy.gyp
new file mode 100644
index 0000000..ab856ed
--- /dev/null
+++ b/build/linux/unbundle/snappy.gyp
@@ -0,0 +1,29 @@
+# Copyright 2013 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+{
+  'targets': [
+    {
+      'target_name': 'snappy',
+      'type': 'none',
+      'variables': {
+        'headers_root_path': 'src',
+        'header_filenames': [
+          'snappy-c.h',
+          'snappy-sinksource.h',
+          'snappy-stubs-public.h',
+          'snappy.h',
+        ],
+      },
+      'includes': [
+        '../../build/shim_headers.gypi',
+      ],
+      'link_settings': {
+        'libraries': [
+          '-lsnappy',
+        ],
+      },
+    },
+  ],
+}
diff --git a/build/linux/unbundle/speex.gyp b/build/linux/unbundle/speex.gyp
new file mode 100644
index 0000000..75376c8
--- /dev/null
+++ b/build/linux/unbundle/speex.gyp
@@ -0,0 +1,45 @@
+# Copyright 2013 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+{
+  'targets': [
+    {
+      'target_name': 'libspeex',
+      'type': 'none',
+      'variables': {
+        'headers_root_path': 'include',
+        'header_filenames': [
+          'speex/speex_types.h',
+          'speex/speex_callbacks.h',
+          'speex/speex_config_types.h',
+          'speex/speex_stereo.h',
+          'speex/speex_echo.h',
+          'speex/speex_preprocess.h',
+          'speex/speex_jitter.h',
+          'speex/speex.h',
+          'speex/speex_resampler.h',
+          'speex/speex_buffer.h',
+          'speex/speex_header.h',
+          'speex/speex_bits.h',
+        ],
+      },
+      'includes': [
+        '../../build/shim_headers.gypi',
+      ],
+      'direct_dependent_settings': {
+        'cflags': [
+          '<!@(pkg-config --cflags speex)',
+        ],
+      },
+      'link_settings': {
+        'ldflags': [
+          '<!@(pkg-config --libs-only-L --libs-only-other speex)',
+        ],
+        'libraries': [
+          '<!@(pkg-config --libs-only-l speex)',
+        ],
+      },
+    },
+  ],
+}
diff --git a/build/linux/unbundle/sqlite.gyp b/build/linux/unbundle/sqlite.gyp
new file mode 100644
index 0000000..918da92
--- /dev/null
+++ b/build/linux/unbundle/sqlite.gyp
@@ -0,0 +1,28 @@
+# Copyright 2013 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+{
+  'targets': [
+    {
+      'target_name': 'sqlite',
+      'type': 'none',
+      'direct_dependent_settings': {
+        'cflags': [
+          '<!@(pkg-config --cflags sqlite3)',
+        ],
+        'defines': [
+          'USE_SYSTEM_SQLITE',
+        ],
+      },
+      'link_settings': {
+        'ldflags': [
+          '<!@(pkg-config --libs-only-L --libs-only-other sqlite3)',
+        ],
+        'libraries': [
+          '<!@(pkg-config --libs-only-l sqlite3)',
+        ],
+      },
+    },
+  ],
+}
diff --git a/build/linux/unbundle/v8.gyp b/build/linux/unbundle/v8.gyp
new file mode 100644
index 0000000..9b06347
--- /dev/null
+++ b/build/linux/unbundle/v8.gyp
@@ -0,0 +1,64 @@
+# Copyright 2013 the V8 project authors. All rights reserved.
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+#     * Redistributions of source code must retain the above copyright
+#       notice, this list of conditions and the following disclaimer.
+#     * Redistributions in binary form must reproduce the above
+#       copyright notice, this list of conditions and the following
+#       disclaimer in the documentation and/or other materials provided
+#       with the distribution.
+#     * Neither the name of Google Inc. nor the names of its
+#       contributors may be used to endorse or promote products derived
+#       from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+{
+  'includes': ['../../build/toolchain.gypi', '../../build/features.gypi'],
+  'targets': [
+    {
+      'target_name': 'v8',
+      'type': 'none',
+      'toolsets': ['host', 'target'],
+      'variables': {
+        'headers_root_path': '../../include',
+        'header_filenames': [
+          'v8-debug.h',
+          'v8-preparser.h',
+          'v8-profiler.h',
+          'v8-testing.h',
+          'v8.h',
+          'v8stdint.h',
+        ],
+      },
+      'includes': [
+        '../../../build/shim_headers.gypi',
+      ],
+      'link_settings': {
+        'libraries': [
+          '-lv8',
+        ],
+      },
+    },
+    {
+      'target_name': 'v8_shell',
+      'type': 'none',
+      'toolsets': ['host', 'target'],
+      'dependencies': [
+        'v8'
+      ],
+    },
+  ],
+}
diff --git a/build/linux/unbundle/zlib.gyp b/build/linux/unbundle/zlib.gyp
new file mode 100644
index 0000000..0a85ff0
--- /dev/null
+++ b/build/linux/unbundle/zlib.gyp
@@ -0,0 +1,67 @@
+# Copyright 2013 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+{
+  'targets': [
+    {
+      'target_name': 'zlib',
+      'type': 'none',
+      'variables': {
+        'headers_root_path': '.',
+        'header_filenames': [
+          'zlib.h',
+        ],
+      },
+      'includes': [
+        '../../build/shim_headers.gypi',
+      ],
+      'direct_dependent_settings': {
+        'defines': [
+          'USE_SYSTEM_ZLIB',
+        ],
+      },
+      'link_settings': {
+        'libraries': [
+          '-lz',
+        ],
+      },
+    },
+    {
+      'target_name': 'minizip',
+      'type': 'static_library',
+      'all_dependent_settings': {
+        'defines': [
+          'USE_SYSTEM_MINIZIP',
+        ],
+      },
+      'defines': [
+        'USE_SYSTEM_MINIZIP',
+      ],
+      'link_settings': {
+        'libraries': [
+          '-lminizip',
+        ],
+      },
+    },
+    {
+      'target_name': 'zip',
+      'type': 'static_library',
+      'dependencies': [
+        'minizip',
+        '../../base/base.gyp:base',
+      ],
+      'include_dirs': [
+        '../..',
+      ],
+      'sources': [
+        'google/zip.cc',
+        'google/zip.h',
+        'google/zip_internal.cc',
+        'google/zip_internal.h',
+        'google/zip_reader.cc',
+        'google/zip_reader.h',
+      ],
+    },
+  ],
+}
diff --git a/build/util/LASTCHANGE b/build/util/LASTCHANGE
index dd8161b..e503f69 100644
--- a/build/util/LASTCHANGE
+++ b/build/util/LASTCHANGE
@@ -1 +1 @@
-LASTCHANGE=3b302fef93f7cc58d9b8168466905237484b2772
+LASTCHANGE=d03a5f1b0f09d9b933efefd0ea0bf26389d89689
diff --git a/testing/perf/BUILD.gn b/testing/perf/BUILD.gn
new file mode 100644
index 0000000..949f15a
--- /dev/null
+++ b/testing/perf/BUILD.gn
@@ -0,0 +1,14 @@
+# Copyright 2014 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+source_set("perf") {
+  testonly = true
+  sources = [
+    "perf_test.cc",
+    "perf_test.h",
+  ]
+  deps = [
+    "//base",
+  ]
+}
diff --git a/testing/perf/perf_test.cc b/testing/perf/perf_test.cc
new file mode 100644
index 0000000..0d5abc0
--- /dev/null
+++ b/testing/perf/perf_test.cc
@@ -0,0 +1,204 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "testing/perf/perf_test.h"
+
+#include <stdio.h>
+
+#include "base/logging.h"
+#include "base/strings/string_number_conversions.h"
+#include "base/strings/stringprintf.h"
+
+namespace {
+
+std::string ResultsToString(const std::string& measurement,
+                            const std::string& modifier,
+                            const std::string& trace,
+                            const std::string& values,
+                            const std::string& prefix,
+                            const std::string& suffix,
+                            const std::string& units,
+                            bool important) {
+  // <*>RESULT <graph_name>: <trace_name>= <value> <units>
+  // <*>RESULT <graph_name>: <trace_name>= {<mean>, <std deviation>} <units>
+  // <*>RESULT <graph_name>: <trace_name>= [<value>,value,value,...,] <units>
+  return base::StringPrintf("%sRESULT %s%s: %s= %s%s%s %s\n",
+         important ? "*" : "", measurement.c_str(), modifier.c_str(),
+         trace.c_str(), prefix.c_str(), values.c_str(), suffix.c_str(),
+         units.c_str());
+}
+
+void PrintResultsImpl(const std::string& measurement,
+                      const std::string& modifier,
+                      const std::string& trace,
+                      const std::string& values,
+                      const std::string& prefix,
+                      const std::string& suffix,
+                      const std::string& units,
+                      bool important) {
+  fflush(stdout);
+  printf("%s", ResultsToString(measurement, modifier, trace, values,
+                               prefix, suffix, units, important).c_str());
+  fflush(stdout);
+}
+
+}  // namespace
+
+namespace perf_test {
+
+void PrintResult(const std::string& measurement,
+                 const std::string& modifier,
+                 const std::string& trace,
+                 size_t value,
+                 const std::string& units,
+                 bool important) {
+  PrintResultsImpl(measurement,
+                   modifier,
+                   trace,
+                   base::UintToString(static_cast<unsigned int>(value)),
+                   std::string(),
+                   std::string(),
+                   units,
+                   important);
+}
+
+void PrintResult(const std::string& measurement,
+                 const std::string& modifier,
+                 const std::string& trace,
+                 double value,
+                 const std::string& units,
+                 bool important) {
+  PrintResultsImpl(measurement,
+                   modifier,
+                   trace,
+                   base::DoubleToString(value),
+                   std::string(),
+                   std::string(),
+                   units,
+                   important);
+}
+
+void AppendResult(std::string& output,
+                  const std::string& measurement,
+                  const std::string& modifier,
+                  const std::string& trace,
+                  size_t value,
+                  const std::string& units,
+                  bool important) {
+  output += ResultsToString(
+      measurement,
+      modifier,
+      trace,
+      base::UintToString(static_cast<unsigned int>(value)),
+      std::string(),
+      std::string(),
+      units,
+      important);
+}
+
+void PrintResult(const std::string& measurement,
+                 const std::string& modifier,
+                 const std::string& trace,
+                 const std::string& value,
+                 const std::string& units,
+                 bool important) {
+  PrintResultsImpl(measurement,
+                   modifier,
+                   trace,
+                   value,
+                   std::string(),
+                   std::string(),
+                   units,
+                   important);
+}
+
+void AppendResult(std::string& output,
+                  const std::string& measurement,
+                  const std::string& modifier,
+                  const std::string& trace,
+                  const std::string& value,
+                  const std::string& units,
+                  bool important) {
+  output += ResultsToString(measurement,
+                            modifier,
+                            trace,
+                            value,
+                            std::string(),
+                            std::string(),
+                            units,
+                            important);
+}
+
+void PrintResultMeanAndError(const std::string& measurement,
+                             const std::string& modifier,
+                             const std::string& trace,
+                             const std::string& mean_and_error,
+                             const std::string& units,
+                             bool important) {
+  PrintResultsImpl(measurement, modifier, trace, mean_and_error,
+                   "{", "}", units, important);
+}
+
+void AppendResultMeanAndError(std::string& output,
+                              const std::string& measurement,
+                              const std::string& modifier,
+                              const std::string& trace,
+                              const std::string& mean_and_error,
+                              const std::string& units,
+                              bool important) {
+  output += ResultsToString(measurement, modifier, trace, mean_and_error,
+                            "{", "}", units, important);
+}
+
+void PrintResultList(const std::string& measurement,
+                     const std::string& modifier,
+                     const std::string& trace,
+                     const std::string& values,
+                     const std::string& units,
+                     bool important) {
+  PrintResultsImpl(measurement, modifier, trace, values,
+                   "[", "]", units, important);
+}
+
+void AppendResultList(std::string& output,
+                      const std::string& measurement,
+                      const std::string& modifier,
+                      const std::string& trace,
+                      const std::string& values,
+                      const std::string& units,
+                      bool important) {
+  output += ResultsToString(measurement, modifier, trace, values,
+                            "[", "]", units, important);
+}
+
+void PrintSystemCommitCharge(const std::string& test_name,
+                             size_t charge,
+                             bool important) {
+  PrintSystemCommitCharge(stdout, test_name, charge, important);
+}
+
+void PrintSystemCommitCharge(FILE* target,
+                             const std::string& test_name,
+                             size_t charge,
+                             bool important) {
+  fprintf(target, "%s", SystemCommitChargeToString(test_name, charge,
+                                                   important).c_str());
+}
+
+std::string SystemCommitChargeToString(const std::string& test_name,
+                                       size_t charge,
+                                       bool important) {
+  std::string trace_name(test_name);
+  std::string output;
+  AppendResult(output,
+               "commit_charge",
+               std::string(),
+               "cc" + trace_name,
+               charge,
+               "kb",
+               important);
+  return output;
+}
+
+}  // namespace perf_test
diff --git a/testing/perf/perf_test.gyp b/testing/perf/perf_test.gyp
new file mode 100644
index 0000000..2065270
--- /dev/null
+++ b/testing/perf/perf_test.gyp
@@ -0,0 +1,18 @@
+# Copyright 2013 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+{
+  'targets': [
+    {
+      'target_name': 'perf_test',
+      'type': 'static_library',
+      'sources': [
+        'perf_test.cc',
+      ],
+      'dependencies': [
+        '../../base/base.gyp:base',
+      ],
+    },
+  ],
+}
diff --git a/testing/perf/perf_test.h b/testing/perf/perf_test.h
new file mode 100644
index 0000000..36e2916
--- /dev/null
+++ b/testing/perf/perf_test.h
@@ -0,0 +1,116 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef TESTING_PERF_PERF_TEST_H_
+#define TESTING_PERF_PERF_TEST_H_
+
+#include <string>
+
+namespace perf_test {
+
+// Prints numerical information to stdout in a controlled format, for
+// post-processing. |measurement| is a description of the quantity being
+// measured, e.g. "vm_peak"; |modifier| is provided as a convenience and
+// will be appended directly to the name of the |measurement|, e.g.
+// "_browser"; |trace| is a description of the particular data point, e.g.
+// "reference"; |value| is the measured value; and |units| is a description
+// of the units of measure, e.g. "bytes". If |important| is true, the output
+// line will be specially marked, to notify the post-processor. The strings
+// may be empty.  They should not contain any colons (:) or equals signs (=).
+// A typical post-processing step would be to produce graphs of the data
+// produced for various builds, using the combined |measurement| + |modifier|
+// string to specify a particular graph and the |trace| to identify a trace
+// (i.e., data series) on that graph.
+void PrintResult(const std::string& measurement,
+                 const std::string& modifier,
+                 const std::string& trace,
+                 size_t value,
+                 const std::string& units,
+                 bool important);
+void PrintResult(const std::string& measurement,
+                 const std::string& modifier,
+                 const std::string& trace,
+                 double value,
+                 const std::string& units,
+                 bool important);
+
+void AppendResult(std::string& output,
+                  const std::string& measurement,
+                  const std::string& modifier,
+                  const std::string& trace,
+                  size_t value,
+                  const std::string& units,
+                  bool important);
+
+// Like the above version of PrintResult(), but takes a std::string value
+// instead of a size_t.
+void PrintResult(const std::string& measurement,
+                 const std::string& modifier,
+                 const std::string& trace,
+                 const std::string& value,
+                 const std::string& units,
+                 bool important);
+
+void AppendResult(std::string& output,
+                  const std::string& measurement,
+                  const std::string& modifier,
+                  const std::string& trace,
+                  const std::string& value,
+                  const std::string& units,
+                  bool important);
+
+// Like PrintResult(), but prints a (mean, standard deviation) result pair.
+// The |<values>| should be two comma-separated numbers, the mean and
+// standard deviation (or other error metric) of the measurement.
+void PrintResultMeanAndError(const std::string& measurement,
+                             const std::string& modifier,
+                             const std::string& trace,
+                             const std::string& mean_and_error,
+                             const std::string& units,
+                             bool important);
+
+void AppendResultMeanAndError(std::string& output,
+                              const std::string& measurement,
+                              const std::string& modifier,
+                              const std::string& trace,
+                              const std::string& mean_and_error,
+                              const std::string& units,
+                              bool important);
+
+// Like PrintResult(), but prints an entire list of results. The |values|
+// will generally be a list of comma-separated numbers. A typical
+// post-processing step might produce plots of their mean and standard
+// deviation.
+void PrintResultList(const std::string& measurement,
+                     const std::string& modifier,
+                     const std::string& trace,
+                     const std::string& values,
+                     const std::string& units,
+                     bool important);
+
+void AppendResultList(std::string& output,
+                      const std::string& measurement,
+                      const std::string& modifier,
+                      const std::string& trace,
+                      const std::string& values,
+                      const std::string& units,
+                      bool important);
+
+// Prints memory commit charge stats for use by perf graphs.
+void PrintSystemCommitCharge(const std::string& test_name,
+                             size_t charge,
+                             bool important);
+
+void PrintSystemCommitCharge(FILE* target,
+                             const std::string& test_name,
+                             size_t charge,
+                             bool important);
+
+std::string SystemCommitChargeToString(const std::string& test_name,
+                                       size_t charge,
+                                       bool important);
+
+}  // namespace perf_test
+
+#endif  // TESTING_PERF_PERF_TEST_H_
diff --git a/tools/generate_library_loader/generate_library_loader.gni b/tools/generate_library_loader/generate_library_loader.gni
new file mode 100644
index 0000000..24f753b
--- /dev/null
+++ b/tools/generate_library_loader/generate_library_loader.gni
@@ -0,0 +1,70 @@
+# Copyright 2014 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# This template makes a stub for a Linux system library that dynamically loads
+# it at runtime.
+
+# name: Name to use for the value of the --name arg.
+# output_h/output_cc: Names for the generated header/cc file with no dir.
+# header: header file to process. Example: "<foo/bar.h>"
+# functions: List of strings for functions to process.
+# config: (optional) Label of the config generated by pkgconfig.
+# bundled_header: (optional)
+template("generate_library_loader") {
+  output_h = "$root_gen_dir/library_loaders/" + invoker.output_h
+  output_cc = "$root_gen_dir/library_loaders/" + invoker.output_cc
+
+  action_visibility = [ ":$target_name" ]
+  action("${target_name}_loader") {
+    visibility = action_visibility
+
+    script = "//tools/generate_library_loader/generate_library_loader.py"
+    if (defined(invoker.visibility)) {
+      visibility = invoker.visibility
+    }
+
+    outputs = [
+      output_h,
+      output_cc,
+    ]
+
+    args = [
+      "--name",
+      invoker.name,
+      "--output-h",
+      rebase_path(output_h),
+      "--output-cc",
+      rebase_path(output_cc),
+      "--header",
+      invoker.header,
+
+      # Note GYP build exposes a per-target variable to control this, which, if
+      # manually set to true, will disable dlopen(). Its not clear this is
+      # needed, so here we just leave off. If this can be done globally, we can
+      # expose one switch for this value, otherwise we need to add a template
+      # param for this.
+      "--link-directly=0",
+    ]
+    if (defined(invoker.bundled_header)) {
+      args += [
+        "--bundled-header",
+        invoker.bundled_header,
+      ]
+    }
+    args += invoker.functions
+  }
+
+  source_set(target_name) {
+    if (defined(invoker.config)) {
+      public_configs = [ invoker.config ]
+    }
+    sources = [
+      output_cc,
+      output_h,
+    ]
+    deps = [
+      ":${target_name}_loader",
+    ]
+  }
+}
diff --git a/tools/generate_library_loader/generate_library_loader.py b/tools/generate_library_loader/generate_library_loader.py
new file mode 100755
index 0000000..5e9da2c
--- /dev/null
+++ b/tools/generate_library_loader/generate_library_loader.py
@@ -0,0 +1,249 @@
+#!/usr/bin/env python
+# Copyright (c) 2012 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""
+Creates a library loader (a header and implementation file),
+which is a wrapper for dlopen or direct linking with given library.
+
+The loader makes it possible to have the same client code for both cases,
+and also makes it easier to write code using dlopen (and also provides
+a standard way to do so, and limits the ugliness just to generated files).
+
+For more info refer to http://crbug.com/162733 .
+"""
+
+
+import optparse
+import os.path
+import re
+import sys
+
+
+HEADER_TEMPLATE = """// This is generated file. Do not modify directly.
+// Path to the code generator: %(generator_path)s .
+
+#ifndef %(unique_prefix)s
+#define %(unique_prefix)s
+
+%(wrapped_header_include)s
+
+#include <string>
+
+class %(class_name)s {
+ public:
+  %(class_name)s();
+  ~%(class_name)s();
+
+  bool Load(const std::string& library_name)
+      __attribute__((warn_unused_result));
+
+  bool loaded() const { return loaded_; }
+
+%(member_decls)s
+
+ private:
+  void CleanUp(bool unload);
+
+#if defined(%(unique_prefix)s_DLOPEN)
+  void* library_;
+#endif
+
+  bool loaded_;
+
+  // Disallow copy constructor and assignment operator.
+  %(class_name)s(const %(class_name)s&);
+  void operator=(const %(class_name)s&);
+};
+
+#endif  // %(unique_prefix)s
+"""
+
+
+HEADER_MEMBER_TEMPLATE = """  decltype(&::%(function_name)s) %(function_name)s;
+"""
+
+
+IMPL_TEMPLATE = """// This is generated file. Do not modify directly.
+// Path to the code generator: %(generator_path)s .
+
+#include "%(generated_header_name)s"
+
+#include <dlfcn.h>
+
+// Put these sanity checks here so that they fire at most once
+// (to avoid cluttering the build output).
+#if !defined(%(unique_prefix)s_DLOPEN) && !defined(%(unique_prefix)s_DT_NEEDED)
+#error neither %(unique_prefix)s_DLOPEN nor %(unique_prefix)s_DT_NEEDED defined
+#endif
+#if defined(%(unique_prefix)s_DLOPEN) && defined(%(unique_prefix)s_DT_NEEDED)
+#error both %(unique_prefix)s_DLOPEN and %(unique_prefix)s_DT_NEEDED defined
+#endif
+
+%(class_name)s::%(class_name)s() : loaded_(false) {
+}
+
+%(class_name)s::~%(class_name)s() {
+  CleanUp(loaded_);
+}
+
+bool %(class_name)s::Load(const std::string& library_name) {
+  if (loaded_)
+    return false;
+
+#if defined(%(unique_prefix)s_DLOPEN)
+  library_ = dlopen(library_name.c_str(), RTLD_LAZY);
+  if (!library_)
+    return false;
+#endif
+
+%(member_init)s
+
+  loaded_ = true;
+  return true;
+}
+
+void %(class_name)s::CleanUp(bool unload) {
+#if defined(%(unique_prefix)s_DLOPEN)
+  if (unload) {
+    dlclose(library_);
+    library_ = NULL;
+  }
+#endif
+  loaded_ = false;
+%(member_cleanup)s
+}
+"""
+
+IMPL_MEMBER_INIT_TEMPLATE = """
+#if defined(%(unique_prefix)s_DLOPEN)
+  %(function_name)s =
+      reinterpret_cast<decltype(this->%(function_name)s)>(
+          dlsym(library_, "%(function_name)s"));
+#endif
+#if defined(%(unique_prefix)s_DT_NEEDED)
+  %(function_name)s = &::%(function_name)s;
+#endif
+  if (!%(function_name)s) {
+    CleanUp(true);
+    return false;
+  }
+"""
+
+IMPL_MEMBER_CLEANUP_TEMPLATE = """  %(function_name)s = NULL;
+"""
+
+def main():
+  parser = optparse.OptionParser()
+  parser.add_option('--name')
+  parser.add_option('--output-cc')
+  parser.add_option('--output-h')
+  parser.add_option('--header')
+
+  parser.add_option('--bundled-header')
+  parser.add_option('--use-extern-c', action='store_true', default=False)
+  parser.add_option('--link-directly', type=int, default=0)
+
+  options, args = parser.parse_args()
+
+  if not options.name:
+    parser.error('Missing --name parameter')
+  if not options.output_cc:
+    parser.error('Missing --output-cc parameter')
+  if not options.output_h:
+    parser.error('Missing --output-h parameter')
+  if not options.header:
+    parser.error('Missing --header paramater')
+  if not args:
+    parser.error('No function names specified')
+
+  # Make sure we are always dealing with paths relative to source tree root
+  # to avoid issues caused by different relative path roots.
+  source_tree_root = os.path.abspath(
+    os.path.join(os.path.dirname(__file__), '..', '..'))
+  options.output_cc = os.path.relpath(options.output_cc, source_tree_root)
+  options.output_h = os.path.relpath(options.output_h, source_tree_root)
+
+  # Create a unique prefix, e.g. for header guards.
+  # Stick a known string at the beginning to ensure this doesn't begin
+  # with an underscore, which is reserved for the C++ implementation.
+  unique_prefix = ('LIBRARY_LOADER_' +
+                   re.sub(r'[\W]', '_', options.output_h).upper())
+
+  member_decls = []
+  member_init = []
+  member_cleanup = []
+  for fn in args:
+    member_decls.append(HEADER_MEMBER_TEMPLATE % {
+      'function_name': fn,
+      'unique_prefix': unique_prefix
+    })
+    member_init.append(IMPL_MEMBER_INIT_TEMPLATE % {
+      'function_name': fn,
+      'unique_prefix': unique_prefix
+    })
+    member_cleanup.append(IMPL_MEMBER_CLEANUP_TEMPLATE % {
+      'function_name': fn,
+      'unique_prefix': unique_prefix
+    })
+
+  header = options.header
+  if options.link_directly == 0 and options.bundled_header:
+    header = options.bundled_header
+  wrapped_header_include = '#include %s\n' % header
+
+  # Some libraries (e.g. libpci) have headers that cannot be included
+  # without extern "C", otherwise they cause the link to fail.
+  # TODO(phajdan.jr): This is a workaround for broken headers. Remove it.
+  if options.use_extern_c:
+    wrapped_header_include = 'extern "C" {\n%s\n}\n' % wrapped_header_include
+
+  # It seems cleaner just to have a single #define here and #ifdefs in bunch
+  # of places, rather than having a different set of templates, duplicating
+  # or complicating more code.
+  if options.link_directly == 0:
+    wrapped_header_include += '#define %s_DLOPEN\n' % unique_prefix
+  elif options.link_directly == 1:
+    wrapped_header_include += '#define %s_DT_NEEDED\n' % unique_prefix
+  else:
+    parser.error('Invalid value for --link-directly. Should be 0 or 1.')
+
+  # Make it easier for people to find the code generator just in case.
+  # Doing it this way is more maintainable, because it's going to work
+  # even if file gets moved without updating the contents.
+  generator_path = os.path.relpath(__file__, source_tree_root)
+
+  header_contents = HEADER_TEMPLATE % {
+    'generator_path': generator_path,
+    'unique_prefix': unique_prefix,
+    'wrapped_header_include': wrapped_header_include,
+    'class_name': options.name,
+    'member_decls': ''.join(member_decls),
+  }
+
+  impl_contents = IMPL_TEMPLATE % {
+    'generator_path': generator_path,
+    'unique_prefix': unique_prefix,
+    'generated_header_name': options.output_h,
+    'class_name': options.name,
+    'member_init': ''.join(member_init),
+    'member_cleanup': ''.join(member_cleanup),
+  }
+
+  header_file = open(os.path.join(source_tree_root, options.output_h), 'w')
+  try:
+    header_file.write(header_contents)
+  finally:
+    header_file.close()
+
+  impl_file = open(os.path.join(source_tree_root, options.output_cc), 'w')
+  try:
+    impl_file.write(impl_contents)
+  finally:
+    impl_file.close()
+
+  return 0
+
+if __name__ == '__main__':
+  sys.exit(main())