-
Notifications
You must be signed in to change notification settings - Fork 1
/
configure
executable file
·101 lines (90 loc) · 2.6 KB
/
configure
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
#!/bin/bash
echo ""
print_usage() {
me="$(basename "$(test -L "$0" && readlink "$0" || echo "$0")")"
echo ""
echo ""
echo " Usage: $me : <Target Architecture CPU> <Android NDK Path>"
echo " <Build OS> <Toolchain Version>"
echo ""
echo " Target Architecture CPU : arm, x86"
echo " Android NDK Path : path to NDK"
echo " e.g. /android/android-ndk-r10e (must be r10e)"
echo ""
exit -1
}
CPU=$1
ANDROID_NDK=$2
BUILD_OS=linux-x86_64
TOOLCHAIN_VERSION=4.9
SYSROOT=$ANDROID_NDK/platforms/android-21/arch-$CPU/
if [ "$CPU" == "" ]; then
echo "Missing Target Architecture CPU parameter"
print_usage
elif [ "$ANDROID_NDK" == "" ]; then
echo "Missing Android NDK Path parameter"
print_usage
fi
echo "Configuring FFmpeg for $CPU with $ANDROID_NDK"
TOOLCHAIN_ARCH=
TOOLCHAIN_BIN_PREFIX=
if [ "$CPU" == "arm" ]; then
TOOLCHAIN_ARCH=arm-linux-androideabi
TOOLCHAIN_BIN_PREFIX=arm-linux-androideabi
elif [ "$CPU" == "x86" ]; then
TOOLCHAIN_ARCH=x86
TOOLCHAIN_BIN_PREFIX=i686-linux-android
fi
TOOLCHAIN=$ANDROID_NDK/toolchains/$TOOLCHAIN_ARCH-$TOOLCHAIN_VERSION/prebuilt/$BUILD_OS
PREFIX=$(pwd)/android/$CPU
# Set these if needed
FF_FLAGS=" "
CC_FLAGS="-w -fpic -pipe -Os -fexceptions -frtti -DANDROID -DNDEBUG "
if [ "$CPU" = "arm" ]; then
CC_FLAGS="$CC_FLAGS -march=armv7-a -mtune=cortex-a9 -mfloat-abi=softfp -mfpu=neon "
FF_FLAGS="$FF_FLAGS --cpu=cortex-a9 --enable-pic --disable-armv5te --disable-armv6t2 "
else
CC_FLAGS="$CC_FLAGS -march=atom -msse3 -ffast-math -mfpmath=sse "
FF_FLAGS="$FF_FLAGS --cpu=i686 --disable-mmx --disable-asm "
fi
CX_FLAGS="$CC_FLAGS -frtti"
cd ./FFmpeg
ret=$?
if [ $ret -eq 0 ]; then
./configure \
--prefix=$PREFIX \
--disable-static \
--enable-shared \
--disable-doc \
--disable-programs \
--disable-avdevice \
--disable-avformat \
--disable-swscale \
--disable-postproc \
--disable-avfilter \
--disable-symver \
--disable-swresample \
--enable-avresample \
--cross-prefix=$TOOLCHAIN/bin/$TOOLCHAIN_BIN_PREFIX- \
--enable-cross-compile \
--cpu=$CPU \
--arch=$CPU \
--target-os=android \
--sysroot=$SYSROOT \
--pkg-config=pkg-config \
--pkg-config-flags="--static" \
--extra-cflags="$CC_FLAGS" \
--extra-cxxflags="$CX_FLAGS" \
--extra-ldexeflags=-pie \
$FF_FLAGS
ret=$?
cd ..
if [ $ret -eq 0 ]; then
echo "Configured"
else
echo "Failed to configure"
fi
else
echo "Failed to move to FFmpeg directory"
fi
exit $ret