Created
April 11, 2012 13:22
-
-
Save JavaDeveloper/2359263 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/env bash | |
# | |
# Usage: put this script int unpacket ffmpeg sources tree and run | |
# ./build-ffmeg-android.sh | |
# | |
# This script was tested on NDK r7 and ffmpeg-0.10.2 | |
# | |
# You need to set up NDK_HOME environment variable in your .bashrc something like that | |
# export NDK_HOME=/usr/local/java/android-ndk-r7 | |
# | |
# | |
RED_COLOR="\e[00;31m" # | |
RESET="\e[00m" | |
if [ $NDK_HOME ] | |
then | |
PLATFORM=$NDK_HOME/platforms/android-8/arch-arm/ | |
PREBUILT=$NDK_HOME/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86 | |
else | |
echo -e $RED_COLOR "Please set up NDK_HOME environment variable" $RESET | |
exit 1 | |
fi | |
function build_one | |
{ | |
./configure --target-os=linux \ | |
--prefix=$PREFIX \ | |
--enable-cross-compile \ | |
--extra-libs="-lgcc" \ | |
--arch=arm \ | |
--cc=$PREBUILT/bin/arm-linux-androideabi-gcc \ | |
--cross-prefix=$PREBUILT/bin/arm-linux-androideabi- \ | |
--nm=$PREBUILT/bin/arm-linux-androideabi-nm \ | |
--sysroot=$PLATFORM \ | |
--extra-cflags=" -O3 -fpic -DANDROID -DHAVE_SYS_UIO_H=1 -Dipv6mr_interface=ipv6mr_ifindex -fasm -Wno-psabi -fno-short-enums -fno-strict-aliasing -finline-limit=300 $OPTIMIZE_CFLAGS " \ | |
--disable-shared \ | |
--enable-static \ | |
--extra-ldflags="-Wl,-rpath-link=$PLATFORM/usr/lib -L$PLATFORM/usr/lib -nostdlib -lc -lm -ldl -llog" \ | |
--disable-ffmpeg \ | |
--disable-ffplay \ | |
--disable-ffprobe \ | |
--disable-ffserver \ | |
--disable-debug \ | |
--disable-everything \ | |
--enable-network \ | |
--enable-avformat \ | |
--enable-avcodec \ | |
--enable-decoder=h264 \ | |
--enable-decoder=mjpeg \ | |
--enable-decoder=aac \ | |
--enable-parser=h264 \ | |
--enable-parser=mjpeg \ | |
--enable-parser=aac \ | |
--enable-demuxer=h264 \ | |
--enable-demuxer=mjpeg \ | |
--enable-demuxer=aac \ | |
--enable-demuxer=rtp \ | |
--enable-demuxer=rtsp \ | |
--enable-protocol=file \ | |
--enable-protocol=rtp \ | |
$ADDITIONAL_CONFIGURE_FLAG | |
make clean | |
make -j4 install | |
# Uncomment this if you want *.so not *.a | |
#$PREBUILT/bin/arm-linux-androideabi-ar d libavcodec/libavcodec.a inverse.o | |
#$PREBUILT/bin/arm-linux-androideabi-ld -rpath-link=$PLATFORM/usr/lib -L$PLATFORM/usr/lib -soname libffmpeg.so -shared -nostdlib -z,noexecstack -Bsymbolic --whole-archive --no-undefined -o $PREFIX/libffmpeg.so libavcodec/libavcodec.a libavformat/libavformat.a libavutil/libavutil.a libswscale/libswscale.a -lc -lm -lz -ldl -llog --warn-once --dynamic-linker=/system/bin/linker $PREBUILT/lib/gcc/arm-linux-androideabi/4.4.3/libgcc.a | |
} | |
CPU=armv5 | |
OPTIMIZE_CFLAGS="-marm -march=$CPU" | |
PREFIX=./android/$CPU | |
ADDITIONAL_CONFIGURE_FLAG= | |
build_one | |
#arm v6 | |
#CPU=armv6 | |
#OPTIMIZE_CFLAGS="-marm -march=$CPU" | |
#PREFIX=./android/$CPU | |
#ADDITIONAL_CONFIGURE_FLAG= | |
#build_one | |
#arm v7vfpv3 | |
#CPU=armv7-a | |
#OPTIMIZE_CFLAGS="-mfloat-abi=softfp -mfpu=vfpv3-d16 -marm -march=$CPU " | |
#PREFIX=./android/$CPU | |
#ADDITIONAL_CONFIGURE_FLAG= | |
#build_one | |
#arm v7vfp | |
#CPU=armv7-a | |
#OPTIMIZE_CFLAGS="-mfloat-abi=softfp -mfpu=vfp -marm -march=$CPU " | |
#PREFIX=./android/$CPU-vfp | |
#ADDITIONAL_CONFIGURE_FLAG= | |
#build_one | |
#arm v7n | |
#CPU=armv7-a | |
#OPTIMIZE_CFLAGS="-mfloat-abi=softfp -mfpu=neon -marm -march=$CPU -mtune=cortex-a8" | |
#PREFIX=./android/$CPU | |
#ADDITIONAL_CONFIGURE_FLAG=--enable-neon | |
#build_one | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment