Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 1 | #! /bin/sh |
| 2 | |
| 3 | # Read the Android Wiki http://wiki.videolan.org/AndroidCompile |
| 4 | # Setup all that stuff correctly. |
Tristan Matthews | 8d02ef6 | 2014-07-22 16:03:17 -0400 | [diff] [blame] | 5 | # Get the latest Android SDK Platform or modify numbers in configure.sh and sflphone-android/default.properties. |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 6 | |
| 7 | set -e |
| 8 | |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 9 | if [ -z "$ANDROID_NDK" -o -z "$ANDROID_SDK" ]; then |
| 10 | echo "You must define ANDROID_NDK, ANDROID_SDK and ANDROID_ABI before starting." |
| 11 | echo "They must point to your NDK and SDK directories.\n" |
| 12 | exit 1 |
| 13 | fi |
| 14 | |
| 15 | if [ -z "$ANDROID_ABI" ]; then |
Alexandre Lision | 7d5df5d | 2014-10-27 13:10:01 -0400 | [diff] [blame] | 16 | echo "Please set ANDROID_ABI to your architecture: armeabi-v7a, armeabi, arm64-v8a, x86, x86_64 or mips." |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 17 | exit 1 |
| 18 | fi |
| 19 | |
Alexandre Lision | 7d5df5d | 2014-10-27 13:10:01 -0400 | [diff] [blame] | 20 | if [ -z "$NO_FPU" ];then |
| 21 | NO_FPU=0 |
| 22 | fi |
| 23 | if [ -z "$NO_ARMV6" ];then |
| 24 | NO_ARMV6=0 |
| 25 | fi |
| 26 | |
| 27 | BUILD=0 |
| 28 | FETCH=0 |
| 29 | RELEASE=0 |
| 30 | JNI=0 |
| 31 | |
| 32 | for i in ${@}; do |
| 33 | case "$i" in |
| 34 | --fetch) |
| 35 | FETCH=1 |
| 36 | ;; |
| 37 | --build) |
| 38 | BUILD=1 |
| 39 | ;; |
| 40 | release|--release) |
| 41 | RELEASE=1 |
| 42 | ;; |
| 43 | jni|--jni) |
| 44 | JNI=1 |
| 45 | ;; |
| 46 | *) |
| 47 | ;; |
| 48 | esac |
| 49 | done |
| 50 | |
| 51 | if [ "$BUILD" = 0 -a "$FETCH" = 0 ];then |
| 52 | BUILD=1 |
| 53 | FETCH=1 |
| 54 | fi |
| 55 | |
| 56 | if [ `set -- ${ANDROID_ABI}; echo $#` -gt 1 ]; then |
| 57 | ANDROID_ABI_LIST="${ANDROID_ABI}" |
| 58 | echo "More than one ABI specified: ${ANDROID_ABI_LIST}" |
| 59 | for i in ${ANDROID_ABI_LIST}; do |
| 60 | echo "$i starts building" |
| 61 | ANDROID_NDK=$ANDROID_NDK ANDROID_SDK=$ANDROID_SDK \ |
| 62 | NO_FPU=$NO_FPU NO_ARMV6=$NO_ARMV6 ANDROID_ABI=$i \ |
| 63 | ./compile.sh $* --jni || { echo "$i build KO"; exit 1; } |
| 64 | mkdir -p obj/ |
| 65 | cp -r sflphone-android/libs/$i obj |
| 66 | echo "$i build OK" |
| 67 | done |
| 68 | for i in ${ANDROID_ABI_LIST}; do |
| 69 | cp -r obj/$i sflphone-android/libs/ |
| 70 | rm -rf obj/$i |
| 71 | done |
| 72 | make -b -j1 RELEASE=$RELEASE apk || exit 1 |
| 73 | exit 0 |
| 74 | fi |
| 75 | |
| 76 | HAVE_ARM=0 |
| 77 | HAVE_X86=0 |
| 78 | HAVE_MIPS=0 |
| 79 | HAVE_64=0 |
| 80 | |
| 81 | |
| 82 | # Set up ABI variables |
| 83 | if [ ${ANDROID_ABI} = "x86" ] ; then |
| 84 | TARGET_TUPLE="i686-linux-android" |
| 85 | PATH_HOST="x86" |
| 86 | HAVE_X86=1 |
| 87 | PLATFORM_SHORT_ARCH="x86" |
| 88 | elif [ ${ANDROID_ABI} = "x86_64" ] ; then |
| 89 | TARGET_TUPLE="x86_64-linux-android" |
| 90 | PATH_HOST="x86_64" |
| 91 | HAVE_X86=1 |
| 92 | HAVE_64=1 |
| 93 | PLATFORM_SHORT_ARCH="x86_64" |
| 94 | elif [ ${ANDROID_ABI} = "mips" ] ; then |
| 95 | TARGET_TUPLE="mipsel-linux-android" |
| 96 | PATH_HOST=$TARGET_TUPLE |
| 97 | HAVE_MIPS=1 |
| 98 | PLATFORM_SHORT_ARCH="mips" |
| 99 | elif [ ${ANDROID_ABI} = "arm64-v8a" ] ; then |
| 100 | TARGET_TUPLE="aarch64-linux-android" |
| 101 | PATH_HOST=$TARGET_TUPLE |
| 102 | HAVE_ARM=1 |
| 103 | HAVE_64=1 |
| 104 | PLATFORM_SHORT_ARCH="arm64" |
| 105 | else |
| 106 | TARGET_TUPLE="arm-linux-androideabi" |
| 107 | PATH_HOST=$TARGET_TUPLE |
| 108 | HAVE_ARM=1 |
| 109 | PLATFORM_SHORT_ARCH="arm" |
| 110 | fi |
| 111 | |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 112 | # try to detect NDK version |
| 113 | REL=$(grep -o '^r[0-9]*.*' $ANDROID_NDK/RELEASE.TXT 2>/dev/null|cut -b2-) |
| 114 | case "$REL" in |
Tristan Matthews | d6033b4 | 2014-10-09 17:00:07 -0400 | [diff] [blame] | 115 | 10*) |
| 116 | if [ "${HAVE_64}" = 1 ];then |
| 117 | GCCVER=4.9 |
Alexandre Lision | 7d5df5d | 2014-10-27 13:10:01 -0400 | [diff] [blame] | 118 | ANDROID_API=android-21 |
Tristan Matthews | d6033b4 | 2014-10-09 17:00:07 -0400 | [diff] [blame] | 119 | else |
| 120 | GCCVER=4.8 |
| 121 | ANDROID_API=android-9 |
| 122 | fi |
| 123 | CXXSTL="/"${GCCVER} |
| 124 | ;; |
| 125 | 9*) |
| 126 | if [ "${HAVE_64}" = 1 ];then |
| 127 | echo "You need the NDKv10 or later for 64 bits build" |
| 128 | exit 1 |
| 129 | fi |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 130 | GCCVER=4.8 |
Tristan Matthews | d6033b4 | 2014-10-09 17:00:07 -0400 | [diff] [blame] | 131 | ANDROID_API=android-9 |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 132 | CXXSTL="/"${GCCVER} |
| 133 | ;; |
| 134 | 7|8|*) |
| 135 | echo "You need the NDKv9 or later" |
| 136 | exit 1 |
| 137 | ;; |
| 138 | esac |
| 139 | |
| 140 | export GCCVER |
| 141 | export CXXSTL |
Tristan Matthews | d6033b4 | 2014-10-09 17:00:07 -0400 | [diff] [blame] | 142 | export ANDROID_API |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 143 | |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 144 | # XXX : important! |
| 145 | [ "$HAVE_ARM" = 1 ] && cat << EOF |
| 146 | For an ARMv6 device without FPU: |
| 147 | $ export NO_FPU=1 |
| 148 | For an ARMv5 device: |
| 149 | $ export NO_ARMV6=1 |
| 150 | |
| 151 | If you plan to use a release build, run 'compile.sh release' |
| 152 | EOF |
| 153 | |
| 154 | export TARGET_TUPLE |
| 155 | export PATH_HOST |
| 156 | export HAVE_ARM |
| 157 | export HAVE_X86 |
| 158 | export HAVE_MIPS |
Alexandre Lision | 7d5df5d | 2014-10-27 13:10:01 -0400 | [diff] [blame] | 159 | export HAVE_64 |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 160 | export PLATFORM_SHORT_ARCH |
| 161 | |
| 162 | # Add the NDK toolchain to the PATH, needed both for contribs and for building |
| 163 | # stub libraries |
| 164 | NDK_TOOLCHAIN_PATH=`echo ${ANDROID_NDK}/toolchains/${PATH_HOST}-${GCCVER}/prebuilt/\`uname|tr A-Z a-z\`-*/bin` |
| 165 | export PATH=${NDK_TOOLCHAIN_PATH}:${PATH} |
| 166 | |
| 167 | ANDROID_PATH="`pwd`" |
| 168 | |
Tristan Matthews | a2665ff | 2014-08-12 18:27:23 -0400 | [diff] [blame] | 169 | # Fetch sflphone daemon source |
Alexandre Lision | 7f46d1c | 2014-10-27 16:39:25 -0400 | [diff] [blame] | 170 | if [ "$FETCH" = 1 ] |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 171 | then |
Tristan Matthews | 8d02ef6 | 2014-07-22 16:03:17 -0400 | [diff] [blame] | 172 | # 1/ libsflphone |
Alexandre Lision | 65a1d10 | 2014-11-07 12:25:57 -0500 | [diff] [blame^] | 173 | TESTED_HASH=86207dcf4d3c37a2ba0139f10da1bcdbc69269ea |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 174 | if [ ! -d "sflphone" ]; then |
Tristan Matthews | a2665ff | 2014-08-12 18:27:23 -0400 | [diff] [blame] | 175 | echo "sflphone daemon source not found, cloning" |
| 176 | git clone https://gerrit-sflphone.savoirfairelinux.com/sflphone |
| 177 | cd sflphone |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 178 | echo android/ >> .git/info/exclude |
| 179 | echo contrib/android/ >> .git/info/exclude |
Alexandre Lision | 3a206cf | 2014-10-15 12:18:51 -0400 | [diff] [blame] | 180 | git checkout $TESTED_HASH |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 181 | else |
Tristan Matthews | a2665ff | 2014-08-12 18:27:23 -0400 | [diff] [blame] | 182 | echo "sflphone daemon source found" |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 183 | cd sflphone |
Alexandre Lision | 65be770 | 2014-09-29 18:06:33 -0400 | [diff] [blame] | 184 | git fetch |
| 185 | git checkout ${TESTED_HASH} |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 186 | # if ! git cat-file -e ${TESTED_HASH}; then |
| 187 | # cat << EOF |
| 188 | #*** |
| 189 | #*** Error: Your sflphone checkout does not contain the latest tested commit *** |
| 190 | #*** |
| 191 | # |
| 192 | #Please update your source with something like: |
| 193 | # |
| 194 | #cd sflphone |
| 195 | #git reset --hard origin |
| 196 | #git pull origin master |
| 197 | #git checkout -B android ${TESTED_HASH} |
| 198 | # |
| 199 | #*** : This will delete any changes you made to the current branch *** |
| 200 | # |
| 201 | #EOF |
| 202 | # exit 1 |
| 203 | # fi |
| 204 | fi |
| 205 | else |
| 206 | cd sflphone |
| 207 | fi |
| 208 | |
| 209 | if [ -z "$BUILD" ] |
| 210 | then |
| 211 | echo "Not building anything, please run $0 --build" |
| 212 | exit 0 |
| 213 | fi |
| 214 | |
| 215 | # Setup CFLAGS |
| 216 | if [ ${ANDROID_ABI} = "armeabi-v7a" ] ; then |
| 217 | EXTRA_CFLAGS="-mfpu=vfpv3-d16 -mcpu=cortex-a8" |
| 218 | EXTRA_CFLAGS="${EXTRA_CFLAGS} -mthumb -mfloat-abi=softfp" |
| 219 | elif [ ${ANDROID_ABI} = "armeabi" ] ; then |
| 220 | if [ -n "${NO_ARMV6}" ]; then |
| 221 | EXTRA_CFLAGS="-march=armv5te -mtune=arm9tdmi -msoft-float" |
| 222 | else |
| 223 | if [ -n "${NO_FPU}" ]; then |
| 224 | EXTRA_CFLAGS="-march=armv6j -mtune=arm1136j-s -msoft-float" |
| 225 | else |
| 226 | EXTRA_CFLAGS="-mfpu=vfp -mcpu=arm1136jf-s -mfloat-abi=softfp" |
| 227 | fi |
| 228 | fi |
Alexandre Lision | 7d5df5d | 2014-10-27 13:10:01 -0400 | [diff] [blame] | 229 | elif [ ${ANDROID_ABI} = "arm64-v8a" ] ; then |
| 230 | EXTRA_CFLAGS="" |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 231 | elif [ ${ANDROID_ABI} = "x86" ] ; then |
Alexandre Lision | 7d5df5d | 2014-10-27 13:10:01 -0400 | [diff] [blame] | 232 | EXTRA_CFLAGS="-march=pentium -m32" |
| 233 | elif [ ${ANDROID_ABI} = "x86_64" ] ; then |
| 234 | EXTRA_CFLAGS="" |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 235 | elif [ ${ANDROID_ABI} = "mips" ] ; then |
| 236 | EXTRA_CFLAGS="-march=mips32 -mtune=mips32r2 -mhard-float" |
| 237 | # All MIPS Linux kernels since 2.4.4 will trap any unimplemented FPU |
| 238 | # instruction and emulate it, so we select -mhard-float. |
| 239 | # See http://www.linux-mips.org/wiki/Floating_point#The_Linux_kernel_and_floating_point |
| 240 | else |
| 241 | echo "Unknown ABI. Die, die, die!" |
| 242 | exit 2 |
| 243 | fi |
| 244 | |
| 245 | EXTRA_CFLAGS="${EXTRA_CFLAGS} -O2" |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 246 | EXTRA_CFLAGS="${EXTRA_CFLAGS} -I${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++${CXXSTL}/include" |
| 247 | EXTRA_CFLAGS="${EXTRA_CFLAGS} -I${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++${CXXSTL}/libs/${ANDROID_ABI}/include" |
| 248 | |
Tristan Matthews | 676fcee | 2014-10-03 15:57:09 -0400 | [diff] [blame] | 249 | # Setup LDFLAGS |
Alexandre Lision | 7d5df5d | 2014-10-27 13:10:01 -0400 | [diff] [blame] | 250 | EXTRA_LDFLAGS="-L${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++${CXXSTL}/libs/${ANDROID_ABI} -lgnustl_static" |
Tristan Matthews | 676fcee | 2014-10-03 15:57:09 -0400 | [diff] [blame] | 251 | |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 252 | # Make in // |
| 253 | UNAMES=$(uname -s) |
| 254 | MAKEFLAGS= |
| 255 | if which nproc >/dev/null |
| 256 | then |
| 257 | MAKEFLAGS=-j`nproc` |
| 258 | elif [ "$UNAMES" == "Darwin" ] && which sysctl >/dev/null |
| 259 | then |
| 260 | MAKEFLAGS=-j`sysctl -n machdep.cpu.thread_count` |
| 261 | fi |
| 262 | |
Tristan Matthews | d6d5d40 | 2014-10-09 16:41:06 -0400 | [diff] [blame] | 263 | # Build buildsystem tools |
| 264 | export PATH=`pwd`/daemon/extras/tools/build/bin:$PATH |
| 265 | echo "Building tools" |
| 266 | cd daemon/extras/tools |
| 267 | ./bootstrap |
| 268 | make $MAKEFLAGS |
Tristan Matthews | eb9209c | 2014-10-09 23:11:44 -0400 | [diff] [blame] | 269 | #FIXME |
| 270 | echo "HACK for old Jenkins builder...forcing libtool to be built" |
| 271 | make .libtool |
Tristan Matthews | d6d5d40 | 2014-10-09 16:41:06 -0400 | [diff] [blame] | 272 | cd ../../.. |
| 273 | |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 274 | ############ |
| 275 | # Contribs # |
| 276 | ############ |
| 277 | echo "Building the contribs" |
Alexandre Lision | 4073432 | 2014-09-03 14:26:59 -0400 | [diff] [blame] | 278 | mkdir -p daemon/contrib/contrib-android-${TARGET_TUPLE} |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 279 | |
| 280 | gen_pc_file() { |
| 281 | echo "Generating $1 pkg-config file" |
| 282 | echo "Name: $1 |
| 283 | Description: $1 |
| 284 | Version: $2 |
| 285 | Libs: -l$1 |
Alexandre Lision | 4073432 | 2014-09-03 14:26:59 -0400 | [diff] [blame] | 286 | Cflags:" > daemon/contrib/${TARGET_TUPLE}/lib/pkgconfig/`echo $1|tr 'A-Z' 'a-z'`.pc |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 287 | } |
| 288 | |
Alexandre Lision | 4073432 | 2014-09-03 14:26:59 -0400 | [diff] [blame] | 289 | mkdir -p daemon/contrib/${TARGET_TUPLE}/lib/pkgconfig |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 290 | |
Alexandre Lision | 4073432 | 2014-09-03 14:26:59 -0400 | [diff] [blame] | 291 | cd daemon/contrib/contrib-android-${TARGET_TUPLE} |
Alexandre Lision | ec1f3ee | 2014-08-04 19:12:42 -0400 | [diff] [blame] | 292 | ../bootstrap --host=${TARGET_TUPLE} |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 293 | |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 294 | # Some libraries have arm assembly which won't build in thumb mode |
| 295 | # We append -marm to the CFLAGS of these libs to disable thumb mode |
| 296 | [ ${ANDROID_ABI} = "armeabi-v7a" ] && echo "NOTHUMB := -marm" >> config.mak |
| 297 | |
| 298 | # Release or not? |
| 299 | if [ $# -ne 0 ] && [ "$1" = "release" ]; then |
| 300 | OPTS="" |
| 301 | EXTRA_CFLAGS="${EXTRA_CFLAGS} -DNDEBUG " |
| 302 | RELEASE=1 |
| 303 | else |
| 304 | OPTS="--enable-debug" |
Tristan Matthews | 8d02ef6 | 2014-07-22 16:03:17 -0400 | [diff] [blame] | 305 | EXTRA_CFLAGS="${EXTRA_CFLAGS} -DNDEBUG " |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 306 | RELEASE=0 |
| 307 | fi |
| 308 | |
| 309 | echo "EXTRA_CFLAGS= -g ${EXTRA_CFLAGS}" >> config.mak |
Tristan Matthews | fc84807 | 2014-10-09 03:43:54 -0400 | [diff] [blame] | 310 | echo "EXTRA_CXXFLAGS= -g ${EXTRA_CXXFLAGS}" >> config.mak |
Tristan Matthews | 676fcee | 2014-10-03 15:57:09 -0400 | [diff] [blame] | 311 | echo "EXTRA_LDFLAGS= ${EXTRA_LDFLAGS}" >> config.mak |
Tristan Matthews | 8d02ef6 | 2014-07-22 16:03:17 -0400 | [diff] [blame] | 312 | export SFLPHONE_EXTRA_CFLAGS="${EXTRA_CFLAGS}" |
Tristan Matthews | fc84807 | 2014-10-09 03:43:54 -0400 | [diff] [blame] | 313 | export SFLPHONE_EXTRA_CXXFLAGS="${EXTRA_CXXFLAGS}" |
Tristan Matthews | 676fcee | 2014-10-03 15:57:09 -0400 | [diff] [blame] | 314 | export SFLPHONE_EXTRA_LDFLAGS="${EXTRA_LDFLAGS}" |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 315 | |
Alexandre Lision | 68d8f2e | 2014-07-30 17:42:40 -0400 | [diff] [blame] | 316 | make install |
Alexandre Lision | ec1f3ee | 2014-08-04 19:12:42 -0400 | [diff] [blame] | 317 | echo ${PWD} |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 318 | # We already have zlib available |
| 319 | [ -e .zlib ] || (mkdir -p zlib; touch .zlib) |
| 320 | which autopoint >/dev/null || make $MAKEFLAGS .gettext |
| 321 | export PATH="$PATH:$PWD/../$TARGET_TUPLE/bin" |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 322 | |
Tristan Matthews | eaaa5ba | 2014-10-09 04:23:06 -0400 | [diff] [blame] | 323 | export SFLPHONE_BUILD_DIR=sflphone/daemon/build-android-${TARGET_TUPLE} |
Alexandre Lision | 7d5df5d | 2014-10-27 13:10:01 -0400 | [diff] [blame] | 324 | |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 325 | ############ |
Tristan Matthews | 8d02ef6 | 2014-07-22 16:03:17 -0400 | [diff] [blame] | 326 | # Make SFLPHONE # |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 327 | ############ |
| 328 | cd ../.. && mkdir -p build-android-${TARGET_TUPLE} && cd build-android-${TARGET_TUPLE} |
| 329 | |
Alexandre Lision | 7d5df5d | 2014-10-27 13:10:01 -0400 | [diff] [blame] | 330 | if [ "$JNI" = 1 ]; then |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 331 | CLEAN="jniclean" |
Tristan Matthews | 33873ca | 2014-10-09 13:35:39 -0400 | [diff] [blame] | 332 | TARGET="sflphone-android/obj/local/${ANDROID_ABI}/libsflphone.so" |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 333 | else |
| 334 | CLEAN="distclean" |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 335 | TARGET= |
| 336 | fi |
| 337 | |
Alexandre Lision | 7d5df5d | 2014-10-27 13:10:01 -0400 | [diff] [blame] | 338 | if [ ! -f config.h ]; then |
| 339 | echo "Bootstraping" |
| 340 | cd ../ |
| 341 | ./autogen.sh |
| 342 | cd ../../ |
| 343 | cd sflphone-android |
| 344 | ./make-swig.sh |
| 345 | cd ../sflphone/daemon/build-android-${TARGET_TUPLE} |
| 346 | echo "Configuring" |
| 347 | ${ANDROID_PATH}/configure.sh ${OPTS} |
| 348 | fi |
| 349 | |
| 350 | # ANDROID NDK FIXUP (BLAME GOOGLE) |
| 351 | config_undef () |
| 352 | { |
| 353 | previous_change=`stat -c "%y" config.h` |
| 354 | sed -i 's,#define '$1' 1,/\* #undef '$1' \*/,' config.h |
| 355 | # don't change modified date in order to don't trigger a full build |
| 356 | touch -d "$previous_change" config.h |
| 357 | } |
| 358 | |
| 359 | # if config dependencies change, ./config.status --recheck |
| 360 | # is run and overwrite previously hacked config.h. So call make Makefile here |
| 361 | # and hack config.h after. |
| 362 | |
| 363 | make $MAKEFLAGS Makefile |
| 364 | |
| 365 | if [ ${ANDROID_ABI} = "x86" -a ${ANDROID_API} != "android-21" ] ; then |
| 366 | # NDK x86 libm.so has nanf symbol but no nanf definition, we don't known if |
| 367 | # intel devices has nanf. Assume they don't have it. |
| 368 | config_undef HAVE_NANF |
| 369 | fi |
| 370 | if [ ${ANDROID_API} = "android-21" ] ; then |
| 371 | # android-21 has empty sys/shm.h headers that triggers shm detection but it |
| 372 | # doesn't have any shm functions and/or symbols. */ |
| 373 | config_undef HAVE_SYS_SHM_H |
| 374 | fi |
| 375 | # END OF ANDROID NDK FIXUP |
| 376 | |
Alexandre Lision | 3a206cf | 2014-10-15 12:18:51 -0400 | [diff] [blame] | 377 | echo "Building libsflphone" |
| 378 | make $MAKEFLAGS |
| 379 | |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 380 | #################################### |
| 381 | # Ring android UI and specific code |
| 382 | #################################### |
| 383 | echo "Building Ring for Android" |
Alexandre Lision | 4073432 | 2014-09-03 14:26:59 -0400 | [diff] [blame] | 384 | cd ../../../ |
Tristan Matthews | fc84807 | 2014-10-09 03:43:54 -0400 | [diff] [blame] | 385 | |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 386 | make $CLEAN |
| 387 | make -j1 TARGET_TUPLE=$TARGET_TUPLE PLATFORM_SHORT_ARCH=$PLATFORM_SHORT_ARCH CXXSTL=$CXXSTL RELEASE=$RELEASE $TARGET |
| 388 | |
| 389 | # |
| 390 | # Exporting a environment script with all the necessary variables |
| 391 | # |
| 392 | echo "Generating environment script." |
| 393 | cat <<EOF |
| 394 | This is a script that will export many of the variables used in this |
| 395 | script. It will allow you to compile parts of the build without having |
| 396 | to rebuild the entire build (e.g. recompile only the Java part). |
| 397 | |
| 398 | To use it, include the script into your shell, like this: |
| 399 | source env.sh |
| 400 | |
| 401 | Now, you can use this command to build the Java portion: |
| 402 | make -e |
| 403 | |
| 404 | The file will be automatically regenerated by compile.sh, so if you change |
| 405 | your NDK/SDK locations or any build configurations, just re-run this |
| 406 | script (sh compile.sh) and it will automatically update the file. |
| 407 | |
| 408 | EOF |
| 409 | |
| 410 | echo "# This file was automatically generated by compile.sh" > env.sh |
| 411 | echo "# Re-run 'sh compile.sh' to update this file." >> env.sh |
| 412 | |
| 413 | # The essentials |
| 414 | cat <<EssentialsA >> env.sh |
| 415 | export ANDROID_ABI=$ANDROID_ABI |
| 416 | export ANDROID_SDK=$ANDROID_SDK |
| 417 | export ANDROID_NDK=$ANDROID_NDK |
| 418 | export GCCVER=$GCCVER |
| 419 | export CXXSTL=$CXXSTL |
Tristan Matthews | fc84807 | 2014-10-09 03:43:54 -0400 | [diff] [blame] | 420 | export SFLPHONE_BUILD_DIR=$SFLPHONE_BUILD_DIR |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 421 | export TARGET_TUPLE=$TARGET_TUPLE |
| 422 | export PATH_HOST=$PATH_HOST |
| 423 | export PLATFORM_SHORT_ARCH=$PLATFORM_SHORT_ARCH |
| 424 | EssentialsA |
| 425 | |
| 426 | # PATH |
| 427 | echo "export PATH=$NDK_TOOLCHAIN_PATH:\${ANDROID_SDK}/platform-tools:\${PATH}" >> env.sh |
| 428 | |
| 429 | # CPU flags |
| 430 | if [ -n "${HAVE_ARM}" ]; then |
| 431 | echo "export HAVE_ARM=1" >> env.sh |
| 432 | elif [ -n "${HAVE_X86}" ]; then |
| 433 | echo "export HAVE_X86=1" >> env.sh |
| 434 | elif [ -n "${HAVE_MIPS}" ]; then |
| 435 | echo "export HAVE_MIPS=1" >> env.sh |
| 436 | fi |
| 437 | |
| 438 | if [ -n "${NO_ARMV6}" ]; then |
| 439 | echo "export NO_ARMV6=1" >> env.sh |
| 440 | fi |
| 441 | if [ -n "${NO_FPU}" ]; then |
| 442 | echo "export NO_FPU=1" >> env.sh |
| 443 | fi |