x264.sh
cd x264
export NDK=/Users/jfyang/Library/Android/sdk/ndk-bundle
export LOCAL=$(pwd)/../android-lib
./configure --help > $LOCAL/../help/x264.help
function build_one
{
./configure --prefix=$PREFIX \
--enable-static \
--enable-shared \
--enable-pic \
--disable-cli \
--host=${HOST} \
--cross-prefix=$CROSS_COMPILE \
--arch=$ARCH \
--sysroot=$SYSROOT \
--extra-cflags="-Os -fpic $ADDI_CFLAGS -I$PREFIX/include -I$SYSROOT/usr/include -Wl,-rpath-link=$SYSROOT/usr/lib $EXTRA_CFLAGS " \
--extra-ldflags="$ADDI_LDFLAGS -L$PREFIX/lib -L$SYSROOT/usr/lib" \
${ADDITIONAL_CONFIGURE_FLAG}
make clean
make
make install
make clean
}
function ARMABI()
{
#armabi
ARCH=arm
PREBUILT=$NDK/toolchains/$ARCH-linux-androideabi-4.9/prebuilt/darwin-x86_64/
CROSS_COMPILE=$PREBUILT/bin/$ARCH-linux-androideabi-
HOST=arm-linux
CPU=arm
SYSROOT=$NDK/platforms/android-18/arch-$CPU/
PREFIX=$LOCAL/${CPU}abi
ADDI_CFLAGS="-marm -march=armv6"
#EXTRA_CFLAGS="-fasm -Wno-psabi -fno-short-enums -fno-strict-aliasing -finline-limit=300 -mfloat-abi=softfp -mfpu=vfp"
build_one
}
function ARMV7()
{
#ARMv7 平台
PREBUILT=$NDK/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/
CROSS_COMPILE=$PREBUILT/bin/arm-linux-androideabi-
HOST=armv7-linux
CPU=arm
ARCH=armv7
SYSROOT=$NDK/platforms/android-18/arch-$CPU/
PREFIX=$LOCAL/${CPU}abi-v7a
ADDI_CFLAGS="-march=armv7-a"
#EXTRA_CFLAGS="-ffunction-sections -funwind-tables -fstack-protector -mfloat-abi=softfp -mfpu=vfpv3-d16 -fomit-frame-pointer -fstrict-aliasing -funswitch-loops -finline-limit=300"
build_one
}
function X86()
{
#x86
ARCH=x86
PREBUILT=$NDK/toolchains/$ARCH-4.9/prebuilt/darwin-x86_64/
CROSS_COMPILE=$PREBUILT/bin/i686-linux-android-
HOST=i686-linux
CPU=x86
SYSROOT=$NDK/platforms/android-18/arch-$CPU/
PREFIX=$LOCAL/$CPU
ADDI_CFLAGS="-march=i686"
#EXTRA_CFLAGS="-mtune=intel -mssse3 -mfpmath=sse -m32"
ADDITIONAL_CONFIGURE_FLAG="--disable-asm"
build_one
}
function MIPS()
{
#mips
ARCH=mipsel
PREBUILT=$NDK/toolchains/$ARCH-linux-android-4.9/prebuilt/darwin-x86_64/
CROSS_COMPILE=$PREBUILT/bin/$ARCH-linux-android-
HOST=mips-linux
CPU=mips
SYSROOT=$NDK/platforms/android-18/arch-$CPU/
PREFIX=$LOCAL/$CPU
ADDI_CFLAGS=""
#EXTRA_CFLAGS=""
ADDITIONAL_CONFIGURE_FLAG="--disable-asm"
#ADDITIONAL_CONFIGURE_FLAG="--disable-mipsdspr1 --disable-mipsdspr2 --disable-mipsfpu"
build_one
}
function ARM64()
{
#arm64-v8a
ARCH=aarch64
PREBUILT=$NDK/toolchains/$ARCH-linux-android-4.9/prebuilt/darwin-x86_64/
CROSS_COMPILE=$PREBUILT/bin/$ARCH-linux-android-
HOST=aarch64-linux
CPU=arm64
SYSROOT=$NDK/platforms/android-21/arch-$CPU/
PREFIX=$LOCAL/${CPU}-v8a
ADDI_CFLAGS=""
#EXTRA_CFLAGS=""
ADDITIONAL_CONFIGURE_FLAG=""
build_one
}
function MIPS64()
{
#mips64
ARCH=mips64el
PREBUILT=$NDK/toolchains/$ARCH-linux-android-4.9/prebuilt/darwin-x86_64/
CROSS_COMPILE=$PREBUILT/bin/$ARCH-linux-android-
HOST=mips64-linux
CPU=mips64
SYSROOT=$NDK/platforms/android-21/arch-$CPU/
PREFIX=$LOCAL/$CPU
ADDI_CFLAGS=""
EXTRA_CFLAGS=""
ADDITIONAL_CONFIGURE_FLAG="--disable-asm"
#ADDITIONAL_CONFIGURE_FLAG="--disable-mipsdspr1 --disable-mipsdspr2 --disable-mipsfpu"
build_one
}
function X86_64()
{
#x86_x64
ARCH=x86_64
PREBUILT=$NDK/toolchains/$ARCH-4.9/prebuilt/darwin-x86_64/
CROSS_COMPILE=$PREBUILT/bin/$ARCH-linux-android-
HOST=x86_64-linux
CPU=x86_64
SYSROOT=$NDK/platforms/android-21/arch-$CPU/
PREFIX=$LOCAL/$CPU
ADDI_CFLAGS="-march=x86-64"
#EXTRA_CFLAGS="-msse4.2 -mpopcnt -m64 -mtune=intel"
ADDITIONAL_CONFIGURE_FLAG="--disable-asm"
build_one
}
#ARMABI
#ARMV7
#X86
#MIPS
ARM64
#MIPS64
#X86_64
cd ..
注意:在windows平台上用此脚本编译需要禁用 asm (--disable-asm)
cd fdk-aac
export NDK=/Users/jfyang/Library/Android/sdk/ndk-bundle
export LOCAL=$(pwd)/../android-lib
./autogen.sh
./configure --help > $LOCAL/../help/fdk-aac.help
function build_one
{
export CPPFLAGS="$CFLAGS"
export CFLAGS="$CFLAGS -arch ${ARCH}"
export CXXFLAGS="$CFLAGS -arch ${ARCH} -I${SYSROOT}/usr/include ${ADDI_CFLAGS}"
export CXX="${CROSS_COMPILE}g++ --sysroot=${SYSROOT}"
export LDFLAGS="$LDFLAGS -arch ${ARCH} -L${SYSROOT}/usr/lib ${ADDI_CFLAGS}"
export CC="${CROSS_COMPILE}gcc --sysroot=${SYSROOT}"
export NM="${CROSS_COMPILE}nm"
export STRIP="${CROSS_COMPILE}strip"
export RANLIB="${CROSS_COMPILE}ranlib"
export AR="${CROSS_COMPILE}ar"
export LD="${CROSS_COMPILE}ld"
export AS="${CROSS_COMPILE}gcc"
./configure --prefix=$PREFIX \
--without-mp4v2 \
--host=${HOSE} \
--enable-pic \
--enable-strip \
--target=android \
--enable-static \
--enable-shared \
--with-sysroot=${SYSROOT}
make clean
make
make install
make clean
}
function ARMABI()
{
#armabi
ARCH=arm
PREBUILT=$NDK/toolchains/$ARCH-linux-androideabi-4.9/prebuilt/darwin-x86_64/
CROSS_COMPILE=$PREBUILT/bin/$ARCH-linux-androideabi-
HOSE=arm-androideabi-linux-4.9
CPU=arm
SYSROOT=$NDK/platforms/android-18/arch-$CPU/
PREFIX=$LOCAL/${CPU}abi
ADDI_CFLAGS="-marm -march=armv6"
#EXTRA_CFLAGS="-fasm -Wno-psabi -fno-short-enums -fno-strict-aliasing -finline-limit=300 -mfloat-abi=softfp -mfpu=vfp"
build_one
}
function ARMV7()
{
#ARMv7 平台
ARCH=armv7
PREBUILT=$NDK/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/
CROSS_COMPILE=$PREBUILT/bin/arm-linux-androideabi-
HOSE=armv7-androideabi-linux-4.9
CPU=arm
SYSROOT=$NDK/platforms/android-18/arch-$CPU/
PREFIX=$LOCAL/${CPU}abi-v7a
ADDI_CFLAGS="-march=armv7-a"
#EXTRA_CFLAGS="-ffunction-sections -funwind-tables -fstack-protector -mfloat-abi=softfp -mfpu=vfpv3-d16 -fomit-frame-pointer -fstrict-aliasing -funswitch-loops -finline-limit=300"
build_one
}
function X86()
{
#x86
ARCH=x86
PREBUILT=$NDK/toolchains/$ARCH-4.9/prebuilt/darwin-x86_64/
CROSS_COMPILE=$PREBUILT/bin/i686-linux-android-
HOSE=i686-android-linux-4.9
CPU=x86
SYSROOT=$NDK/platforms/android-18/arch-$CPU/
PREFIX=$LOCAL/$CPU
ADDI_CFLAGS="-march=i686"
#EXTRA_CFLAGS="-mtune=intel -mssse3 -mfpmath=sse -m32"
#ADDITIONAL_CONFIGURE_FLAG=""
build_one
}
function MIPS()
{
#mips
ARCH=mipsel
PREBUILT=$NDK/toolchains/$ARCH-linux-android-4.9/prebuilt/darwin-x86_64/
CROSS_COMPILE=$PREBUILT/bin/$ARCH-linux-android-
HOSE=mipsel-android-linux-4.9
CPU=mips
SYSROOT=$NDK/platforms/android-18/arch-$CPU/
PREFIX=$LOCAL/$CPU
ADDI_CFLAGS=""
#EXTRA_CFLAGS=""
#ADDITIONAL_CONFIGURE_FLAG="--disable-mipsdspr1 --disable-mipsdspr2 --disable-mipsfpu"
build_one
}
function ARM64()
{
#arm64-v8a
ARCH=aarch64
PREBUILT=$NDK/toolchains/$ARCH-linux-android-4.9/prebuilt/darwin-x86_64/
CROSS_COMPILE=$PREBUILT/bin/$ARCH-linux-android-
HOSE=aarch64-android-linux-4.9
CPU=arm64
SYSROOT=$NDK/platforms/android-21/arch-$CPU/
PREFIX=$LOCAL/${CPU}-v8a
ADDI_CFLAGS="-march=aarch64"
#EXTRA_CFLAGS=""
build_one
}
function MIPS64()
{
#mips64
ARCH=mips64el
PREBUILT=$NDK/toolchains/$ARCH-linux-android-4.9/prebuilt/darwin-x86_64/
CROSS_COMPILE=$PREBUILT/bin/$ARCH-linux-android-
HOSE=mips64-android-linux-4.9
CPU=mips64
SYSROOT=$NDK/platforms/android-21/arch-$CPU/
PREFIX=$LOCAL/$CPU
ADDI_CFLAGS=""
EXTRA_CFLAGS=""
#ADDITIONAL_CONFIGURE_FLAG="--disable-mipsdspr1 --disable-mipsdspr2 --disable-mipsfpu"
build_one
}
function X86_64()
{
#x86_x64
ARCH=x86_64
PREBUILT=$NDK/toolchains/$ARCH-4.9/prebuilt/darwin-x86_64/
CROSS_COMPILE=$PREBUILT/bin/$ARCH-linux-android-
HOSE=x86_64-android-linux-4.9
CPU=x86_64
SYSROOT=$NDK/platforms/android-21/arch-$CPU/
PREFIX=$LOCAL/$CPU
ADDI_CFLAGS="-march=x86-64"
#EXTRA_CFLAGS="-msse4.2 -mpopcnt -m64 -mtune=intel"
#ADDITIONAL_CONFIGURE_FLAG=""
build_one
}
#ARMABI
#ARMV7
#X86
#MIPS
ARM64
#MIPS64
#X86_64
cd ..
#!/bin/bash
cd ffmpeg-2.7.1
#: 以下三个变量根据自己系统环境配置
export NDK=$NDK_ROOT
#NDK=/Users/jfyang/Library/Android/sdk/ndk-bundle
export LOCAL=$(pwd)/../android-lib
./configure --help > $LOCAL/../help/ffmpeg.help
function build_one
{
./configure \
--prefix=$PREFIX \
--enable-shared \
--enable-static \
--enable-gpl \
--enable-nonfree \
--disable-doc \
--disable-ffmpeg \
--disable-ffplay \
--disable-ffprobe \
--disable-ffserver \
--disable-doc \
--disable-symver \
--disable-yasm \
--enable-small \
--enable-libx264 \
--enable-libfdk-aac \
--cross-prefix=$CROSS_COMPILE \
--target-os=linux \
--arch=$ARCH \
--host-os=android \
--enable-cross-compile \
--sysroot=$SYSROOT \
--extra-cflags="-Os -fpic -DANDROID $ADDI_CFLAGS -I$PREFIX/include -I$SYSROOT/usr/include -Wl,-rpath-link=$SYSROOT/usr/lib $EXTRA_CFLAGS " \
--extra-ldflags="$ADDI_LDFLAGS -L$PREFIX/lib -L$SYSROOT/usr/lib" \
$ADDITIONAL_CONFIGURE_FLAG
make clean
make
make install
}
function ARMABI()
{
#armabi
ARCH=arm
PREBUILT=$NDK/toolchains/$ARCH-linux-androideabi-4.9/prebuilt/darwin-x86_64/
CROSS_COMPILE=$PREBUILT/bin/$ARCH-linux-androideabi-
CPU=arm
SYSROOT=$NDK/platforms/android-18/arch-$CPU/
PREFIX=$LOCAL/${CPU}abi
ADDI_CFLAGS="-marm -march=armv6"
EXTRA_CFLAGS="-fasm -Wno-psabi -fno-short-enums -fno-strict-aliasing -finline-limit=300 -mfloat-abi=softfp -mfpu=vfp"
build_one
}
function ARMV7()
{
#ARMv7 平台
PREBUILT=$NDK/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/
CROSS_COMPILE=$PREBUILT/bin/arm-linux-androideabi-
CPU=arm
ARCH=arm
SYSROOT=$NDK/platforms/android-18/arch-$CPU/
PREFIX=$LOCAL/${CPU}abi-v7a
ADDI_CFLAGS="-march=armv7-a"
EXTRA_CFLAGS="-ffunction-sections -funwind-tables -fstack-protector -mfloat-abi=softfp -mfpu=vfpv3-d16 -fomit-frame-pointer -fstrict-aliasing -funswitch-loops -finline-limit=300"
build_one
}
function X86()
{
#x86
ARCH=x86
PREBUILT=$NDK/toolchains/$ARCH-4.9/prebuilt/darwin-x86_64/
CROSS_COMPILE=$PREBUILT/bin/i686-linux-android-
CPU=x86
SYSROOT=$NDK/platforms/android-18/arch-$CPU/
PREFIX=$LOCAL/$CPU
ADDI_CFLAGS="-march=i686"
EXTRA_CFLAGS="-mtune=intel -mssse3 -mfpmath=sse -m32"
ADDITIONAL_CONFIGURE_FLAG=""
build_one
}
function MIPS()
{
#mips
ARCH=mipsel
PREBUILT=$NDK/toolchains/$ARCH-linux-android-4.9/prebuilt/darwin-x86_64/
CROSS_COMPILE=$PREBUILT/bin/$ARCH-linux-android-
CPU=mips
SYSROOT=$NDK/platforms/android-18/arch-$CPU/
PREFIX=$LOCAL/$CPU
ADDI_CFLAGS=""
EXTRA_CFLAGS=""
ADDITIONAL_CONFIGURE_FLAG="--disable-mipsdspr1 --disable-mipsdspr2 --disable-mipsfpu"
build_one
}
function ARM64()
{
#arm64-v8a
ARCH=aarch64
PREBUILT=$NDK/toolchains/$ARCH-linux-android-4.9/prebuilt/darwin-x86_64/
CROSS_COMPILE=$PREBUILT/bin/$ARCH-linux-android-
CPU=arm64
SYSROOT=$NDK/platforms/android-21/arch-$CPU/
PREFIX=$LOCAL/$CPU-v8a
ADDI_CFLAGS=""
EXTRA_CFLAGS=""
build_one
}
function MIPS64()
{
#mips64
ARCH=mips64el
PREBUILT=$NDK/toolchains/$ARCH-linux-android-4.9/prebuilt/darwin-x86_64/
CROSS_COMPILE=$PREBUILT/bin/$ARCH-linux-android-
CPU=mips64
SYSROOT=$NDK/platforms/android-21/arch-$CPU/
PREFIX=$LOCAL/$CPU
ADDI_CFLAGS=""
EXTRA_CFLAGS=""
ADDITIONAL_CONFIGURE_FLAG="--disable-asm --disable-mips32r2 --disable-mips32r5 --disable-mips64r6 --disable-mipsdspr1 --disable-mipsdspr2 --disable-mipsfpu"
build_one
}
function X86_64()
{
#x86_64
ARCH=x86_64
PREBUILT=$NDK/toolchains/$ARCH-4.9/prebuilt/darwin-x86_64/
CROSS_COMPILE=$PREBUILT/bin/$ARCH-linux-android-
CPU=x86_64
SYSROOT=$NDK/platforms/android-21/arch-$CPU/
PREFIX=$LOCAL/$CPU
ADDI_CFLAGS="-march=x86-64"
EXTRA_CFLAGS="-msse4.2 -mpopcnt -m64 -mtune=intel"
ADDITIONAL_CONFIGURE_FLAG=""
build_one
}
#ARMABI
#ARMV7
#X86
#MIPS
#ARM64
MIPS64
#X86_64
cd ..