//============================================================================================
Terms and abbreviations:
//============================================================================================
<NDK> - path to Android NDK base directory
(in my case: "/home/ik/android-ndk-r3")

<svn> - path to project svn working copy base directory
(in my case: "/home/ik/svn"))
 
<curl> - path to curl library sources base directory. Currently used curl version 7.20.0 stored in <svn>/3rdparty subtree. 
(in my case: "<svn>/3rdparty/curl-7.20.0")

<wbxml2> - path to wbxml2 library sources base directory. Currently used wbxml2 version 0.9.2 stored in <svn>/3rdparty subtree. 
(in my case: "<svn>/3rdparty/wbxml2-0.9.2")

<crypto> - path to crypto library sources base directory. Currently used openssl version 0.9.8e stored in <svn>/3rdparty subtree. 
(in my case: "<svn>/3rdparty/openssl-0.9.8e/crypto")

//============================================================================================

How to install NDK (r3)

1) update "bash_profile" config file: 

ANDROID_ROOT=<NDK>
export ANDROID_ROOT

PATH=$PATH:$ANDROID_ROOT/build/prebuilt/linux-x86/arm-eabi-4.4.0/bin/
export PATH

ANDROID_NDK_ROOT=$ANDROID_ROOT
export ANDROID_NDK_ROOT
NDK_DIR=$ANDROID_ROOT
export NDK_DIR

2) read <NDK>/docs/INSTALL.TXT and do initial configuration accordingly 

3) create directory <NDK>/sources
 
//============================================================================================

How to build FunambolSDK, dependent libraries and oma_dm_client on Android

//============================================================================================

For build and link oma_dm_client need compile some dependent libs and port STL.

Next shared libs need to port and build before oma_dm_client:
- curl
- wbxml
- openssl
- funambol

Also need attach STL port with android support and appropriate user defines (no RTTI, no exception, no IOstreams)

//============================================================================================

For build all dependent libs need first configure it with appropriate paramaters using ./configure
all parameters for ./configure is stored in <svn>/OMA-DMClient/build/android/configure_command.txt

//============================================================================================
Porting curl
//============================================================================================

1) configure curl library with ./configure:

./configure --host=arm-eabi CC=arm-eabi-gcc CPPFLAGS="-I$ANDROID_ROOT/build/platforms/android-5/arch-arm/usr/include/" CFLAGS="-nostdlib -fno-exceptions -fno-rtti -Wno-multichar" LDFLAGS="-Wl,-rpath-link=$ANDROID_ROOT/build/platforms/android-5/arch-arm/usr/lib/ -L$ANDROID_ROOT/build/platforms/android-5/arch-arm/usr/lib/" LIBS="-lc"

2)Copy:  
<svn>/OMA-DMClient/build/android/curl/Application.mk 
to
<NDK>/apps/curl/

3) Make directory <NDK>/sources/curl

4) Make symbolic link:
ln -s <curl> <NDK>/sources/curl/jni
(example in my case: ln -s /home/ik/svn/3rdparty/curl-7.20.0 /home/ik/android-ndk-r3/sources/curl/jni)

5) Change dir to <NDK> and enter in command line:
make APP=curl

After success build we have static library in next path:
<NDK>/out/apps/curl/armeabi/libcurl.a

//============================================================================================
porting wbxml2
//============================================================================================

1) execute ./bootstrap. It create ./configure 
2) configure wbxml2 library with ./configure:

./configure --host=arm-eabi CXX=arm-eabi-g++ CPPFLAGS="-I$ANDROID_ROOT/build/platforms/android-5/arch-arm/usr/include/ -nostdlib -fno-exceptions -fno-rtti -Wno-multichar" LDFLAGS="-Wl,-rpath-link=$ANDROID_ROOT/build/platforms/android-5/arch-arm/usr/lib/ -L$ANDROID_ROOT/build/platforms/android-5/arch-arm/usr/lib/" LIBS="-lc"

3) Copy:
<svn>/build/android/wbxml2/Application.mk 
to
<NDK>/apps/wbxml2/

2) Make directory <NDK>/sources/wbxml2

3)Create next symbolic link:
ln -s <wbxml2> <NDK>/sources/wbxml2/jni
(example in my case: ln -s /home/ik/svn/3rdparty/wbxml2-0.9.2 /home/ik/android-ndk-r3/sources/wbxml2/jni)

4)Copy:  
<svn>/build/android/wbxml2/sources/Android.mk 	
to
<NDK>/sources/wbxml2/jni/

5)Change dir to <NDK> and enter in command line:
make APP=wbxml2

After success build we have shared library in next path:
<NDK>/out/apps/wbxml2/armeabi/libwbxml2.so

//============================================================================================
porting openssl (crypto)
//============================================================================================

Notice: Now I can't configure lib with right parameters !!! I don't know algorithm. Maybe it's not problem

1) Copy:  
<svn>/build/android/crypto/Application.mk 
to
<NDK>/apps/crypto/

2) Make directory <NDK>/sources/crypto 

3) Create next symbolic link:
ln -s <crypto> <NDK>/sources/crypto/jni
(example in my case: ln -s /home/ik/svn/3rdparty/openssl-0.9.8e/crypto /home/ik/android-ndk-r3/sources/crypto/jni)

4)Copy:  
<svn>/build/android/crypto/sources/Android.mk 	
to
<NDK>/sources/crypto/jni/

Change dir to <NDK> and enter in command line:
make APP=crypto

After success build we have static library in next path:
<NDK>/out/apps/crypto/armeabi/libcrypto.a
//============================================================================================

Porting STL (STLPort)

No need compile STL library. We will be use only headers with templates implementation.
There is limitation where using only headers: we can't use iostreams. For iostreams need build STL lib.
Get STLPort from <android_installs> (there is some modifications for Android) and copy content to <NDK>/stlport directory. 
Rename <NDK>/build/platforms/android-1.6/arch-arm/usr/include/utility.h to utility.ccc (skip utility.h from build process) 

//============================================================================================

Build FunambolSDK

1) Configure FunambolSDK library with ./configure:

./configure --host=arm-eabi --disable-shared --prefix=/home/ik/svn/tmp/cpp-sdk CXX=arm-eabi-g++ CPPFLAGS="-I$ANDROID_ROOT/build/platforms/android-5/arch-arm/usr/include/ -nostdlib -fno-exceptions -fno-rtti -Wno-multichar" LDFLAGS="-Wl,-rpath-link=$ANDROID_ROOT/build/platforms/android-5/arch-arm/usr/lib/ -L$ANDROID_ROOT/build/platforms/android-5/arch-arm/usr/lib/" LIBS="-lc"

2) Create directory: <NDK>/sources/FunambolSDK

3) Need create next symbolic links:

ln -s <svn>/3rdparty/funambol/sdk/cpp/build/android <NDK>/sources/FunambolSDK/jni
(example in my case: ln -s /home/ik/svn/3rdparty/funambol/sdk/cpp/build/android /home/ik/android-ndk-r3/sources/FunambolSDK/jni)

ln -s <svn>/3rdparty/funambol/sdk/cpp/src/cpp <NDK>/sources/FunambolSDK/jni/cpp
(example in my case: ln -s /home/ik/svn/3rdparty/funambol/sdk/cpp/src/cpp /home/ik/android-ndk-r3/sources/FunambolSDK/jni/cpp)

ln -s <svn>/3rdparty/funambol/sdk/cpp/src/include <NDK>/sources/FunambolSDK/jni/include
(example in my case: ln -s /home/ik/svn/3rdparty/funambol/sdk/cpp/src/include /home/ik/android-ndk-r3/sources/FunambolSDK/jni/include)

4) Change dir to <NDK> and enter in command line:
make APP=FunambolSDK

After success build we have static library in next path:
<NDK>/out/apps/FunambolSDK/armeabi/libFunambol.a

//============================================================================================

How to build OMA-DMClient on Android

1) need do some changes in bionic CRT headers:

modify next header:
<NDK>/build/platforms/android-X/arch-arm/usr/include/wchar.h:

update line:

typedef struct { int  dummy; }  mbstate_t;

with next:

#ifndef _STLP_USE_OWN_MBSTATE_T
typedef struct { int  dummy; }  mbstate_t;
#endif

it prevent declaration conflict with STL. 

2) Copy:  
<svn>/build/android/oma_dm_client/Application.mk 
to
<NDK>/apps/oma_dm_client/

3) Create directory: <NDK>/sources/oma_dm_client

4) Create next symbolic links:

ln -s <svn>/OMA-DMClient <NDK>/sources/oma_dm_client/jni
(example in my case: ln -s /home/ik/svn/OMA-DMClient /home/ik/android-ndk-r3/sources/oma_dm_client/jni)

5) Change dir to <NDK> and enter in command line:
make APP=oma_dm_client

After success build we have set of static (dynamic) libraries in next path:
<NDK>/out/apps/oma_dm_client/armeabi/







