Improved control.sh for the upcoming GUI, local testing made easier
[kindlebrew:mplayer.git] / build.sh
1 #!/bin/sh
2 ## Tested with the toolchain described in the x-compile file in kindle-x-tc.tar.gz
3 ## available at <http://www.mobileread.com/forums/showthread.php?t=88004>
4 VER=0.2.0
5
6 ## Prefix where alsa-lib 1.0.13 for arm is installed
7 ## For some reason, I couldn't get alsa to make a dynamic version of
8 ## libasound.so.2, so I copied it from the Kindle
9 ## If you do that you'll need to create a symbolic link:
10 ## ln -s libasound.so.2 libasound.so
11 ALSAPREFIX=/opt/kindle
12
13 ##Number of make jobs to run in parallel
14 JOBS=$(grep processor /proc/cpuinfo | wc -l)
15
16 if [ "x$CROSS_PREFIX" = "x" ]; then
17     CROSS_PREFIX=arm-kindle-linux-gnueabi-
18 fi
19 if ! which ${CROSS_PREFIX}gcc >/dev/null 2>&1; then
20     echo "${CROSS_PREFIX}gcc not found, please correct your \$PATH"
21     exit 1
22 fi
23
24 mkdir -p build
25 cd build
26 if [ ! -e ready-to-build ]; then
27     echo "Downloading MPlayer"
28     wget -c http://www.mplayerhq.hu/MPlayer/releases/MPlayer-1.0rc4.tar.bz2
29     tar xvf MPlayer-1.0rc4.tar.bz2
30     cd MPlayer-1.0rc4
31
32     ## Needed if you build with glibc >= 2.7, to avoid pulling symbols from GLIBC_2.7
33     echo "Patching MPlayer"
34     patch -p1 < ../../patches/01-make-gnu89-compatible.patch
35     touch ../ready-to-build
36 fi
37
38 cd MPlayer-1.0rc4
39 if [ ! -e mplayer ]; then
40     echo "Building MPlayer"
41     export CFLAGS="-O4 -I$ALSAPREFIX/include/ -march=armv6j -mtune=arm1136jf-s -U_FORTIFY_SOURCE"
42     export LDFLAGS="-L$ALSAPREFIX/lib/"
43     ./configure --prefix=$ALSAPREFIX\
44      --enable-cross-compile --enable-armv6 --target=arm-linux --host-cc=gcc\
45      --cc=${CROSS_PREFIX}cc --as=${CROSS_PREFIX}as --nm=${CROSS_PREFIX}nm --ranlib=${CROSS_PREFIX}ranlib\
46      --disable-mencoder\
47      --disable-libdvdcss-internal --disable-dvdread-internal\
48      --disable-tv --disable-tga --disable-dvb --disable-v4l2 --disable-yuv4mpeg
49
50     if [ $? = 0 ]; then
51         make -j$JOBS
52     fi
53
54     if [ $? = 0 ]; then
55         ${CROSS_PREFIX}strip --strip-all mplayer
56     fi
57
58     cp mplayer ../../src/mplayer
59 fi
60
61 cd ../..
62 echo "Building shuf"
63 ${CROSS_PREFIX}gcc -o src/mplayer/shuf shuf.c -O3 -march=armv6j -mtune=arm1136jf-s
64 ${CROSS_PREFIX}strip --strip-all src/mplayer/shuf
65
66 echo "Creating tgz archive"
67 cd src
68 tar cvzf mplayer-${VER}.tgz *
69 mv *.tgz ..
70 echo "Creating zip archive"
71 zip -r mplayer-${VER}.zip *
72 mv *.zip ..