compile

Compile Python 2.7, OpenSSL and zlib with a Custom Prefix

First, export an environment variable with your prefix:

1
export MY_PREFIX=$HOME/python27

Configure, make and install zlib:

1
2
3
4
5
tar xf zlib-1.2.8.tar.gz
cd zlib-1.2.8
./configure --prefix=$MY_PREFIX
make -j4
make install

Configure, make and install OpenSSL:

1
2
3
4
5
tar xf openssl-1.0.2f.tar.gz
cd openssl-1.0.2f
./config shared --prefix=$MY_PREFIX
make -j4
make install

Configure, make and install Python:

1
2
3
4
5
6
7
8
tar xf Python-2.7.11.tar.xz
cd Python-2.7.11
LDFLAGS="-L$MY_PREFIX/lib -L$MY_PREFIX/lib64 -Wl,-rpath=$MY_PREFIX/lib" \
LD_LIBRARY_PATH="$MY_PREFIX/lib:$MY_PREFIX/lib64" \
CPPFLAGS="-I$MY_PREFIX/include -I$MY_PREFIX/ssl" \
./configure --prefix=$MY_PREFIX --enable-shared
make -j4
make install

Check that it was installed correctly:

1
2
3
4
export PATH=$MY_PREFIX/bin:$PATH
which python
python --version
python

Compile Tor Statically

Make a temporary directory to work in:

1
2
mkdir /tmp/static_tor
cd /tmp/static_tor

Make a directory that we will install the static libraries in:

1
mkdir install

Download and compile the dependencies (libevent, openssl and zlib):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
wget https://github.com/libevent/libevent/releases/download/release-2.0.22-stable/libevent-2.0.22-stable.tar.gz
tar xf libevent-2.0.22-stable.tar.gz
cd libevent-2.0.22-stable
./configure --disable-shared --enable-static --with-pic --prefix=/tmp/static_tor/install
make -j4
make install
cd ..
wget https://www.openssl.org/source/openssl-1.0.1r.tar.gz
tar xf openssl-1.0.1r.tar.gz
cd openssl-1.0.1r
./config no-shared no-dso --prefix=/tmp/static_tor/install
make -j4
make install
cd ..
wget http://zlib.net/zlib-1.2.8.tar.gz
tar xf zlib-1.2.8.tar.gz
cd zlib-1.2.8
./configure --static --prefix=/tmp/static_tor/install
make -j4
make install
cd ..

Clone the Tor source and compile it:

1
2
3
4
5
6
git clone https://git.torproject.org/tor.git
cd tor
git co tor-0.2.7.6
./autogen.sh
./configure --disable-asciidoc --enable-static-tor --with-libevent-dir=/tmp/static_tor/install --with-openssl-dir=/tmp/static_tor/install --with-zlib-dir=/tmp/static_tor/install
make -j4

The Tor binary should be statically compiled:

1
./src/or/tor --version