1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348
|
#!/bin/bash
# Script to compile BOINC for Android.
# Requires the BOINC source directory and the Android NDK.
#
# Date: December 12th, 2011
# Author: Peter Hanappe (Sony Computer Science Laboratory)
BOINCDIR=`pwd`
NDK_SYSROOT=""
NDK_PATH=""
NDK_ARCH="arm"
NDK_ROOT=""
NDK_ABI="armeabi"
NDK_VERSION="android-8"
COMPILE_BOINC="yes"
COMPILE_ZLIB="yes"
COMPILE_OPENSSL="yes"
COMPILE_CURL="yes"
CONFIGURE="yes"
MAKE_CLEAN="no"
function print_usage()
{
echo "Options:"
echo " --help"
echo " --boinc-dir <dir> Root directory of BOINC source tree (default: current dir)."
echo " --android-root <dir> The root directory of the Android NDK."
echo " --android-sysroot <dir> The target sysroot directory of the Android NDK."
echo " --android-bin <dir> The bin directory of the Android NDK compilers."
echo " --android-arch <dir> Compile for 'arm' or 'x86' architecture (default: arm)."
echo " --android-version <val> Specify Android version (default: android-8)."
echo " --skip-boinc Don't compile BOINC."
echo " --skip-zlib Don't download and compile zlib."
echo " --skip-openssl Don't download and compile OpenSSL."
echo " --skip-curl Don't download and compile curl."
echo " --skip-configure Don't run configure script before compiling."
echo " --make-clean Run 'make clean' before compiling."
echo "Example: ./AndroidBuild.sh \\"
echo " --android-root /opt/google/android-ndk-r6 \\"
echo " --android-bin /opt/google/android-ndk-r6/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin"
exit 0
}
while (($#)); do
option=$1
shift
case "$option" in
--help)
print_usage
shift
;;
--boinc-dir)
BOINCDIR=$1
shift
;;
--android-sysroot)
NDK_SYSROOT=$1
shift
;;
--android-root)
NDK_ROOT=$1
shift
;;
--android-bin)
NDK_PATH=$1
shift
;;
--android-arch)
NDK_ARCH=$1
shift
;;
--android-version)
NDK_VERSION=$1
shift
;;
--skip-boinc)
COMPILE_BOINC="no"
;;
--skip-zlib)
COMPILE_ZLIB="no"
;;
--skip-openssl)
COMPILE_OPENSSL="no"
;;
--skip-curl)
COMPILE_CURL="no"
;;
--skip-configure)
CONFIGURE="no"
;;
--make-clean)
MAKE_CLEAN="yes"
;;
*)
echo "Unknown option ${option}"
print_usage
;;
esac
done
###################################################
# Test options and paths
if [ ! -e "${BOINCDIR}/client/gui_rpc_server.h" ]; then
echo "Please launch this script in the boinc root directory, or use the --boinc-dir <dir> option."
print_usage
fi
if [ "x${NDK_ROOT}" == "x" ]; then
echo "Please specify the Android NDK root directory."
print_usage
fi
if [ ${NDK_ARCH} == "arm" ]; then
NDK_HOST=arm-linux-androideabi
elif [ ${NDK_ARCH} == "x86" ]; then
NDK_HOST=i686-android-linux
else
echo "Please specify the Android architecture."
print_usage
fi
NDK_CC=${NDK_HOST}-gcc
if [ "x${NDK_SYSROOT}" == "x" ]; then
NDK_SYSROOT=${NDK_ROOT}/platforms/${NDK_VERSION}/arch-${NDK_ARCH}
if [ ! -d ${NDK_SYSROOT} ]; then
echo "Please specify the Android NDK sysroot."
echo "Tried, but failed: ${NDK_SYSROOT}"
print_usage
fi
fi
if [ "x${NDK_PATH}" == "x" ]; then
echo "Please specify the Android binary directory."
print_usage
fi
if [ ! -e "${NDK_SYSROOT}/usr/include/stdio.h" ]; then
echo "Could not find ${NDK_SYSROOT}/usr/include/stdio.h header. Please verify the sysroot."
print_usage
fi
if [ ! -e "${NDK_PATH}/${NDK_CC}" ]; then
echo "Could not find the ${NDK_CC} compiler. Please verify the binary path."
print_usage
fi
###################################################
echo "================================================"
echo "BOINCDIR ${BOINCDIR}"
echo "NDK_ROOT ${NDK_ROOT}"
echo "NDK_SYSROOT ${NDK_SYSROOT}"
echo "NDK_PATH ${NDK_PATH}"
echo "NDK_ARCH ${NDK_ARCH}"
echo "NDK_HOST ${NDK_HOST}"
echo "NDK_ABI ${NDK_ABI}"
echo "NDK_VERSION ${NDK_VERSION}"
echo "NDK_CC ${NDK_CC}"
echo "COMPILE_ZLIB $COMPILE_ZLIB"
echo "COMPILE_OPENSSL $COMPILE_OPENSSL"
echo "COMPILE_CURL $COMPILE_CURL"
echo "CONFIGURE $CONFIGURE"
echo "MAKE_CLEAN $MAKE_CLEAN"
echo "================================================"
###################################################
function compile_zlib()
{
echo "================================================"
echo "= Starting download and compilation of zlib ="
echo "================================================"
cd ${BOINCDIR}/android
if [ ! -e zlib-1.2.5 ]; then
wget http://zlib.net/zlib-1.2.5.tar.gz
tar xzvf zlib-1.2.5.tar.gz
fi
cd zlib-1.2.5
if [ $CONFIGURE == "yes" ]; then
CC="${NDK_PATH}/${NDK_CC} --sysroot=${NDK_SYSROOT}" \
./configure --prefix=${BOINCDIR}/android/${NDK_ARCH} --static
fi
if [ $MAKE_CLEAN == "yes" ]; then
make clean
fi
make
# The 'make install' script fails
mkdir -p ${BOINCDIR}/android/${NDK_ARCH}/lib
mkdir -p ${BOINCDIR}/android/${NDK_ARCH}/include
cp libz.a ${BOINCDIR}/android/${NDK_ARCH}/lib
cp zlib.h ${BOINCDIR}/android/${NDK_ARCH}/lib
cp zconf.h ${BOINCDIR}/android/${NDK_ARCH}/lib
}
###################################################
function compile_openssl()
{
echo "================================================"
echo "= Starting download and compilation of openssl ="
echo "================================================"
cd ${BOINCDIR}/android
if [ ! -e openssl-1.0.0e ]; then
wget http://www.openssl.org/source/openssl-1.0.0e.tar.gz
tar xzvf openssl-1.0.0e.tar.gz
fi
cd openssl-1.0.0e
if [ $CONFIGURE == "yes" ]; then
CC="${NDK_PATH}/${NDK_CC} --sysroot=${NDK_SYSROOT}" \
./config --prefix=${BOINCDIR}/android/${NDK_ARCH} no-shared no-asm
fi
if [ $MAKE_CLEAN == "yes" ]; then
make clean
fi
make
make install
}
###################################################
function compile_curl()
{
echo "================================================"
echo "= Starting download and compilation of curl ="
echo "================================================"
cd ${BOINCDIR}/android
if [ ! -e curl-7.23.1 ]; then
wget http://curl.haxx.se/download/curl-7.23.1.tar.gz
tar xzvf curl-7.23.1.tar.gz
fi
cd curl-7.23.1
# Export binary path.
export PATH=${PATH}:${NDK_PATH}
#
# ./configure --with-sysroot=${NDK_SYSROOT} doesn't seem to work. Pass
# the correct path using the CFLAGS environment variable.
#
# The ANDROID flag is used in curl-7.23.1/include/curl/curl.h
#
if [ $CONFIGURE == "yes" ]; then
CFLAGS="--sysroot=${NDK_SYSROOT} -DANDROID" \
./configure --host=${NDK_HOST} \
--with-sysroot=${NDK_SYSROOT} \
--prefix=${BOINCDIR}/android/${NDK_ARCH} --enable-debug \
--disable-shared --enable-static \
--enable-http --disable-ftp --disable-ldap --disable-ldaps \
--disable-rtsp --disable-proxy --disable-dict --disable-telnet \
--disable-tftp --disable-pop3 --disable-imap --disable-smtp \
--disable-gopher --disable-ipv6 --disable-sspi --disable-crypto-auth \
--disable-tls-srp --disable-ntlm-wb --disable-cookies --disable-manual \
--disable-threaded-resolver --without-ca-bundle
fi
if [ $MAKE_CLEAN == "yes" ]; then
make clean
fi
make
make install
}
###################################################
# Problems:
# - problems in configure.ac with curl: --with-curl doesn't use the correct path
# - config.sub too old to recognize --host=arm-linux-androideabi, used newer config.sub (2011-03-23)
# - changed lib/network.cpp:298: !defined(__ANDROID__)
# - changed lib/synch.cpp: #if defined(__ANDROID__) \ #define create_semaphore(_key) (-1), ...
# - changed lib/mac_address.cpp:189: #elif (defined(SIOCGIFCONF) || defined(SIOCGLIFCONF)) && !defined(__ANDROID__)
function compile_boinc()
{
cd ${BOINCDIR}
# Export binary path.
export PATH=${PATH}:${NDK_PATH}
if [ $CONFIGURE == "yes" ]; then
bash _autosetup
OPTIONS="--host=${NDK_HOST} \
--disable-server \
--enable-client \
--disable-manager \
--enable-libraries \
--enable-debug \
--with-ssl=${BOINCDIR}/android/arm/lib"
echo "================================================"
echo "Configuring BOINC with: $OPTIONS"
echo "================================================"
FLAGS="--sysroot=${NDK_SYSROOT} \
-I${NDK_ROOT}/sources/cxx-stl/gnu-libstdc++/include \
-I${NDK_ROOT}/sources/cxx-stl/gnu-libstdc++/libs/${NDK_ABI}/include"
CFLAGS="${FLAGS}" \
CXXFLAGS="${FLAGS}" \
LDFLAGS="-L${BOINCDIR}/android/arm/lib -L${NDK_ROOT}/sources/cxx-stl/gnu-libstdc++/libs/${NDK_ABI}" \
LIBS="-lstdc++" \
./configure ${OPTIONS}
fi
if [ $MAKE_CLEAN == "yes" ]; then
make clean
fi
make
}
###################################################
if [ ! -e "${BOINCDIR}/android" ]; then
echo "================================================"
echo "= Creating the android direcory ="
echo "================================================"
mkdir ${BOINCDIR}/android
fi
if [ $COMPILE_ZLIB == "yes" ]; then
compile_zlib
fi
if [ $COMPILE_OPENSSL == "yes" ]; then
compile_openssl
fi
if [ $COMPILE_CURL == "yes" ]; then
compile_curl
fi
if [ $COMPILE_BOINC == "yes" ]; then
compile_boinc
fi
|