Skip to content

Commit 13a3c96

Browse files
committed
Initial android commit (without test project)
1 parent 461e769 commit 13a3c96

30 files changed

+1824
-879
lines changed

Build_android/Makefile

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
# Note: we require android ndk r9d available from
2+
# https://dl.google.com/android/ndk/android-ndk-r9d-linux-x86_64.tar.bz2
3+
# https://dl.google.com/android/ndk/android-ndk-r9d-windows-x86_64.zip
4+
5+
# Variables setup
6+
7+
NDK:=$(realpath ${ANDROID_NDK})
8+
9+
ifndef ANDROID_NDK
10+
define check-ndk
11+
$(error ANDROID_NDK is undefined);
12+
endef
13+
else
14+
ifeq '${NDK}' ''
15+
define check-ndk
16+
$(error ANDROID_NDK does not point to a directory);
17+
endef
18+
else
19+
define check-ndk
20+
endef
21+
endif
22+
endif
23+
24+
SRC_DIR:=$(shell pwd)
25+
26+
all: build/CMakeCache.txt
27+
28+
# --------
29+
# Openssl
30+
# --------
31+
32+
# This steps are based on the github project openssl1.0.1g-android
33+
# https://github.com/aluvalasuman/openssl1.0.1g-android
34+
35+
openssl/openssl-1.0.1h.tar.gz:
36+
cd openssl && \
37+
wget http://www.openssl.org/source/openssl-1.0.1h.tar.gz
38+
39+
openssl/openssl-1.0.1h/Configure: openssl/openssl-1.0.1h.tar.gz
40+
cd openssl && \
41+
rm -rf openssl-1.0.1h && \
42+
tar xzf openssl-1.0.1h.tar.gz
43+
touch $@
44+
45+
openssl/r9d-9-armeabiv7/lib/libssl.a: openssl/openssl-1.0.1h/Configure
46+
$(call check-ndk)
47+
cd openssl/openssl-1.0.1h && \
48+
export ANDROID_NDK="${NDK}" && \
49+
. ../android_configure_armeabiv7.sh && \
50+
./Configure android no-shared --prefix=${SRC_DIR}/openssl/r9d-9-armeabiv7 --openssldir=openssl && \
51+
$(MAKE) all install_sw
52+
53+
# --------
54+
# libiconv
55+
# --------
56+
57+
# This steps are based on the blog post
58+
# http://danilogiulianelli.blogspot.com/2012/12/how-to-cross-compile-libiconv-for.html
59+
60+
libiconv/libiconv-1.13.1.tar.gz:
61+
cd libiconv && \
62+
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gz
63+
64+
libiconv/iconv-patched-stamp: libiconv/libiconv-1.13.1.tar.gz
65+
cd libiconv && \
66+
rm -rf libiconv-1.13.1 && \
67+
tar xzf libiconv-1.13.1.tar.gz && \
68+
patch -b -p0 < ./libiconv.patch && \
69+
touch iconv-patched-stamp
70+
71+
libiconv/libiconv-1.13.1/include/iconv.h: libiconv/iconv-patched-stamp
72+
cd libiconv/libiconv-1.13.1 && \
73+
./configure
74+
75+
libiconv/libs/armeabi-v7a/libiconv.so: libiconv/libiconv-1.13.1/include/iconv.h
76+
$(call check-ndk)
77+
cd libiconv/jni && \
78+
${ANDROID_NDK}/ndk-build
79+
80+
libiconv/r9d-9-armeabiv7a/include/iconv.h: libiconv/libiconv-1.13.1/include/iconv.h
81+
mkdir -p libiconv/r9d-9-armeabiv7a/include
82+
cp $< $@
83+
84+
libiconv/r9d-9-armeabiv7a/lib/libiconv.so: libiconv/libs/armeabi-v7a/libiconv.so
85+
mkdir -p libiconv/r9d-9-armeabiv7a/lib
86+
cp $< $@
87+
88+
# libiconv: libiconv/r9d-9-armeabiv7a/lib/libiconv.so libiconv/r9d-9-armeabiv7a/include/iconv.h
89+
90+
# -----
91+
# Boost
92+
# -----
93+
# Uses the script from MysticTreeGames
94+
95+
Boost-for-Android/.git:
96+
git clone https://github.com/MysticTreeGames/Boost-for-Android.git
97+
98+
Boost-for-Android/patched-stamp: Boost-for-Android/.git boost-for-android.patch
99+
cd Boost-for-Android && \
100+
git checkout 8075d96cc9ef42d5c52d233b8ee42cb8421a2818 && \
101+
git checkout -- . && \
102+
patch -p1 < ../boost-for-android.patch && \
103+
touch patched-stamp
104+
105+
Boost-for-Android/build/lib/libboost_locale-gcc-mt-1_55.a: \
106+
libiconv/r9d-9-armeabiv7a/lib/libiconv.so \
107+
libiconv/r9d-9-armeabiv7a/include/iconv.h \
108+
Boost-for-Android/patched-stamp
109+
$(call check-ndk)
110+
cd Boost-for-Android && \
111+
./build-android.sh "${NDK}"
112+
113+
# -------------
114+
# android-cmake
115+
# -------------
116+
117+
android-cmake/android.toolchain.cmake:
118+
git clone https://github.com/taka-no-me/android-cmake.git
119+
120+
# ----------
121+
# casablanca
122+
# ----------
123+
124+
build/CMakeCache.txt: \
125+
android-cmake/android.toolchain.cmake \
126+
Boost-for-Android/build/lib/libboost_locale-gcc-mt-1_55.a \
127+
openssl/r9d-9-armeabiv7/lib/libssl.a \
128+
../Release/CMakeLists.txt
129+
$(call check-ndk)
130+
mkdir -p build
131+
cd build && \
132+
cmake ../../Release/ \
133+
-DCMAKE_TOOLCHAIN_FILE=../android-cmake/android.toolchain.cmake \
134+
-DANDROID_ABI=armeabi-v7a \
135+
-DANDROID_TOOLCHAIN_NAME=arm-linux-androideabi-4.8 \
136+
-DANDROID_STL=none \
137+
-DANDROID_STL_FORCE_FEATURES=ON \
138+
-DANDROID_NDK=${ANDROID_NDK} \
139+
-DANDROID_NATIVE_API_LEVEL=android-9 \
140+
-DANDROID_GOLD_LINKER=OFF \
141+
-DCMAKE_BUILD_TYPE=Debug
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
export NDK=${ANDROID_NDK}
2+
3+
export TOOLCHAIN_INSTALL_DIR=`pwd`/../android/android-toolchain-armv7
4+
5+
$NDK/build/tools/make-standalone-toolchain.sh --platform=android-9 --toolchain=arm-linux-androideabi-4.8 --install-dir=$TOOLCHAIN_INSTALL_DIR
6+
export TOOLCHAIN_PATH=$TOOLCHAIN_INSTALL_DIR/bin
7+
export TOOL=arm-linux-androideabi
8+
export NDK_TOOLCHAIN_BASENAME=${TOOLCHAIN_PATH}/${TOOL}
9+
export CC=$NDK_TOOLCHAIN_BASENAME-gcc
10+
export CXX=$NDK_TOOLCHAIN_BASENAME-g++
11+
export CPP=${NDK_TOOLCHAIN_BASENAME}-cpp
12+
export LINK=${CXX}
13+
export LD=$NDK_TOOLCHAIN_BASENAME-ld
14+
export AR=$NDK_TOOLCHAIN_BASENAME-ar
15+
export AS=${NDK_TOOLCHAIN_BASENAME}-as
16+
export RANLIB=$NDK_TOOLCHAIN_BASENAME-ranlib
17+
export STRIP=$NDK_TOOLCHAIN_BASENAME-strip
18+
export NM=${NDK_TOOLCHAIN_BASENAME}-nm
19+
export OBJDUMP=${NDK_TOOLCHAIN_BASENAME}-objdump
20+
export ARCH_FLAGS="-march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16"
21+
export ARCH_LINK="-march=armv7-a -Wl,--fix-cortex-a8"
22+
export CPPFLAGS=" ${ARCH_FLAGS} -fpic -ffunction-sections -funwind-tables -fstack-protector -fno-strict-aliasing -finline-limit=64 "
23+
export CXXFLAGS=" ${ARCH_FLAGS} -fpic -ffunction-sections -funwind-tables -fstack-protector -fno-strict-aliasing -finline-limit=64 -frtti -fexceptions "
24+
export CFLAGS=" ${ARCH_FLAGS} -fpic -ffunction-sections -funwind-tables -fstack-protector -fno-strict-aliasing -finline-limit=64 "
25+
export LDFLAGS=" ${ARCH_LINK} "
26+

Build_android/boost-for-android.patch

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
diff --git a/build-android.sh b/build-android.sh
2+
index 7aa2eee..5e621af 100755
3+
--- a/build-android.sh
4+
+++ b/build-android.sh
5+
@@ -28,9 +28,9 @@
6+
# -----------------------
7+
8+
BOOST_VER1=1
9+
-BOOST_VER2=53
10+
+BOOST_VER2=55
11+
BOOST_VER3=0
12+
-register_option "--boost=<version>" boost_version "Boost version to be used, one of {1.55.0,1.54.0,1.53.0,1.49.0, 1.48.0, 1.45.0}, default is 1.53.0."
13+
+register_option "--boost=<version>" boost_version "Boost version to be used, one of {1.55.0,1.54.0,1.53.0,1.49.0, 1.48.0, 1.45.0}, default is 1.55.0."
14+
boost_version()
15+
{
16+
if [ "$1" = "1.55.0" ]; then
17+
@@ -82,7 +82,7 @@ do_download ()
18+
CLEAN=yes
19+
}
20+
21+
-LIBRARIES=--with-libraries=date_time,filesystem,program_options,regex,signals,system,thread,iostreams
22+
+LIBRARIES=--with-libraries=locale,random,date_time,filesystem,system,thread,chrono,locale
23+
24+
register_option "--with-libraries=<list>" do_with_libraries "Comma separated list of libraries to build."
25+
do_with_libraries () { LIBRARIES="--with-libraries=$1"; }
26+
@@ -245,7 +245,7 @@ case "$NDK_RN" in
27+
TOOLSET=gcc-androidR8e
28+
;;
29+
"9 (64-bit)"|"9b (64-bit)"|"9c (64-bit)"|"9d (64-bit)")
30+
- TOOLCHAIN=${TOOLCHAIN:-arm-linux-androideabi-4.6}
31+
+ TOOLCHAIN=${TOOLCHAIN:-arm-linux-androideabi-4.8}
32+
CXXPATH=$AndroidNDKRoot/toolchains/${TOOLCHAIN}/prebuilt/${PlatformOS}-x86_64/bin/arm-linux-androideabi-g++
33+
TOOLSET=gcc-androidR8e
34+
;;
35+
@@ -314,7 +314,7 @@ then
36+
exit 1
37+
fi
38+
cd $PROGDIR
39+
-
40+
+
41+
# -------------------------------------------------------------
42+
# Patching will be done only if we had a successfull bootstrap!
43+
# -------------------------------------------------------------
44+
@@ -376,8 +376,12 @@ echo "Building boost for android"
45+
link=static \
46+
threading=multi \
47+
--layout=versioned \
48+
- install 2>&1 \
49+
- || { dump "ERROR: Failed to build boost for android!" ; exit 1 ; }
50+
+ --build-type=complete \
51+
+ boost.locale.posix=off \
52+
+ boost.locale.std=on \
53+
+ -sICONV_PATH="`pwd`/../../libiconv/r9d-9-armeabiv7a" \
54+
+ -s"NO_BZIP2=1" \
55+
+ install 2>&1
56+
} | tee -a $PROGDIR/build.log
57+
58+
# PIPESTATUS variable is defined only in Bash, and we are using /bin/sh, which is not Bash on newer Debian/Ubuntu
59+
diff --git a/configs/user-config-boost-1_55_0.jam b/configs/user-config-boost-1_55_0.jam
60+
index 666d4c8..8250029 100644
61+
--- a/configs/user-config-boost-1_55_0.jam
62+
+++ b/configs/user-config-boost-1_55_0.jam
63+
@@ -39,84 +39,38 @@
64+
65+
import os ;
66+
local AndroidNDKRoot = [ os.environ AndroidNDKRoot ] ;
67+
+local ToolChainPath = $(AndroidNDKRoot)/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64 ;
68+
+local ToolChainBinPath = $(ToolChainPath)/bin ;
69+
70+
-# --------------------------------------------------------------------
71+
-# Is same for 8b, 8c and 8d
72+
-using gcc : androidR8b
73+
-:
74+
-arm-linux-androideabi-g++
75+
-:
76+
-<archiver>arm-linux-androideabi-ar
77+
-<compileflags>-fexceptions
78+
-<compileflags>-frtti
79+
-<compileflags>-fpic
80+
-<compileflags>-ffunction-sections
81+
-<compileflags>-funwind-tables
82+
-<compileflags>-D__ARM_ARCH_5__
83+
-<compileflags>-D__ARM_ARCH_5T__
84+
-<compileflags>-D__ARM_ARCH_5E__
85+
-<compileflags>-D__ARM_ARCH_5TE__
86+
-<compileflags>-Wno-psabi
87+
-<compileflags>-march=armv5te
88+
-<compileflags>-mtune=xscale
89+
-<compileflags>-msoft-float
90+
-<compileflags>-mthumb
91+
-<compileflags>-Os
92+
-<compileflags>-fomit-frame-pointer
93+
-<compileflags>-fno-strict-aliasing
94+
-<compileflags>-finline-limit=64
95+
-<compileflags>-I$(AndroidNDKRoot)/platforms/android-9/arch-arm/usr/include
96+
-<compileflags>-Wa,--noexecstack
97+
-<compileflags>-DANDROID
98+
-<compileflags>-D__ANDROID__
99+
-<compileflags>-DNDEBUG
100+
-<compileflags>-O2
101+
-<compileflags>-g
102+
-<compileflags>-I$(AndroidNDKRoot)/sources/cxx-stl/gnu-libstdc++/4.6/include
103+
-<compileflags>-I$(AndroidNDKRoot)/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi/include
104+
-# @Moss - Above are the 'oficial' android flags
105+
-<architecture>arm
106+
-<compileflags>-fvisibility=hidden
107+
-<compileflags>-fvisibility-inlines-hidden
108+
-<compileflags>-fdata-sections
109+
-<cxxflags>-D__arm__
110+
-<cxxflags>-D_REENTRANT
111+
-<cxxflags>-D_GLIBCXX__PTHREADS
112+
-;
113+
-
114+
-# --------------------------------------------------------------------
115+
using gcc : androidR8e
116+
:
117+
-arm-linux-androideabi-g++
118+
+$(ToolChainBinPath)/arm-linux-androideabi-g++
119+
:
120+
-<archiver>arm-linux-androideabi-ar
121+
<compileflags>-fexceptions
122+
<compileflags>-frtti
123+
<compileflags>-fpic
124+
<compileflags>-ffunction-sections
125+
<compileflags>-funwind-tables
126+
-<compileflags>-D__ARM_ARCH_5__
127+
-<compileflags>-D__ARM_ARCH_5T__
128+
-<compileflags>-D__ARM_ARCH_5E__
129+
-<compileflags>-D__ARM_ARCH_5TE__
130+
-<compileflags>-Wno-psabi
131+
-<compileflags>-march=armv5te
132+
+<compileflags>-Wno-pedantic
133+
+<compileflags>-march=armv7-a
134+
<compileflags>-mtune=xscale
135+
<compileflags>-msoft-float
136+
<compileflags>-mthumb
137+
+<compileflags>-O2
138+
<compileflags>-Os
139+
+<compileflags>-g
140+
+<compileflags>-DNDEBUG
141+
<compileflags>-fomit-frame-pointer
142+
<compileflags>-fno-strict-aliasing
143+
-<compileflags>-finline-limit=64
144+
-<compileflags>-I$(AndroidNDKRoot)/platforms/android-9/arch-arm/usr/include
145+
-<compileflags>-Wa,--noexecstack
146+
+<compileflags>-I$(AndroidNDKRoot)/sources/cxx-stl/gnu-libstdc++/4.8/include
147+
+<compileflags>-I$(AndroidNDKRoot)/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/include
148+
+<compileflags>-I$(AndroidNDKRoot)/sources/cxx-stl/gnu-libstdc++/4.8/include/backward
149+
+<compileflags>--sysroot=$(AndroidNDKRoot)/platforms/android-9/arch-arm
150+
<compileflags>-DANDROID
151+
<compileflags>-D__ANDROID__
152+
-<compileflags>-DNDEBUG
153+
-<compileflags>-O2
154+
-<compileflags>-g
155+
-<compileflags>-I$(AndroidNDKRoot)/sources/cxx-stl/gnu-libstdc++/4.6/include
156+
-<compileflags>-I$(AndroidNDKRoot)/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi/include
157+
+<compileflags>-Wa,--noexecstack
158+
+<cxxflags>-std=c++11
159+
+<linkflags>--sysroot=$(AndroidNDKRoot)/platforms/android-9/arch-arm
160+
# @Moss - Above are the 'oficial' android flags
161+
<architecture>arm
162+
<compileflags>-fvisibility=hidden
163+
@@ -125,9 +79,10 @@ arm-linux-androideabi-g++
164+
<cxxflags>-D__arm__
165+
<cxxflags>-D_REENTRANT
166+
<cxxflags>-D_GLIBCXX__PTHREADS
167+
+<cxxflags>-D_BOOST_SYSTEM_NO_DEPRECATED
168+
+<cxxflags>-D_NO_BZIP2
169+
;
170+
171+
-
172+
# ------------------
173+
# GCC configuration.
174+
# ------------------

0 commit comments

Comments
 (0)