diff options
| author | Brent Cook <busterb@gmail.com> | 2024-05-28 08:25:41 -0500 |
|---|---|---|
| committer | Brent Cook <busterb@gmail.com> | 2024-05-28 08:25:41 -0500 |
| commit | d9c3a5000c182fd1c8beb253970d2661e0b54516 (patch) | |
| tree | f9525fca0d0162788912986221aa91efd584b019 | |
| parent | 1e0d453f05c316e5d568b43cb59128ba696a89b5 (diff) | |
| parent | 937a3d920ead4c5a8bff162bbc719f39208988ee (diff) | |
| download | portable-d9c3a5000c182fd1c8beb253970d2661e0b54516.tar.gz portable-d9c3a5000c182fd1c8beb253970d2661e0b54516.tar.bz2 portable-d9c3a5000c182fd1c8beb253970d2661e0b54516.zip | |
Land #1048, clarify that Windows builds are easy
| -rw-r--r-- | Makefile.am | 2 | ||||
| -rw-r--r-- | README.md | 96 | ||||
| -rw-r--r-- | README.mingw.md (renamed from README.windows) | 40 | ||||
| -rwxr-xr-x | dist-win.sh | 48 | ||||
| -rw-r--r-- | m4/check-os-options.m4 | 2 |
5 files changed, 55 insertions, 133 deletions
diff --git a/Makefile.am b/Makefile.am index 2edef0d..3f62cd9 100644 --- a/Makefile.am +++ b/Makefile.am | |||
| @@ -10,7 +10,7 @@ if !ENABLE_LIBTLS_ONLY | |||
| 10 | pkgconfig_DATA += libcrypto.pc libssl.pc openssl.pc | 10 | pkgconfig_DATA += libcrypto.pc libssl.pc openssl.pc |
| 11 | endif | 11 | endif |
| 12 | 12 | ||
| 13 | EXTRA_DIST = README.md README.windows VERSION config scripts | 13 | EXTRA_DIST = README.md README.mingw.md VERSION config scripts |
| 14 | EXTRA_DIST += CMakeLists.txt cmake_export_symbol.cmake cmake_uninstall.cmake.in FindLibreSSL.cmake LibreSSLConfig.cmake.in | 14 | EXTRA_DIST += CMakeLists.txt cmake_export_symbol.cmake cmake_uninstall.cmake.in FindLibreSSL.cmake LibreSSLConfig.cmake.in |
| 15 | EXTRA_DIST += cert.pem openssl.cnf x509v3.cnf | 15 | EXTRA_DIST += cert.pem openssl.cnf x509v3.cnf |
| 16 | 16 | ||
| @@ -49,7 +49,7 @@ LibreSSL also supports the following Windows environments: | |||
| 49 | 49 | ||
| 50 | * Microsoft Windows (Windows 7 / Windows Server 2008r2 or later, x86 and x64) | 50 | * Microsoft Windows (Windows 7 / Windows Server 2008r2 or later, x86 and x64) |
| 51 | * Wine (32-bit and 64-bit) | 51 | * Wine (32-bit and 64-bit) |
| 52 | * Mingw-w64, Cygwin, and Visual Studio | 52 | * MinGW-w64, Cygwin, and Visual Studio |
| 53 | 53 | ||
| 54 | Official release tarballs are available at your friendly neighborhood | 54 | Official release tarballs are available at your friendly neighborhood |
| 55 | OpenBSD mirror in directory | 55 | OpenBSD mirror in directory |
| @@ -68,27 +68,24 @@ sent to the core team at libressl-security@openbsd.org. | |||
| 68 | 68 | ||
| 69 | # Building LibreSSL | 69 | # Building LibreSSL |
| 70 | 70 | ||
| 71 | ## Prerequisites when building from a Git checkout | 71 | ## Building from a Git checkout |
| 72 | 72 | ||
| 73 | If you have checked this source using Git, or have downloaded a source tarball | 73 | If you have checked out this source using Git, or have downloaded a source |
| 74 | from GitHub, follow these initial steps to prepare the source tree for | 74 | tarball from GitHub, follow these initial steps to prepare the source tree for |
| 75 | building. _Note: Your build will fail if you do not follow these instructions! | 75 | building. _Note: Your build will fail if you do not follow these instructions! |
| 76 | If you cannot follow these instructions (e.g. Windows system using CMake) or | 76 | If you cannot follow these instructions or cannot meet these prerequisites, |
| 77 | cannot meet these prerequistes, please download an official release distribution | 77 | please download an official release distribution from |
| 78 | from https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/ instead. Using official | 78 | https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/ instead. Using official |
| 79 | releases is strongly advised if you are not a developer._ | 79 | releases is strongly advised if you are not a developer._ |
| 80 | 80 | ||
| 81 | 1. Ensure you have the following packages installed: | 81 | 1. Ensure that you have a bash shell. This is also required on Windows. |
| 82 | automake, autoconf, git, libtool, perl | 82 | 2. Ensure that you have the following packages installed: |
| 83 | 2. Run `./autogen.sh` to prepare the source tree for building or | 83 | automake, autoconf, git, libtool, perl. |
| 84 | run `./dist.sh` to prepare a tarball. | 84 | 3. Run `./autogen.sh` to prepare the source tree for building. |
| 85 | 85 | ||
| 86 | ## Steps that apply to all builds | 86 | ## Build steps using configure |
| 87 | 87 | ||
| 88 | Once you have a source tree, either by downloaded using git and having | 88 | Once you have the source tree prepared, run these commands to build and install: |
| 89 | run the `autogen.sh` script above, or by downloading a release distribution from | ||
| 90 | an OpenBSD mirror, run these commands to build and install the package on most | ||
| 91 | systems: | ||
| 92 | 89 | ||
| 93 | ```sh | 90 | ```sh |
| 94 | ./configure # see ./configure --help for configuration options | 91 | ./configure # see ./configure --help for configuration options |
| @@ -96,7 +93,11 @@ make check # runs builtin unit tests | |||
| 96 | make install # set DESTDIR= to install to an alternate location | 93 | make install # set DESTDIR= to install to an alternate location |
| 97 | ``` | 94 | ``` |
| 98 | 95 | ||
| 99 | If you wish to use the CMake build system, use these commands: | 96 | Alternatively, it is possible to run `./dist.sh` to prepare a tarball. |
| 97 | |||
| 98 | ## Build steps using CMake | ||
| 99 | |||
| 100 | Once you have the source tree prepared, run these commands to build and install: | ||
| 100 | 101 | ||
| 101 | ```sh | 102 | ```sh |
| 102 | mkdir build | 103 | mkdir build |
| @@ -106,7 +107,7 @@ make | |||
| 106 | make test | 107 | make test |
| 107 | ``` | 108 | ``` |
| 108 | 109 | ||
| 109 | For faster builds, you can use Ninja as well: | 110 | For faster builds, you can use Ninja: |
| 110 | 111 | ||
| 111 | ```sh | 112 | ```sh |
| 112 | mkdir build-ninja | 113 | mkdir build-ninja |
| @@ -116,44 +117,15 @@ ninja | |||
| 116 | ninja test | 117 | ninja test |
| 117 | ``` | 118 | ``` |
| 118 | 119 | ||
| 119 | ### OS specific build information | 120 | Or another supported build system like Visual Studio: |
| 120 | |||
| 121 | #### HP-UX (11i) | ||
| 122 | |||
| 123 | Set the UNIX_STD environment variable to `2003` before running `configure` | ||
| 124 | in order to build with the HP C/aC++ compiler. See the "standards(5)" man | ||
| 125 | page for more details. | ||
| 126 | |||
| 127 | ```sh | ||
| 128 | export UNIX_STD=2003 | ||
| 129 | ./configure | ||
| 130 | make | ||
| 131 | ``` | ||
| 132 | |||
| 133 | #### Windows - Mingw-w64 | ||
| 134 | |||
| 135 | LibreSSL builds against relatively recent versions of Mingw-w64, not to be | ||
| 136 | confused with the original mingw.org project. Mingw-w64 3.2 or later | ||
| 137 | should work. See README.windows for more information | ||
| 138 | |||
| 139 | #### Windows - Visual Studio | ||
| 140 | |||
| 141 | LibreSSL builds using the CMake target "Visual Studio 12 2013" and newer. To | ||
| 142 | generate a Visual Studio project, install CMake, enter the LibreSSL source | ||
| 143 | directory and run: | ||
| 144 | 121 | ||
| 145 | ```sh | 122 | ```sh |
| 146 | ./update.sh | 123 | mkdir build-vs2022 |
| 147 | mkdir build-vs2013 | 124 | cd build-vs2022 |
| 148 | cd build-vs2013 | 125 | cmake -G"Visual Studio 17 2022" .. |
| 149 | cmake -G"Visual Studio 12 2013" .. | ||
| 150 | ``` | 126 | ``` |
| 151 | 127 | ||
| 152 | Replace "Visual Studio 12 2013" with whatever version of Visual Studio you | 128 | #### Additional CMake Options |
| 153 | have installed. This will generate a LibreSSL.sln file that you can incorporate | ||
| 154 | into other projects or build by itself. | ||
| 155 | |||
| 156 | #### CMake - Additional Options | ||
| 157 | 129 | ||
| 158 | | Option Name | Default | Description | | 130 | | Option Name | Default | Description | |
| 159 | |-------------------------|--------:|-----------------------------------------------------------------------------------------------------------------| | 131 | |-------------------------|--------:|-----------------------------------------------------------------------------------------------------------------| |
| @@ -166,6 +138,26 @@ into other projects or build by itself. | |||
| 166 | | `ENABLE_NC` | `OFF` | Enable installing TLS-enabled nc(1) | | 138 | | `ENABLE_NC` | `OFF` | Enable installing TLS-enabled nc(1) | |
| 167 | | `OPENSSLDIR` | Blank | Set the default openssl directory. Can be specified from command line using <br>```-DOPENSSLDIR=<dirname>``` | | 139 | | `OPENSSLDIR` | Blank | Set the default openssl directory. Can be specified from command line using <br>```-DOPENSSLDIR=<dirname>``` | |
| 168 | 140 | ||
| 141 | ## Build information for specific systems | ||
| 142 | |||
| 143 | ### HP-UX (11i) | ||
| 144 | |||
| 145 | Set the UNIX_STD environment variable to `2003` before running `configure` | ||
| 146 | in order to build with the HP C/aC++ compiler. See the "standards(5)" man | ||
| 147 | page for more details. | ||
| 148 | |||
| 149 | ```sh | ||
| 150 | export UNIX_STD=2003 | ||
| 151 | ./configure | ||
| 152 | make | ||
| 153 | ``` | ||
| 154 | |||
| 155 | ### MinGW-w64 - Windows | ||
| 156 | |||
| 157 | LibreSSL builds against relatively recent versions of [MinGW-w64](https://www.mingw-w64.org/), not to be | ||
| 158 | confused with the original mingw.org project. MinGW-w64 3.2 or later | ||
| 159 | should work. See [README.mingw.md](README.mingw.md) for more information. | ||
| 160 | |||
| 169 | # Using LibreSSL | 161 | # Using LibreSSL |
| 170 | 162 | ||
| 171 | ## CMake | 163 | ## CMake |
diff --git a/README.windows b/README.mingw.md index 4d74a2e..a90de5f 100644 --- a/README.windows +++ b/README.mingw.md | |||
| @@ -1,13 +1,13 @@ | |||
| 1 | # Building | 1 | ## Building with MinGW-w64 for 32- and 64-bit |
| 2 | 2 | ||
| 3 | For Windows systems, LibreSSL supports the mingw-w64 toolchain, which can use | 3 | For Windows systems, LibreSSL supports the MinGW-w64 toolchain, which can use |
| 4 | GCC or Clang as the compiler. Contrary to its name, mingw-w64 supports both | 4 | GCC or Clang as the compiler. Contrary to its name, MinGW-w64 supports both |
| 5 | 32-bit and 64-bit build environments. If your project already uses mingw-w64, | 5 | 32-bit and 64-bit build environments. If your project already uses MinGW-w64, |
| 6 | then LibreSSL should integrate very nicely. Old versions of the mingw-w64 | 6 | then LibreSSL should integrate very nicely. Old versions of the MinGW-w64 |
| 7 | toolchain, such as the one packaged with Ubuntu 12.04, may have trouble | 7 | toolchain, such as the one packaged with Ubuntu 12.04, may have trouble |
| 8 | building LibreSSL. Please try it with a recent toolchain if you encounter | 8 | building LibreSSL. Please try it with a recent toolchain if you encounter |
| 9 | troubles. Cygwin provides an easy method of installing the latest mingw-w64 | 9 | troubles. Cygwin provides an easy method of installing the latest MinGW-w64 |
| 10 | cross compilers on Windows. | 10 | cross-compilers on Windows. |
| 11 | 11 | ||
| 12 | To configure and build LibreSSL for a 32-bit system, use the following | 12 | To configure and build LibreSSL for a 32-bit system, use the following |
| 13 | build steps: | 13 | build steps: |
| @@ -23,7 +23,7 @@ For 64-bit builds, use these instead: | |||
| 23 | make | 23 | make |
| 24 | make check | 24 | make check |
| 25 | 25 | ||
| 26 | # Why the -D__MINGW_USE_VC2005_COMPAT flag on 32-bit systems? | 26 | ### Why the -D__MINGW_USE_VC2005_COMPAT flag on 32-bit systems? |
| 27 | 27 | ||
| 28 | An ABI change introduced with Microsoft Visual C++ 2005 (also known as | 28 | An ABI change introduced with Microsoft Visual C++ 2005 (also known as |
| 29 | Visual C++ 8.0) switched time_t from 32-bit to 64-bit. It is important to | 29 | Visual C++ 8.0) switched time_t from 32-bit to 64-bit. It is important to |
| @@ -36,30 +36,8 @@ expiry date is set past 19 January 2038, it will be unable to tell if the | |||
| 36 | certificate has expired or not, and thus take the safe stance and reject it. | 36 | certificate has expired or not, and thus take the safe stance and reject it. |
| 37 | 37 | ||
| 38 | In order to avoid this, you need to build LibreSSL (and everything that links | 38 | In order to avoid this, you need to build LibreSSL (and everything that links |
| 39 | with it) with the -D__MINGW_USE_VC2005_COMPAT flag. This tells mingw-w64 to | 39 | with it) with the -D__MINGW_USE_VC2005_COMPAT flag. This tells MinGW-w64 to |
| 40 | use the new ABI. | 40 | use the new ABI. |
| 41 | 41 | ||
| 42 | 64-bit systems always have a 64-bit time_t and are not affected by this | 42 | 64-bit systems always have a 64-bit time_t and are not affected by this |
| 43 | problem. | 43 | problem. |
| 44 | |||
| 45 | # Using Libressl with Visual Studio | ||
| 46 | |||
| 47 | A script for generating ready-to-use .DLL and static .LIB files is included in | ||
| 48 | the source repository at | ||
| 49 | https://github.com/libressl/portable/blob/master/dist-win.sh | ||
| 50 | |||
| 51 | This script uses mingw-w64 to build LibreSSL and then uses Visual Studio tools | ||
| 52 | to generate compatible library import files ready-to-use with Visual | ||
| 53 | Studio projects. Static and dynamic libraries are included. The script uses | ||
| 54 | cv2pdb to generate Visual Studio and windbg compatible debug files. cv2pdb is a | ||
| 55 | tool developed for the D language and can be found here: | ||
| 56 | https://github.com/rainers/cv2pdb | ||
| 57 | |||
| 58 | The mingw-w64 code is largely, but not 100%, compatible with code built from | ||
| 59 | Visual Studio. Notably, FILE * pointers cannot be shared between code built for | ||
| 60 | Mingw-w64 and Visual Studio. | ||
| 61 | |||
| 62 | As of LibreSSL 2.2.2, Visual Studio Native builds can also be produced using | ||
| 63 | CMake. This produces ABI-compatible libraries for linking with native code | ||
| 64 | generated by Visual Studio. Currently tested versions are VS 2019 and 2022, | ||
| 65 | though earlier versions may work as well. | ||
diff --git a/dist-win.sh b/dist-win.sh deleted file mode 100755 index e4e0fd0..0000000 --- a/dist-win.sh +++ /dev/null | |||
| @@ -1,48 +0,0 @@ | |||
| 1 | #!/bin/bash | ||
| 2 | set -e | ||
| 3 | #set -x | ||
| 4 | |||
| 5 | export PATH=/cygdrive/c/Program\ Files\ \(x86\)/Microsoft\ Visual\ Studio\ 12.0/VC/bin:$PATH | ||
| 6 | VERSION=`cat VERSION` | ||
| 7 | DIST=libressl-$VERSION-windows | ||
| 8 | |||
| 9 | rm -fr $DIST | ||
| 10 | mkdir -p $DIST | ||
| 11 | autoreconf -i | ||
| 12 | |||
| 13 | for ARCH in X86 X64; do | ||
| 14 | |||
| 15 | if [ $ARCH = X86 ]; then | ||
| 16 | HOST=i686-w64-mingw32 | ||
| 17 | ARCHDIR=x86 | ||
| 18 | else | ||
| 19 | HOST=x86_64-w64-mingw32 | ||
| 20 | ARCHDIR=x64 | ||
| 21 | fi | ||
| 22 | |||
| 23 | echo Building for $HOST | ||
| 24 | |||
| 25 | CC=$HOST-gcc ./configure --host=$HOST --with-openssldir=c:/libressl/ssl | ||
| 26 | make clean | ||
| 27 | PATH=$PATH:/usr/$HOST/sys-root/mingw/bin \ | ||
| 28 | make -j 4 check | ||
| 29 | make -j 4 install DESTDIR=`pwd`/stage-$ARCHDIR | ||
| 30 | |||
| 31 | mkdir -p $DIST/$ARCHDIR | ||
| 32 | if [ ! -e $DIST/include ]; then | ||
| 33 | cp -r stage-$ARCHDIR/usr/local/include $DIST | ||
| 34 | fi | ||
| 35 | |||
| 36 | cp stage-$ARCHDIR/usr/local/bin/* $DIST/$ARCHDIR | ||
| 37 | |||
| 38 | for i in libcrypto libssl libtls; do | ||
| 39 | DLL=$(basename `ls -1 $DIST/$ARCHDIR/$i*.dll`|cut -d. -f1) | ||
| 40 | echo EXPORTS > $DLL.def | ||
| 41 | dumpbin /exports $DIST/$ARCHDIR/$DLL.dll | \ | ||
| 42 | awk '{print $4}' | awk 'NF' |tail -n +9 >> $DLL.def | ||
| 43 | lib /MACHINE:$ARCH /def:$DLL.def /out:$DIST/$ARCHDIR/$DLL.lib | ||
| 44 | cv2pdb $DIST/$ARCHDIR/$DLL.dll | ||
| 45 | done | ||
| 46 | done | ||
| 47 | |||
| 48 | zip -r $DIST.zip $DIST | ||
diff --git a/m4/check-os-options.m4 b/m4/check-os-options.m4 index a8c4904..91c3021 100644 --- a/m4/check-os-options.m4 +++ b/m4/check-os-options.m4 | |||
| @@ -147,7 +147,7 @@ if test "$ac_cv_sizeof_time_t" = "4"; then | |||
| 147 | if test "$host_os" = "mingw32" ; then | 147 | if test "$host_os" = "mingw32" ; then |
| 148 | echo " **" | 148 | echo " **" |
| 149 | echo " ** You can solve this by adjusting the build flags in your" | 149 | echo " ** You can solve this by adjusting the build flags in your" |
| 150 | echo " ** mingw-w64 toolchain. Refer to README.windows for details." | 150 | echo " ** mingw-w64 toolchain. Refer to README.mingw.md for details." |
| 151 | fi | 151 | fi |
| 152 | fi | 152 | fi |
| 153 | 153 | ||
