compile.sh 3.88 KB
Newer Older
ivoire's avatar
ivoire committed
1
2
#! /bin/sh

3
# Read the Android Wiki and setup all that stuff correctly.
Rafaël Carré's avatar
Rafaël Carré committed
4
5
6
7
# Get the Android SDK Platform 2.1, 2.2 and 2.3 API : version 7, 8 and (9 or 10)
# or modify numbers in configure.sh and vlc-android/default.properties.
# Create an AVD with this platform.

8
9
set -e

10
11
12
13
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
14
15
   exit 1
fi
ivoire's avatar
ivoire committed
16

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

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
31
32
fi

33
34
35
36
# Add the NDK toolchain to the PATH, needed both for contribs and for building
# stub libraries
export PATH=${ANDROID_NDK}/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin:${PATH}

Rafaël Carré's avatar
Rafaël Carré committed
37
# 1/ libvlc, libvlccore and its plugins
38
TESTED_HASH=3e140bd0
39
if [ ! -d "vlc" ]; then
40
    echo "VLC source not found, cloning"
41
    git clone git://git.videolan.org/vlc.git vlc
Philipp Dreimann's avatar
Philipp Dreimann committed
42
    cd vlc
43
    git checkout -B android ${TESTED_HASH}
44
45
    echo "Applying the patches"
    git am ../patches/*.patch
46
else
47
    echo "VLC source found"
48
    cd vlc
49
50
51
52
53
54
55
    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:
ivoire's avatar
ivoire committed
56
57

cd vlc
58
59
60
61
62
63
64
65
66
67
68
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
ivoire's avatar
ivoire committed
69
70

echo "Building the contribs"
71
72
mkdir -p contrib/android
cd contrib/android
73
../bootstrap --host=arm-linux-androideabi --disable-disc --disable-sout --enable-small \
Rafaël Carré's avatar
Rafaël Carré committed
74
75
76
77
78
79
80
81
    --disable-sdl \
    --disable-SDL_image \
    --disable-fontconfig \
    --disable-zvbi \
    --disable-kate \
    --disable-caca \
    --disable-gettext \
    --disable-mpcdec \
82
    --disable-upnp \
83
    --disable-gme \
84
85
    --disable-tremor \
    --disable-vorbis \
86
    --disable-sidplay2 \
Sébastien Toque's avatar
Sébastien Toque committed
87
88
    --disable-samplerate \
    --enable-iconv
Rafaël Carré's avatar
Rafaël Carré committed
89

90
# TODO: mpeg2, theora
91

92
93
94
95
96
97
98
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"
99
    echo "NOTHUMB := -marm" >> config.mak
100
101
102
103
104
105
106
107
108
109
elif [ ${ANDROID_ABI} = "armeabi" ] ; then
    export NO_NEON=1
    if test -z "${NO_FPU}" ; then
        EXTRA_CFLAGS="-mfpu=vfp -mcpu=arm1136jf-s -mfloat-abi=softfp"
    else
        EXTRA_CFLAGS="-march=armv6j -mtune=arm1136j-s -msoft-float"
    fi
else
    echo "Unknown ABI. Die, die, die!"
    exit 2
110
111
fi

112
# Release or not?
113
if [ $# -ne 0 ] && [ "$1" == "release" ]; then
114
    OPTS=""
115
116
    EXTRA_CFLAGS="${EXTRA_CFLAGS} -DNDEBUG "
    RELEASEFLAG="RELEASE=1"
117
118
119
120
else
    OPTS="--enable-debug"
fi

121
122
123
echo "EXTRA_CFLAGS= -g ${EXTRA_CFLAGS}" >> config.mak
export VLC_EXTRA_CFLAGS=${EXTRA_CFLAGS}

Rafaël Carré's avatar
Rafaël Carré committed
124
125
make fetch
make
ivoire's avatar
ivoire committed
126
127
128

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

129
if test ! -s "../configure" ; then
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
130
    echo "Bootstraping"
Sébastien Toque's avatar
Sébastien Toque committed
131
    ../bootstrap
Rafaël Carré's avatar
Rafaël Carré committed
132
fi
ivoire's avatar
ivoire committed
133
134

echo "Configuring"
135
../../configure.sh $OPTS
ivoire's avatar
ivoire committed
136

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
137
echo "Building"
ivoire's avatar
ivoire committed
138
make
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
139

Rafaël Carré's avatar
Rafaël Carré committed
140
141
142

# 2/ VLC android UI and specific code

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
143
144
echo "Building Android"
cd ../../
Rafaël Carré's avatar
Rafaël Carré committed
145

146
export ANDROID_SYS_HEADERS_GINGERBREAD=${PWD}/android-headers-gingerbread
147
export ANDROID_SYS_HEADERS_HC=${PWD}/android-headers-hc
148
export ANDROID_SYS_HEADERS_ICS=${PWD}/android-headers-ics
Rafaël Carré's avatar
Rafaël Carré committed
149
150

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

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
153
make distclean
154
make $RELEASEFLAG