# 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.

import("flags.gni")
import("//build/config/linux/pkg_config.gni")

config("ssl_preprocessor_flags") {
  if (use_openssl) {
    defines = [ "USE_OPENSSL" ]
  } else if (use_nss) {
    defines = [ "USE_NSS" ]
  }
}

# Config for system SSL on Linux.
if (is_linux && use_system_ssl) {
  pkg_config("system_ssl_config") {
    packages = [ "nss" ]
    defines = [ "USE_SYSTEM_SSL" ]
  }
}

# This meta-target will include the SSL library according to the build flags.
group("metassl") {
  direct_dependent_configs = [ ":ssl_preprocessor_flags" ]

  if (use_openssl) {
    assert(is_linux)
    deps = "//third_party/openssl"
    use_openssl = false
  } else if (use_system_ssl) {
    assert(is_linux)
    direct_dependent_configs = ":system_ssl_config"
  } else {
    deps = [ "//net/third_party/nss:ssl" ]
  }

  forward_dependent_configs_from = deps
}