diff options
author | Yorhel <git@yorhel.nl> | 2019-05-24 18:00:30 +0200 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2019-05-24 18:00:30 +0200 |
commit | 9474aaa190938cb5de21ec0513192fc462bacb21 (patch) | |
tree | 1e509fe7f8696f1d2ae5ff63deffb37cd97e220a | |
parent | 1adcd9cfe15260b757a8234d67feb18bdbba0668 (diff) |
Some improvements + support for a musl-based static build
-rw-r--r-- | README.md | 11 | ||||
-rwxr-xr-x | build.sh | 35 | ||||
-rwxr-xr-x | clean.sh | 2 | ||||
-rwxr-xr-x | x86_64-linux-musl.sh | 12 |
4 files changed, 42 insertions, 18 deletions
@@ -18,11 +18,18 @@ This repo builds: - Make - Autotools -The build has only been tested on Linux so far. - # Usage +The build has only been tested on Linux so far, but I plan to add support for +Windows & OS X as well. + - Make sure you have all the required dependencies.. - Run `./build.sh` - Wait. - Discover that you suddenly have a working `tor-static` binary. + +The generated binary is not *entirely* static because it still links against +your system libraries. If you have +[musl-cross](https://bitbucket.org/GregorR/musl-cross/) built and installed in +`/opt/cross`, then you can run `./x86_64-linux-musl.sh` to "cross"-compile a +fully static binary. Scripts for other arches are TBD. @@ -2,23 +2,27 @@ set -e -mkdir -p build -PWD=`pwd` -PREFIX="$PWD/build" +mkdir -p _build +PREFIX="`pwd`/_build" +[ -z "$MAKE" ] && MAKE="make -j4" + +HOSTFLAG= +[ -n "$HOST" ] && HOSTFLAG="--host=$HOST" + build_zlib() { cd zlib - ./configure --prefix="$PREFIX" - make -j4 - make install + ./configure --prefix="$PREFIX" --static + $MAKE + $MAKE install cd .. } build_openssl() { cd openssl ./config --prefix="$PREFIX" no-shared no-dso no-zlib - make build_libs - make install_dev + $MAKE build_libs + $MAKE install_dev cd .. } @@ -27,9 +31,9 @@ build_libevent() { ./autogen.sh ./configure --prefix="$PREFIX" --disable-shared --enable-static --with-pic\ --disable-samples -disable-libevent-regress\ - "CPPFLAGS=-I$PREFIX/include", "LDFLAGS=-L$PREFIX/lib" - make -j4 - make install + "CPPFLAGS=-I$PREFIX/include" "LDFLAGS=-L$PREFIX/lib" "$HOSTFLAG" + $MAKE + $MAKE install cd .. } @@ -42,10 +46,11 @@ build_tor() { --enable-static-openssl --with-openssl-dir="$PREFIX"\ --enable-static-zlib --with-zlib-dir="$PREFIX"\ --disable-systemd --disable-lzma --disable-zstd --disable-rust\ - --disable-seccomp --disable-libscrypt\ - "CPPFLAGS=-I$PREFIX/include" "LDFLAGS=-L$PREFIX/lib" - make -j4 V=1 - make install + --disable-seccomp --disable-libscrypt $HOSTFLAG\ + --disable-tool-name-check\ + "CPPFLAGS=-I$PREFIX/include" "LDFLAGS=-L$PREFIX/lib $LDFLAGS" + $MAKE V=1 + $MAKE install cd .. } @@ -2,7 +2,7 @@ set -e -rm -rf build/ tor-static +rm -rf _build/ tor-static for d in zlib tor openssl libevent do diff --git a/x86_64-linux-musl.sh b/x86_64-linux-musl.sh new file mode 100755 index 0000000..0fb15ab --- /dev/null +++ b/x86_64-linux-musl.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +export PATH="/opt/cross/x86_64-linux-musl/bin:$PATH" +export HOST=x86_64-musl-linux +export CC=x86_64-linux-musl-gcc +export AR=x86_64-linux-musl-ar +export RANLIB=x86_64-linux-musl-ranlib +export LD=x86_64-linux-musl-ld + +export LDFLAGS=-static + +exec ./build.sh |