2019-09-15 11:45:50 +00:00
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
function build_one {
|
2022-02-03 15:25:39 +00:00
|
|
|
echo "Building ${ARCH}..."
|
|
|
|
|
|
|
|
PREBUILT=${NDK}/toolchains/${PREBUILT_ARCH}${PREBUILT_MIDDLE}-${VERSION}/prebuilt/${BUILD_PLATFORM}
|
|
|
|
PLATFORM=${NDK}/platforms/android-${ANDROID_API}/arch-${ARCH}
|
|
|
|
|
|
|
|
TOOLS_PREFIX="${LLVM_BIN}/${ARCH_NAME}-linux-${BIN_MIDDLE}-"
|
|
|
|
|
|
|
|
LD=${TOOLS_PREFIX}ld
|
|
|
|
AR=${TOOLS_PREFIX}ar
|
|
|
|
STRIP=${TOOLS_PREFIX}strip
|
|
|
|
NM=${TOOLS_PREFIX}nm
|
|
|
|
|
|
|
|
CC_PREFIX="${LLVM_BIN}/${CLANG_PREFIX}-linux-${BIN_MIDDLE}${ANDROID_API}-"
|
|
|
|
|
|
|
|
CC=${CC_PREFIX}clang
|
|
|
|
CXX=${CC_PREFIX}clang++
|
|
|
|
CROSS_PREFIX=${PREBUILT}/bin/${ARCH_NAME}-linux-${BIN_MIDDLE}-
|
|
|
|
|
2022-02-04 12:17:14 +00:00
|
|
|
INCLUDES=" -I./${LIBVPXPREFIX}/include"
|
|
|
|
LIBS=" -L./${LIBVPXPREFIX}/lib"
|
2019-09-15 11:45:50 +00:00
|
|
|
|
2021-10-31 13:09:32 +00:00
|
|
|
echo "Cleaning..."
|
|
|
|
rm -f config.h
|
|
|
|
make clean || true
|
2019-09-15 11:45:50 +00:00
|
|
|
|
|
|
|
echo "Configuring..."
|
|
|
|
|
|
|
|
./configure \
|
|
|
|
--nm=${NM} \
|
|
|
|
--ar=${AR} \
|
|
|
|
--strip=${STRIP} \
|
|
|
|
--cc=${CC} \
|
|
|
|
--cxx=${CXX} \
|
|
|
|
--enable-stripping \
|
|
|
|
--arch=$ARCH \
|
|
|
|
--target-os=linux \
|
|
|
|
--enable-cross-compile \
|
2022-02-03 15:25:39 +00:00
|
|
|
--x86asmexe=$NDK/prebuilt/${BUILD_PLATFORM}/bin/yasm \
|
2019-09-15 11:45:50 +00:00
|
|
|
--prefix=$PREFIX \
|
|
|
|
--enable-pic \
|
|
|
|
--disable-shared \
|
|
|
|
--enable-static \
|
2022-02-03 15:25:39 +00:00
|
|
|
--enable-asm \
|
|
|
|
--enable-inline-asm \
|
|
|
|
--enable-x86asm \
|
2019-09-15 11:45:50 +00:00
|
|
|
--cross-prefix=$CROSS_PREFIX \
|
2022-02-03 15:25:39 +00:00
|
|
|
--sysroot="${LLVM_PREFIX}/sysroot" \
|
2022-02-04 12:17:14 +00:00
|
|
|
--extra-cflags="${INCLUDES} -Wl,-Bsymbolic -Os -DCONFIG_LINUX_PERF=0 -DANDROID $OPTIMIZE_CFLAGS -fPIE -pie --static -fPIC" \
|
|
|
|
--extra-cxxflags="${INCLUDES} -Wl,-Bsymbolic -Os -DCONFIG_LINUX_PERF=0 -DANDROID $OPTIMIZE_CFLAGS -fPIE -pie --static -fPIC" \
|
|
|
|
--extra-ldflags="${LIBS} -Wl,-Bsymbolic -Wl,-rpath-link=$PLATFORM/usr/lib -L$PLATFORM/usr/lib -lc -lm -ldl -fPIC" \
|
2019-09-15 11:45:50 +00:00
|
|
|
\
|
|
|
|
--enable-version3 \
|
|
|
|
--enable-gpl \
|
|
|
|
\
|
|
|
|
--disable-linux-perf \
|
|
|
|
\
|
|
|
|
--disable-doc \
|
|
|
|
--disable-htmlpages \
|
|
|
|
--disable-avx \
|
|
|
|
\
|
|
|
|
--disable-everything \
|
|
|
|
--disable-network \
|
|
|
|
--disable-zlib \
|
|
|
|
--disable-avfilter \
|
|
|
|
--disable-avdevice \
|
|
|
|
--disable-postproc \
|
|
|
|
--disable-debug \
|
|
|
|
--disable-programs \
|
|
|
|
--disable-ffplay \
|
|
|
|
--disable-ffprobe \
|
|
|
|
--disable-postproc \
|
|
|
|
\
|
2022-02-04 03:28:29 +00:00
|
|
|
--enable-libvpx \
|
|
|
|
--enable-decoder=libvpx_vp9 \
|
2019-09-15 11:45:50 +00:00
|
|
|
--enable-runtime-cpudetect \
|
|
|
|
--enable-pthreads \
|
|
|
|
--enable-avresample \
|
|
|
|
--enable-swscale \
|
|
|
|
--enable-protocol=file \
|
2021-10-31 16:02:43 +00:00
|
|
|
--enable-decoder=opus \
|
2019-09-15 11:45:50 +00:00
|
|
|
--enable-decoder=h264 \
|
|
|
|
--enable-decoder=mpeg4 \
|
|
|
|
--enable-decoder=mjpeg \
|
|
|
|
--enable-decoder=gif \
|
|
|
|
--enable-decoder=alac \
|
|
|
|
--enable-demuxer=mov \
|
|
|
|
--enable-demuxer=gif \
|
2021-10-31 13:09:32 +00:00
|
|
|
--enable-demuxer=ogg \
|
2022-02-03 15:25:39 +00:00
|
|
|
--enable-demuxer=matroska \
|
2019-09-15 11:45:50 +00:00
|
|
|
--enable-hwaccels \
|
|
|
|
$ADDITIONAL_CONFIGURE_FLAG
|
|
|
|
|
|
|
|
#echo "continue?"
|
|
|
|
#read
|
|
|
|
make -j$COMPILATION_PROC_COUNT
|
|
|
|
make install
|
|
|
|
}
|
|
|
|
|
|
|
|
function setCurrentPlatform {
|
|
|
|
|
2022-02-03 15:25:39 +00:00
|
|
|
CURRENT_PLATFORM="$(uname -s)"
|
|
|
|
case "${CURRENT_PLATFORM}" in
|
|
|
|
Darwin*)
|
|
|
|
BUILD_PLATFORM=darwin-x86_64
|
|
|
|
COMPILATION_PROC_COUNT=`sysctl -n hw.physicalcpu`
|
|
|
|
;;
|
|
|
|
Linux*)
|
|
|
|
BUILD_PLATFORM=linux-x86_64
|
|
|
|
COMPILATION_PROC_COUNT=$(nproc)
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo -e "\033[33mWarning! Unknown platform ${CURRENT_PLATFORM}! falling back to linux-x86_64\033[0m"
|
|
|
|
BUILD_PLATFORM=linux-x86_64
|
|
|
|
COMPILATION_PROC_COUNT=1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
echo "Build platform: ${BUILD_PLATFORM}"
|
|
|
|
echo "Parallel jobs: ${COMPILATION_PROC_COUNT}"
|
2019-09-15 11:45:50 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function checkPreRequisites {
|
|
|
|
|
2022-02-03 15:25:39 +00:00
|
|
|
if ! [ -d "ffmpeg" ] || ! [ "$(ls -A ffmpeg)" ]; then
|
|
|
|
echo -e "\033[31mFailed! Submodule 'ffmpeg' not found!\033[0m"
|
|
|
|
echo -e "\033[31mTry to run: 'git submodule init && git submodule update'\033[0m"
|
|
|
|
exit
|
|
|
|
fi
|
2019-09-15 11:45:50 +00:00
|
|
|
|
2022-02-03 15:25:39 +00:00
|
|
|
if [ -z "$NDK" -a "$NDK" == "" ]; then
|
|
|
|
echo -e "\033[31mFailed! NDK is empty. Run 'export NDK=[PATH_TO_NDK]'\033[0m"
|
|
|
|
exit
|
|
|
|
fi
|
2019-09-15 11:45:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
setCurrentPlatform
|
|
|
|
checkPreRequisites
|
|
|
|
|
|
|
|
# TODO: fix env variable for NDK
|
|
|
|
# NDK=/opt/android-sdk/ndk-bundle
|
|
|
|
|
|
|
|
cd ffmpeg
|
|
|
|
|
|
|
|
## common
|
2022-02-03 15:25:39 +00:00
|
|
|
LLVM_PREFIX="${NDK}/toolchains/llvm/prebuilt/linux-x86_64"
|
|
|
|
LLVM_BIN="${LLVM_PREFIX}/bin"
|
|
|
|
VERSION="4.9"
|
|
|
|
|
|
|
|
function build {
|
|
|
|
for arg in "$@"; do
|
|
|
|
case "${arg}" in
|
|
|
|
x86_64)
|
|
|
|
ANDROID_API=21
|
|
|
|
|
|
|
|
ARCH=x86_64
|
|
|
|
ARCH_NAME=x86_64
|
|
|
|
PREBUILT_ARCH=x86_64
|
|
|
|
PREBUILT_MIDDLE=
|
|
|
|
CLANG_PREFIX=x86_64
|
|
|
|
BIN_MIDDLE=android
|
|
|
|
CPU=x86_64
|
|
|
|
PREFIX=./build/$CPU
|
2022-02-04 12:17:14 +00:00
|
|
|
LIBVPXPREFIX=../libvpx/build/x86_64
|
2022-02-03 15:25:39 +00:00
|
|
|
ADDITIONAL_CONFIGURE_FLAG="--disable-asm"
|
|
|
|
build_one
|
|
|
|
;;
|
|
|
|
arm64)
|
|
|
|
ANDROID_API=21
|
|
|
|
|
|
|
|
ARCH=arm64
|
|
|
|
ARCH_NAME=aarch64
|
|
|
|
PREBUILT_ARCH=aarch64
|
|
|
|
PREBUILT_MIDDLE="-linux-android"
|
|
|
|
CLANG_PREFIX=aarch64
|
|
|
|
BIN_MIDDLE=android
|
|
|
|
CPU=arm64-v8a
|
|
|
|
OPTIMIZE_CFLAGS=
|
|
|
|
PREFIX=./build/$CPU
|
2022-02-03 16:45:21 +00:00
|
|
|
LIBVPXPREFIX=../libvpx/build/arm64-v8a
|
2022-02-03 15:25:39 +00:00
|
|
|
ADDITIONAL_CONFIGURE_FLAG="--enable-neon --enable-optimizations"
|
|
|
|
build_one
|
|
|
|
;;
|
|
|
|
arm)
|
|
|
|
ANDROID_API=16
|
|
|
|
|
|
|
|
ARCH=arm
|
|
|
|
ARCH_NAME=arm
|
|
|
|
PREBUILT_ARCH=arm
|
|
|
|
PREBUILT_MIDDLE="-linux-androideabi"
|
|
|
|
CLANG_PREFIX=armv7a
|
|
|
|
BIN_MIDDLE=androideabi
|
|
|
|
CPU=armv7-a
|
|
|
|
OPTIMIZE_CFLAGS="-marm -march=$CPU"
|
|
|
|
PREFIX=./build/armeabi-v7a
|
|
|
|
LIBVPXPREFIX=../libvpx/build/armeabi-v7a
|
2022-02-04 12:17:14 +00:00
|
|
|
ADDITIONAL_CONFIGURE_FLAG="--enable-neon"
|
2022-02-03 15:25:39 +00:00
|
|
|
build_one
|
|
|
|
;;
|
|
|
|
x86)
|
|
|
|
ANDROID_API=16
|
|
|
|
|
|
|
|
ARCH=x86
|
|
|
|
ARCH_NAME=i686
|
|
|
|
PREBUILT_ARCH=x86
|
|
|
|
PREBUILT_MIDDLE=
|
|
|
|
CLANG_PREFIX=i686
|
|
|
|
BIN_MIDDLE=android
|
|
|
|
CPU=i686
|
|
|
|
OPTIMIZE_CFLAGS="-march=$CPU"
|
2022-02-03 16:45:21 +00:00
|
|
|
PREFIX=./build/x86
|
|
|
|
LIBVPXPREFIX=../libvpx/build/x86
|
2022-02-03 15:25:39 +00:00
|
|
|
ADDITIONAL_CONFIGURE_FLAG="--disable-x86asm --disable-inline-asm --disable-asm"
|
|
|
|
build_one
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
if (( $# == 0 )); then
|
|
|
|
build x86_64 arm64 arm x86
|
|
|
|
else
|
|
|
|
build $@
|
|
|
|
fi
|