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