• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2#
3# Copyright (C) 2019 The Android Open Source Project
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9#      http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16#
17
18FFMPEG_EXT_PATH=$1
19NDK_PATH=$2
20HOST_PLATFORM=$3
21ENABLED_DECODERS=("${@:4}")
22COMMON_OPTIONS="
23    --target-os=android
24    --disable-static
25    --enable-shared
26    --disable-doc
27    --disable-programs
28    --disable-everything
29    --disable-avdevice
30    --disable-avformat
31    --disable-swscale
32    --disable-postproc
33    --disable-avfilter
34    --disable-symver
35    --disable-avresample
36    --enable-swresample
37    --extra-ldexeflags=-pie
38    "
39TOOLCHAIN_PREFIX="${NDK_PATH}/toolchains/llvm/prebuilt/${HOST_PLATFORM}/bin"
40for decoder in "${ENABLED_DECODERS[@]}"
41do
42    COMMON_OPTIONS="${COMMON_OPTIONS} --enable-decoder=${decoder}"
43done
44cd "${FFMPEG_EXT_PATH}"
45(git -C ffmpeg pull || git clone git://source.ffmpeg.org/ffmpeg ffmpeg)
46cd ffmpeg
47git checkout release/4.2
48./configure \
49    --libdir=android-libs/armeabi-v7a \
50    --arch=arm \
51    --cpu=armv7-a \
52    --cross-prefix="${TOOLCHAIN_PREFIX}/armv7a-linux-androideabi16-" \
53    --nm="${TOOLCHAIN_PREFIX}/arm-linux-androideabi-nm" \
54    --strip="${TOOLCHAIN_PREFIX}/arm-linux-androideabi-strip" \
55    --extra-cflags="-march=armv7-a -mfloat-abi=softfp" \
56    --extra-ldflags="-Wl,--fix-cortex-a8" \
57    ${COMMON_OPTIONS}
58make -j4
59make install-libs
60make clean
61./configure \
62    --libdir=android-libs/arm64-v8a \
63    --arch=aarch64 \
64    --cpu=armv8-a \
65    --cross-prefix="${TOOLCHAIN_PREFIX}/aarch64-linux-android21-" \
66    --nm="${TOOLCHAIN_PREFIX}/aarch64-linux-android-nm" \
67    --strip="${TOOLCHAIN_PREFIX}/aarch64-linux-android-strip" \
68    ${COMMON_OPTIONS}
69make -j4
70make install-libs
71make clean
72./configure \
73    --libdir=android-libs/x86 \
74    --arch=x86 \
75    --cpu=i686 \
76    --cross-prefix="${TOOLCHAIN_PREFIX}/i686-linux-android16-" \
77    --nm="${TOOLCHAIN_PREFIX}/i686-linux-android-nm" \
78    --strip="${TOOLCHAIN_PREFIX}/i686-linux-android-strip" \
79    --disable-asm \
80    ${COMMON_OPTIONS}
81make -j4
82make install-libs
83make clean
84./configure \
85    --libdir=android-libs/x86_64 \
86    --arch=x86_64 \
87    --cpu=x86_64 \
88    --cross-prefix="${TOOLCHAIN_PREFIX}/x86_64-linux-android21-" \
89    --nm="${TOOLCHAIN_PREFIX}/x86_64-linux-android-nm" \
90    --strip="${TOOLCHAIN_PREFIX}/x86_64-linux-android-strip" \
91    --disable-asm \
92    ${COMMON_OPTIONS}
93make -j4
94make install-libs
95make clean
96