diff options
author | Yorhel <git@yorhel.nl> | 2019-05-30 15:12:33 +0200 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2019-05-30 15:12:35 +0200 |
commit | 1906bf176323ae669257e7142044e6b4b410fca8 (patch) | |
tree | b323a2deb61784f5562e39aeaa46cc08924a86fd | |
parent | 9474aaa190938cb5de21ec0513192fc462bacb21 (diff) |
Add support for Windows/MinGW through MSYS2
I'll see if I can fix a MinGW-based cross compile from Linux now that
this works.
-rw-r--r-- | README.md | 6 | ||||
-rwxr-xr-x | build.sh | 29 |
2 files changed, 27 insertions, 8 deletions
@@ -14,14 +14,14 @@ This repo builds: # Requirements +- Linux or Windows+MSYS2 - A proper C compiler toolchain. - Make - Autotools -# Usage +For Arch Linux & MSYS2-MinGW64: `pacman -S base-devel` -The build has only been tested on Linux so far, but I plan to add support for -Windows & OS X as well. +# Usage - Make sure you have all the required dependencies.. - Run `./build.sh` @@ -9,12 +9,20 @@ PREFIX="`pwd`/_build" HOSTFLAG= [ -n "$HOST" ] && HOSTFLAG="--host=$HOST" +[ -z "$CC" ] && CC=gcc + build_zlib() { cd zlib - ./configure --prefix="$PREFIX" --static - $MAKE - $MAKE install + if $CC -dumpmachine | grep -q 'w64-mingw32'; then + $MAKE -f win32/Makefile.gcc + $MAKE -f win32/Makefile.gcc install\ + INCLUDE_PATH="$PREFIX/include" LIBRARY_PATH="$PREFIX/lib" BINARY_PATH="$PREFIX/bin" + else + ./configure --prefix="$PREFIX" --static + $MAKE + $MAKE install + fi cd .. } @@ -40,6 +48,17 @@ build_libevent() { build_tor() { cd tor ./autogen.sh + + # The order of linker flags is always a major pain in the ass when linking + # static binaries, and the tor configure script doesn't provide much + # flexibility to influence the flag order. So, as a workaround, let's just + # pass *all* the flags necessary for openssl. There will be some duplicate + # link flags in the final build, but that's alright. + # The -static is needed on MinGW in order to remove the dependency on + # libssp and libwinpthread. + TOR_LIBS= + $CC -dumpmachine | grep -q 'w64-mingw32' && TOR_LIBS="-lssl -lcrypto -lcrypt32 -lgdi32 -lws2_32 -static" + # 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"\ @@ -48,7 +67,7 @@ build_tor() { --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" + "CPPFLAGS=-I$PREFIX/include" "LDFLAGS=-L$PREFIX/lib $LDFLAGS" "LIBS=$TOR_LIBS" $MAKE V=1 $MAKE install cd .. @@ -60,4 +79,4 @@ build_libevent build_tor cp "$PREFIX/bin/tor" tor-static -strip tor-static +strip tor-static{,.exe} |