forked from georgepar/opensmile
-
Notifications
You must be signed in to change notification settings - Fork 0
/
buildAndroid.sh
executable file
·94 lines (77 loc) · 3.47 KB
/
buildAndroid.sh
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
#!/bin/sh
# This file is part of openSMILE.
#
# Copyright (c) audEERING. All rights reserved.
# See the file COPYING for details on license terms.
STATIC_BIN="no";
Pwdd=`pwd`;
if [ "$STATIC_BIN" = "yes" ]; then
STATIC_DEFINE="-D__STATIC_LINK";
DYN_LIBS="";
ENABLE_SHARED="no";
else
DYN_LIBS="-llog -lOpenSLES";
ENABLE_SHARED="yes";
STATIC_DEFINE="";
fi
##cross compiler variables
./autogen.sh ;
./autogen.sh ;
## cross compiler variables
platform=android-21
############## NOTE: Update the path to your Android NDK.
############## Version 10e is required!
export NDK=`realpath ~/android/ndk-r10e`;
#########################################################
export CROSS_COMPILE=arm-linux-androideabi
STL_VERSION=4.8
export NDK_TOOLCHAIN=${NDK}/toolchains/${CROSS_COMPILE}-4.9/prebuilt/linux-x86_64/bin
export CC=${NDK_TOOLCHAIN}/${CROSS_COMPILE}-gcc
export CXX=${NDK_TOOLCHAIN}/${CROSS_COMPILE}-g++
export LD=${NDK_TOOLCHAIN}/${CROSS_COMPILE}-ld
export AR=${NDK_TOOLCHAIN}/${CROSS_COMPILE}-ar
export RANLIB=${NDK_TOOLCHAIN}/${CROSS_COMPILE}-ranlib
export STRIP=${NDK_TOOLCHAIN}/${CROSS_COMPILE}-strip
export ac_cv_func_malloc_0_nonnull=yes
export ac_cv_func_realloc_0_nonnull=yes
##flags
export OPTIMISE="-fPIE -pie -ffast-math -ftree-vectorize -march=armv7-a -mthumb -mfloat-abi=softfp -mfpu=vfp -mfpu=neon -funsafe-math-optimizations";
export LDFLAGS="-fPIE -pie -fexceptions -Wl,-rpath-link=${NDK}/platforms/${platform}/arch-arm/usr/lib -L${NDK}/platforms/${platform}/arch-arm/usr/lib -L${NDK}/sources/cxx-stl/gnu-libstdc++/${STL_VERSION}/libs/armeabi"
export LDFLAGS_CORE="-fPIE -pie -fexceptions -L${NDK}/platforms/${platform}/arch-arm/usr/lib -L${NDK}/sources/cxx-stl/gnu-libstdc++/${STL_VERSION}/libs/armeabi"
export SYSROOT=${NDK}/platforms/${platform}/arch-arm
export CXXFLAGS="-I${NDK}/platforms/${platform}/arch-arm/usr/include -I${NDK}/sources/cxx-stl/gnu-libstdc++/${STL_VERSION}/include -I${NDK}/sources/cxx-stl/gnu-libstdc++/${STL_VERSION}/libs/armeabi/include --sysroot=${SYSROOT} -g -O3 $OPTIMISE"
DEFINES="-DOPENSMILE_BUILD -DBUILD_LIBSVM -DBUILD_SVMSMO -DBUILD_RNNFAST -DBUILD_WITHOUT_EXPERIMENTAL"
export CPPFLAGS="--sysroot=${SYSROOT} -D__ANDROID__ ${DEFINES} -DHAVE_OPENSLES $STATIC_DEFINE"
export CFLAGS="--sysroot=${SYSROOT} -nostdlib -g -O3 ${OPTIMISE}"
###add compiler options
#export LIBS="-lc -lm -lgcc -lgnustl_shared -lsupc++ -llog -lOpenSLES"
export LIBS="-lc -lm -lgcc -lgnustl_static -lsupc++ $DYN_LIBS"
##configure opensmile
mkdir -p "$Pwdd/inst/android"
./configure --enable-static --enable-shared=no --host=arm-linux-androideabi --target=arm-linux-androideabi LIBS="$LIBS" --prefix="$Pwdd/inst/android";
if [ $? != 0 ]; then
echo "failed to configure openSMILE!";
exit -1;
fi
make clean &&
make -j8
make install
if [ $? != 0 ]; then
echo "failed to build openSMILE!";
exit -1;
fi
# fully static binary:
if [ "$STATIC_BIN" = "yes" ]; then
rm SMILExtract
$CXX $CXXFLAGS -o $Pwdd/inst/android/SMILExtract-static progsrc/smilextract/SMILExtract-SMILExtract.o .libs/libopensmile.a -static $LDFLAGS $LIBS
fi
####
chmod 777 SMILExtract
chmod 777 inst/android/bin/SMILExtract
echo ""
if [ "$STATIC_BIN" = "yes" ]; then
echo "build successfull. You can now use the inst/android/bin/SMILExtract-static binary for Android. For linking with Android project, use builds in inst/android/lib folder."
else
echo "build successfull. You can now use the inst/android/bin/SMILExtract binary for Android. For linking with Android project, use builds in inst/android/lib folder."
fi
echo ""