Only configure the SSL library in one place.

Build settings now use use_openssl in both Chromium and standalone builds. It
moves all the platform-specific SSL-related build checks to be conditioned on
this flag as appropriate.

This is to avoid colliding with Chromium's transition away from NSS.

This is a fixup of https://webrtc-codereview.appspot.com/29559004 to avoid
breaking use_legacy_ssl_defaults.

BUG=chromium:413497
R=henrike@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/24109004

git-svn-id: http://webrtc.googlecode.com/svn/trunk/webrtc@7537 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/base/BUILD.gn b/base/BUILD.gn
index be53e40..1c2527a 100644
--- a/base/BUILD.gn
+++ b/base/BUILD.gn
@@ -40,7 +40,7 @@
   ]
 }
 
-config("no_openssl_config") {
+config("nss_config") {
   defines = [
     "SSL_USE_NSS",
     "HAVE_NSS_SSL_H",
@@ -465,24 +465,30 @@
       "opensslstreamadapter.h",
     ]
   } else {
-    public_configs += [ ":no_openssl_config" ]
+    public_configs += [ ":nss_config" ]
+    if (rtc_build_ssl) {
+      if (build_with_chromium) {
+        deps += [ "//crypto:platform" ]
+      } else {
+        deps += [ "//net/third_party/nss/ssl:libssl" ]
+        if (is_linux) {
+          deps += [ ":linux_system_ssl" ]
+        } else {
+          deps += [
+            "//third_party/nss:nspr",
+            "//third_party/nss:nss",
+          ]
+        }
+      }
+    } else {
+      configs += [ "external_ssl_library" ]
+    }
     sources += [
       "nssidentity.cc",
       "nssidentity.h",
       "nssstreamadapter.cc",
       "nssstreamadapter.h",
     ]
-    if (is_mac || is_ios || is_win) {
-      if (rtc_build_ssl) {
-        deps += [
-          "//net/third_party/nss/ssl:libssl",
-          "//third_party/nss:nspr",
-          "//third_party/nss:nss",
-        ]
-      } else {
-        configs += [ "external_ssl_library" ]
-      }
-    }
   }
 
   if (is_android) {
@@ -518,13 +524,9 @@
 
   if (is_linux) {
     libs += [
-      "crypto",
       "dl",
       "rt",
     ]
-    if (rtc_build_ssl) {
-      configs += [ "//third_party/nss:system_nss_no_ssl_config" ]
-    }
   }
 
   if (is_mac) {
@@ -595,16 +597,4 @@
       "linux.h",
     ]
   }
-
-  if (is_posix && !is_mac && !is_ios && !is_android) {
-    if (build_with_chromium) {
-      deps += [ "//crypto:platform" ]
-    } else {
-      if (rtc_build_ssl) {
-        deps += [ ":linux_system_ssl" ]
-      } else {
-        configs += [ "external_ssl_library" ]
-      }
-    }
-  }
 }
diff --git a/base/base.gyp b/base/base.gyp
index 569db74..2fd64ba 100644
--- a/base/base.gyp
+++ b/base/base.gyp
@@ -539,32 +539,31 @@
                 ],
               },
             }],
-            ['OS=="mac" or OS=="ios" or OS=="win"', {
+            ['build_ssl==1', {
               'conditions': [
-                ['build_ssl==1', {
+                # On some platforms, the rest of NSS is bundled. On others,
+                # it's pulled from the system.
+                ['OS == "mac" or OS == "ios" or OS == "win"', {
                   'dependencies': [
                     '<(DEPTH)/net/third_party/nss/ssl.gyp:libssl',
                     '<(DEPTH)/third_party/nss/nss.gyp:nspr',
                     '<(DEPTH)/third_party/nss/nss.gyp:nss',
                   ],
-                }, {
-                  'include_dirs': [
-                    '<(ssl_root)',
+                }],
+                ['os_posix == 1 and OS != "mac" and OS != "ios" and OS != "android"', {
+                  'dependencies': [
+                    '<(DEPTH)/build/linux/system.gyp:ssl',
                   ],
                 }],
               ],
+            }, {
+              'include_dirs': [
+                '<(ssl_root)',
+              ],
             }],
           ],
         }],
         ['OS == "android"', {
-          'defines': [
-            'HAVE_OPENSSL_SSL_H'
-          ],
-          'direct_dependent_settings': {
-            'defines': [
-              'HAVE_OPENSSL_SSL_H'
-            ],
-          },
           'link_settings': {
             'libraries': [
               '-llog',
@@ -572,20 +571,6 @@
             ],
           },
         }, {
-          'conditions': [
-            ['use_legacy_ssl_defaults!=1', {
-              'defines': [
-                'HAVE_NSS_SSL_H',
-                'SSL_USE_NSS_RNG',
-              ],
-              'direct_dependent_settings': {
-                'defines': [
-                  'HAVE_NSS_SSL_H',
-                  'SSL_USE_NSS_RNG',
-                ],
-              },
-            }],
-          ],
           'sources!': [
             'ifaddrs-android.cc',
             'ifaddrs-android.h',
@@ -627,21 +612,6 @@
               '-lrt',
             ],
           },
-          'conditions': [
-            ['build_ssl==1', {
-              'link_settings': {
-                'libraries': [
-                  '<!@(<(pkg-config) --libs-only-l nss | sed -e "s/-lssl3//")',
-                ],
-              },
-              'cflags': [
-                '<!@(<(pkg-config) --cflags nss)',
-              ],
-              'ldflags': [
-                '<!@(<(pkg-config) --libs-only-L --libs-only-other nss)',
-              ],
-            }],
-          ],
         }, {
           'sources!': [
             'dbus.cc',
@@ -757,19 +727,6 @@
             'linux.h',
           ],
         }],
-        ['os_posix == 1 and OS != "mac" and OS != "ios" and OS != "android"', {
-          'conditions': [
-            ['build_ssl==1', {
-              'dependencies': [
-                '<(DEPTH)/build/linux/system.gyp:ssl',
-              ],
-            }, {
-              'include_dirs': [
-                '<(ssl_root)',
-              ],
-            }],
-          ],
-        }],
       ],
     },
   ],