summaryrefslogtreecommitdiff
path: root/build.sh
blob: 00b99da042584da3ff143e3b1a1cdcbd6560e83f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/sh

set -e

mkdir -p _build
PREFIX="`pwd`/_build"
[ -z "$MAKE" ] && MAKE="make -j4"

HOSTFLAG=
[ -n "$HOST" ] && HOSTFLAG="--host=$HOST"


build_zlib() {
    cd zlib
    ./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
    cd ..
}

build_libevent() {
    cd 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" "$HOSTFLAG"
    $MAKE
    $MAKE install
    cd ..
}

build_tor() {
    cd tor
    ./autogen.sh
    # TODO: See if we can enable some more features (seccomp, rust, zstd, lzma, scrypt (what's that used for?))
    ./configure --prefix="$PREFIX" --disable-asciidoc --disable-unittests\
        --enable-static-libevent --with-libevent-dir="$PREFIX"\
        --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 $HOSTFLAG\
        --disable-tool-name-check\
        "CPPFLAGS=-I$PREFIX/include" "LDFLAGS=-L$PREFIX/lib $LDFLAGS"
    $MAKE V=1
    $MAKE install
    cd ..
}

build_zlib
build_openssl
build_libevent
build_tor

cp "$PREFIX/bin/tor" tor-static
strip tor-static