tor-static-mingw.txt 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. # Building Tor for Windows x64 guide (Last update:19/09/2021)
  2. # This guide was written for Ubuntu 20.04.3 (amd64)
  3. # Install debootstrap to isolate installation enviroment
  4. sudo apt install debootstrap
  5. # Make a minimal ubuntu install
  6. sudo debootstrap --variant=minbase focal $HOME/ubuntu http://archive.ubuntu.com/ubuntu
  7. # Change root to your fresh installation
  8. sudo chroot $HOME/ubuntu
  9. # Install needed packages
  10. export LC_ALL=C
  11. echo "deb http://archive.ubuntu.com/ubuntu focal main universe" > /etc/apt/sources.list
  12. apt update
  13. apt install wget gcc-mingw-w64-x86-64 g++-mingw-w64-x86-64 make pkg-config cmake
  14. # Download sources and build zlib
  15. cd $HOME && wget https://zlib.net/zlib-1.2.11.tar.gz
  16. mkdir $HOME/zlib && tar xzvf zlib-1.2.11.tar.gz -C $HOME/zlib
  17. cd $HOME/zlib/zlib-1.2.11
  18. 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"
  19. # Download sources and build openssl
  20. cd $HOME && wget https://www.openssl.org/source/openssl-3.0.0.tar.gz
  21. mkdir $HOME/openssl && tar xzvf openssl-3.0.0.tar.gz -C $HOME/openssl
  22. cd $HOME/openssl/openssl-3.0.0
  23. ./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
  24. make install
  25. # Download sources and build libevent
  26. cd $HOME && wget https://github.com/libevent/libevent/releases/download/release-2.1.12-stable/libevent-2.1.12-stable.tar.gz
  27. mkdir $HOME/libevent && tar xzvf libevent-2.1.12-stable.tar.gz -C $HOME/libevent
  28. cd $HOME/libevent/libevent-2.1.12-stable
  29. PKG_CONFIG_PATH="$HOME/openssl/install/lib64/pkgconfig" LIBS="-lcrypt32" ./configure --host="x86_64-w64-mingw32" --prefix="$HOME/libevent/install" --disable-shared
  30. make install
  31. # Download sources and build xz
  32. cd $HOME && wget https://tukaani.org/xz/xz-5.2.5.tar.gz
  33. mkdir $HOME/xz && tar xzvf xz-5.2.5.tar.gz -C $HOME/xz
  34. cd $HOME/xz/xz-5.2.5
  35. ./configure --host="x86_64-w64-mingw32" --prefix="$HOME/xz/install" --disable-shared
  36. make install
  37. # Download sources and build zstd
  38. cd $HOME && wget https://github.com/facebook/zstd/releases/download/v1.5.0/zstd-1.5.0.tar.gz
  39. mkdir $HOME/zstd && tar xzvf zstd-1.5.0.tar.gz -C $HOME/zstd
  40. cd $HOME/zstd/zstd-1.5.0/build/cmake
  41. 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
  42. make install
  43. # Download sources and build tor
  44. cd $HOME && wget https://dist.torproject.org/tor-0.4.6.7.tar.gz
  45. mkdir $HOME/tor && tar xzvf tor-0.4.6.7.tar.gz -C $HOME/tor
  46. 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"
  47. export ZSTD_CFLAGS="-I$HOME/zstd/install/include"
  48. export ZSTD_LIBS=$HOME/zstd/install/lib/libzstd.a
  49. export LZMA_CFLAGS="-I$HOME/xz/install/include"
  50. export LZMA_LIBS=$HOME/xz/install/lib/liblzma.a
  51. export LIBS="-lcrypt32"
  52. cd $HOME/tor/tor-0.4.6.7
  53. ./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
  54. make
  55. # Package tor for distribution
  56. mkdir $HOME/package
  57. cp $HOME/tor/tor-0.4.6.7/src/app/tor.exe $HOME/package
  58. x86_64-w64-mingw32-strip $HOME/package/tor.exe
  59. cp $HOME/tor/tor-0.4.6.7/src/config/geo* $HOME/package
  60. echo "DataDirectory data" >> $HOME/package/torrc
  61. echo "GeoIPFile geoip" >> $HOME/package/torrc
  62. echo "GeoIPv6File geoip6" >> $HOME/package/torrc
  63. echo "AvoidDiskWrites 1" >> $HOME/package/torrc
  64. echo "@echo off" >> $HOME/package/launcher.bat
  65. echo "tor -f torrc" >> $HOME/package/launcher.bat
  66. tar czvf $HOME/tor-0.4.6.7-win64.tar.gz -C $HOME/package .