Build Skia as a static library

- Roll GYP so that we get non-thin archives on Linux
- Add merge_static_libs.py
- Add skia_core_lib target which builds core, ports, opts*, and utils
- Replace dependencies on core/ports/opts/utils with skia_core_libs
- Rename exportable libraries with "skia_"
Review URL: https://codereview.appspot.com/6619049

git-svn-id: http://skia.googlecode.com/svn/trunk@5889 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/DEPS b/DEPS
index 10dbd41..016213e 100644
--- a/DEPS
+++ b/DEPS
@@ -9,7 +9,7 @@
 #
 deps = {
   "third_party/externals/angle" : "http://angleproject.googlecode.com/svn/trunk@1268",
-  "third_party/externals/gyp" : "http://gyp.googlecode.com/svn/trunk@1509",
+  "third_party/externals/gyp" : "http://gyp.googlecode.com/svn/trunk@1517",
   "third_party/externals/libjpeg" : "http://src.chromium.org/svn/trunk/src/third_party/libjpeg@125399",
   "third_party/externals/jsoncpp" : "http://src.chromium.org/svn/trunk/src/third_party/jsoncpp@125399",
   "third_party/externals/jsoncpp/source/include" : "http://jsoncpp.svn.sourceforge.net/svnroot/jsoncpp/trunk/jsoncpp/include@248",
diff --git a/Makefile b/Makefile
index 4de8bc6..aa14410 100644
--- a/Makefile
+++ b/Makefile
@@ -29,7 +29,12 @@
 
 BUILDTYPE ?= Debug
 CWD := $(shell pwd)
-ALL_TARGETS := core SampleApp bench gm tests tools
+ALL_TARGETS := skia_base_libs \
+               bench \
+               gm \
+               SampleApp \
+               tests \
+               tools
 
 ifneq (,$(findstring skia_os=android, $(GYP_DEFINES)))
 ifeq (,$(findstring android_make_apk=0, $(GYP_DEFINES)))
diff --git a/gyp/FileReaderApp.gyp b/gyp/FileReaderApp.gyp
index b56460b..bcd0f0d 100644
--- a/gyp/FileReaderApp.gyp
+++ b/gyp/FileReaderApp.gyp
@@ -18,11 +18,8 @@
         '../src/utils/mac/SkOSWindow_Mac.cpp',
       ],
       'dependencies': [
-        'core.gyp:core',
+        'skia_base_libs.gyp:skia_base_libs',
         'effects.gyp:effects',
-        'opts.gyp:opts',
-        'ports.gyp:ports',
-        'utils.gyp:utils',
         'views.gyp:views',
         'xml.gyp:xml',
       ],
diff --git a/gyp/SampleApp.gyp b/gyp/SampleApp.gyp
index 3920152..c33c67f 100644
--- a/gyp/SampleApp.gyp
+++ b/gyp/SampleApp.gyp
@@ -135,12 +135,10 @@
         '../samplecode/SampleFontCache.cpp',
       ],
       'dependencies': [
-        'core.gyp:core',
+        'skia_base_libs.gyp:skia_base_libs',
         'effects.gyp:effects',
         'images.gyp:images',
-        'ports.gyp:ports',
         'views.gyp:views',
-        'utils.gyp:utils',
         'animator.gyp:animator',
         'xml.gyp:xml',
         'experimental.gyp:experimental',
@@ -290,10 +288,6 @@
           'include_dirs': [
             '../src/gpu', # To pull gl/GrGLUtil.h
           ],
-          'dependencies': [
-            'gpu.gyp:gr',
-            'gpu.gyp:skgr',
-          ],
         }],
       ],
       'msvs_settings': {
diff --git a/gyp/SimpleCocoaApp.gyp b/gyp/SimpleCocoaApp.gyp
index dd02c41..3e17ad5 100644
--- a/gyp/SimpleCocoaApp.gyp
+++ b/gyp/SimpleCocoaApp.gyp
@@ -25,10 +25,7 @@
 
       ],
       'dependencies': [
-        'core.gyp:core',
-        'opts.gyp:opts',
-        'ports.gyp:ports',
-        'utils.gyp:utils',
+        'skia_base_libs.gyp:skia_base_libs',
         'views.gyp:views',
         'xml.gyp:xml',
       ],
diff --git a/gyp/SimpleiOSApp.gyp b/gyp/SimpleiOSApp.gyp
index ea702be..3678e7c 100644
--- a/gyp/SimpleiOSApp.gyp
+++ b/gyp/SimpleiOSApp.gyp
@@ -28,12 +28,9 @@
         '../experimental/SimpleiOSApp/SimpleiOSApp-Info.plist',
       ],
       'dependencies': [
-        'core.gyp:core',
+        'skia_base_libs.gyp:skia_base_libs',
         'effects.gyp:effects',
         'images.gyp:images',
-        'opts.gyp:opts',
-        'ports.gyp:ports',
-        'utils.gyp:utils',
         'views.gyp:views',
         'xml.gyp:xml',
       ],
diff --git a/gyp/animator.gyp b/gyp/animator.gyp
index b3c651c..942e849 100644
--- a/gyp/animator.gyp
+++ b/gyp/animator.gyp
@@ -6,7 +6,9 @@
   'targets': [
     {
       'target_name': 'animator',
+      'product_name': 'skia_animator',
       'type': 'static_library',
+      'standalone_static_library': 1,
       'include_dirs': [
         '../include/config',
         '../include/core',
diff --git a/gyp/bench.gyp b/gyp/bench.gyp
index 7a413e1..1524b72 100644
--- a/gyp/bench.gyp
+++ b/gyp/bench.gyp
@@ -15,11 +15,9 @@
         'bench.gypi'
       ],
       'dependencies': [
-        'core.gyp:core',
+        'skia_base_libs.gyp:skia_base_libs',
         'effects.gyp:effects',
         'images.gyp:images',
-        'ports.gyp:ports',
-        'utils.gyp:utils',
         'bench_timer',
       ],
       'conditions': [
@@ -28,10 +26,6 @@
             'include_dirs' : [
               '../src/gpu',
             ],
-            'dependencies': [
-              'gpu.gyp:gr',
-              'gpu.gyp:skgr',
-            ],
           },
         ],
       ],
@@ -54,7 +48,7 @@
         '../src/gpu',
       ],
       'dependencies': [
-        'core.gyp:core',
+        'skia_base_libs.gyp:skia_base_libs',
       ],
       'conditions': [
         [ 'skia_os not in ["mac", "ios"]', {
@@ -83,9 +77,6 @@
           ],
         }],
         ['skia_gpu == 1', {
-          'dependencies': [
-            'gpu.gyp:gr',
-          ],
           'sources': [
             '../bench/BenchGpuTimer_gl.h',
             '../bench/BenchGpuTimer_gl.cpp',
diff --git a/gyp/common_conditions.gypi b/gyp/common_conditions.gypi
index f8f283b..e8e2fca 100644
--- a/gyp/common_conditions.gypi
+++ b/gyp/common_conditions.gypi
@@ -324,7 +324,6 @@
         'SK_USE_POSIX_THREADS'
       ],
     }],
-
   ], # end 'conditions'
   # The Xcode SYMROOT must be at the root. See build/common.gypi in chromium for more details
   'xcode_settings': {
diff --git a/gyp/common_variables.gypi b/gyp/common_variables.gypi
index d2a3d10..1976dbe 100644
--- a/gyp/common_variables.gypi
+++ b/gyp/common_variables.gypi
@@ -52,21 +52,30 @@
       'skia_os%': '<(skia_os)',
 
       'conditions': [
-        ['skia_os == "win"', {
+        [ 'skia_os == "win"', {
           'os_posix%': 0,
         }, {
           'os_posix%': 1,
         }],
-        ['skia_os in ["linux", "freebsd", "openbsd", "solaris"]', {
+        [ 'skia_os in ["linux", "freebsd", "openbsd", "solaris"]', {
           'skia_arch_width%': 64,
         }, {
           'skia_arch_width%': 32,
         }],
-        ['skia_os == "android"', {
+        [ 'skia_os == "android"', {
           'skia_static_initializers%': 0,
         }, {
           'skia_static_initializers%': 1,
         }],
+        [ 'skia_os == "ios"', {
+          'skia_arch_type%': 'arm',
+          'armv7%': 1,
+          'arm_neon%': 0, # neon asm files known not to work with the ios build
+        },{ # skia_os is not ios
+          'skia_arch_type%': 'x86',
+          'armv7%': 0,
+          'arm_neon%': 0,
+        }],
       ],
 
       'skia_scalar%': 'float',
@@ -82,6 +91,8 @@
 
     # Re-define all variables defined within the level-2 'variables' dict,
     # so that siblings of the level-1 'variables' dict can see them.
+    'armv7%': '<(armv7)',
+    'arm_neon%': '<(arm_neon)',
     'skia_os%': '<(skia_os)',
     'os_posix%': '<(os_posix)',
     'skia_scalar%': '<(skia_scalar)',
@@ -89,6 +100,7 @@
     'skia_nv_path_rendering%': '<(skia_nv_path_rendering)',
     'skia_angle%': '<(skia_angle)',
     'skia_arch_width%': '<(skia_arch_width)',
+    'skia_arch_type%': '<(skia_arch_type)',
     'skia_directwrite%': '<(skia_directwrite)',
     'android_make_apk%': '<(android_make_apk)',
     'skia_nacl%': '<(skia_nacl)',
@@ -97,15 +109,6 @@
     'skia_static_initializers%': '<(skia_static_initializers)',
     'ios_sdk_version%': '6.0',
 
-    'conditions': [
-      ['skia_os == "ios"', {
-        'skia_arch_type%': 'arm',
-        'armv7%': 1,
-        'arm_neon%': 0, # neon asm files known not to work with the ios build
-      },{ # skia_os is not ios
-        'skia_arch_type%': 'x86',
-      }],
-    ],
     # These are referenced by our .gypi files that list files (e.g. core.gypi)
     #
     'skia_src_path%': '../src',
diff --git a/gyp/core.gyp b/gyp/core.gyp
index 134ca8a..228fd06 100644
--- a/gyp/core.gyp
+++ b/gyp/core.gyp
@@ -3,7 +3,9 @@
   'targets': [
     {
       'target_name': 'core',
+      'product_name': 'skia_core',
       'type': 'static_library',
+      'standalone_static_library': 1,
       'msvs_guid': 'B7760B5E-BFA8-486B-ACFD-49E3A6DE8E76',
 
       'includes': [
@@ -100,6 +102,24 @@
           '../include/pipe',
           'ext',
         ],
+        'conditions': [
+          [ 'skia_os == "mac"', {
+            'include_dirs': [
+              '../include/utils/mac',
+              '../third_party/freetype/include/**',
+            ],
+          }],
+          [ 'skia_os == "ios"', {
+            'include_dirs': [
+              '../include/utils/ios',
+            ],
+          }],
+          [ 'skia_os == "win"', {
+            'include_dirs': [
+              'config/win',
+            ],
+          }],
+        ],
       },
       'dependencies': [
         'opts.gyp:opts'
diff --git a/gyp/debugger.gyp b/gyp/debugger.gyp
index 5552ca1..cbaf492 100644
--- a/gyp/debugger.gyp
+++ b/gyp/debugger.gyp
@@ -118,12 +118,9 @@
         '<(moc_src_dir)/moc_SkGLWidget.cpp',
       ],
       'dependencies': [
-        'core.gyp:core',
+        'skia_base_libs.gyp:skia_base_libs',
         'images.gyp:images',
-        'ports.gyp:ports',
         'effects.gyp:effects',
-        'gpu.gyp:gr',
-        'gpu.gyp:skgr',
         'debugger_mocs',
       ],
       'link_settings': {
diff --git a/gyp/effects.gyp b/gyp/effects.gyp
index ef42cb9..e110c9f 100644
--- a/gyp/effects.gyp
+++ b/gyp/effects.gyp
@@ -2,7 +2,9 @@
   'targets': [
     {
       'target_name': 'effects',
+      'product_name': 'skia_effects',
       'type': 'static_library',
+      'standalone_static_library': 1,
       'includes': [
         'effects.gypi',
       ],
@@ -16,7 +18,7 @@
         ],
       },
       'dependencies': [
-        'core.gyp:core',
+        'skia_base_libs.gyp:skia_base_libs',
       ],
       'sources': [
         'effects.gypi', # Makes the gypi appear in IDEs (but does not modify the build).
@@ -26,10 +28,6 @@
           'include_dirs': [
             '../src/gpu',
           ],
-          'dependencies': [
-            'gpu.gyp:gr',
-            'gpu.gyp:skgr',
-          ],
         }],
       ],
     },
diff --git a/gyp/gm.gyp b/gyp/gm.gyp
index f519824..6f0fc3d 100644
--- a/gyp/gm.gyp
+++ b/gyp/gm.gyp
@@ -22,12 +22,10 @@
         '../src/pipe/utils/SamplePipeControllers.cpp',
       ],
       'dependencies': [
-        'core.gyp:core',
+        'skia_base_libs.gyp:skia_base_libs',
         'effects.gyp:effects',
         'images.gyp:images',
         'pdf.gyp:pdf',
-        'ports.gyp:ports',
-        'utils.gyp:utils',
       ],
       'conditions': [
         ['skia_os == "mac"', {
@@ -53,10 +51,6 @@
           'include_dirs': [
             '../src/gpu',
           ],
-          'dependencies': [
-            'gpu.gyp:gr',
-            'gpu.gyp:skgr',
-          ],
         }],
       ],
     },
diff --git a/gyp/gpu.gyp b/gyp/gpu.gyp
index 98ab257..0dc84ee 100644
--- a/gyp/gpu.gyp
+++ b/gyp/gpu.gyp
@@ -109,7 +109,9 @@
   'targets': [
     {
       'target_name': 'skgr',
+      'product_name': 'skia_skgr',
       'type': 'static_library',
+      'standalone_static_library': 1,
       'includes': [
         'gpu.gypi',
       ],
@@ -157,7 +159,9 @@
     },
     {
       'target_name': 'gr',
+      'product_name': 'skia_gr',
       'type': 'static_library',
+      'standalone_static_library': 1,
       'includes': [
         'gpu.gypi',
       ],
diff --git a/gyp/images.gyp b/gyp/images.gyp
index 7824cf9..2989afe 100644
--- a/gyp/images.gyp
+++ b/gyp/images.gyp
@@ -2,7 +2,9 @@
   'targets': [
     {
       'target_name': 'images',
+      'product_name': 'skia_images',
       'type': 'static_library',
+      'standalone_static_library': 1,
       'dependencies': [
         'libjpeg.gyp:*',
         'utils.gyp:utils',
diff --git a/gyp/opts.gyp b/gyp/opts.gyp
index e5ceb36..b8d7e22 100644
--- a/gyp/opts.gyp
+++ b/gyp/opts.gyp
@@ -20,7 +20,9 @@
     # separately as well.
     {
       'target_name': 'opts',
+      'product_name': 'skia_opts',
       'type': 'static_library',
+      'standalone_static_library': 1,
       'include_dirs': [
         '../include/config',
         '../include/core',
@@ -97,7 +99,9 @@
     # gcc to generate SSSE3 code.
     {
       'target_name': 'opts_ssse3',
+      'product_name': 'skia_opts_ssse3',
       'type': 'static_library',
+      'standalone_static_library': 1,
       'include_dirs': [
         '../include/config',
         '../include/core',
@@ -130,7 +134,9 @@
     # is very similar to the SSSE3 one.
     {
       'target_name': 'opts_neon',
+      'product_name': 'skia_opts_neon',
       'type': 'static_library',
+      'standalone_static_library': 1,
       'include_dirs': [
         '../include/config',
         '../include/core',
diff --git a/gyp/pdf.gyp b/gyp/pdf.gyp
index e7b0369..7b3b9ea 100644
--- a/gyp/pdf.gyp
+++ b/gyp/pdf.gyp
@@ -2,11 +2,11 @@
   'targets': [
     {
       'target_name': 'pdf',
+      'product_name': 'skia_pdf',
       'type': 'static_library',
+      'standalone_static_library': 1,
       'dependencies': [
-        'core.gyp:core',
-        'ports.gyp:ports',
-        'utils.gyp:utils',
+        'skia_base_libs.gyp:skia_base_libs',
         'zlib.gyp:zlib',
       ],
       'include_dirs': [
diff --git a/gyp/ports.gyp b/gyp/ports.gyp
index 1aa112f..f743ad4 100644
--- a/gyp/ports.gyp
+++ b/gyp/ports.gyp
@@ -3,7 +3,9 @@
   'targets': [
     {
       'target_name': 'ports',
+      'product_name': 'skia_ports',
       'type': 'static_library',
+      'standalone_static_library': 1,
       'dependencies': [
         'core.gyp:core',
         'sfnt.gyp:sfnt',
diff --git a/gyp/sfnt.gyp b/gyp/sfnt.gyp
index 17dd2d8..d4d9627 100644
--- a/gyp/sfnt.gyp
+++ b/gyp/sfnt.gyp
@@ -2,7 +2,9 @@
   'targets': [
     {
       'target_name': 'sfnt',
+      'product_name': 'skia_sfnt',
       'type': 'static_library',
+      'standalone_static_library': 1,
       'dependencies': [
         'core.gyp:core',
       ],
diff --git a/gyp/shapeops_demo.gyp b/gyp/shapeops_demo.gyp
index 25ac70a..b6718cb 100644
--- a/gyp/shapeops_demo.gyp
+++ b/gyp/shapeops_demo.gyp
@@ -65,12 +65,10 @@
         '../experimental/Intersection/TSearch.h',
       ],
       'dependencies': [
-        'core.gyp:core',
+        'skia_base_libs.gyp:skia_base_libs',
         'effects.gyp:effects',
         'images.gyp:images',
-        'ports.gyp:ports',
         'views.gyp:views',
-        'utils.gyp:utils',
         'animator.gyp:animator',
         'xml.gyp:xml',
         'svg.gyp:svg',
@@ -108,12 +106,6 @@
             '../experimental/Intersection/EdgeDemoApp.xib',
           ],
         }],
-        [ 'skia_gpu == 1', {
-          'dependencies': [
-            'gpu.gyp:gr',
-            'gpu.gyp:skgr',
-          ],
-        }],
       ],
       'msvs_settings': {
         'VCLinkerTool': {
diff --git a/gyp/shapeops_edge.gyp b/gyp/shapeops_edge.gyp
index cc62f3e..11fe4b2 100644
--- a/gyp/shapeops_edge.gyp
+++ b/gyp/shapeops_edge.gyp
@@ -107,23 +107,17 @@
         '../experimental/Intersection/thingsToDo.txt',
       ],
       'dependencies': [
-        'core.gyp:core',
+        'skia_base_libs.gyp:skia_base_libs',
         'effects.gyp:effects',
         'experimental.gyp:experimental',
         'images.gyp:images',
-        'ports.gyp:ports',
         'pdf.gyp:pdf',
-        'utils.gyp:utils',
       ],
       'conditions': [
         [ 'skia_gpu == 1', {
           'include_dirs': [
             '../src/gpu',
           ],
-          'dependencies': [
-            'gpu.gyp:gr',
-            'gpu.gyp:skgr',
-          ],
         }],
       ],
     },
diff --git a/gyp/skia_base_libs.gyp b/gyp/skia_base_libs.gyp
new file mode 100644
index 0000000..a611d30
--- /dev/null
+++ b/gyp/skia_base_libs.gyp
@@ -0,0 +1,47 @@
+# The minimal set of static libraries for basic Skia functionality.
+{
+  'variables': {
+    'component_libs': [
+      'core.gyp:core',
+      'opts.gyp:opts',
+      'ports.gyp:ports',
+      'utils.gyp:utils',
+    ],
+    'conditions': [
+      [ 'skia_arch_type == "x86"', {
+        'component_libs': [
+          'opts.gyp:opts_ssse3',
+        ],
+      }],
+      [ 'arm_neon == 1', {
+        'component_libs': [
+          'opts.gyp:opts_neon',
+        ],
+      }],
+      [ 'skia_gpu', {
+        'component_libs': [
+          'gpu.gyp:gr',
+          'gpu.gyp:skgr',
+        ],
+      }],
+    ],
+  },
+  'targets': [
+    {
+      'target_name': 'skia_base_libs',
+      'type': 'none',
+      'dependencies': [
+        '<@(component_libs)',
+      ],
+      'export_dependent_settings': [
+        '<@(component_libs)',
+      ],
+    },
+  ],
+}
+
+# Local Variables:
+# tab-width:2
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=2 shiftwidth=2:
diff --git a/gyp/svg.gyp b/gyp/svg.gyp
index 9e90f28..3952fd7 100644
--- a/gyp/svg.gyp
+++ b/gyp/svg.gyp
@@ -2,7 +2,9 @@
   'targets': [
     {
       'target_name': 'svg',
+      'product_name': 'skia_svg',
       'type': 'static_library',
+      'standalone_static_library': 1,
       'include_dirs': [
         '../include/config',
         '../include/core',
diff --git a/gyp/tests.gyp b/gyp/tests.gyp
index 874bb7f..c91388c 100644
--- a/gyp/tests.gyp
+++ b/gyp/tests.gyp
@@ -103,24 +103,18 @@
         '../src/pipe/utils/SamplePipeControllers.cpp',
       ],
       'dependencies': [
-        'core.gyp:core',
+        'skia_base_libs.gyp:skia_base_libs',
         'effects.gyp:effects',
         'experimental.gyp:experimental',
         'images.gyp:images',
-        'ports.gyp:ports',
         'pdf.gyp:pdf',
         'tools.gyp:picture_utils',
-        'utils.gyp:utils',
       ],
       'conditions': [
         [ 'skia_gpu == 1', {
           'include_dirs': [
             '../src/gpu',
           ],
-          'dependencies': [
-            'gpu.gyp:gr',
-            'gpu.gyp:skgr',
-          ],
         }],
       ],
     },
diff --git a/gyp/tools.gyp b/gyp/tools.gyp
index 69c6cae..f6e9a93 100644
--- a/gyp/tools.gyp
+++ b/gyp/tools.gyp
@@ -31,11 +31,9 @@
         '../tools/skdiff_main.cpp',
       ],
       'dependencies': [
-        'core.gyp:core',
+        'skia_base_libs.gyp:skia_base_libs',
         'effects.gyp:effects',
         'images.gyp:images',
-        'ports.gyp:ports',
-        'utils.gyp:utils',
       ],
     },
     {
@@ -45,11 +43,9 @@
         '../tools/skhello.cpp',
       ],
       'dependencies': [
-        'core.gyp:core',
+        'skia_base_libs.gyp:skia_base_libs',
         'effects.gyp:effects',
         'images.gyp:images',
-        'ports.gyp:ports',
-        'utils.gyp:utils',
       ],
     },
     {
@@ -59,11 +55,9 @@
         '../tools/skimage_main.cpp',
       ],
       'dependencies': [
-        'core.gyp:core',
+        'skia_base_libs.gyp:skia_base_libs',
         'effects.gyp:effects',
         'images.gyp:images',
-        'ports.gyp:ports',
-        'utils.gyp:utils',
       ],
     },
     {
@@ -76,8 +70,7 @@
         '../src/pipe/utils/',
       ],
       'dependencies': [
-        'core.gyp:core',
-        'ports.gyp:ports',
+        'skia_base_libs.gyp:skia_base_libs',
         'tools.gyp:picture_renderer',
         'tools.gyp:picture_utils',
       ],
@@ -97,47 +90,34 @@
         '../bench',
       ],
       'dependencies': [
-        'core.gyp:core',
+        'skia_base_libs.gyp:skia_base_libs',
         'effects.gyp:effects',
-        'ports.gyp:ports',
         'tools.gyp:picture_utils',
         'tools.gyp:picture_renderer',
         'bench.gyp:bench_timer',
       ],
     },
     {
-     'target_name': 'picture_renderer',
-     'type': 'static_library',
-     'sources': [
+      'target_name': 'picture_renderer',
+      'type': 'static_library',
+      'sources': [
         '../tools/PictureRenderer.cpp',
         '../src/pipe/utils/SamplePipeControllers.h',
         '../src/pipe/utils/SamplePipeControllers.cpp',
-     ],
-     'include_dirs': [
-       '../src/pipe/utils/',
-       '../src/utils/',
-     ],
-     'dependencies': [
-        'core.gyp:core',
+      ],
+      'include_dirs': [
+        '../src/pipe/utils/',
+        '../src/utils/',
+      ],
+      'dependencies': [
+        'skia_base_libs.gyp:skia_base_libs',
         'effects.gyp:effects',
         'images.gyp:images',
         'tools.gyp:picture_utils',
-        'utils.gyp:utils',
-     ],
-     'export_dependent_settings': [
-       'images.gyp:images',
-     ],
-     'conditions': [
-       ['skia_gpu == 1', {
-         'dependencies': [
-           'gpu.gyp:gr',
-           'gpu.gyp:skgr',
-         ],
-         'export_dependent_settings': [
-            'gpu.gyp:gr',
-         ],
-       }],
-    ],
+      ],
+      'export_dependent_settings': [
+        'images.gyp:images',
+      ],
     },
     {
       'target_name': 'picture_utils',
@@ -147,7 +127,7 @@
         '../tools/picture_utils.h',
       ],
       'dependencies': [
-        'core.gyp:core',
+        'skia_base_libs.gyp:skia_base_libs',
       ],
     },
     {
@@ -157,11 +137,9 @@
         '../tools/pinspect.cpp',
       ],
       'dependencies': [
-        'core.gyp:core',
+        'skia_base_libs.gyp:skia_base_libs',
         'effects.gyp:effects',
         'images.gyp:images',
-        'ports.gyp:ports',
-        'utils.gyp:utils',
       ],
     },
     {
@@ -174,11 +152,9 @@
         '../tools/filtermain.cpp',
       ],
       'dependencies': [
-        'core.gyp:core',
+        'skia_base_libs.gyp:skia_base_libs',
         'effects.gyp:effects',
         'images.gyp:images',
-        'ports.gyp:ports',
-        'utils.gyp:utils',
       ],
     },
   ],
diff --git a/gyp/utils.gyp b/gyp/utils.gyp
index e5274ed..cc25349 100644
--- a/gyp/utils.gyp
+++ b/gyp/utils.gyp
@@ -2,11 +2,12 @@
   'targets': [
     {
       'target_name': 'utils',
-      'dependencies': [
-        'core.gyp:core',
-      ],
+      'product_name': 'skia_utils',
       'type': 'static_library',
+      'standalone_static_library': 1,
       'include_dirs': [
+        '../include/config',
+        '../include/core',
         '../include/effects',
         '../include/pipe',
         '../include/utils',
diff --git a/gyp/views.gyp b/gyp/views.gyp
index db748c7..ccb61e1 100644
--- a/gyp/views.gyp
+++ b/gyp/views.gyp
@@ -8,7 +8,9 @@
   'targets': [
     {
       'target_name': 'views',
+      'product_name': 'skia_views',
       'type': 'static_library',
+      'standalone_static_library': 1,
       'include_dirs': [
         '../include/config',
         '../include/core',
@@ -110,11 +112,6 @@
             '../src/views/win/skia_win.cpp',
           ],
         }],
-        [ 'skia_gpu == 1', {
-          'include_dirs': [
-            '../include/gpu',
-          ],
-        }],
       ],
       'direct_dependent_settings': {
         'include_dirs': [
diff --git a/gyp/xml.gyp b/gyp/xml.gyp
index b7878e2..b7fdb83 100644
--- a/gyp/xml.gyp
+++ b/gyp/xml.gyp
@@ -2,7 +2,9 @@
   'targets': [
     {
       'target_name': 'xml',
+      'product_name': 'skia_xml',
       'type': 'static_library',
+      'standalone_static_library': 1,
       'include_dirs': [
         '../include/config',
         '../include/core',
diff --git a/gyp/xps.gyp b/gyp/xps.gyp
index 1337fd3..e5b7c0d 100644
--- a/gyp/xps.gyp
+++ b/gyp/xps.gyp
@@ -2,11 +2,12 @@
   'targets': [
     {
       'target_name': 'xps',
+      'product_name': 'skia_xps',
       'type': 'static_library',
+      'standalone_static_library': 1,
       'dependencies': [
-        'core.gyp:core',
+        'skia_base_libs.gyp:skia_base_libs',
         'images.gyp:images',
-        'utils.gyp:utils',
       ],
       'include_dirs': [
         '../include/device/xps',
diff --git a/skia.gyp b/skia.gyp
index 559ce75..d78435e 100644
--- a/skia.gyp
+++ b/skia.gyp
@@ -15,6 +15,9 @@
       'target_name': 'all',
       'type': 'none',
       'dependencies': [
+        # The minimal set of static libraries for basic Skia functionality.
+        'gyp/skia_base_libs.gyp:skia_base_libs',
+
         'gyp/bench.gyp:bench',
         'gyp/gm.gyp:gm',
         'gyp/SampleApp.gyp:SampleApp',
diff --git a/tools/merge_static_libs.py b/tools/merge_static_libs.py
new file mode 100755
index 0000000..842be18
--- /dev/null
+++ b/tools/merge_static_libs.py
@@ -0,0 +1,66 @@
+#!/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 os
+import shutil
+import subprocess
+import sys
+import tempfile
+
+def _Usage():
+  print 'Usage: merge_static_libs OUTPUT_LIB INPUT_LIB [INPUT_LIB]*'
+  sys.exit(1)
+
+def MergeLibs(in_libs, out_lib):
+  """ Merges multiple static libraries into one.
+  
+  in_libs: list of paths to static libraries to be merged
+  out_lib: path to the static library which will be created from in_libs
+  """
+  if os.name == 'posix':
+    tempdir = tempfile.mkdtemp()
+    abs_in_libs = []
+    for in_lib in in_libs:
+      abs_in_libs.append(os.path.abspath(in_lib))
+    curdir = os.getcwd()
+    os.chdir(tempdir)
+    objects = []
+    ar = os.environ.get('AR', 'ar')
+    for in_lib in abs_in_libs:
+      proc = subprocess.Popen([ar, '-t', in_lib], stdout=subprocess.PIPE)
+      proc.wait()
+      obj_str = proc.communicate()[0]
+      current_objects = obj_str.rstrip().split('\n')
+      proc = subprocess.Popen([ar, '-x', in_lib], stdout=subprocess.PIPE,
+                              stderr=subprocess.STDOUT)
+      proc.wait()
+      if proc.poll() == 0:
+        # The static library is non-thin, and we extracted objects
+        for object in current_objects:
+          objects.append(os.path.abspath(object))
+      elif 'thin archive' in proc.communicate()[0]:
+        # The static library is thin, so it contains the paths to its objects
+        for object in current_objects:
+          objects.append(object)
+      else:
+        raise Exception('Failed to extract objects from %s.' % in_lib)
+    os.chdir(curdir)
+    if not subprocess.call([ar, '-crs', out_lib] + objects) == 0:
+      raise Exception('Failed to add object files to %s' % out_lib)
+    shutil.rmtree(tempdir)
+  elif os.name == 'nt':
+    subprocess.call(['lib', '/OUT:%s' % out_lib] + in_libs)
+  else:
+    raise Exception('Error: Your platform is not supported')
+
+def Main():
+  if len(sys.argv) < 3:
+    _Usage()
+  out_lib = sys.argv[1]
+  in_libs = sys.argv[2:]
+  MergeLibs(in_libs, out_lib)
+
+if '__main__' == __name__:
+  sys.exit(Main())