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