Skip to content
This repository has been archived by the owner on May 30, 2023. It is now read-only.

fixed Android x86 support #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ line. For example, using the 32-bit NDK on a 64-bit system:

NDK_COMPILER_VERSION=4.4.3 ./configure_make_everything.sh

Or building for an x86 Android target:

NDK_ABI=x86 ./configure_make_everything.sh

customizing
-----------
Expand Down
21 changes: 16 additions & 5 deletions configure_ffmpeg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,36 @@ patch -d ffmpeg -N -p1 --reject-file=- < \

pushd ffmpeg

if [[ $NDK_ABI == "arm" ]]; then
EXTRA_CFLAGS="$EXTRA_CFLAGS -mfloat-abi=softfp -mfpu=neon"
fi

if [[ $NDK_ABI == "x86" ]]; then
EXTRA_CFLAGS="$EXTRA_CFLAGS -mtune=atom -mssse3 -mfpmath=sse"
NDK_TOOLCHAIN_BASE=$NDK_BASE/toolchains/x86-4.8/prebuilt/$NDK_UNAME-$NDK_PROCESSOR #force gcc 4.8 because of http://www.ffmpeg.org/faq.html#error_003a-can_0027t-find-a-register-in-class-_0027GENERAL_005fREGS_0027-while-reloading-_0027asm_0027
fi


./configure \
$DEBUG_FLAG \
--arch=arm \
--cpu=cortex-a8 \
--arch=$NDK_ABI \
--cpu=$TARGET_CPU \
--target-os=linux \
--enable-runtime-cpudetect \
--enable-cross-compile \
--prefix=$prefix \
--enable-pic \
--disable-shared \
--enable-static \
--cross-prefix=$NDK_TOOLCHAIN_BASE/bin/$NDK_ABI-linux-androideabi- \
--cross-prefix=$NDK_TOOLCHAIN_BASE/bin/$HOST- \
--sysroot="$NDK_SYSROOT" \
--extra-cflags="-I../x264 -mfloat-abi=softfp -mfpu=neon -fPIE -pie" \
--extra-cflags="-I../x264 -fPIE -pie $EXTRA_CFLAGS" \
--extra-ldflags="-L../x264 -fPIE -pie" \
\
--enable-version3 \
--enable-gpl \
\
--disable-doc \
--disable-avx \
--enable-yasm \
\
--enable-decoders \
Expand Down
10 changes: 9 additions & 1 deletion configure_freetype2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,20 @@ pushd `dirname $0`

pushd freetype2

case $TARGET_ARCH in
x86)
;;
arm)
EXTRA_CFLAGS="$EXTRA_CFLAGS -mcpu=cortex-a8 -marm -mfloat-abi=softfp -mfpu=neon"
;;
esac

./autogen.sh

./configure \
CC="$CC" \
LD="$LD" \
CFLAGS="-std=gnu99 -mcpu=cortex-a8 -marm -mfloat-abi=softfp -mfpu=neon -fPIE -pie" \
CFLAGS="-std=gnu99 -fPIE -pie $EXTRA_CFLAGS" \
--host=$HOST \
--with-sysroot="$NDK_SYSROOT" \
--enable-static \
Expand Down
1 change: 1 addition & 0 deletions configure_sox.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ patch -N -p1 --reject-file=- < ../sox-update-ffmpeg-api.patch
autoreconf --install --force --verbose

./configure \
--prefix=$prefix \
CFLAGS="-I$LOCAL/include -fPIE -pie" \
LDFLAGS="-L$LOCAL/lib -L$DESTDIR/x264 -fPIE -pie" \
LIBS="-lavformat -lavcodec -lavutil -lz -lx264" \
Expand Down
16 changes: 13 additions & 3 deletions configure_x264.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,23 @@ pushd `dirname $0`

pushd x264

./configure --cross-prefix=$NDK_TOOLCHAIN_BASE/bin/arm-linux-androideabi- \
case $NDK_ABI in
x86)
TARGET_HOST=i686-linux
;;
arm)
TARGET_HOST=arm-linux
;;
esac

./configure --cross-prefix=$NDK_TOOLCHAIN_BASE/bin/$HOST- \
--sysroot="$NDK_SYSROOT" \
--host=arm-linux \
--host=$TARGET_HOST \
--enable-pic \
--enable-static \
--extra-cflags="-fPIE -pie" \
--extra-ldflags="-fPIE -pie" \
--disable-cli
--disable-cli \
--disable-opencl

popd;popd
28 changes: 24 additions & 4 deletions settings.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ if [[ "x$NDK_BASE" == "x" ]]; then
echo "No NDK_BASE set, using $NDK_BASE"
fi

if [[ "x$NDK_ABI" == "x" ]]; then
NDK_ABI=arm
echo "No NDK_ABI set, using $NDK_ABI"
fi

# Android now has 64-bit and 32-bit versions of the NDK for GNU/Linux. We
# assume that the build platform uses the appropriate version, otherwise the
# user building this will have to manually set NDK_PROCESSOR or NDK_TOOLCHAIN.
Expand All @@ -17,18 +22,33 @@ else
fi

# Android NDK setup
NDK_PLATFORM_LEVEL=16
NDK_ABI=arm
case $NDK_ABI in
arm)
NDK_PLATFORM_LEVEL=16
TARGET_CPU=armv7-a
EXTRA_CFLAGS="-mfpu=neon"
EXTRA_LDFLAGS=""
;;
x86)
NDK_PLATFORM_LEVEL=16
TARGET_CPU=x86
EXTRA_CFLAGS="-mtune=atom -mssse3 -mfpmath=sse"
EXTRA_LDFLAGS=""
;;
esac

NDK_COMPILER_VERSION=4.6
NDK_SYSROOT=$NDK_BASE/platforms/android-$NDK_PLATFORM_LEVEL/arch-$NDK_ABI
NDK_UNAME=`uname -s | tr '[A-Z]' '[a-z]'`
if [ $NDK_ABI = "x86" ]; then

if [[ "$NDK_ABI" == "x86" ]]; then
HOST=i686-linux-android
NDK_TOOLCHAIN=$NDK_ABI-$NDK_COMPILER_VERSION
NDK_TOOLCHAIN=x86-$NDK_COMPILER_VERSION
else
HOST=$NDK_ABI-linux-androideabi
NDK_TOOLCHAIN=$HOST-$NDK_COMPILER_VERSION
fi

NDK_TOOLCHAIN_BASE=$NDK_BASE/toolchains/$NDK_TOOLCHAIN/prebuilt/$NDK_UNAME-$NDK_PROCESSOR

CC="$NDK_TOOLCHAIN_BASE/bin/$HOST-gcc --sysroot=$NDK_SYSROOT"
Expand Down