| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- # Building Tor for Windows x64 guide (Last update:19/09/2021)
- # This guide was written for Ubuntu 20.04.3 (amd64)
- # Install debootstrap to isolate installation enviroment
- sudo apt install debootstrap
- # Make a minimal ubuntu install
- sudo debootstrap --variant=minbase focal $HOME/ubuntu http://archive.ubuntu.com/ubuntu
- # Change root to your fresh installation
- sudo chroot $HOME/ubuntu
- # Install needed packages
- export LC_ALL=C
- echo "deb http://archive.ubuntu.com/ubuntu focal main universe" > /etc/apt/sources.list
- apt update
- apt install wget gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64 make pkg-config cmake
- # Download sources and build zlib
- cd $HOME && wget https://zlib.net/zlib-1.2.11.tar.gz
- mkdir $HOME/zlib && tar xzvf zlib-1.2.11.tar.gz -C $HOME/zlib
- cd $HOME/zlib/zlib-1.2.11
- make install -f win32/Makefile.gcc PREFIX="x86_64-w64-mingw32-" BINARY_PATH="$HOME/zlib/install/bin" INCLUDE_PATH="$HOME/zlib/install/include" LIBRARY_PATH="$HOME/zlib/install/lib"
- # Download sources and build openssl
- cd $HOME && wget https://www.openssl.org/source/openssl-3.0.0.tar.gz
- mkdir $HOME/openssl && tar xzvf openssl-3.0.0.tar.gz -C $HOME/openssl
- cd $HOME/openssl/openssl-3.0.0
- ./Configure --cross-compile-prefix="x86_64-w64-mingw32-" --prefix="$HOME/openssl/install" --openssldir="$HOME/openssl/install" enable-ec_nistp_64_gcc_128 no-ssl3 no-shared no-dso no-weak-ssl-ciphers no-dtls no-autoload-config mingw64
- make install
- # Download sources and build libevent
- cd $HOME && wget https://github.com/libevent/libevent/releases/download/release-2.1.12-stable/libevent-2.1.12-stable.tar.gz
- mkdir $HOME/libevent && tar xzvf libevent-2.1.12-stable.tar.gz -C $HOME/libevent
- cd $HOME/libevent/libevent-2.1.12-stable
- PKG_CONFIG_PATH="$HOME/openssl/install/lib64/pkgconfig" LIBS="-lcrypt32" ./configure --host="x86_64-w64-mingw32" --prefix="$HOME/libevent/install" --disable-shared
- make install
- # Download sources and build xz
- cd $HOME && wget https://tukaani.org/xz/xz-5.2.5.tar.gz
- mkdir $HOME/xz && tar xzvf xz-5.2.5.tar.gz -C $HOME/xz
- cd $HOME/xz/xz-5.2.5
- ./configure --host="x86_64-w64-mingw32" --prefix="$HOME/xz/install" --disable-shared
- make install
- # Download sources and build zstd
- cd $HOME && wget https://github.com/facebook/zstd/releases/download/v1.5.0/zstd-1.5.0.tar.gz
- mkdir $HOME/zstd && tar xzvf zstd-1.5.0.tar.gz -C $HOME/zstd
- cd $HOME/zstd/zstd-1.5.0/build/cmake
- cmake ./ -DCMAKE_C_COMPILER="x86_64-w64-mingw32-gcc" -DCMAKE_CXX_COMPILER="x86_64-w64-mingw32-g++" -DCMAKE_INSTALL_PREFIX="$HOME/zstd/install" -DZSTD_BUILD_STATIC=ON -DZSTD_BUILD_PROGRAMS=OFF
- make install
- # Download sources and build tor
- cd $HOME && wget https://dist.torproject.org/tor-0.4.6.7.tar.gz
- mkdir $HOME/tor && tar xzvf tor-0.4.6.7.tar.gz -C $HOME/tor
- export CFLAGS="-I$HOME/openssl/install/include -I$HOME/zlib/install/include -I$HOME/libevent/install/include -I$HOME/xz/install/include -I$HOME/zstd/install/include"
- export ZSTD_CFLAGS="-I$HOME/zstd/install/include"
- export ZSTD_LIBS=$HOME/zstd/install/lib/libzstd.a
- export LZMA_CFLAGS="-I$HOME/xz/install/include"
- export LZMA_LIBS=$HOME/xz/install/lib/liblzma.a
- export LIBS="-lcrypt32"
- cd $HOME/tor/tor-0.4.6.7
- ./configure --host="x86_64-w64-mingw32" --prefix="" --enable-static-tor --disable-system-torrc --disable-asciidoc --disable-manpage --disable-html-manual --disable-module-relay --disable-module-dirauth --disable-tool-name-check --disable-seccomp --enable-lzma --enable-zstd --with-libevent-dir=$HOME/libevent/install/lib --with-openssl-dir=$HOME/openssl/install/lib64 --with-zlib-dir=$HOME/zlib/install/lib
- make
- # Package tor for distribution
- mkdir $HOME/package
- cp $HOME/tor/tor-0.4.6.7/src/app/tor.exe $HOME/package
- x86_64-w64-mingw32-strip $HOME/package/tor.exe
- cp $HOME/tor/tor-0.4.6.7/src/config/geo* $HOME/package
- echo "DataDirectory data" >> $HOME/package/torrc
- echo "GeoIPFile geoip" >> $HOME/package/torrc
- echo "GeoIPv6File geoip6" >> $HOME/package/torrc
- echo "AvoidDiskWrites 1" >> $HOME/package/torrc
- echo "@echo off" >> $HOME/package/launcher.bat
- echo "tor -f torrc" >> $HOME/package/launcher.bat
- tar czvf $HOME/tor-0.4.6.7-win64.tar.gz -C $HOME/package .
|