From ddd62f29aead215a39d937218ff3deafec129bd2 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Thu, 5 Dec 2013 18:38:11 -0500 Subject: [PATCH 1/3] remove spaces and tabs where 'make' complains about them spaces and tabs can have meaning in a Makefile, so stray ones can cause troubles. emacs makefile-mode warns about potentially troublesome errant whitespace. --- external/Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/external/Makefile b/external/Makefile index 72da8a1b..6ecc3f60 100644 --- a/external/Makefile +++ b/external/Makefile @@ -98,7 +98,7 @@ libevent/Makefile: cp config.sub libevent cp config.guess libevent cd libevent && \ - CC="$(CC)" AR="$(AR)" RANLIB=$(RANLIB) CFLAGS="$(CFLAGS) -I$(EXTERNAL_ROOT)/include" LDFLAGS="$(LDFLAGS)" \ + CC="$(CC)" AR="$(AR)" RANLIB=$(RANLIB) CFLAGS="$(CFLAGS) -I$(EXTERNAL_ROOT)/include" LDFLAGS="$(LDFLAGS)" \ ./configure \ --host=$(HOST) \ --disable-shared @@ -128,7 +128,7 @@ iptables/Makefile: cp config.sub iptables cp config.guess iptables cd iptables && \ - CC="$(CC)" AR="$(AR)" RANLIB=$(RANLIB) CFLAGS="$(CFLAGS) -DNO_SHARED_LIBS -DXTABLES_INTERNAL -DIPTABLES_VERSION=\"1.4.10\" =-DXTABLES_VERSION=\"1.4.10\" # -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" -DXTABLES_LIBDIR -I$(EXTERNAL_ROOT)/include" LDFLAGS="$(LDFLAGS)" \ + CC="$(CC)" AR="$(AR)" RANLIB=$(RANLIB) CFLAGS="$(CFLAGS) -DNO_SHARED_LIBS -DXTABLES_INTERNAL -DIPTABLES_VERSION=\"1.4.10\" =-DXTABLES_VERSION=\"1.4.10\" # -DIPT_LIB_DIR=\"$(IPT_LIBDIR)\" -DXTABLES_LIBDIR -I$(EXTERNAL_ROOT)/include" LDFLAGS="$(LDFLAGS)" \ ./configure \ --host=$(HOST) \ --disable-shared @@ -267,7 +267,7 @@ simple-build-stamp: simple/bin/simple.jar simple: simple-build-stamp test -d bin || mkdir bin cp simple/bin/simple.jar bin - + simple-clean: - rm -f bin/simple.jar - rm -f simple-build-stamp @@ -289,7 +289,7 @@ jtorctl-build-stamp: jtorctl/bin/jtorctl.jar 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 From 2d34745b87c90e4cf764ac0646a9d213a756886d Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Thu, 5 Dec 2013 18:49:23 -0500 Subject: [PATCH 2/3] include note about git submodules in BUILD instructions --- BUILD | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/BUILD b/BUILD index a2d60565..049eb2ec 100644 --- a/BUILD +++ b/BUILD @@ -16,6 +16,11 @@ Please install the following prerequisites (instructions for each follows): You will need to run the 'android' command in the SDK to install the necessary Android platform supports (ICS 4.x or android-15) +Be sure that you have all of the git submodules up-to-date: + + git submodule init + git submodule update + To begin building, from the Orbot root directory, you first need to build all external C/native dependencies: export NDK_BASE={PATH TO YOUR NDK INSTALL} From ca8197fa5b2dc22f538943482849b9ee90a1b808 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Thu, 5 Dec 2013 19:28:54 -0500 Subject: [PATCH 3/3] update native build to include Android NDK build flags This updates external/Makefile to be more integrated into the Android NDK, by using the same variable names and including build flags from the NDK. --- external/Makefile | 112 +++++++++++++++++++++++++++++----------------- 1 file changed, 72 insertions(+), 40 deletions(-) diff --git a/external/Makefile b/external/Makefile index 6ecc3f60..b6771a41 100644 --- a/external/Makefile +++ b/external/Makefile @@ -5,55 +5,73 @@ # 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)/.. -EXTERNAL_ROOT = $(CWD) +EXTERNAL_ROOT := $(shell pwd) -# Android NDK setup: -NDK_BASE ?= /usr/local/android-ndk -NDK_PLATFORM_LEVEL ?= 8 -NDK_TOOLCHAIN_VERSION=4.6 -NDK_SYSROOT=$(NDK_BASE)/platforms/android-$(NDK_PLATFORM_LEVEL)/arch-arm -NDK_UNAME:=`uname -s | tr '[A-Z]' '[a-z]'` -NDK_PROCESSOR:=`uname -m` +# Android now has 64-bit and 32-bit versions of the NDK for GNU/Linux. We +# assume that the build platform uses the appropriate version, otherwise the +# user building this will have to manually set NDK_PROCESSOR or NDK_TOOLCHAIN. +CPU := $(shell uname -m) +ifeq ($(CPU),x86_64) + NDK_PROCESSOR=x86_64 +else + NDK_PROCESSOR=x86 +endif -#NDK_TOOLCHAIN=$(NDK_BASE)/toolchains/arm-linux-androideabi-4.4.3/prebuilt/$(NDK_UNAME)-$(NDK_PROCESSOR) -NDK_TOOLCHAIN=$(NDK_BASE)/toolchains/arm-linux-androideabi-4.6/prebuilt/$(NDK_UNAME)-$(NDK_PROCESSOR) +# Android NDK setup +NDK_BASE ?= /opt/android-ndk +NDK_ABI=arm +APP_ABI=armeabi +# NDK platform level, aka APP_PLATFORM, is equivalent to minSdkVersion +APP_PLATFORM := android-$(shell sed -n 's,.*android:minSdkVersion="\([0-9][0-9]*\)".*,\1,p' \ + $(EXTERNAL_ROOT)/../AndroidManifest.xml) +NDK_SYSROOT=$(NDK_BASE)/platforms/$(APP_PLATFORM)/arch-$(NDK_ABI) +NDK_TOOLCHAIN_VERSION=4.7 +NDK_UNAME := $(shell uname -s | tr '[A-Z]' '[a-z]') +ifeq ($(NDK_ABI),x86) + HOST = i686-linux-android + NDK_TOOLCHAIN = $(NDK_ABI)-$(NDK_TOOLCHAIN_VERSION) +else + HOST = $(NDK_ABI)-linux-androideabi + NDK_TOOLCHAIN = $(HOST)-$(NDK_TOOLCHAIN_VERSION) +endif +NDK_TOOLCHAIN_BASE=$(NDK_BASE)/toolchains/$(NDK_TOOLCHAIN)/prebuilt/$(NDK_UNAME)-$(NDK_PROCESSOR) -# 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 +# include Android's build flags +TARGET_ARCH_ABI = $(APP_ABI) +include $(NDK_BASE)/toolchains/$(NDK_TOOLCHAIN)/setup.mk -# install root for built files -DESTDIR = $(EXTERNAL_ROOT) -# TODO try adding the Android-style /data/app.name here -prefix = -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 \ +CC := $(NDK_TOOLCHAIN_BASE)/bin/$(HOST)-gcc --sysroot=$(NDK_SYSROOT) +CXX := $(NDK_TOOLCHAIN_BASE)/bin/$(HOST)-g++ +CPP := $(NDK_TOOLCHAIN_BASE)/bin/$(HOST)-cpp +LD := $(NDK_TOOLCHAIN_BASE)/bin/$(HOST)-ld +AR := $(NDK_TOOLCHAIN_BASE)/bin/$(HOST)-ar +RANLIB := $(NDK_TOOLCHAIN_BASE)/bin/$(HOST)-ranlib +STRIP := $(NDK_TOOLCHAIN_BASE)/bin/$(HOST)-strip \ --strip-unneeded -R .note -R .comment -CFLAGS = -DANDROID -I$(LOCAL) -I$(LOCAL)/include -I$(NDK_SYSROOT)/usr/include -LDFLAGS = -L$(LOCAL) -L$(LOCAL)/lib -L$(NDK_SYSROOT)/usr/lib +CFLAGS = -DANDROID $(TARGET_CFLAGS) +LDFLAGS = -llog $(TARGET_LDFLAGS) -# build as small as possible, mostly useful for static binaries -CFLAGS += -fdata-sections -ffunction-sections -Os -LDFLAGS += -Wl,--gc-sections +# change 'release' to 'debug' for unoptimized debug builds +ifeq ($(APP_ABI),armeabi-v7a) + CFLAGS += $(TARGET_arm_release_CFLAGS) +endif +ifeq ($(APP_ABI),armeabi) + CFLAGS += $(TARGET_thumb_release_CFLAGS) +endif + +.PHONY = clean showsetup \ + assets assets-clean \ + openssl-static openssl-static-clean \ + libevent libevent-clean \ + iptables iptables-clean \ + tor tor-clean \ + obfsproxy obfsproxy-clean \ + privoxy privoxy-clean all: assets @@ -158,7 +176,6 @@ tor/Makefile: tor/configure LIBS="-L$(EXTERNAL_ROOT)/lib" CFLAGS="-I$(EXTERNAL_ROOT)/include -I$(EXTERNAL_ROOT)/include/event2" \ ./configure \ --host=$(HOST) \ - --prefix=$(NDK_TOOLCHAIN) \ --disable-asciidoc \ --enable-static-libevent --with-libevent-dir=$(EXTERNAL_ROOT) \ --enable-static-openssl --with-openssl-dir=$(EXTERNAL_ROOT) \ @@ -197,7 +214,6 @@ obfsproxy/Makefile: 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 @@ -319,3 +335,19 @@ assets-clean: # cleanup, cleanup, put the toys away clean: openssl-static-clean libevent-clean tor-clean privoxy-clean jtorctl-clean assets-clean + + +#------------------------------------------------------------------------------# +# debugging stuff + +showsetup: + @echo "NDK_TOOLCHAIN_VERSION: $(NDK_TOOLCHAIN_VERSION)" + @echo "NDK_TOOLCHAIN: $(NDK_TOOLCHAIN)" + @echo "NDK_SYSROOT: $(NDK_SYSROOT)" + @echo "APP_PLATFORM: $(APP_PLATFORM)" + @echo "APP_ABI: $(APP_ABI)" + @echo "HOST: $(HOST)" + @echo "CC: $(CC)" + @echo "LD: $(LD)" + @echo "CFLAGS: $(CFLAGS)" + @echo "LDFLAGS: $(LDFLAGS)"