Imported Upstream version 1.0.26
[platform/upstream/libsndfile.git] / Scripts / android-configure.sh
1 #!/bin/bash -e
2
3 # Copyright (C) 2013 Erik de Castro Lopo <erikd@mega-nerd.com>
4 #
5 # All rights reserved.
6 #
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions are
9 # met:
10 #
11 #     * Redistributions of source code must retain the above copyright
12 #       notice, this list of conditions and the following disclaimer.
13 #     * Neither the author nor the names of any contributors may be used
14 #       to endorse or promote products derived from this software without
15 #       specific prior written permission.
16 #
17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19 # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
21 # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22 # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23 # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
24 # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25 # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
26 # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
27 # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
29 # Android NDK version number; eg r8e, r9 etc
30 ANDROID_NDK_VER=r9
31
32 # Android NDK gcc version; eg 4.7, 4.9 etc.
33 ANDROID_GCC_VER=4.8
34
35 # Android API version; eg 9 (Android 2.3), 14 (Android 4.0) etc.
36 ANDROID_API_VER=9
37
38 #-------------------------------------------------------------------------------
39 # No more user config beyond here.
40
41 BUILD_MACHINE=$(uname -s | tr 'A-Z' 'a-z')-$(uname -m)
42
43 function die_with {
44         echo $1
45         exit 1
46 }
47
48 export CROSS_COMPILE=arm-linux-androideabi
49
50 # I put all my dev stuff in here
51 export DEV_PREFIX=$HOME/Android
52 test -d ${DEV_PREFIX} || die_with "Error : DEV_PREFIX '$DEV_PREFIX' does not exist."
53
54 # Don't forget to adjust this to your NDK path
55 export ANDROID_NDK=${DEV_PREFIX}/android-ndk-${ANDROID_NDK_VER}
56 test -d ${ANDROID_NDK} || die_with "Error : ANDROID_NDK '$ANDROID_NDK' does not exist."
57
58 export ANDROID_PREFIX=${ANDROID_NDK}/toolchains/arm-linux-androideabi-${ANDROID_GCC_VER}/prebuilt/${BUILD_MACHINE}
59 test -d ${ANDROID_PREFIX} || die_with "Error : ANDROID_PREFIX '$ANDROID_PREFIX' does not exist."
60
61 export SYSROOT=${ANDROID_NDK}/platforms/android-${ANDROID_API_VER}/arch-arm
62 test -d ${SYSROOT} || die_with "Error : SYSROOT '$SYSROOT' does not exist."
63
64 export CROSS_PREFIX=${ANDROID_PREFIX}/bin/${CROSS_COMPILE}
65 test -f ${CROSS_PREFIX}-gcc || die_with "Error : CROSS_PREFIX compiler '${CROSS_PREFIX}-gcc' does not exist."
66
67
68 # Non-exhaustive lists of compiler + binutils
69 # Depending on what you compile, you might need more binutils than that
70 export CPP=${CROSS_PREFIX}-cpp
71 export AR=${CROSS_PREFIX}-ar
72 export AS=${CROSS_PREFIX}-as
73 export NM=${CROSS_PREFIX}-nm
74 export CC=${CROSS_PREFIX}-gcc
75 export CXX=${CROSS_PREFIX}-g++
76 export LD=${CROSS_PREFIX}-ld
77 export RANLIB=${CROSS_PREFIX}-ranlib
78
79 # Don't mix up .pc files from your host and build target
80 export PKG_CONFIG_PATH=${PREFIX}/lib/pkgconfig
81
82 # Set up the needed FLAGS.
83 export CFLAGS="${CFLAGS} -gstabs --sysroot=${SYSROOT} -I${SYSROOT}/usr/include -I${ANDROID_PREFIX}/include"
84 export CXXFLAGS="${CXXFLAGS} -gstabs -fno-exceptions --sysroot=${SYSROOT} -I${SYSROOT}/usr/include -I${ANDROID_PREFIX}/include -I${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/${ANDROID_GCC_VER}/include/ -I${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/${ANDROID_GCC_VER}/libs/armeabi/include"
85
86 export CPPFLAGS="${CFLAGS}"
87 export LDFLAGS="${LDFLAGS} -L${SYSROOT}/usr/lib -L${ANDROID_PREFIX}/lib"
88
89 # Create a symlink to the gdbclient.
90 test -h gdbclient || ln -s ${ANDROID_PREFIX}/bin/arm-linux-androideabi-gdb gdbclient
91
92 ./configure --host=${CROSS_COMPILE} --with-sysroot=${SYSROOT} "$@"