David Benjamin | c895d6b | 2016-08-11 13:26:41 -0400 | [diff] [blame] | 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 | |
| 15 | licenses(["notice"]) |
| 16 | |
| 17 | exports_files(["LICENSE"]) |
| 18 | |
| 19 | load( |
| 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 Sloan | 8ff0355 | 2017-06-14 12:40:58 -0700 | [diff] [blame^] | 26 | "fips_fragments", |
David Benjamin | c895d6b | 2016-08-11 13:26:41 -0400 | [diff] [blame] | 27 | "ssl_headers", |
| 28 | "ssl_internal_headers", |
David Benjamin | f31229b | 2017-01-25 14:08:15 -0500 | [diff] [blame] | 29 | "ssl_c_sources", |
| 30 | "ssl_cc_sources", |
David Benjamin | c895d6b | 2016-08-11 13:26:41 -0400 | [diff] [blame] | 31 | "tool_sources", |
| 32 | "tool_headers", |
| 33 | ) |
| 34 | |
| 35 | config_setting( |
| 36 | name = "linux_x86_64", |
| 37 | values = {"cpu": "k8"}, |
| 38 | ) |
| 39 | |
| 40 | config_setting( |
| 41 | name = "mac_x86_64", |
| 42 | values = {"cpu": "darwin"}, |
| 43 | ) |
| 44 | |
| 45 | boringssl_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 | |
| 73 | crypto_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. |
| 80 | boringssl_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. |
| 88 | boringssl_copts_cxx = boringssl_copts + [ |
| 89 | "-std=c++11", |
| 90 | "-Wmissing-declarations", |
| 91 | ] |
| 92 | |
| 93 | cc_library( |
| 94 | name = "crypto", |
| 95 | srcs = crypto_sources + crypto_internal_headers + crypto_sources_asm, |
Robert Sloan | 8ff0355 | 2017-06-14 12:40:58 -0700 | [diff] [blame^] | 96 | hdrs = crypto_headers + fips_fragments, |
David Benjamin | c895d6b | 2016-08-11 13:26:41 -0400 | [diff] [blame] | 97 | 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 | |
| 106 | cc_library( |
| 107 | name = "ssl", |
David Benjamin | f31229b | 2017-01-25 14:08:15 -0500 | [diff] [blame] | 108 | srcs = ssl_c_sources + ssl_internal_headers, |
David Benjamin | c895d6b | 2016-08-11 13:26:41 -0400 | [diff] [blame] | 109 | hdrs = ssl_headers, |
| 110 | copts = boringssl_copts_c11, |
| 111 | includes = ["src/include"], |
| 112 | visibility = ["//visibility:public"], |
David Benjamin | f31229b | 2017-01-25 14:08:15 -0500 | [diff] [blame] | 113 | deps = [":crypto", ":ssl_cc"], |
| 114 | ) |
| 115 | |
| 116 | cc_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 Benjamin | c895d6b | 2016-08-11 13:26:41 -0400 | [diff] [blame] | 122 | deps = [":crypto"], |
| 123 | ) |
| 124 | |
| 125 | cc_binary( |
| 126 | name = "bssl", |
David Benjamin | f0c4a6c | 2016-08-11 13:26:41 -0400 | [diff] [blame] | 127 | srcs = tool_sources + tool_headers, |
David Benjamin | c895d6b | 2016-08-11 13:26:41 -0400 | [diff] [blame] | 128 | copts = boringssl_copts_cxx, |
| 129 | visibility = ["//visibility:public"], |
| 130 | deps = [":ssl"], |
| 131 | ) |