blob: c75851f57a920c2397aad6b19d8f17e1f98fb1d6 [file] [log] [blame] [view]
David Benjamin95aaf4a2015-09-03 12:09:36 -04001# Building BoringSSL
2
3## Build Prerequisites
4
5 * [CMake] [1] 2.8.8 or later is required.
6
7 * Perl 5.6.1 or later is required. On Windows, [Strawberry Perl] [2] and MSYS
8 Perl have both been reported to work. If not found by CMake, it may be
9 configured explicitly by setting `PERL_EXECUTABLE`.
10
11 * On Windows you currently must use [Ninja] [3] to build; on other platforms,
12 it is not required, but recommended, because it makes builds faster.
13
14 * If you need to build Ninja from source, then a recent version of
15 [Python] [4] is required (Python 2.7.5 works).
16
17 * On Windows only, [Yasm] [5] is required. If not found by CMake, it may be
18 configured explicitly by setting `CMAKE_ASM_NASM_COMPILER`.
19
20 * A C compiler is required. On Windows, MSVC 12 (Visual Studio 2013) or later
21 with Platform SDK 8.1 or later are supported. Recent versions of GCC and
22 Clang should work on non-Windows platforms, and maybe on Windows too.
23
24 * [Go] [6] is required. If not found by CMake, the go executable may be
25 configured explicitly by setting `GO_EXECUTABLE`.
26
27## Building
28
29Using Ninja (note the 'N' is capitalized in the cmake invocation):
30
31 mkdir build
32 cd build
33 cmake -GNinja ..
34 ninja
35
36Using Make (does not work on Windows):
37
38 mkdir build
39 cd build
40 cmake ..
41 make
42
43You usually don't need to run `cmake` again after changing `CMakeLists.txt`
44files because the build scripts will detect changes to them and rebuild
45themselves automatically.
46
47Note that the default build flags in the top-level `CMakeLists.txt` are for
48debugging—optimisation isn't enabled.
49
50If you want to cross-compile then there is an example toolchain file for 32-bit
51Intel in `util/`. Wipe out the build directory, recreate it and run `cmake` like
52this:
53
54 cmake -DCMAKE_TOOLCHAIN_FILE=../util/32-bit-toolchain.cmake -GNinja ..
55
56If you want to build as a shared library, pass `-DBUILD_SHARED_LIBS=1`. On
57Windows, where functions need to be tagged with `dllimport` when coming from a
58shared library, define `BORINGSSL_SHARED_LIBRARY` in any code which `#include`s
59the BoringSSL headers.
60
61### Building for Android
62
63It's possible to build BoringSSL with the Android NDK using CMake. This has
64been tested with version 10d of the NDK.
65
66Unpack the Android NDK somewhere and export `ANDROID_NDK` to point to the
67directory. Clone https://github.com/taka-no-me/android-cmake into `util/`. Then
68make a build directory as above and run CMake *twice* like this:
69
70 cmake -DANDROID_NATIVE_API_LEVEL=android-9 \
71 -DANDROID_ABI=armeabi-v7a \
72 -DCMAKE_TOOLCHAIN_FILE=../util/android-cmake/android.toolchain.cmake \
73 -DANDROID_NATIVE_API_LEVEL=16 \
74 -GNinja ..
75
76Once you've run that twice, Ninja should produce Android-compatible binaries.
77You can replace `armeabi-v7a` in the above with `arm64-v8a` to build aarch64
78binaries.
79
80## Known Limitations on Windows
81
82 * Versions of CMake since 3.0.2 have a bug in its Ninja generator that causes
83 yasm to output warnings
84
85 yasm: warning: can open only one input file, only the last file will be processed
86
87 These warnings can be safely ignored. The cmake bug is
88 http://www.cmake.org/Bug/view.php?id=15253.
89
90 * CMake can generate Visual Studio projects, but the generated project files
91 don't have steps for assembling the assembly language source files, so they
92 currently cannot be used to build BoringSSL.
93
94
95 [1]: http://www.cmake.org/download/
96 [2]: http://strawberryperl.com/
97 [3]: https://martine.github.io/ninja/
98 [4]: https://www.python.org/downloads/
99 [5]: http://yasm.tortall.net/
100 [6]: https://golang.org/dl/