4 # Copyright 2018 Collabora ltd.
6 # This library is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU Lesser General Public
8 # License as published by the Free Software Foundation; either
9 # version 2.1 of the License, or (at your option) any later version.
11 # This library is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # Lesser General Public License for more details.
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with this library; if not, see <http://www.gnu.org/licenses/>.
19 # Author: Xavier Claessens <xavier.claessens@collabora.com>
26 # Download Android NDK
27 wget
--quiet https
://dl.google.com
/android
/repository
/android-ndk-r16-linux-x86_64.
zip
28 echo "5b9ec70eac78f6cef8572dff9a133c9b18c83155dc6d980237a6925df4ae65b7b2adb3d8ea55b3ce9f3f75868f20eefdb8c87da110683c2dd1a1a27c44dc5b91 android-ndk-r16-linux-x86_64.zip" | sha512sum
-c
29 unzip android-ndk-r16-linux-x86_64.
zip
30 rm android-ndk-r16-linux-x86_64.
zip
32 # Setup cross build env
33 export ANDROID_HOST
=aarch64-linux-android
34 export ANDROID_BUILD
=linux-x86_64
35 export ANDROID_ARCH
=arm64
36 export ANDROID_NDK
=/opt
/android-ndk-r16
37 export ANDROID_VERSION
=21
38 export ANDROID_TOOLCHAIN_VERSION
=4.9
39 export ANDROID_SYSROOT
=$ANDROID_NDK/platforms
/android-
$ANDROID_VERSION/arch-
$ANDROID_ARCH
40 export ANDROID_PREBUILT
=$ANDROID_NDK/toolchains
/$ANDROID_HOST-$ANDROID_TOOLCHAIN_VERSION/prebuilt
/$ANDROID_BUILD/bin
41 export CPPFLAGS
="--sysroot=$ANDROID_SYSROOT -isystem $ANDROID_NDK/sysroot/usr/include/ -isystem $ANDROID_NDK/sysroot/usr/include/$ANDROID_HOST"
42 export CFLAGS
="$CPPFLAGS -D__ANDROID_API__=$ANDROID_VERSION"
43 export AR
=$ANDROID_HOST-ar
44 export RANLIB
=$ANDROID_HOST-ranlib
45 export CPP
=$ANDROID_HOST-cpp
46 export PATH
=$ANDROID_PREBUILT:$PATH
48 # Cross build libiconv
49 wget
--quiet http
://ftp.gnu.org
/pub
/gnu
/libiconv
/libiconv-1.15.
tar.gz
50 echo "1233fe3ca09341b53354fd4bfe342a7589181145a1232c9919583a8c9979636855839049f3406f253a9d9829908816bb71fd6d34dd544ba290d6f04251376b1a libiconv-1.15.tar.gz" | sha512sum
-c
51 tar xzf libiconv-1.15.
tar.gz
52 rm libiconv-1.15.
tar.gz
54 .
/configure
--host=$ANDROID_HOST --prefix=/opt
/$ANDROID_HOST --libdir=/opt
/$ANDROID_HOST/lib64
60 wget
--quiet https
://github.com
/libffi
/libffi
/releases
/download
/v3.3
-rc0/libffi-3.3
-rc0.
tar.gz
61 echo "e6e695d32cd6eb7d65983f32986fccdfc786a593d2ea18af30ce741f58cfa1eb264b1a8d09df5084cb916001aea15187b005c2149a0620a44397a4453b6137d4 libffi-3.3-rc0.tar.gz" | sha512sum
-c
62 tar xzf libffi-3.3
-rc0.
tar.gz
63 rm libffi-3.3
-rc0.
tar.gz
65 .
/configure
--host=$ANDROID_HOST --prefix=/opt
/$ANDROID_HOST --libdir=/opt
/$ANDROID_HOST/lib64
70 # Create a pkg-config wrapper that won't pick fedora libraries
71 export PKG_CONFIG
=/opt
/${ANDROID_HOST}/bin
/pkg-config
72 cat > $PKG_CONFIG <<- EOM
74 SYSROOT=/opt/${ANDROID_HOST}
75 export PKG_CONFIG_DIR=
76 export PKG_CONFIG_LIBDIR=\${SYSROOT}/lib64/pkgconfig
77 export PKG_CONFIG_SYSROOT_DIR=\${SYSROOT}
82 # Create a cross file that can be passed to meson
83 cat > /opt
/cross-file-android_ndk_r16_api21_arm64.txt
<<- EOM
91 c_args = ['--sysroot=${ANDROID_SYSROOT}',
92 '-isystem', '/opt/${ANDROID_HOST}/include',
93 '-isystem', '${ANDROID_NDK}/sysroot/usr/include/',
94 '-isystem', '${ANDROID_NDK}/sysroot/usr/include/${ANDROID_HOST}',
95 '-D__ANDROID_API__=${ANDROID_VERSION}']
96 c_link_args = ['--sysroot=${ANDROID_SYSROOT}',
97 '-L/opt/${ANDROID_HOST}/lib64',
101 c = '${ANDROID_PREBUILT}/${ANDROID_HOST}-gcc'
102 cpp = '${ANDROID_PREBUILT}/${ANDROID_HOST}-g++'
103 ar = '${ANDROID_PREBUILT}/${ANDROID_HOST}-ar'
104 strip = '${ANDROID_PREBUILT}/${ANDROID_HOST}-strip'
105 pkgconfig = '${PKG_CONFIG}'