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