#!/bin/bash
#build by VinterYoung
export NDK_HOME=/media/system/juruiyuan/ndk/android-ndk-r19c
if [ "$NDK_HOME" = "" ]
then
export NDK_HOME=./../android-ndk-r20b
echo NDK variable not set , assuming ${NDK_HOME}
fi
HOST_TAG=linux-x86_64
TOOLCHAIN=$NDK_HOME/toolchains/llvm/prebuilt/$HOST_TAG
API=28
configure()
{
CPU=$1
PREFIX=`pwd`/android/$CPU
ARCH=""
SYSROOT=""
CROSS_PREFIX=""
CC=""
CXX=""
EXTRA_CFLAGS=""
EXTRA_LDFLAGS=""
EXTRA_LIBS=""
if [ "$CPU" = "armv7a" ]
then
ARCH=arm
SYSROOT=$TOOLCHAIN/sysroot
CROSS_PREFIX=$TOOLCHAIN/bin/arm-linux-androideabi-
CC=$TOOLCHAIN/bin/armv7a-linux-androideabi$API-clang
CXX=$TOOLCHAIN/bin/armv7a-linux-androideabi$API-clang++
EXTRA_CFLAGS="-march=armv7-a -marm -mtune=cortex-a8 -mfloat-abi=softfp -mfpu=neon "
else
ARCH=aarch64
SYSROOT=$TOOLCHAIN/sysroot
CROSS_PREFIX=$TOOLCHAIN/bin/aarch64-linux-android-
CC=$TOOLCHAIN/bin/aarch64-linux-android$API-clang
CXX=$TOOLCHAIN/bin/aarch64-linux-android$API-clang++
EXTRA_CFLAGS="-march=armv8-a "
fi
CONFIG_FLAG="--target-os=android \
--prefix=$PREFIX \
--arch=$ARCH \
--sysroot=$SYSROOT \
--cross-prefix=$CROSS_PREFIX \
--cc=$CC \
--cxx=$CXX \
--enable-cross-compile \
--disable-shared \
--enable-static \
--disable-doc \
--disable-ffmpeg \
--disable-ffplay \
--disable-ffprobe \
--disable-avdevice \
--disable-doc \
--disable-symver \
"
echo $CONFIG_FLAG --extra-cflags="$EXTRA_CFLAGS" --extra-ldflags="$EXTRA_LDFLAGS" --extra-libs="$EXTRA_LIBS"
./configure $CONFIG_FLAG --extra-cflags="$EXTRA_CFLAGS" --extra-ldflags="$EXTRA_LDFLAGS" --extra-libs="$EXTRA_LIBS"
}
build()
{
CPU=$1
echo "build $CPU"
configure $CPU
make -j32
make install
if [ "$CPU" = "armv7a" ]
then
mkdir -p $(pwd)/../ffmpeg_prebuild/lib
cp $(pwd)/android/$CPU/lib/*.a* $(pwd)/../ffmpeg_prebuild/lib
mkdir -p $(pwd)/../ffmpeg_prebuild/include
cp -rf $(pwd)/android/$CPU/include/* $(pwd)/../ffmpeg_prebuild/include/
else
mkdir -p $(pwd)/../ffmpeg_prebuild/lib64
cp $(pwd)/android/$CPU/lib/*.so* $(pwd)/../ffmpeg_prebuild/lib64
mkdir -p $(pwd)/../ffmpeg_prebuild/include
cp -rf $(pwd)/android/$CPU/include/* $(pwd)/../ffmpeg_prebuild/include/
#cp $(pwd)/prebuild.make $(pwd)/../ffmpeg_prebuild/Android.mk
cp $(pwd)/Android.bp.prebuild $(pwd)/../ffmpeg_prebuild/Android.bp
#cp $(pwd)/all-subdir-makefiles.make $(pwd)/../Android.mk
fi
make clean
}
make clean
build armv7a