1#!/bin/bash
2#
3# this script is used to update the prebuilt libqemu-audio.a file in the Android source tree
4# we use a prebuilt package because we don't want to force the installation of the ALSA / EsounD / Whatever
5# development packages on every developer machine, or every build server.
6#
7
8# assumes this script is located in the 'distrib' sub-directory
9cd `dirname $0`
10cd ..
11. android/build/common.sh
12
13check_android_build
14if [ $IN_ANDROID_BUILD != yes ] ; then
15    echo "Sorry, this script can only be run from a full Android build tree"
16    exit 1
17fi
18
19force_32bit_binaries
20locate_android_prebuilt
21
22# find the prebuilt directory
23OS=`uname -s`
24EXE=""
25case "$OS" in
26    Darwin)
27        CPU=`uname -p`
28        if [ "$CPU" == "i386" ] ; then
29            OS=darwin-x86
30        else
31            OS=darwin-ppc
32        fi
33        ;;
34    Linux)
35        CPU=`uname -m`
36        case "$CPU" in
37        i?86|x86_64|amd64)
38            CPU=x86
39            ;;
40        esac
41        OS=linux-$CPU
42        ;;
43    *_NT-*)
44        OS=windows
45        EXE=.exe
46        ;;
47esac
48
49PREBUILT=$(locate_depot_files //branches/cupcake/android/prebuilt/$OS)
50
51# find the GNU Make program
52is_gnu_make ()
53{
54    version=$($1 -v | grep GNU)
55    if test -n "$version"; then
56        echo "$1"
57    else
58        echo ""
59    fi
60}
61
62if test -z "$GNUMAKE"; then
63    GNUMAKE=`which make` && GNUMAKE=$(is_gnu_make $GNUMAKE)
64fi
65
66if test -z "$GNUMAKE"; then
67    GNUMAKE=`which gmake` && GNUMAKE=$(is_gnu_make $GNUMAKE)
68fi
69
70if test -z "$GNUMAKE"; then
71    echo "could not find GNU Make on this machine. please define GNUMAKE to point to it"
72    exit 3
73fi
74
75TEST=$(is_gnu_make $GNUMAKE)
76if test -z "$TEST"; then
77    echo "it seems that '$GNUMAKE' is not a working GNU Make binary. please check the definition of GNUMAKE"
78    exit 3
79fi
80
81# ensure we have a recent audio library built
82#
83#echo "GNUMAKE is $GNUMAKE"
84source=objs/libqemu-audio.a
85./android-configure.sh
86$GNUMAKE $source BUILD_QEMU_AUDIO_LIB=true || (echo "could not build the audio library. Aborting" && exit 1)
87
88# now do a p4 edit, a copy and ask for submission
89#
90TARGET=$ANDROID_PREBUILT/emulator/libqemu-audio.a
91
92cp -f $source $TARGET
93echo "ok, file copied to $TARGET"
94
95