• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2016, Google Inc.
2#
3# Permission to use, copy, modify, and/or distribute this software for any
4# purpose with or without fee is hereby granted, provided that the above
5# copyright notice and this permission notice appear in all copies.
6#
7# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
10# SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
12# OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
13# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
14
15licenses(["notice"])
16
17exports_files(["LICENSE"])
18
19load(
20    ":BUILD.generated.bzl",
21    "crypto_headers",
22    "crypto_internal_headers",
23    "crypto_sources",
24    "crypto_sources_linux_x86_64",
25    "crypto_sources_linux_ppc64le",
26    "crypto_sources_mac_x86_64",
27    "fips_fragments",
28    "ssl_headers",
29    "ssl_internal_headers",
30    "ssl_sources",
31    "tool_sources",
32    "tool_headers",
33)
34
35config_setting(
36    name = "linux_x86_64",
37    values = {"cpu": "k8"},
38)
39
40config_setting(
41    name = "linux_ppc64le",
42    values = {"cpu": "ppc"},
43)
44
45config_setting(
46    name = "mac_x86_64",
47    values = {"cpu": "darwin"},
48)
49
50config_setting(
51    name = "windows_x86_64",
52    values = {"cpu": "x64_windows"},
53)
54
55config_setting(
56    name = "android",
57    values = {"crosstool_top": "//external:android/crosstool"}
58)
59
60posix_copts = [
61    # Assembler option --noexecstack adds .note.GNU-stack to each object to
62    # ensure that binaries can be built with non-executable stack.
63    "-Wa,--noexecstack",
64
65    # This is needed on Linux systems (at least) to get rwlock in pthread.
66    "-D_XOPEN_SOURCE=700",
67
68    # This list of warnings should match those in the top-level CMakeLists.txt.
69    "-Wall",
70    "-Werror",
71    "-Wformat=2",
72    "-Wsign-compare",
73    "-Wmissing-field-initializers",
74    "-Wwrite-strings",
75    "-Wshadow",
76    "-fno-common",
77
78    # Modern build environments should be able to set this to use atomic
79    # operations for reference counting rather than locks. However, it's
80    # known not to work on some Android builds.
81    # "-DOPENSSL_C11_ATOMIC",
82]
83
84boringssl_copts = select({
85    ":linux_x86_64": posix_copts,
86    ":linux_ppc64le": posix_copts,
87    ":mac_x86_64": posix_copts,
88    ":windows_x86_64": [
89        "-DWIN32_LEAN_AND_MEAN",
90        "-DOPENSSL_NO_ASM",
91    ],
92    "//conditions:default": ["-DOPENSSL_NO_ASM"],
93})
94
95crypto_sources_asm = select({
96    ":linux_x86_64": crypto_sources_linux_x86_64,
97    ":linux_ppc64le": crypto_sources_linux_ppc64le,
98    ":mac_x86_64": crypto_sources_mac_x86_64,
99    "//conditions:default": [],
100})
101
102# For C targets only (not C++), compile with C11 support.
103posix_copts_c11 = [
104    "-std=c11",
105    "-Wmissing-prototypes",
106    "-Wold-style-definition",
107    "-Wstrict-prototypes",
108]
109
110boringssl_copts_c11 = boringssl_copts + select({
111    ":linux_x86_64": posix_copts_c11,
112    ":linux_ppc64le": posix_copts_c11,
113    ":mac_x86_64": posix_copts_c11,
114    "//conditions:default": [],
115})
116
117# For C++ targets only (not C), compile with C++11 support.
118posix_copts_cxx = [
119    "-std=c++11",
120    "-Wmissing-declarations",
121]
122
123boringssl_copts_cxx = boringssl_copts + select({
124    ":linux_x86_64": posix_copts_cxx,
125    ":linux_ppc64le": posix_copts_cxx,
126    ":mac_x86_64": posix_copts_cxx,
127    "//conditions:default": [],
128})
129
130cc_library(
131    name = "crypto",
132    srcs = crypto_sources + crypto_internal_headers + crypto_sources_asm,
133    hdrs = crypto_headers + fips_fragments,
134    copts = boringssl_copts_c11,
135    includes = ["src/include"],
136    linkopts = select({
137        ":mac_x86_64": [],
138        # Android supports pthreads, but does not provide a libpthread
139        # to link against.
140        ":android": [],
141        ":windows_x86_64": ["-defaultlib:advapi32.lib"],
142        "//conditions:default": ["-lpthread"],
143    }),
144    visibility = ["//visibility:public"],
145)
146
147cc_library(
148    name = "ssl",
149    srcs = ssl_sources + ssl_internal_headers,
150    hdrs = ssl_headers,
151    copts = boringssl_copts_cxx,
152    includes = ["src/include"],
153    visibility = ["//visibility:public"],
154    deps = [
155        ":crypto",
156    ],
157)
158
159cc_binary(
160    name = "bssl",
161    srcs = tool_sources + tool_headers,
162    copts = boringssl_copts_cxx,
163    visibility = ["//visibility:public"],
164    deps = [":ssl"],
165)
166