# 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("//build/config/c++/c++.gni")

group("linux") {
  visibility = [ "//:optimize_gn_gen" ]
}

# This is included by reference in the //build/config/compiler config that
# is applied to all targets. It is here to separate out the logic that is
# Linux-only.
config("compiler") {
}

# This is included by reference in the //build/config/compiler:runtime_library
# config that is applied to all targets. It is here to separate out the logic
# that is Linux-only. Please see that target for advice on what should go in
# :runtime_library vs. :compiler.
config("runtime_library") {
  # Set here because OS_CHROMEOS cannot be autodetected in build_config.h like OS_LINUX and the like.
  if (is_chromeos) {
    defines = [ "OS_CHROMEOS" ]
  }
  libs = []
  if ((!is_chromeos || default_toolchain != "//build/toolchain/cros:target") &&
      !use_custom_libcxx) {
    libs += [ "atomic" ]
  }

  # double framework, use prebuilt libc++.
  if (is_double_framework) {
    if (current_cpu == "x86") {
      libs += [ "${asdk_libs_dir}/ndk/libcxx/linux_x86/libc++.so" ]
    } else {
      libs += [ "${asdk_libs_dir}/ndk/libcxx/linux_x86_64/libc++.so" ]
    }
  }
}

config("executable_config") {
  cflags = [ "-fPIE" ]
  asmflags = [ "-fPIE" ]
  ldflags = [ "-pie" ]
}

config("x11") {
  libs = [
    "X11",
    "X11-xcb",
    "xcb",
    "Xcomposite",
    "Xcursor",
    "Xdamage",
    "Xext",
    "Xfixes",
    "Xi",
    "Xrender",
    "Xtst",
  ]
}

# Ensures all exported symbols are added to the dynamic symbol table.  This is
# necessary to expose Chrome's custom operator new() and operator delete() (and
# other memory-related symbols) to libraries.  Otherwise, they might
# (de)allocate memory on a different heap, which would spell trouble if pointers
# to heap-allocated memory are passed over shared library boundaries.
config("export_dynamic") {
  ldflags = [ "-rdynamic" ]
}