libx264 compile for android

#!/bin/bash


X264_PREFIX=/usr/local/andro/x264


ANDROID_INC="$ANDROID_NDK_ROOT/platforms/android-14/arch-arm/usr/include"
ANDROID_ARMLIB="$ANDROID_NDK_ROOT/platforms/android-14/arch-arm/usr/lib"


EXTRA_CFLAGS=" -I$ANDROID_INC -fPIC -DANDROID -Wl,--no-undefined -Wl,-z,noexecstack -fpic -mthumb-interwork -ffunction-sections -funwind-tables -fstack-protector -fno-short-enums -march=armv7-a -mtune=cortex-a9 -mfloat-abi=softfp -mfpu=neon -D__ARM_ARCH_7__ -D__ARM_ARCH_7A__  -Wno-psabi -msoft-float -mthumb -Os -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -DANDROID  -Wa,--noexecstack -MMD -MP"


#EXTRA_LDFLAGS="-nostdlib -Bdynamic -Wl,--no-undefined -Wl,-z,noexecstack -L$ANDROID_ARMLIB -nostdlib $ANDROID_ARMLIB/crtbegin_dynamic.o $ANDROID_ARMLIB/crtend_android.o -lc -lm -ldl -lgcc"


EXTRA_LDFLAGS="-nostdlib -Bdynamic -Wl,--no-undefined -Wl,-z,noexecstack -L$ANDROID_ARMLIB -nostdlib -lc -lm -ldl -lgcc"
X264_DIR=x264


cd $X264_DIR


TOOLCHAIN=/opt/android/bintools
SYSROOT=$TOOLCHAIN/sysroot/
$ANDROID_NDK_ROOT/build/tools/make-standalone-toolchain.sh --arch=arm --platform=android-14 --toolchain=arm-linux-androideabi-4.4.3 --install-dir=$TOOLCHAIN


export PATH=$TOOLCHAIN/bin:$PATH


export CC="ccache arm-linux-androideabi-gcc"
export LD=arm-linux-androideabi-ld
export AR=arm-linux-androideabi-ar


./configure --prefix=$X264_PREFIX \
    --cross-prefix=arm-linux-androideabi- \
    --disable-gpac \
    --host=arm-linux \
    --enable-shared \
    --enable-strip \
    --enable-pic \
    --extra-cflags=" -I${ANDROID_INC} $EXTRA_CFLAGS" \
    --extra-ldflags="$EXTRA_LDFLAGS" \
    --sysroot="$SYSROOT"


make clean
make -j4 || exit 1
make install || exit 1

你可能感兴趣的:(libx264)