Linux: change gyp and add a shim header to build with system speex.

This will be useful for Linux distributions shipping Chromium.
The default setting is still to build with the bundled speex library.

More changes will be required (in src). This is the part in deps.

BUG=68524
TEST=none
Review URL: http://codereview.chromium.org/5990013

git-svn-id: http://src.chromium.org/svn/trunk/deps/third_party/speex@70427 4ff67af0-8c30-449e-8e8b-ad334ec8d88c
diff --git a/speex.gyp b/speex.gyp
index 1987e97..1afd70e 100644
--- a/speex.gyp
+++ b/speex.gyp
@@ -3,86 +3,116 @@
 # found in the LICENSE file.
 
 {
-  'targets': [
-    {
-      'target_name': 'libspeex',
-      'product_name': 'speex',
-      'type': '<(library)',
-      'sources': [
-        'libspeex/arch.h',
-        'libspeex/bits.c',
-        'libspeex/cb_search.c',
-        'libspeex/cb_search.h',
-        'libspeex/exc_10_16_table.c',
-        'libspeex/exc_10_32_table.c',
-        'libspeex/exc_20_32_table.c',
-        'libspeex/exc_5_256_table.c',
-        'libspeex/exc_5_64_table.c',
-        'libspeex/exc_8_128_table.c',
-        'libspeex/filters.c',
-        'libspeex/filters.h',
-        'libspeex/gain_table.c',
-        'libspeex/gain_table_lbr.c',
-        'libspeex/hexc_10_32_table.c',
-        'libspeex/hexc_table.c',
-        'libspeex/high_lsp_tables.c',
-        'libspeex/lpc.c',
-        'libspeex/lpc.h',
-        'libspeex/lsp.c',
-        'libspeex/lsp.h',
-        'libspeex/lsp_tables_nb.c',
-        'libspeex/ltp.c',
-        'libspeex/ltp.h',
-        'libspeex/math_approx.h',
-        'libspeex/modes.c',
-        'libspeex/modes.h',
-        'libspeex/modes_wb.c',
-        'libspeex/nb_celp.c',
-        'libspeex/nb_celp.h',
-        'libspeex/os_support.h',
-        'libspeex/pseudofloat.h',
-        'libspeex/quant_lsp.c',
-        'libspeex/quant_lsp.h',
-        'libspeex/sb_celp.c',
-        'libspeex/sb_celp.h',
-        'libspeex/speex.c',
-        'libspeex/speex_callbacks.c',
-        'libspeex/speex_header.c',
-        'libspeex/stack_alloc.h',
-        'libspeex/stereo.c',
-        'libspeex/vbr.c',
-        'libspeex/vbr.h',
-        'libspeex/vq.c',
-        'libspeex/vq.h',
-        'libspeex/window.c',
-        'include/speex/speex.h',
-        'include/speex/speex_bits.h',
-        'include/speex/speex_buffer.h',
-        'include/speex/speex_callbacks.h',
-        'include/speex/speex_echo.h',
-        'include/speex/speex_header.h',
-        'include/speex/speex_jitter.h',
-        'include/speex/speex_preprocess.h',
-        'include/speex/speex_resampler.h',
-        'include/speex/speex_stereo.h',
-        'include/speex/speex_types.h',
+  'variables': {
+    'use_system_speex%': 0,
+  },
+  'conditions': [
+    ['use_system_speex==0', {
+      'targets': [
+        {
+          'target_name': 'libspeex',
+          'product_name': 'speex',
+          'type': '<(library)',
+          'sources': [
+            'libspeex/arch.h',
+            'libspeex/bits.c',
+            'libspeex/cb_search.c',
+            'libspeex/cb_search.h',
+            'libspeex/exc_10_16_table.c',
+            'libspeex/exc_10_32_table.c',
+            'libspeex/exc_20_32_table.c',
+            'libspeex/exc_5_256_table.c',
+            'libspeex/exc_5_64_table.c',
+            'libspeex/exc_8_128_table.c',
+            'libspeex/filters.c',
+            'libspeex/filters.h',
+            'libspeex/gain_table.c',
+            'libspeex/gain_table_lbr.c',
+            'libspeex/hexc_10_32_table.c',
+            'libspeex/hexc_table.c',
+            'libspeex/high_lsp_tables.c',
+            'libspeex/lpc.c',
+            'libspeex/lpc.h',
+            'libspeex/lsp.c',
+            'libspeex/lsp.h',
+            'libspeex/lsp_tables_nb.c',
+            'libspeex/ltp.c',
+            'libspeex/ltp.h',
+            'libspeex/math_approx.h',
+            'libspeex/modes.c',
+            'libspeex/modes.h',
+            'libspeex/modes_wb.c',
+            'libspeex/nb_celp.c',
+            'libspeex/nb_celp.h',
+            'libspeex/os_support.h',
+            'libspeex/pseudofloat.h',
+            'libspeex/quant_lsp.c',
+            'libspeex/quant_lsp.h',
+            'libspeex/sb_celp.c',
+            'libspeex/sb_celp.h',
+            'libspeex/speex.c',
+            'libspeex/speex_callbacks.c',
+            'libspeex/speex_header.c',
+            'libspeex/stack_alloc.h',
+            'libspeex/stereo.c',
+            'libspeex/vbr.c',
+            'libspeex/vbr.h',
+            'libspeex/vq.c',
+            'libspeex/vq.h',
+            'libspeex/window.c',
+            'include/speex/speex.h',
+            'include/speex/speex_bits.h',
+            'include/speex/speex_buffer.h',
+            'include/speex/speex_callbacks.h',
+            'include/speex/speex_echo.h',
+            'include/speex/speex_header.h',
+            'include/speex/speex_jitter.h',
+            'include/speex/speex_preprocess.h',
+            'include/speex/speex_resampler.h',
+            'include/speex/speex_stereo.h',
+            'include/speex/speex_types.h',
+          ],
+          'defines': [
+            'FLOATING_POINT',
+            'EXPORT=',
+            'USE_ALLOCA',
+            'inline=__inline',
+          ],
+          'include_dirs': [
+            'include',
+            'libspeex',
+          ],
+          'direct_dependent_settings': {
+            'include_dirs': [
+              'include',  # Clients expect <speex/speex.h> to be a system header.
+            ],
+          },
+        },
       ],
-      'defines': [
-        'FLOATING_POINT',
-        'EXPORT=',
-        'USE_ALLOCA',
-        'inline=__inline',
+    }, { # use_system_speex != 0
+      'targets': [
+        {
+          'target_name': 'libspeex',
+          'type': 'settings',
+          'direct_dependent_settings': {
+            'cflags': [
+              '<!@(pkg-config --cflags speex)',
+            ],
+            'defines': [
+              'USE_SYSTEM_SPEEX',
+            ],
+          },
+          'link_settings': {
+            'ldflags': [
+              '<!@(pkg-config --libs-only-L --libs-only-other speex)',
+            ],
+            'libraries': [
+              '<!@(pkg-config --libs-only-l speex)',
+            ],
+          },
+        },
       ],
-      'include_dirs': [
-        'include',
-        'libspeex',
-      ],
-      'direct_dependent_settings': {
-        'include_dirs': [
-          'include',  # Clients expect <speex/speex.h> to be a system header.
-        ],
-      },
-    },
+    }],
   ],
 }
 
diff --git a/speex.h b/speex.h
new file mode 100644
index 0000000..39591ce
--- /dev/null
+++ b/speex.h
@@ -0,0 +1,18 @@
+// 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.
+
+#ifndef THIRD_PARTY_SPEEX_SPEEX_H_
+#define THIRD_PARTY_SPEEX_SPEEX_H_
+#pragma once
+
+// This is a shim header to include the right speex header.
+// Use this instead of referencing the speex header directly.
+
+#if defined(USE_SYSTEM_SPEEX)
+#include <speex/speex.h>
+#else
+#include "third_party/speex/include/speex/speex.h"
+#endif
+
+#endif  // THIRD_PARTY_SPEEX_SPEEX_H_