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

Rafaël Carré's avatar
Rafaël Carré committed
3
4
5
6
7
# Read the Android HOWTO and setup all that stuff correctly.
# 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

Rafaël Carré's avatar
Rafaël Carré committed
10
# XXX : important!
11
cat << EOF
Edward Wang's avatar
Edward Wang committed
12
If you plan to use a device without NEON (e.g. the emulator), you need a build without NEON:
13
$ export NO_NEON=1
Edward Wang's avatar
Edward Wang committed
14
Make sure it is set throughout the entire process.
15

Edward Wang's avatar
Edward Wang committed
16
The script will attempt to automatically detect if you have NDK v7, but you can override this.
17
18
19
20
21
If you do not have NDK v7 or later:
export NO_NDK_V7=1
or if you are sure you have NDK v7:
export NO_NDK_V7=0

22
If you plan to use a release build, run 'compile.sh release'
23
EOF
Edward Wang's avatar
Edward Wang committed
24

25
26
27
28
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
29
30
   exit 1
fi
ivoire's avatar
ivoire committed
31

32
33
if [ -z "$NO_NDK_V7" ]; then
    # try to detect NDK version
34
    REL=$(grep -o '^r[0-9]*' $ANDROID_NDK/RELEASE.TXT 2>/dev/null|cut -b2-)
35
    if [ -z $REL ]; then
36
        export NO_NDK_V7=1
37
38
39
    fi
fi

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

cd vlc
65
66
67
68
69
70
71
72
73
74
75
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
76
77

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

97
# TODO: mpeg2, theora
98

99
100
101
102
103
104
105
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"
106
    echo "NOTHUMB := -marm" >> config.mak
107
108
109
110
111
112
113
114
115
116
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
117
118
fi

119
# Release or not?
120
if [ $# -ne 0 ] && [ "$1" == "release" ]; then
121
    OPTS=""
122
123
    EXTRA_CFLAGS="${EXTRA_CFLAGS} -DNDEBUG "
    RELEASEFLAG="RELEASE=1"
124
125
126
127
else
    OPTS="--enable-debug"
fi

128
129
130
echo "EXTRA_CFLAGS= -g ${EXTRA_CFLAGS}" >> config.mak
export VLC_EXTRA_CFLAGS=${EXTRA_CFLAGS}

Rafaël Carré's avatar
Rafaël Carré committed
131
132
make fetch
make
ivoire's avatar
ivoire committed
133
134
135

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

136
if test ! -s "../configure" ; then
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
137
    echo "Bootstraping"
Sébastien Toque's avatar
Sébastien Toque committed
138
    ../bootstrap
Rafaël Carré's avatar
Rafaël Carré committed
139
fi
ivoire's avatar
ivoire committed
140
141

echo "Configuring"
142
../../configure.sh $OPTS
ivoire's avatar
ivoire committed
143

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
144
echo "Building"
ivoire's avatar
ivoire committed
145
make
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
146

Rafaël Carré's avatar
Rafaël Carré committed
147
148
149

# 2/ VLC android UI and specific code

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
150
151
echo "Building Android"
cd ../../
Rafaël Carré's avatar
Rafaël Carré committed
152

153
export ANDROID_SYS_HEADERS_GINGERBREAD=${PWD}/android-headers-gingerbread
154
export ANDROID_SYS_HEADERS_HC=${PWD}/android-headers-hc
155
export ANDROID_SYS_HEADERS_ICS=${PWD}/android-headers-ics
Rafaël Carré's avatar
Rafaël Carré committed
156
157

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

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
160
make distclean
161
make $RELEASEFLAG