2012-05-03 22:29:28 +00:00
|
|
|
# Please install the following prerequisites (instructions for each follows):
|
|
|
|
# Android OS SDK: http://source.android.com/download
|
|
|
|
#
|
|
|
|
# Install and prepare the Android OS SDK ( http://source.android.com/download )
|
|
|
|
# on Debian or Ubuntu
|
|
|
|
|
|
|
|
### these modify the calling shell
|
|
|
|
# point pkg-config to the .pc files generated from these builds
|
|
|
|
export PKG_CONFIG_PATH=$(LOCAL)/lib/pkgconfig
|
|
|
|
# workaround for cross-compiling bug in autoconf
|
|
|
|
export ac_cv_func_malloc_0_nonnull=yes
|
|
|
|
export ac_cv_func_setpgrp_void=yes
|
|
|
|
|
|
|
|
CWD = $(shell pwd)
|
|
|
|
PROJECT_ROOT = $(CWD)/..
|
2012-05-04 21:00:17 +00:00
|
|
|
EXTERNAL_ROOT = $(CWD)
|
2012-05-03 22:29:28 +00:00
|
|
|
|
|
|
|
# Android NDK setup:
|
|
|
|
NDK_BASE ?= /usr/local/android-ndk
|
|
|
|
NDK_PLATFORM_LEVEL ?= 8
|
|
|
|
NDK_SYSROOT=$(NDK_BASE)/platforms/android-$(NDK_PLATFORM_LEVEL)/arch-arm
|
|
|
|
NDK_UNAME=`uname -s | tr '[A-Z]' '[a-z]'`
|
|
|
|
NDK_TOOLCHAIN=$(NDK_BASE)/toolchains/arm-linux-androideabi-4.4.3/prebuilt/$(NDK_UNAME)-x86
|
|
|
|
|
|
|
|
# to use the real HOST tag, you need the latest libtool files:
|
|
|
|
# http://stackoverflow.com/questions/4594736/configure-does-not-recognize-androideabi
|
|
|
|
#HOST := arm-none-linux-gnueabi
|
|
|
|
HOST := arm-linux-androideabi
|
|
|
|
|
|
|
|
# install root for built files
|
|
|
|
DESTDIR = $(EXTERNAL_ROOT)
|
|
|
|
# TODO try adding the Android-style /data/app.name here
|
2012-05-04 21:00:17 +00:00
|
|
|
prefix =
|
2012-05-03 22:29:28 +00:00
|
|
|
LOCAL := $(DESTDIR)$(prefix)
|
|
|
|
|
|
|
|
export PATH := ${PATH}:$(NDK_TOOLCHAIN)/bin:$(LOCAL)/bin
|
|
|
|
|
|
|
|
CC := $(NDK_TOOLCHAIN)/bin/arm-linux-androideabi-gcc --sysroot=$(NDK_SYSROOT)
|
|
|
|
CXX := $(NDK_TOOLCHAIN)/bin/arm-linux-androideabi-g++
|
|
|
|
CPP := $(NDK_TOOLCHAIN)/bin/arm-linux-androideabi-cpp
|
|
|
|
LD := $(NDK_TOOLCHAIN)/bin/arm-linux-androideabi-ld
|
|
|
|
AR := $(NDK_TOOLCHAIN)/bin/arm-linux-androideabi-ar
|
|
|
|
RANLIB := $(NDK_TOOLCHAIN)/bin/arm-linux-androideabi-ranlib
|
|
|
|
STRIP := $(NDK_TOOLCHAIN)/bin/arm-linux-androideabi-strip \
|
|
|
|
--strip-unneeded -R .note -R .comment
|
|
|
|
|
2012-05-04 21:00:17 +00:00
|
|
|
CFLAGS = -DANDROID -I$(LOCAL)/include -I$(NDK_SYSROOT)/usr/include
|
|
|
|
LDFLAGS = -L$(LOCAL)/lib -L$(NDK_SYSROOT)/usr/lib
|
2012-05-03 22:29:28 +00:00
|
|
|
|
|
|
|
# build as small as possible, mostly useful for static binaries
|
|
|
|
CFLAGS += -fdata-sections -ffunction-sections -Os
|
|
|
|
LDFLAGS += -Wl,--gc-sections
|
|
|
|
|
2012-05-03 22:46:17 +00:00
|
|
|
all: assets
|
2012-05-03 22:29:28 +00:00
|
|
|
|
|
|
|
#------------------------------------------------------------------------------#
|
|
|
|
# openssl-static
|
|
|
|
|
|
|
|
openssl-static/obj/local/armeabi/libcrypto.a:
|
|
|
|
cd openssl-static && \
|
|
|
|
ndk-build
|
|
|
|
|
|
|
|
openssl-static/obj/local/armeabi/libssl.a:
|
2012-05-03 23:10:41 +00:00
|
|
|
cp config.sub openssl-static
|
|
|
|
cp config.guess openssl-static
|
2012-05-03 22:29:28 +00:00
|
|
|
cd openssl-static && \
|
|
|
|
ndk-build
|
|
|
|
|
|
|
|
openssl-static-build-stamp: openssl-static/obj/local/armeabi/libcrypto.a openssl-static/obj/local/armeabi/libssl.a
|
|
|
|
touch openssl-static-build-stamp
|
|
|
|
|
|
|
|
openssl-static: openssl-static-build-stamp
|
|
|
|
test -d lib || mkdir lib
|
|
|
|
test -d include || mkdir include
|
|
|
|
cp openssl-static/obj/local/armeabi/libcrypto.a lib
|
|
|
|
cp openssl-static/obj/local/armeabi/libssl.a lib
|
|
|
|
cp -R openssl-static/include/openssl include
|
|
|
|
|
|
|
|
openssl-static-clean:
|
|
|
|
-cd openssl-static && \
|
|
|
|
ndk-build clean
|
2012-05-04 21:00:17 +00:00
|
|
|
-rm openssl-static-build-stamp
|
2012-05-03 22:29:28 +00:00
|
|
|
-rm lib/libcrypto.a
|
|
|
|
-rm lib/libssl.a
|
2012-05-04 21:00:17 +00:00
|
|
|
-cd openssl-static && \
|
|
|
|
git clean -fdx
|
2012-05-03 22:29:28 +00:00
|
|
|
|
|
|
|
#------------------------------------------------------------------------------#
|
|
|
|
# libevent
|
|
|
|
|
2012-05-04 21:00:17 +00:00
|
|
|
libevent/Makefile:
|
2012-05-03 22:29:28 +00:00
|
|
|
cd libevent && ./autogen.sh
|
2012-05-03 23:10:41 +00:00
|
|
|
cp config.sub libevent
|
|
|
|
cp config.guess libevent
|
2012-05-03 22:29:28 +00:00
|
|
|
cd libevent && \
|
2012-05-09 04:43:33 +00:00
|
|
|
CC="$(CC)" AR="$(AR)" RANLIB=$(RANLIB) CFLAGS="$(CFLAGS) -I$(EXTERNAL_ROOT)/include" LDFLAGS="$(LDFLAGS)" \
|
2012-05-03 22:29:28 +00:00
|
|
|
./configure \
|
|
|
|
--host=$(HOST) \
|
2012-05-04 21:00:17 +00:00
|
|
|
--disable-shared
|
2012-05-03 22:29:28 +00:00
|
|
|
|
|
|
|
libevent-build-stamp: libevent/Makefile
|
|
|
|
$(MAKE) -C libevent
|
|
|
|
touch libevent-build-stamp
|
|
|
|
|
2012-05-09 04:11:59 +00:00
|
|
|
libevent: openssl-static libevent-build-stamp
|
2012-05-03 22:29:28 +00:00
|
|
|
test -d lib || mkdir lib
|
|
|
|
test -d include || mkdir include
|
|
|
|
cp libevent/.libs/libevent.a lib
|
2012-05-04 21:00:17 +00:00
|
|
|
cp -R libevent/include/* include
|
2012-05-03 22:29:28 +00:00
|
|
|
|
|
|
|
libevent-clean:
|
|
|
|
-rm -f include/*.h
|
|
|
|
-rm -f lib/libevent.a
|
|
|
|
-rm -f libevent-build-stamp
|
2012-05-04 21:00:17 +00:00
|
|
|
-cd libevent && \
|
|
|
|
git clean -fdx
|
2012-05-03 22:29:28 +00:00
|
|
|
|
|
|
|
#------------------------------------------------------------------------------#
|
|
|
|
# tor
|
|
|
|
|
|
|
|
tor/configure:
|
|
|
|
cd tor && \
|
|
|
|
./autogen.sh
|
|
|
|
|
|
|
|
tor/Makefile: tor/configure
|
2012-05-03 23:10:41 +00:00
|
|
|
cp config.sub tor
|
|
|
|
cp config.guess tor
|
2012-05-03 22:29:28 +00:00
|
|
|
cd tor && \
|
|
|
|
CC="$(CC)" AR="$(AR)" RANLIB=$(RANLIB) CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \
|
|
|
|
./configure \
|
|
|
|
--host=$(HOST) \
|
|
|
|
--prefix=$(NDK_TOOLCHAIN) \
|
|
|
|
--disable-asciidoc \
|
|
|
|
--with-libevent-dir=$(EXTERNAL_ROOT) --enable-static-libevent \
|
2012-06-20 00:44:06 +00:00
|
|
|
--with-openssl-dir=$(EXTERNAL_ROOT) --enable-static-openssl \
|
|
|
|
--disable-gcc-hardening
|
|
|
|
|
|
|
|
## --disable-linker-hardening --disable-gcc-hardening
|
|
|
|
|
2012-05-03 22:29:28 +00:00
|
|
|
|
|
|
|
tor-build-stamp: tor/Makefile
|
|
|
|
$(MAKE) -C tor
|
|
|
|
touch tor-build-stamp
|
|
|
|
|
2012-05-03 22:46:17 +00:00
|
|
|
tor: libevent openssl-static tor-build-stamp
|
2012-05-03 22:29:28 +00:00
|
|
|
test -d bin || mkdir bin
|
|
|
|
cp tor/src/or/tor bin
|
|
|
|
|
|
|
|
tor-clean:
|
|
|
|
-rm -f bin/tor
|
|
|
|
-rm -f tor-build-stamp
|
2012-05-04 21:00:17 +00:00
|
|
|
-cd tor && \
|
|
|
|
git clean -fdx
|
|
|
|
|
|
|
|
|
|
|
|
#------------------------------------------------------------------------------#
|
|
|
|
# obfsproxy
|
|
|
|
|
|
|
|
|
|
|
|
obfsproxy/Makefile:
|
2012-05-04 21:38:37 +00:00
|
|
|
cp obfsproxy_android_no_hardening.patch obfsproxy
|
2012-05-04 21:00:17 +00:00
|
|
|
cd obfsproxy && \
|
2012-05-04 21:38:37 +00:00
|
|
|
patch -N -p1 --reject-file=- < obfsproxy_android_no_hardening.patch
|
|
|
|
cd obfsproxy && \
|
|
|
|
./autogen.sh
|
2012-05-04 21:00:17 +00:00
|
|
|
cp config.sub obfsproxy
|
|
|
|
cp config.guess obfsproxy
|
|
|
|
cd obfsproxy && \
|
|
|
|
CC="$(CC)" AR="$(AR)" RANLIB=$(RANLIB) CFLAGS="$(CFLAGS) -D_FORTIFY_SOURCE=2 -fPIE -fwrapv -fno-strict-aliasing -fno-strict-overflow" LDFLAGS="$(LDFLAGS)" \
|
|
|
|
libevent_LIBS="-L$(EXTERNAL_ROOT)/lib -levent" libevent_CFLAGS="-I$(EXTERNAL_ROOT)/include" \
|
|
|
|
libcrypto_LIBS="-L$(EXTERNAL_ROOT)/lib -lcrypto" libcrypto_CFLAGS="-I$(EXTERNAL_ROOT)/include" \
|
|
|
|
./configure \
|
|
|
|
--host=$(HOST) \
|
|
|
|
--prefix=$(NDK_TOOLCHAIN) \
|
|
|
|
|
|
|
|
obfsproxy-build-stamp: obfsproxy/Makefile
|
|
|
|
$(MAKE) -C obfsproxy
|
|
|
|
touch obfsproxy-build-stamp
|
|
|
|
|
|
|
|
obfsproxy: openssl-static libevent obfsproxy-build-stamp
|
|
|
|
test -d bin || mkdir bin
|
|
|
|
cp obfsproxy/obfsproxy bin
|
|
|
|
|
|
|
|
obfsproxy-clean:
|
|
|
|
-rm -f bin/obfsproxy
|
|
|
|
-rm -f obfsproxy-build-stamp
|
|
|
|
-cd obfsproxy && \
|
|
|
|
git clean -fdx
|
2012-05-03 22:29:28 +00:00
|
|
|
|
|
|
|
#------------------------------------------------------------------------------#
|
|
|
|
# privoxy
|
|
|
|
|
|
|
|
|
2012-05-07 02:47:34 +00:00
|
|
|
privoxy/config.log:
|
2012-05-04 22:03:18 +00:00
|
|
|
cd privoxy && \
|
|
|
|
autoheader
|
|
|
|
cd privoxy && \
|
|
|
|
autoconf
|
2012-05-03 23:10:41 +00:00
|
|
|
cp config.sub privoxy
|
|
|
|
cp config.guess privoxy
|
2012-05-03 22:29:28 +00:00
|
|
|
cd privoxy && \
|
|
|
|
CC="$(CC)" AR="$(AR)" RANLIB=$(RANLIB) CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \
|
|
|
|
./configure \
|
2012-06-05 16:04:56 +00:00
|
|
|
--host=arm-linux-eabi --enable-pthread
|
|
|
|
## --disable-pthread
|
2012-05-03 22:29:28 +00:00
|
|
|
|
2012-05-07 02:47:34 +00:00
|
|
|
privoxy-build-stamp: privoxy/config.log
|
2012-05-03 22:29:28 +00:00
|
|
|
$(MAKE) -C privoxy
|
|
|
|
touch privoxy-build-stamp
|
|
|
|
|
|
|
|
privoxy: privoxy-build-stamp
|
|
|
|
test -d bin || mkdir bin
|
|
|
|
cp privoxy/privoxy bin
|
|
|
|
|
|
|
|
privoxy-clean:
|
2012-05-03 23:10:41 +00:00
|
|
|
$(MAKE) -C privoxy clean
|
2012-05-03 22:29:28 +00:00
|
|
|
-rm -f bin/privoxy
|
|
|
|
-rm -f privoxy-build-stamp
|
2012-06-28 02:23:00 +00:00
|
|
|
-git checkout privoxy
|
|
|
|
-cd privoxy && \
|
|
|
|
git clean -fdx .
|
2012-05-03 22:29:28 +00:00
|
|
|
|
|
|
|
#------------------------------------------------------------------------------#
|
|
|
|
# JTorControl library
|
|
|
|
|
2012-05-07 02:47:34 +00:00
|
|
|
jtorctl/bin/jtorctl.jar:
|
2012-05-03 22:29:28 +00:00
|
|
|
test -d jtorctl/bin || mkdir jtorctl/bin
|
|
|
|
cd jtorctl && \
|
2012-06-20 00:44:06 +00:00
|
|
|
javac -source 1.6 -target 1.6 net/freehaven/tor/control/TorControlConnection.java -d bin
|
2012-05-03 22:46:17 +00:00
|
|
|
cd jtorctl/bin && \
|
2012-05-07 02:47:34 +00:00
|
|
|
jar cvf jtorctl.jar *
|
2012-05-03 22:29:28 +00:00
|
|
|
|
2012-05-07 02:47:34 +00:00
|
|
|
jtorctl-build-stamp: jtorctl/bin/jtorctl.jar
|
|
|
|
touch jtorctl-build-stamp
|
|
|
|
|
|
|
|
jtorctl: jtorctl-build-stamp
|
|
|
|
test -d bin || mkdir bin
|
|
|
|
cp jtorctl/bin/jtorctl.jar bin
|
|
|
|
|
|
|
|
jtorctl-clean:
|
|
|
|
-rm -rf jtorctl/bin
|
|
|
|
-rm jtorctl-build-stamp
|
2012-05-03 22:29:28 +00:00
|
|
|
|
|
|
|
#------------------------------------------------------------------------------#
|
2012-05-07 02:47:34 +00:00
|
|
|
#create and clean assets: FYI - tor is stored as a ZIP file with an mp3 extension
|
|
|
|
#in order to stop Android OS (older devices) from trying to compress/decompress it
|
|
|
|
#this is related to a bug in compression of assets and resources > 1MB
|
|
|
|
|
|
|
|
assets: tor privoxy jtorctl obfsproxy
|
2012-05-03 22:46:17 +00:00
|
|
|
install -d ../res/raw
|
|
|
|
install -d ../libs
|
|
|
|
install bin/privoxy ../res/raw
|
2012-05-04 22:03:18 +00:00
|
|
|
install bin/obfsproxy ../res/raw
|
2012-05-07 02:47:34 +00:00
|
|
|
install bin/jtorctl.jar ../libs
|
|
|
|
cd bin && \
|
|
|
|
zip ../../res/raw/tor.mp3 tor
|
2012-05-03 23:10:41 +00:00
|
|
|
|
|
|
|
assets-clean:
|
2012-05-08 00:40:17 +00:00
|
|
|
-rm ../res/raw/tor
|
2012-05-07 02:47:34 +00:00
|
|
|
-rm ../res/raw/tor.mp3
|
2012-05-03 23:10:41 +00:00
|
|
|
-rm ../res/raw/privoxy
|
2012-05-08 02:07:44 +00:00
|
|
|
-rm ../libs/*
|
2012-05-04 22:03:18 +00:00
|
|
|
-rm ../res/raw/obfsproxy
|
2012-05-03 22:29:28 +00:00
|
|
|
|
2012-05-03 22:46:17 +00:00
|
|
|
#------------------------------------------------------------------------------#
|
|
|
|
# cleanup, cleanup, put the toys away
|
|
|
|
|
2012-05-07 02:47:34 +00:00
|
|
|
clean: openssl-static-clean libevent-clean tor-clean privoxy-clean jtorctl-clean assets-clean
|