Browse Source

android compiling

miguelfreitas
Miguel Freitas 11 years ago
parent
commit
15d7fd07b0
  1. 11
      libtorrent/runme-android.sh
  2. 4
      libtorrent/src/asio_ssl.cpp
  3. 41
      src/makefile.android
  4. 5
      src/runme-android.sh

11
libtorrent/runme-android.sh

@ -4,10 +4,9 @@ export NDK_BASE=$NDK
export SYSROOT=$NDK/platforms/android-9/arch-arm export SYSROOT=$NDK/platforms/android-9/arch-arm
export BOOSTDIR=/home/miguel/android/Boost-for-Android/build/ export BOOSTDIR=/home/miguel/android/Boost-for-Android/build/
#make -j2 if [ $1 == "configure" ]; then
#exit ./configure --host=arm-linux-androideabi --enable-shared=no --enable-static=yes \
--enable-debug \
./configure --host=arm-linux-androideabi --enable-shared=no --enable-static=yes\
CPPFLAGS="-I$SYSROOT/usr/include/ -I$BOOSTDIR/include \ CPPFLAGS="-I$SYSROOT/usr/include/ -I$BOOSTDIR/include \
-I$NDK_BASE/sources/cxx-stl/gnu-libstdc++/4.6/include \ -I$NDK_BASE/sources/cxx-stl/gnu-libstdc++/4.6/include \
-I$NDK_BASE/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi/include \ -I$NDK_BASE/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi/include \
@ -17,3 +16,7 @@ export BOOSTDIR=/home/miguel/android/Boost-for-Android/build/
$NDK_BASE/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi/libgnustl_static.a" \ $NDK_BASE/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi/libgnustl_static.a" \
LIBS="-lc" CFLAGS="-nostdlib" --prefix="$SYSROOT/usr" \ LIBS="-lc" CFLAGS="-nostdlib" --prefix="$SYSROOT/usr" \
--with-boost=$BOOSTDIR --with-boost-libdir=$BOOSTDIR/lib && make -j2 --with-boost=$BOOSTDIR --with-boost-libdir=$BOOSTDIR/lib && make -j2
fi
make -j2

4
libtorrent/src/asio_ssl.cpp

@ -1,6 +1,10 @@
// builds all boost.asio SSL source as a separate compilation unit // builds all boost.asio SSL source as a separate compilation unit
#include <boost/version.hpp> #include <boost/version.hpp>
#ifdef __ANDROID__
#define OPENSSL_NO_ENGINE 1
#endif
#if BOOST_VERSION >= 104610 #if BOOST_VERSION >= 104610
#include <boost/asio/ssl/impl/src.hpp> #include <boost/asio/ssl/impl/src.hpp>
#endif #endif

41
src/makefile.android

@ -13,7 +13,7 @@ USE_IPV6:=0
LINK:=$(CXX) LINK:=$(CXX)
DEFS=-DBOOST_SPIRIT_THREADSAFE -D_FILE_OFFSET_BITS=64 DEFS=-DBOOST_SPIRIT_THREADSAFE -D_FILE_OFFSET_BITS=64 -DBOOST_THREAD_USE_LIB
DEFS += $(addprefix -I,$(CURDIR) $(CURDIR)/obj $(BOOST_INCLUDE_PATH) $(BDB_INCLUDE_PATH) $(OPENSSL_INCLUDE_PATH)) DEFS += $(addprefix -I,$(CURDIR) $(CURDIR)/obj $(BOOST_INCLUDE_PATH) $(BDB_INCLUDE_PATH) $(OPENSSL_INCLUDE_PATH))
LIBS = $(addprefix -L,$(BOOST_LIB_PATH) $(BDB_LIB_PATH) $(OPENSSL_LIB_PATH)) LIBS = $(addprefix -L,$(BOOST_LIB_PATH) $(BDB_LIB_PATH) $(OPENSSL_LIB_PATH))
@ -21,7 +21,7 @@ LIBS = $(addprefix -L,$(BOOST_LIB_PATH) $(BDB_LIB_PATH) $(OPENSSL_LIB_PATH))
TESTDEFS = -DTEST_DATA_DIR=$(abspath test/data) TESTDEFS = -DTEST_DATA_DIR=$(abspath test/data)
LMODE = static LMODE = static
LMODE2 = static LMODE2 = dynamic
ifdef STATIC ifdef STATIC
LMODE = static LMODE = static
ifeq (${STATIC}, all) ifeq (${STATIC}, all)
@ -31,17 +31,6 @@ else
TESTDEFS += -DBOOST_TEST_DYN_LINK TESTDEFS += -DBOOST_TEST_DYN_LINK
endif endif
# for boost 1.37, add -mt to the boost libraries
LIBS += \
-Wl,-B$(LMODE) \
-l boost_system$(BOOST_LIB_SUFFIX) \
-l boost_filesystem$(BOOST_LIB_SUFFIX) \
-l boost_program_options$(BOOST_LIB_SUFFIX) \
-l boost_thread$(BOOST_LIB_SUFFIX) \
-l db_cxx$(BDB_LIB_SUFFIX) \
-l ssl \
-l crypto \
-l rt
TESTLIBS += \ TESTLIBS += \
-Wl,-B$(LMODE) \ -Wl,-B$(LMODE) \
@ -59,11 +48,6 @@ ifneq (${USE_IPV6}, -)
DEFS += -DUSE_IPV6=$(USE_IPV6) DEFS += -DUSE_IPV6=$(USE_IPV6)
endif endif
LIBS+= \
-Wl,-B$(LMODE2) \
-l z \
-l dl \
-l pthread
# Hardening # Hardening
@ -179,6 +163,27 @@ DEFS += -DBOOST_ASIO_SEPARATE_COMPILATION
@echo "Building libtorrent ..." && cd ../libtorrent && $(MAKE) CC=$(CC) CXX=$(CXX) OPT="$(xCXXFLAGS)" && cd ../src @echo "Building libtorrent ..." && cd ../libtorrent && $(MAKE) CC=$(CC) CXX=$(CXX) OPT="$(xCXXFLAGS)" && cd ../src
# for boost 1.37, add -mt to the boost libraries
LIBS += \
-Wl,-B$(LMODE) \
-Wl,--entry=main,-rpath-link=$(SYSROOT)/usr/lib/ -L$(SYSROOT)/usr/lib/ \
-L$(BOOSTDIR)/lib \
-l boost_system$(BOOST_LIB_SUFFIX) \
-l boost_filesystem$(BOOST_LIB_SUFFIX) \
-l boost_program_options$(BOOST_LIB_SUFFIX) \
-l boost_thread$(BOOST_LIB_SUFFIX) \
-l db_cxx$(BDB_LIB_SUFFIX) \
-L$(NDK_BASE)/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi/ -lgnustl_static
# -l ssl_static \
# -l crypto_static \
LIBS+= \
-Wl,-B$(LMODE2) \
-Wl,--entry=main,-rpath-link=$(SYSROOT)/usr/lib/ -L$(SYSROOT)/usr/lib/ \
-lssl -lcrypto -lstdc++ -lm -lgcc -nostdlib -lc \
$(NDK_BASE)/platforms/android-9/arch-arm/usr/lib/crtbegin_static.o
# auto-generated dependencies: # auto-generated dependencies:
-include obj/*.P -include obj/*.P
-include obj-test/*.P -include obj-test/*.P

5
src/runme-android.sh

@ -9,7 +9,10 @@ export CXX=arm-linux-androideabi-gcc
export CXXFLAGS="-I$SYSROOT/usr/include/ -I$BOOSTDIR/include/boost-1_49 \ export CXXFLAGS="-I$SYSROOT/usr/include/ -I$BOOSTDIR/include/boost-1_49 \
-I$NDK_BASE/sources/cxx-stl/gnu-libstdc++/4.6/include \ -I$NDK_BASE/sources/cxx-stl/gnu-libstdc++/4.6/include \
-I$NDK_BASE/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi/include \ -I$NDK_BASE/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi/include \
-fexceptions -frtti -DHAVE_CXX_STDHEADERS -DANDROID" -fexceptions -frtti -DHAVE_CXX_STDHEADERS -DANDROID -nostdlib \
-fno-use-cxa-atexit"
export BOOST_LIB_SUFFIX=-gcc-mt-1_49
export BDB_LIB_SUFFIX=-4.8
make -f makefile.android -j2 make -f makefile.android -j2
#make -j2 #make -j2

Loading…
Cancel
Save