forked from supremegamers/android_external_ffmpeg
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgen-android-configs
executable file
·75 lines (67 loc) · 4.73 KB
/
gen-android-configs
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
#!/bin/bash
#
# Generate configurations for various FFMPEG targets
# TARGETS="armv5te armv7-a armv7-a-neon armv8-a silvermont x86 x86_64"
TARGETS="x86 x86_64"
# SYSROOT_BASE="../../prebuilts/ndk/current/platforms/android-21"
# TOOLS_BASE="../../prebuilts/gcc/linux-x86"
[ -d "$ANDROID_NDK_HOME" ] || { echo "ANDROID_NDK_HOME is not properly set"; exit 1; }
TOOLS_BASE="$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin"
BASE_CONFIG="--disable-static --enable-shared --enable-optimizations --disable-doc --disable-symver --disable-ffmpeg --disable-ffplay --disable-ffprobe --disable-avdevice --disable-devices --disable-filters --disable-demuxer=srt --disable-demuxer=microdvd --disable-demuxer=jacosub --disable-demuxer=sami --disable-demuxer=realtext --disable-demuxer=dts --disable-demuxer=subviewer --disable-demuxer=subviewer1 --disable-demuxer=pjs --disable-demuxer=vplayer --disable-demuxer=mpl2 --disable-decoder=ass --disable-decoder=srt --disable-decoder=subrip --disable-decoder=microdvd --disable-decoder=jacosub --disable-decoder=sami --disable-decoder=realtext --disable-decoder=movtext --disable-decoder=subviewer --disable-decoder=subviewer1 --disable-decoder=pjs --disable-decoder=vplayer --disable-decoder=mpl2 --disable-v4l2_m2m --enable-filter=scale --enable-filter=yadif --enable-filter=scale_vaapi --enable-filter=deinterlace_vaapi --enable-zlib --enable-pic --disable-debug --nm=${TOOLS_BASE}/llvm-nm --strip=${TOOLS_BASE}/llvm-strip --ar=${TOOLS_BASE}/llvm-ar --ranlib=${TOOLS_BASE}/llvm-ranlib --x86asmexe=${TOOLS_BASE}/yasm"
# OPTS_armv5te="--arch=arm --cpu=armv5te --build_suffix= --cross-prefix=${TOOLS_BASE}/arm/arm-linux-androideabi-4.9/bin/arm-linux-androideabi- --enable-cross-compile --sysroot=${SYSROOT_BASE}/arch-arm --target-os=android"
#
# OPTS_armv7_a="--arch=arm --disable-neon --cpu=armv7-a --build_suffix= --cross-prefix=${TOOLS_BASE}/arm/arm-linux-androideabi-4.9/bin/arm-linux-androideabi- --enable-cross-compile --sysroot=${SYSROOT_BASE}/arch-arm --target-os=android"
#
# OPTS_armv7_a_neon="--arch=arm --cpu=armv7-a --build_suffix= --cross-prefix=${TOOLS_BASE}/arm/arm-linux-androideabi-4.9/bin/arm-linux-androideabi- --enable-cross-compile --sysroot=${SYSROOT_BASE}/arch-arm --target-os=android"
#
# OPTS_armv8_a="--arch=aarch64 --enable-cross-compile --cross-prefix=${TOOLS_BASE}/aarch64/aarch64-linux-android-4.9/bin/aarch64-linux-android- --sysroot=${SYSROOT_BASE}/arch-arm64 --target-os=android"
#
# OPTS_silvermont="--arch=x86 --cpu=silvermont --build_suffix= --cross-prefix=${TOOLS_BASE}/x86/x86_64-linux-android-4.9/bin/x86_64-linux-android- --enable-cross-compile --sysroot=${SYSROOT_BASE}/arch-x86 --target-os=android --extra-cflags=-m32"
OPTS_x86="--arch=x86 --cpu=i686 --build_suffix= --cross-prefix=${TOOLS_BASE}/i686-linux-android31- --enable-cross-compile --target-os=android --cc=${TOOLS_BASE}/i686-linux-android31-clang --cxx=${TOOLS_BASE}/i686-linux-android31-clang++"
OPTS_x86_64="--arch=x86_64 --cpu=generic --build_suffix= --cross-prefix=${TOOLS_BASE}/x86_64-linux-android31- --enable-cross-compile --target-os=android --cc=${TOOLS_BASE}/x86_64-linux-android31-clang --cxx=${TOOLS_BASE}/x86_64-linux-android31-clang++"
for TARGET in $TARGETS;do
echo "Generating configuration for: ${TARGET}"
ARCH_OPTS=OPTS_`echo $TARGET | tr "-" "_"`
echo "configure ${!ARCH_OPTS} $BASE_CONFIG"
./configure ${!ARCH_OPTS} $BASE_CONFIG
if [ "$TARGET" = "x86" -o "$TARGET" = "x86_64" ]; then
mkdir -p android/include
cp config.asm android/include/config-${TARGET}.asm
TARGET=$TARGET-$TARGET
fi
mkdir -p android
mv ffbuild/config.mak android/config-${TARGET}.mak
cat config.h | sed -e "s/^#define \(ARCH_.*\|HAVE_.*\) \(.*\)/#ifdef \1\n#undef \1\n#endif\n#define \1 \2/g" > android/include/config-${TARGET}.h
rm -f config.asm config.h
done
GENERATED_FILES=" \
config_components.h \
libavutil/avconfig.h \
libavfilter/filter_list.c \
libavcodec/codec_list.c \
libavcodec/parser_list.c \
libavcodec/bsf_list.c \
libavformat/demuxer_list.c \
libavformat/muxer_list.c \
libavformat/protocol_list.c \
"
for gen in $GENERATED_FILES; do
mkdir -p android/include/`dirname $gen`
mv $gen android/include/$gen
done
sed -i -e '1 i\
#ifdef ANDROID\
URLProtocol ff_android_protocol;\
#endif\
' -e '1 a\
#ifdef ANDROID\
&ff_android_protocol,\
#endif' android/include/libavformat/protocol_list.c
# # Not sure why this gets configured wrong..
# perl -pi -e "s/define HAVE_EBP_AVAILABLE 1/define HAVE_EBP_AVAILABLE 0/g" android/include/config-silvermont.h android/include/config-x86.h android/include/config.asm
cat > android/include/libavutil/ffversion.h <<EOF
#ifndef FFVERSION_H
#define FFVERSION_H
#define FFMPEG_VERSION "`cat RELEASE` (Android-x86)"
#endif /* FFVERSION_H */
EOF