Skip to content

Instantly share code, notes, and snippets.

@n8fr8
Created May 3, 2012 01:57
Show Gist options
  • Save n8fr8/2582505 to your computer and use it in GitHub Desktop.
Save n8fr8/2582505 to your computer and use it in GitHub Desktop.
current Orbot from scratch via NDK and SDK (no ANdroid OS build needed!)
# begin by defining NDK_ROOT
if test -z $NDK_ROOT; then echo "NDK_ROOT is not exported, do so by something close to this: export NDK_ROOT=/path/to/android-ndk-r5"; exit; fi
mkdir native
#Build openssl using default ndk-build
echo "BUILD OPENSSL"
cd native
git clone git://github.com/guardianproject/android-external-openssl-ndk-static.git
cd android-external-openssl-ndk-static
ndk-build
cp obj/local/armeabi/*.a ../lib
cp -R include/openssl ../include
cd ../..
echo "SETTING UP CROSS COMPILER"
# export needed variables
export NDK_TOOLCHAIN=$NDK_ROOT/my-android-toolchain
# remove the old toolchain
rm -rf $NDK_TOOLCHAIN/*
# create the toolchain
$NDK_ROOT/build/tools/make-standalone-toolchain.sh --platform=android-9 --install-dir=$NDK_TOOLCHAIN
# export needed variables for crosscompile
export PATH="$NDK_TOOLCHAIN/bin/:$PATH"
export HOST=arm-linux-androideabi
export CC=$HOST-gcc
export CXX=$HOST-g++
export AR=$HOST-ar
export LD=$HOST-ld
export AS=$HOST-as
export NM=$HOST-nm
export STRIP=$HOST-strip
export RANLIB=$HOST-ranlib
export OBJDUMP=$HOST-objdump
export CPPFLAGS="--sysroot=$NDK_TOOLCHAIN/sysroot -I$NDK_TOOLCHAIN/sysroot/usr/include -I$NDK_TOOLCHAIN/include"
n8fr8@didactic:~/dev/gp/repos/orbot$ cat Makefile.sh
# begin by defining NDK_ROOT
if test -z $NDK_ROOT; then echo "NDK_ROOT is not exported, do so by something close to this: export NDK_ROOT=/path/to/android-ndk-r5"; exit; fi
mkdir native
#Build openssl using default ndk-build
echo "BUILD OPENSSL"
cd native
git clone git://github.com/guardianproject/android-external-openssl-ndk-static.git
cd android-external-openssl-ndk-static
ndk-build
cp obj/local/armeabi/*.a ../lib
cp -R include/openssl ../include
cd ../..
echo "SETTING UP CROSS COMPILER"
# export needed variables
export NDK_TOOLCHAIN=$NDK_ROOT/my-android-toolchain
# remove the old toolchain
rm -rf $NDK_TOOLCHAIN/*
# create the toolchain
$NDK_ROOT/build/tools/make-standalone-toolchain.sh --platform=android-9 --install-dir=$NDK_TOOLCHAIN
# export needed variables for crosscompile
export PATH="$NDK_TOOLCHAIN/bin/:$PATH"
export HOST=arm-linux-androideabi
export CC=$HOST-gcc
export CXX=$HOST-g++
export AR=$HOST-ar
export LD=$HOST-ld
export AS=$HOST-as
export NM=$HOST-nm
export STRIP=$HOST-strip
export RANLIB=$HOST-ranlib
export OBJDUMP=$HOST-objdump
export CPPFLAGS="--sysroot=$NDK_TOOLCHAIN/sysroot -I$NDK_TOOLCHAIN/sysroot/usr/include -I$NDK_TOOLCHAIN/include"
export LDFLAGS="-L$NDK_TOOLCHAIN/sysroot/usr/lib -L$NDK_TOOLCHAIN/lib"
#export LIBS="-lc"
mkdir native
mkdir native/lib
mkdir native/include
#Build libevent
echo "BUILD LIBEVENT"
mkdir native/libevent
cd native/libevent
svn co https://levent.svn.sourceforge.net/svnroot/levent/tags/release-1.4.13-stable/libevent/ .
./autogen.sh
./configure --host=arm-linux-eabi --build=$BUILD --prefix=$NDK_TOOLCHAIN
make
cp .libs/libevent.a ../lib
cp *.h ../include
cd ../..
#Build Tor
echo "BUILD TOR"
cd native
git clone git://git.torproject.org/git/tor.git
cd tor/
./autogen.sh
./configure --host=arm-linux-eabi --disable-asciidoc --prefix=$NDK_TOOLCHAIN --with-libevent-dir=$PWD/../ --enable-static-libevent --with-openssl-dir=$PWD/../ --enable-static-openssl
make
cd ../..
#Build JTorControl
cd libs
git clone git://git.torproject.org/git/jtorctl
cd jtorctl
mkdir bin
javac net/freehaven/tor/control/TorControlConnection.java -d bin
cd bin
jar cvf jtorctrl.jar *
cp jtorctrl.jar ../..
cd ../../..
#BUILD privoxy
mkdir native/privoxy
cd native/privoxy
wget http://sourceforge.net/projects/ijbswa/files/Sources/3.0.12%20%28stable%29/privoxy-3.0.12-stable-src.tar.gz/download
tar xzvf download
cd privoxy-3.0.12-stable
autoheader
autoconf
#need to disable setpgrp check in configure
export ac_cv_func_setpgrp_void=yes
./configure --host=arm-linux-eabi --build=$BUILD --prefix=$NDK_TOOLCHAIN --disable-pthread
make clean
make
cd ../../..
mkdir assets
cp native/privoxy/privoxy-3.0.12-stable/privoxy assets
cp native/tor/src/or/tor assets
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment