summaryrefslogtreecommitdiff
path: root/build.sh
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2019-06-12 15:47:36 +0200
committerYorhel <git@yorhel.nl>2019-06-12 15:47:36 +0200
commitf423f9835a90ebf195a4edd3dfb9674adf10f4b2 (patch)
treebae4894af2f5c4e296675ff78272dbd68a67990f /build.sh
parent1906bf176323ae669257e7142044e6b4b410fca8 (diff)
Support cross-compilation from Linux to Windows
Diffstat (limited to 'build.sh')
-rwxr-xr-xbuild.sh25
1 files changed, 19 insertions, 6 deletions
diff --git a/build.sh b/build.sh
index ea6f8e9..b4c6eb9 100755
--- a/build.sh
+++ b/build.sh
@@ -7,15 +7,25 @@ PREFIX="`pwd`/_build"
[ -z "$MAKE" ] && MAKE="make -j4"
HOSTFLAG=
-[ -n "$HOST" ] && HOSTFLAG="--host=$HOST"
-
-[ -z "$CC" ] && CC=gcc
+if [ -n "$HOST" ]; then
+ HOSTFLAG="--host=$HOST"
+ [ -z "$CC" ] && export CC=$HOST-gcc
+ [ -z "$AR" ] && export AR=$HOST-ar
+ [ -z "$RANLIB" ] && export RANLIB=$HOST-ranlib
+ [ -z "$LD" ] && export LD=$HOST-ld
+ [ -z "$STRIP" ] && export STRIP=$HOST-strip
+else
+ [ -z "$CC" ] && CC=gcc
+ [ -z "$STRIP"] && STRIP=strip
+fi
build_zlib() {
cd zlib
if $CC -dumpmachine | grep -q 'w64-mingw32'; then
- $MAKE -f win32/Makefile.gcc
+ TOOLPREFIX=
+ [ -n "$HOST" ] && TOOLPREFIX="$HOST-"
+ $MAKE -f win32/Makefile.gcc PREFIX="$TOOLPREFIX"
$MAKE -f win32/Makefile.gcc install\
INCLUDE_PATH="$PREFIX/include" LIBRARY_PATH="$PREFIX/lib" BINARY_PATH="$PREFIX/bin"
else
@@ -78,5 +88,8 @@ build_openssl
build_libevent
build_tor
-cp "$PREFIX/bin/tor" tor-static
-strip tor-static{,.exe}
+EXT=
+[ -e "$PREFIX/bin/tor.exe" ] && EXT=.exe
+
+cp "$PREFIX/bin/tor$EXT" tor-static$EXT
+$STRIP tor-static$EXT