couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Couchdb Wiki] Update of "Installing_on_Android" by MattAdams
Date Sun, 30 Jan 2011 04:12:02 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Couchdb Wiki" for change notification.

The "Installing_on_Android" page has been changed by MattAdams.
http://wiki.apache.org/couchdb/Installing_on_Android?action=diff&rev1=1&rev2=2

--------------------------------------------------

- Currently under development!
+ Please note that the following instructions for Android produce a build that mostly works
but is not entirely bug free.  Any help tracking down and resolving problems with couchjs
would be greatly appreciated.  From what I can tell these probably stem from ABI incompatibility
with the version of Spidermonkey that is used. -- Matt 2011-01-29
  
+ The following build instructions are intended for Android 2.2.2 and were run on Debian Squeeze.
 The "scripts" below were run with Bash from a single directory I called {{{android-build}}}.
+ 
+ I used Java 1.5.0.22 to [[http://source.android.com/source/download.html|build Android from
source]].  You will also [[http://developer.android.com/sdk/index.html|need an SDK]] (I used
r08).
+ 
+ A lot of the credit should go to [[https://github.com/apage43|Aaron Miller]] for doing the
original port upon which these instructions are based as well as the good folks in #couchdb
and #jsapi for their assistance, explanations and testing along the way.
+ 
+ = Step 1: Build Android from Source =
+ 
+ {{{
+ cd ~/software/android/sdk/sources
+ 
+ repo init -b froyo
+ repo sync
+ 
+ source build/envsetup.sh
+ 
+ export JAVA_HOME=$HOME/software/jdk1.5.0_22
+ export ANDROID_JAVA_HOME=$JAVA_HOME
+ export PATH=$JAVA_HOME/bin:$PATH
+ 
+ lunch
+ make -s
+ }}}
+ 
+ = Step 2: Build cURL (against Android) =
+ 
+ {{{
+ VERSION=7.20.0
+ 
+ [[ -f curl-$VERSION.tar.bz2 ]] || wget http://curl.haxx.se/download/curl-$VERSION.tar.bz2
+ 
+ rm -rf curl-$VERSION
+ tar jxf curl-$VERSION.tar.bz2
+ cd curl-$VERSION
+ 
+ source $HOME/software/android/scripts/env
+ ANDROID_SDK=$HOME/software/android/sdk
+ 
+ CPPFLAGS="-I$ANDROID_SDK/sources/external/openssl/include -I$ANDROID_SDK/sources/external/zlib"
\
+ CC=agcc \
+ ./configure \
+ --disable-shared \
+ --without-random \
+ --host=arm-linux
+ --disable-tftp \
+ --disable-sspi \
+ --disable-ipv6 \
+ --disable-ldaps \
+ --disable-ldap \
+ --disable-telnet \
+ --disable-pop3 \
+ --disable-ftp \
+ --with-ssl=$ANDROID_SDK/sources/external/openssl \
+ --disable-imap \
+ --disable-smtp \
+ --disable-pop3 \
+ --disable-rtsp \
+ --disable-ares \
+ --without-ca-bundle \
+ --disable-warnings \
+ --disable-manual \
+ --without-nss \
+ --with-zlib=$ANDROID_SDK/sources/external/zlib
+ 
+ make -s
+ }}}
+ 
+ = Step 3: Build Mozilla NSPR & Spidermonkey (against Android) =
+ 
+ The following instructions are based on the Fennec instructions [[https://wiki.mozilla.org/Mobile/Fennec/Android#JS.2FNSPR_only|for
building JS/NSPR only]].  I also used [[http://ftp.mozilla.org/pub/mozilla.org/mobile/source/android-ndk-r4c-0moz3.tar.bz2|their
Android NDK package]] for the builds. 
+ 
+ == NSPR ==
+ 
+ {{{
+ HGREV=21e90d198613
+ 
+ [[ -f mozilla-central-$HGREV.tar.bz2 ]] || wget http://hg.mozilla.org/mozilla-central/archive/$HGREV.tar.bz2
+ 
+ rm -rf mozilla-central mozilla-central-$HGREV
+ tar -jxf mozilla-central-$HGREV.tar.bz2
+ ln -s mozilla-central-$HGREV mozilla-central
+ 
+ source $HOME/software/android/scripts/env
+ ANDROID_NDK=$HOME/software/android/android-ndk-r4c
+ ANDROID_SDK=$HOME/software/android/sdk
+ 
+ cd mozilla-central/nsprpub
+ make clean
+ autoconf2.13
+ 
+ ./configure \
+ --target=arm-android-eabi \
+ --with-android-ndk=$ANDROID_NDK \
+ --with-android-platform=$ANDROID_NDK/build/platforms/android-8/arch-arm
+ 
+ make -s
+ 
+ # Remove shared libraries so that Couch is built with the static ones
+ rm dist/lib/*so
+ }}}
+ 
+ == Spidermonkey ==
+ 
+ Be aware that Spidermonkey '''[[https://bugzilla.mozilla.org/show_bug.cgi?id=617115|will
not]]''' build against Android NDK r5.
+ 
+ {{{
+ ANDROID_NDK=$HOME/software/android/android-ndk-r4c
+ 
+ cd mozilla-central/js/src
+ rm config.cache
+ autoconf2.13
+ 
+ LDFLAGS=-L$ANDROID_NDK/build/prebuilt/linux-x86/arm-eabi-4.4.0/arm-eabi/lib \
+ ./configure \
+ --target=arm-android-eabi \
+ --with-android-ndk=$ANDROID_NDK \
+ --with-android-sdk=$ANDROID_NDK/build/platforms/android-8 \
+ --with-android-version=8 \
+ --with-nspr-cflags=-I$(pwd)/../../nsprpub/dist/include/nspr \
+ --with-nspr-libs="-L$(pwd)/../../nsprpub/dist/lib -lnspr4 -lplc4 -lplds4" \
+ --disable-shared \
+ --enable-debug \
+ --disable-optimizations \
+ --enable-static \
+ --enable-threadsafe \
+ --enable-endian=little \
+ --with-arm-kuser
+ 
+ make -s
+ 
+ # Remove the shared lib to force Couch to link statically
+ # (Could not get this to work -- even with patches to Couch autoconf files)
+ #rm libmozjs.so
+ 
+ # Rename lib
+ mv libjs_static.a libmozjs.a
+ }}}
+ 
+ You should remove {{{--enable-debug}}} and {{{--disable-optimizations}}} for production
builds.
+ 
+ = Step 4: Build Erlang/OTP =
+ 
+ {{{
+ rm -rf otp
+ rm -rf otp_rel
+ git clone git://github.com/apage43/otp.git
+ cd otp
+ git checkout origin/android
+ 
+ ##
+ # Patches:
+ #
+ # 1) Add back in support for the "beam" binary (binary is still to
+ # large, should do something about this & link to libbeam.so)
+ #
+ # 2) Our default autoconf is 2.67 and we need to switch back to 2.59
+ # for this operation
+ #
+ patch -p1 < ../otp.patch
+ 
+ source $HOME/software/android/scripts/env
+ export ANDROID_SDK=$HOME/software/android/sdk
+ export ANDROID_SYS_ROOT=$ANDROID_SDK/sources
+ 
+ ./otp_build autoconf
+ ./otp_build configure --xcomp-conf=xcomp/erl-xcomp-android.conf
+ ./otp_build boot -a
+ ./otp_build release -a $(pwd)/../otp_rel
+ }}}
+ 
+ = Step 5: Compile Couch =
+ 
+ {{{
+ rm -rf couchdb
+ git clone git://github.com/apache/couchdb.git
+ cd couchdb
+ git checkout 1.0.1
+ 
+ # Android Build Support from https://github.com/apage43/couchdb/tree/0.11.x-android
+ patch -p1 < ../couchdb.patch
+ 
+ ./bootstrap
+ 
+ # "Fix" configure so that it thinks that libmozjs.a is cool
+ # (This isn't being used and can be removed -- I could not get it to work)
+ #patch -p1 < ../couchdb2.patch
+ 
+ source $HOME/software/android/scripts/env
+ ANDROID_SDK=$HOME/software/android/sdk
+ 
+ ERL=$(pwd)/../otp/bootstrap/bin/erl \
+ ERLC=$(pwd)/../otp/bootstrap/bin/erlc \
+ LDFLAGS="-L$(pwd)/../mozilla-central/nsprpub/dist/lib -lnspr4 -lplc4 -lplds4 -L$(pwd)/../mozilla-central/js/src
-lmozjs" \
+ CC=agcc \
+ ./configure \
+ --host=arm-eabi \
+ --prefix=/sdcard/couch \
+ --with-android=$ANDROID_SDK/sources \
+ --with-android-curl=$(pwd)/../curl-7.20.0 \
+ --with-erlang=$(pwd)/../otp_rel/usr/include \
+ --with-js-include=$(pwd)/../mozilla-central/js/src/dist/include \
+ --with-js-lib=$(pwd)/../mozilla-central/js/src
+ 
+ make
+ make install
+ }}}
+ 
+ = Step 7: Package for use on Android =
+ 
+ if [ -z "$1" ]; then
+     echo "Give me a release number bub!"
+     exit 1
+ fi
+ 
+ DATE=$(date +"%Y-%m-%d_%H-%M-%S")
+ RELEASE="release-$DATE"
+ 
+ mkdir -p $RELEASE/data/data/com.your.namespace/bin
+ 
+ ##
+ # Configure and package Erlang/OTP
+ #
+ 
+ cp -Rdp otp_rel otp_rel.package
+ 
+ cd otp_rel.package
+ 
+ ./Install -cross -sasl /data/data/com.your.namespace/erlang
+ rm Install
+ 
+ rm -rf erts-5.7.5/include/* misc releases usr
+ 
+ cd lib
+ 
+ libs_to_keep="crypto-1.6.4 erts-5.7.5 inets-5.3 kernel-2.13.5 sasl-2.1.9 ssl-3.10.8 stdlib-1.16.5
xmerl-1.2.4"
+ 
+ mkdir backuplib
+ 
+ for i in $libs_to_keep
+ do
+     mv $i backuplib/
+ done
+ 
+ mv backuplib ../
+ rm -rf *
+ 
+ mv ../backuplib/* .
+ rmdir ../backuplib
+ 
+ # Remove vestigal files
+ rm -rf crypto-1.6.4/src/*.erl
+ rm -rf erts-5.7.5/src/*.erl
+ rm -rf inets-5.3/examples/* inets-5.3/src/*.erl
+ rm -rf kernel-2.13.5/examples/* kernel-2.13.5/include/* kernel-2.13.5/src/*.erl
+ rm -rf sasl-2.1.9/src/*.erl
+ rm -rf ssl-3.10.8/examples/certs ssl-3.10.8/examples/ebin ssl-3.10.8/examples/src ssl-3.10.8/include/*
ssl-3.10.8/pkix/*.erl ssl-3.10.8/src/*.erl
+ rm -rf stdlib-1.16.5/examples/* stdlib-1.16.5/include/* stdlib-1.16.5/src/*.erl
+ rm -rf xmerl-1.2.4/include xmerl-1.2.4/src
+ 
+ cd ..
+ 
+ # Update path to Android sh -- replace with a nice patch at some point
+ for i in bin/erl bin/start bin/start_erl erts-5.7.5/bin/erl erts-5.7.5/bin/erl.src erts-5.7.5/bin/start
erts-5.7.5/bin/start_erl.src erts-5.7.5/bin/start.src lib/inets-5.3/priv/bin/runcgi.sh
+ do
+     sed -e "s;#!/bin/sh;#!/system/bin/sh;" $i > $i.new
+     mv $i.new $i
+     chmod 755 $i
+ done
+ 
+ chmod -x erts-5.7.5/bin/start_erl.src erts-5.7.5/bin/start.src
+ 
+ cd ..
+ 
+ ##
+ # Configure and package CouchDB
+ # 
+ 
+ cp -Rdp /sdcard sdcard.package
+ 
+ mv sdcard.package/couch/lib/couchdb/erlang/lib/couch-1.0.1 otp_rel.package/lib
+ mv sdcard.package/couch/lib/couchdb/bin/couchjs $RELEASE/data/data/com.your.namespace/bin
+ cp mozilla-central/js/src/libmozjs.so $RELEASE/data/data/com.your.namespace/bin
+ 
+ cd sdcard.package/couch
+ 
+ # Reflect updated locations and the Android environment
+ patch -p1 < ../../../sdcard.patch
+ 
+ cd ../../..
+ 
+ ##
+ # Finally move things into place
+ #
+ 
+ mv otp_rel.package $RELEASE/data/data/com.your.namespace/erlang
+ mv sdcard.package $RELEASE/sdcard
+ 
+ cd $RELEASE
+ 
+ # DNS fixes from apage43's couchdb-android.s3.amazonaws.com/dns-fix.tgz
+ touch data/data/com.your.namspace/erlang/bin/erl_inetrc
+ patch -p1 < ../release.patch
+ 
+ # Build ICU for whatever version of Android was compiled in ~/software/android/sdk/sources
+ source $HOME/software/android/scripts/env
+ 
+ agcc \
+ -shared \
+ -o data/data/com.your.namespace/couch_icu_driver.so ../couchdb/src/couchdb/priv/.libs/libcouch_icu_driver.a
\
+ -licuuc \
+ -licudata \
+ -licui18n \
+ -L/home/matt/projects/couch/android-build/otp_rel/erts-5.7.5/bin \
+ -lbeam
+ 
+ ##
+ # Archive the release
+ #
+ tar -czf ../release-$1.tgz *
+ 
+ cd ..
+ }}}
+ 

Mime
View raw message