blob: 68a17a604383f93e9d5722c71d0883838a5e24af [file] [log] [blame]
David Benjaminc895d6b2016-08-11 13:26:41 -04001# 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_mac_x86_64",
Robert Sloan8ff03552017-06-14 12:40:58 -070026 "fips_fragments",
David Benjaminc895d6b2016-08-11 13:26:41 -040027 "ssl_headers",
28 "ssl_internal_headers",
David Benjaminf31229b2017-01-25 14:08:15 -050029 "ssl_c_sources",
30 "ssl_cc_sources",
David Benjaminc895d6b2016-08-11 13:26:41 -040031 "tool_sources",
32 "tool_headers",
33)
34
35config_setting(
36 name = "linux_x86_64",
37 values = {"cpu": "k8"},
38)
39
40config_setting(
41 name = "mac_x86_64",
42 values = {"cpu": "darwin"},
43)
44
45boringssl_copts = [
46 # Assembler option --noexecstack adds .note.GNU-stack to each object to
47 # ensure that binaries can be built with non-executable stack.
48 "-Wa,--noexecstack",
49
50 # This is needed on Linux systems (at least) to get rwlock in pthread.
51 "-D_XOPEN_SOURCE=700",
52
53 # This list of warnings should match those in the top-level CMakeLists.txt.
54 "-Wall",
55 "-Werror",
56 "-Wformat=2",
57 "-Wsign-compare",
58 "-Wmissing-field-initializers",
59 "-Wwrite-strings",
60 "-Wshadow",
61 "-fno-common",
62
63 # Modern build environments should be able to set this to use atomic
64 # operations for reference counting rather than locks. However, it's
65 # known not to work on some Android builds.
66 # "-DOPENSSL_C11_ATOMIC",
67] + select({
68 ":linux_x86_64": [],
69 ":mac_x86_64": [],
70 "//conditions:default": ["-DOPENSSL_NO_ASM"],
71})
72
73crypto_sources_asm = select({
74 ":linux_x86_64": crypto_sources_linux_x86_64,
75 ":mac_x86_64": crypto_sources_mac_x86_64,
76 "//conditions:default": [],
77})
78
79# For C targets only (not C++), compile with C11 support.
80boringssl_copts_c11 = boringssl_copts + [
81 "-std=c11",
82 "-Wmissing-prototypes",
83 "-Wold-style-definition",
84 "-Wstrict-prototypes",
85]
86
87# For C targets only (not C++), compile with C11 support.
88boringssl_copts_cxx = boringssl_copts + [
89 "-std=c++11",
90 "-Wmissing-declarations",
91]
92
93cc_library(
94 name = "crypto",
95 srcs = crypto_sources + crypto_internal_headers + crypto_sources_asm,
Robert Sloan8ff03552017-06-14 12:40:58 -070096 hdrs = crypto_headers + fips_fragments,
David Benjaminc895d6b2016-08-11 13:26:41 -040097 copts = boringssl_copts_c11,
98 includes = ["src/include"],
99 linkopts = select({
100 ":mac_x86_64": [],
101 "//conditions:default": ["-lpthread"],
102 }),
103 visibility = ["//visibility:public"],
104)
105
106cc_library(
107 name = "ssl",
David Benjaminf31229b2017-01-25 14:08:15 -0500108 srcs = ssl_c_sources + ssl_internal_headers,
David Benjaminc895d6b2016-08-11 13:26:41 -0400109 hdrs = ssl_headers,
110 copts = boringssl_copts_c11,
111 includes = ["src/include"],
112 visibility = ["//visibility:public"],
David Benjaminf31229b2017-01-25 14:08:15 -0500113 deps = [":crypto", ":ssl_cc"],
114)
115
116cc_library(
117 name = "ssl_cc",
118 srcs = ssl_cc_sources + ssl_internal_headers,
119 hdrs = ssl_headers,
120 copts = boringssl_copts,
121 includes = ["src/include"],
David Benjaminc895d6b2016-08-11 13:26:41 -0400122 deps = [":crypto"],
123)
124
125cc_binary(
126 name = "bssl",
David Benjaminf0c4a6c2016-08-11 13:26:41 -0400127 srcs = tool_sources + tool_headers,
David Benjaminc895d6b2016-08-11 13:26:41 -0400128 copts = boringssl_copts_cxx,
129 visibility = ["//visibility:public"],
130 deps = [":ssl"],
131)