• 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_MODULE_PATH=$1
19NDK_PATH=$2
20HOST_PLATFORM=$3
21ENABLED_DECODERS=("${@:4}")
22JOBS=$(nproc 2> /dev/null || sysctl -n hw.ncpu 2> /dev/null || echo 4)
23echo "Using $JOBS jobs for make"
24COMMON_OPTIONS="
25    --target-os=android
26    --enable-static
27    --disable-shared
28    --disable-doc
29    --disable-programs
30    --disable-everything
31    --disable-avdevice
32    --disable-avformat
33    --disable-swscale
34    --disable-postproc
35    --disable-avfilter
36    --disable-symver
37    --disable-avresample
38    --enable-swresample
39    --extra-ldexeflags=-pie
40    "
41TOOLCHAIN_PREFIX="${NDK_PATH}/toolchains/llvm/prebuilt/${HOST_PLATFORM}/bin"
42for decoder in "${ENABLED_DECODERS[@]}"
43do
44    COMMON_OPTIONS="${COMMON_OPTIONS} --enable-decoder=${decoder}"
45done
46cd "${FFMPEG_MODULE_PATH}/jni/ffmpeg"
47./configure \
48    --libdir=android-libs/armeabi-v7a \
49    --arch=arm \
50    --cpu=armv7-a \
51    --cross-prefix="${TOOLCHAIN_PREFIX}/armv7a-linux-androideabi16-" \
52    --nm="${TOOLCHAIN_PREFIX}/llvm-nm" \
53    --ar="${TOOLCHAIN_PREFIX}/llvm-ar" \
54    --ranlib="${TOOLCHAIN_PREFIX}/llvm-ranlib" \
55    --strip="${TOOLCHAIN_PREFIX}/llvm-strip" \
56    --extra-cflags="-march=armv7-a -mfloat-abi=softfp" \
57    --extra-ldflags="-Wl,--fix-cortex-a8" \
58    ${COMMON_OPTIONS}
59make -j$JOBS
60make install-libs
61make clean
62./configure \
63    --libdir=android-libs/arm64-v8a \
64    --arch=aarch64 \
65    --cpu=armv8-a \
66    --cross-prefix="${TOOLCHAIN_PREFIX}/aarch64-linux-android21-" \
67    --nm="${TOOLCHAIN_PREFIX}/llvm-nm" \
68    --ar="${TOOLCHAIN_PREFIX}/llvm-ar" \
69    --ranlib="${TOOLCHAIN_PREFIX}/llvm-ranlib" \
70    --strip="${TOOLCHAIN_PREFIX}/llvm-strip" \
71    ${COMMON_OPTIONS}
72make -j$JOBS
73make install-libs
74make clean
75./configure \
76    --libdir=android-libs/x86 \
77    --arch=x86 \
78    --cpu=i686 \
79    --cross-prefix="${TOOLCHAIN_PREFIX}/i686-linux-android16-" \
80    --nm="${TOOLCHAIN_PREFIX}/llvm-nm" \
81    --ar="${TOOLCHAIN_PREFIX}/llvm-ar" \
82    --ranlib="${TOOLCHAIN_PREFIX}/llvm-ranlib" \
83    --strip="${TOOLCHAIN_PREFIX}/llvm-strip" \
84    --disable-asm \
85    ${COMMON_OPTIONS}
86make -j$JOBS
87make install-libs
88make clean
89./configure \
90    --libdir=android-libs/x86_64 \
91    --arch=x86_64 \
92    --cpu=x86_64 \
93    --cross-prefix="${TOOLCHAIN_PREFIX}/x86_64-linux-android21-" \
94    --nm="${TOOLCHAIN_PREFIX}/llvm-nm" \
95    --ar="${TOOLCHAIN_PREFIX}/llvm-ar" \
96    --ranlib="${TOOLCHAIN_PREFIX}/llvm-ranlib" \
97    --strip="${TOOLCHAIN_PREFIX}/llvm-strip" \
98    --disable-asm \
99    ${COMMON_OPTIONS}
100make -j$JOBS
101make install-libs
102make clean
103