blob: af7bd303fc1667eaa1a04dcbdd7571f57211248d [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",
Garret Kelly0da939d2017-06-06 16:41:36 -040026 "fips_fragments",
Adam Langley01867872016-06-30 14:16:59 -070027 "ssl_headers",
28 "ssl_internal_headers",
Yun Pengd3632472017-07-28 13:17:13 +020029 "ssl_sources",
Adam Langley01867872016-06-30 14:16:59 -070030 "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
Yun Pengd3632472017-07-28 13:17:13 +020044config_setting(
45 name = "windows_x86_64",
46 values = {"cpu": "x64_windows"},
47)
48
49posix_copts = [
Adam Langley01867872016-06-30 14:16:59 -070050 # Assembler option --noexecstack adds .note.GNU-stack to each object to
51 # ensure that binaries can be built with non-executable stack.
52 "-Wa,--noexecstack",
53
54 # This is needed on Linux systems (at least) to get rwlock in pthread.
55 "-D_XOPEN_SOURCE=700",
56
Adam Langley01867872016-06-30 14:16:59 -070057 # This list of warnings should match those in the top-level CMakeLists.txt.
58 "-Wall",
59 "-Werror",
60 "-Wformat=2",
61 "-Wsign-compare",
62 "-Wmissing-field-initializers",
63 "-Wwrite-strings",
64 "-Wshadow",
65 "-fno-common",
66
67 # Modern build environments should be able to set this to use atomic
68 # operations for reference counting rather than locks. However, it's
69 # known not to work on some Android builds.
70 # "-DOPENSSL_C11_ATOMIC",
Yun Pengd3632472017-07-28 13:17:13 +020071]
72
73boringssl_copts = select({
74 ":linux_x86_64": posix_copts,
75 ":mac_x86_64": posix_copts,
76 ":windows_x86_64": [
77 "-DWIN32_LEAN_AND_MEAN",
78 "-DOPENSSL_NO_ASM",
79 ],
Adam Langley01867872016-06-30 14:16:59 -070080 "//conditions:default": ["-DOPENSSL_NO_ASM"],
81})
82
83crypto_sources_asm = select({
84 ":linux_x86_64": crypto_sources_linux_x86_64,
85 ":mac_x86_64": crypto_sources_mac_x86_64,
86 "//conditions:default": [],
87})
88
89# For C targets only (not C++), compile with C11 support.
Yun Pengd3632472017-07-28 13:17:13 +020090posix_copts_c11 = [
Adam Langley01867872016-06-30 14:16:59 -070091 "-std=c11",
92 "-Wmissing-prototypes",
93 "-Wold-style-definition",
94 "-Wstrict-prototypes",
95]
96
Yun Pengd3632472017-07-28 13:17:13 +020097boringssl_copts_c11 = boringssl_copts + select({
98 ":linux_x86_64": posix_copts_c11,
99 ":mac_x86_64": posix_copts_c11,
100 "//conditions:default": [],
101})
102
103# For C++ targets only (not C), compile with C++11 support.
104posix_copts_cxx = [
Adam Langley01867872016-06-30 14:16:59 -0700105 "-std=c++11",
106 "-Wmissing-declarations",
107]
108
Yun Pengd3632472017-07-28 13:17:13 +0200109boringssl_copts_cxx = boringssl_copts + select({
110 ":linux_x86_64": posix_copts_cxx,
111 ":mac_x86_64": posix_copts_cxx,
112 "//conditions:default": [],
113})
114
Adam Langley01867872016-06-30 14:16:59 -0700115cc_library(
116 name = "crypto",
117 srcs = crypto_sources + crypto_internal_headers + crypto_sources_asm,
Garret Kelly0da939d2017-06-06 16:41:36 -0400118 hdrs = crypto_headers + fips_fragments,
Adam Langley01867872016-06-30 14:16:59 -0700119 copts = boringssl_copts_c11,
120 includes = ["src/include"],
121 linkopts = select({
122 ":mac_x86_64": [],
123 "//conditions:default": ["-lpthread"],
124 }),
125 visibility = ["//visibility:public"],
126)
127
128cc_library(
129 name = "ssl",
Yun Pengd3632472017-07-28 13:17:13 +0200130 srcs = ssl_sources + ssl_internal_headers,
Adam Langley01867872016-06-30 14:16:59 -0700131 hdrs = ssl_headers,
Yun Pengd3632472017-07-28 13:17:13 +0200132 copts = boringssl_copts_cxx,
Adam Langley01867872016-06-30 14:16:59 -0700133 includes = ["src/include"],
134 visibility = ["//visibility:public"],
Yun Pengd3632472017-07-28 13:17:13 +0200135 deps = [
136 ":crypto",
137 ],
Adam Langley01867872016-06-30 14:16:59 -0700138)
139
140cc_binary(
141 name = "bssl",
Matt Braithwaited17d74d2016-08-17 20:10:28 -0700142 srcs = tool_sources + tool_headers,
Adam Langley01867872016-06-30 14:16:59 -0700143 copts = boringssl_copts_cxx,
144 visibility = ["//visibility:public"],
145 deps = [":ssl"],
146)