compile.sh 5 KB
Newer Older
Rémi Duraffort's avatar
Rémi Duraffort committed
1 2
#! /bin/sh

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
3 4 5
# Read the Android Wiki http://wiki.videolan.org/AndroidCompile
# Setup all that stuff correctly.
# Get the latest Android SDK Platform or modify numbers in configure.sh and vlc-android/default.properties.
Rafaël Carré's avatar
Rafaël Carré committed
6

7 8
set -e

9 10 11 12
if [ -z "$ANDROID_NDK" -o -z "$ANDROID_SDK" -o -z "$ANDROID_ABI" ]; then
   echo "You must define ANDROID_NDK, ANDROID_SDK and ANDROID_ABI before starting."
   echo "They must point to your NDK and SDK directories.\n"
   echo "ANDROID_ABI should match your ABI: armeabi-v7a, armeabi or ..."
Rafaël Carré's avatar
Rafaël Carré committed
13 14
   exit 1
fi
Rémi Duraffort's avatar
Rémi Duraffort committed
15

16 17
# XXX : important!
cat << EOF
Edward Wang's avatar
Edward Wang committed
18
For an ARMv7-A device without NEON, you need a build without NEON:
19 20 21
$ export NO_NEON=1
For an ARMv6 device without FPU, you need a build without FPU:
$ export NO_FPU=1
Edward Wang's avatar
Edward Wang committed
22 23
For an ARMv5 device or the Android emulator, you need an ARMv5 build:
$ export NO_ARMV6=1
24 25 26 27 28 29 30 31

If you plan to use a release build, run 'compile.sh release'
EOF
# try to detect NDK version
REL=$(grep -o '^r[0-9]*' $ANDROID_NDK/RELEASE.TXT 2>/dev/null|cut -b2-)
if [ -z $REL ]; then
    echo "You need the NDKv7 or later"
    exit 1
32 33
fi

Edward Wang's avatar
Edward Wang committed
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
# Set up ABI variables
if [ ${ANDROID_ABI} = "x86" ] ; then
    TARGET_TUPLE="i686-android-linux"
    PATH_HOST="x86"
    HAVE_X86=1
    PLATFORM_SHORT_ARCH="x86"
elif [ ${ANDROID_ABI} = "mips" ] ; then
    TARGET_TUPLE="mipsel-linux-android"
    PATH_HOST=$TARGET_TUPLE
    HAVE_MIPS=1
    PLATFORM_SHORT_ARCH="mips"
else
    TARGET_TUPLE="arm-linux-androideabi"
    PATH_HOST=$TARGET_TUPLE
    HAVE_ARM=1
    PLATFORM_SHORT_ARCH="arm"
fi
export TARGET_TUPLE
export PATH_HOST
export HAVE_ARM
export HAVE_X86
export HAVE_MIPS
export PLATFORM_SHORT_ARCH

58 59
# Add the NDK toolchain to the PATH, needed both for contribs and for building
# stub libraries
Rui Zhang's avatar
Rui Zhang committed
60
export PATH=${ANDROID_NDK}/toolchains/${PATH_HOST}-4.4.3/prebuilt/darwin-x86/bin:${PATH}
Edward Wang's avatar
Edward Wang committed
61
export PATH=${ANDROID_NDK}/toolchains/${PATH_HOST}-4.4.3/prebuilt/linux-x86/bin:${PATH}
62

Rafaël Carré's avatar
Rafaël Carré committed
63
# 1/ libvlc, libvlccore and its plugins
64
TESTED_HASH=57cace3
65
if [ ! -d "vlc" ]; then
66
    echo "VLC source not found, cloning"
67
    git clone git://git.videolan.org/vlc.git vlc
Philipp Dreimann's avatar
Philipp Dreimann committed
68
    cd vlc
69
    git checkout -B android ${TESTED_HASH}
70 71
    echo "Applying the patches"
    git am ../patches/*.patch
72 73 74 75 76
    if [ $? -ne 0 ]; then
        git am --abort
        echo "Applying the patches failed, aborting git-am"
        exit 1
    fi
77
else
78
    echo "VLC source found"
79
    cd vlc
80 81 82 83 84 85 86
    if ! git cat-file -e ${TESTED_HASH}; then
        cat << EOF
***
*** Error: Your vlc checkout does not contain the latest tested commit ***
***

Please update your source with something like:
Rémi Duraffort's avatar
Rémi Duraffort committed
87 88

cd vlc
89 90 91 92 93 94 95 96 97 98 99
git reset --hard origin
git pull origin master
git checkout -B android ${TESTED_HASH}
git am ../patches/*

*** : This will delete any changes you made to the current branch ***

EOF
        exit 1
    fi
fi
Rémi Duraffort's avatar
Rémi Duraffort committed
100 101

echo "Building the contribs"
102 103
mkdir -p contrib/android
cd contrib/android
Edward Wang's avatar
Edward Wang committed
104
../bootstrap --host=${TARGET_TUPLE} --disable-disc --disable-sout --enable-small \
Rafaël Carré's avatar
Rafaël Carré committed
105 106 107 108 109 110 111 112
    --disable-sdl \
    --disable-SDL_image \
    --disable-fontconfig \
    --disable-zvbi \
    --disable-kate \
    --disable-caca \
    --disable-gettext \
    --disable-mpcdec \
113
    --disable-upnp \
114
    --disable-gme \
115 116
    --disable-tremor \
    --disable-vorbis \
117
    --disable-sidplay2 \
Sébastien Toque's avatar
Sébastien Toque committed
118
    --disable-samplerate \
Edward Wang's avatar
Edward Wang committed
119
    --disable-faad2 \
Sébastien Toque's avatar
Sébastien Toque committed
120
    --enable-iconv
Rafaël Carré's avatar
Rafaël Carré committed
121

122
# TODO: mpeg2, theora
123

124 125 126 127 128 129 130
if [ ${ANDROID_ABI} = "armeabi-v7a" ] ; then
    if test -z "${NO_NEON}" ; then
        EXTRA_CFLAGS="-mfpu=neon -mcpu=cortex-a8"
    else
        EXTRA_CFLAGS="-mfpu=vfpv3-d16 -mcpu=cortex-a9"
    fi
    EXTRA_CFLAGS="${EXTRA_CFLAGS} -mthumb -mfloat-abi=softfp"
131
    echo "NOTHUMB := -marm" >> config.mak
132 133
elif [ ${ANDROID_ABI} = "armeabi" ] ; then
    export NO_NEON=1
Edward Wang's avatar
Edward Wang committed
134 135
    if [ -n "${NO_ARMV6}" ]; then
        EXTRA_CFLAGS="-march=armv5te -mtune=arm9tdmi -msoft-float"
136
    else
Edward Wang's avatar
Edward Wang committed
137 138 139 140 141
        if [ -n "${NO_FPU}" ]; then
            EXTRA_CFLAGS="-march=armv6j -mtune=arm1136j-s -msoft-float"
        else
            EXTRA_CFLAGS="-mfpu=vfp -mcpu=arm1136jf-s -mfloat-abi=softfp"
        fi
142
    fi
Edward Wang's avatar
Edward Wang committed
143 144
elif [ ${ANDROID_ABI} = "x86" ] ; then
    EXTRA_CFLAGS="-march=pentium -ffunction-sections -funwind-tables -frtti -fno-exceptions"
145 146 147
else
    echo "Unknown ABI. Die, die, die!"
    exit 2
148 149
fi

150
# Release or not?
151
if [ $# -ne 0 ] && [ "$1" == "release" ]; then
152
    OPTS=""
153 154
    EXTRA_CFLAGS="${EXTRA_CFLAGS} -DNDEBUG "
    RELEASEFLAG="RELEASE=1"
155 156 157 158
else
    OPTS="--enable-debug"
fi

159
echo "EXTRA_CFLAGS= -g ${EXTRA_CFLAGS}" >> config.mak
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
160
export VLC_EXTRA_CFLAGS="${EXTRA_CFLAGS}"
161

Rafaël Carré's avatar
Rafaël Carré committed
162 163
make fetch
make
Rémi Duraffort's avatar
Rémi Duraffort committed
164 165 166

cd ../.. && mkdir -p android && cd android

167
if test ! -s "../configure" ; then
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
168
    echo "Bootstraping"
Sébastien Toque's avatar
Sébastien Toque committed
169
    ../bootstrap
Rafaël Carré's avatar
Rafaël Carré committed
170
fi
Rémi Duraffort's avatar
Rémi Duraffort committed
171 172

echo "Configuring"
173
../../configure.sh $OPTS
Rémi Duraffort's avatar
Rémi Duraffort committed
174

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
175
echo "Building"
Rémi Duraffort's avatar
Rémi Duraffort committed
176
make
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
177

Rafaël Carré's avatar
Rafaël Carré committed
178 179 180

# 2/ VLC android UI and specific code

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
181 182
echo "Building Android"
cd ../../
Rafaël Carré's avatar
Rafaël Carré committed
183

184
export ANDROID_SYS_HEADERS_GINGERBREAD=${PWD}/android-headers-gingerbread
185
export ANDROID_SYS_HEADERS_HC=${PWD}/android-headers-hc
186
export ANDROID_SYS_HEADERS_ICS=${PWD}/android-headers-ics
Rafaël Carré's avatar
Rafaël Carré committed
187 188

export ANDROID_LIBS=${PWD}/android-libs
189
export VLC_BUILD_DIR=vlc/android
Rafaël Carré's avatar
Rafaël Carré committed
190

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
191
make distclean
Edward Wang's avatar
Edward Wang committed
192
make TARGET_TUPLE=$TARGET_TUPLE PLATFORM_SHORT_ARCH=$PLATFORM_SHORT_ARCH $RELEASEFLAG