1#!/bin/bash
2
3set -e
4set -x
5
6if [ ! -d "$NDK" ]; then
7  echo 'Please set $NDK to the path to NDK'
8  exit 1
9fi
10
11cd $(dirname "$0")
12
13function RunConfigure() {
14  HOST=$1
15  TARGET=$2
16  ARCH=$3
17
18  TOOLCHAIN=${NDK}/toolchains/llvm/prebuilt/linux-x86_64/bin/
19
20  export AR=${TOOLCHAIN}${HOST}-ar
21  export AS=${TOOLCHAIN}${TARGET}-clang
22  export CC=${TOOLCHAIN}${TARGET}-clang
23  export CXX=${TOOLCHAIN}${TARGET}-clang++
24  export LD=${TOOLCHAIN}${HOST}-ld
25  export STRIP=${TOOLCHAIN}${HOST}-strip
26
27  # Tell configure what flags Android requires.
28  export CFLAGS="-fPIE -fPIC"
29  export LDFLAGS="-pie"
30
31  ./configure --host=${HOST}
32}
33
34# All arches generates the same iperf_config.h (for now).
35RunConfigure "aarch64-linux-android" "aarch64-linux-android28" "arm64"
36# RunConfigure "arm-linux-androideabi" "armv7a-linux-androideabi28" "arm"
37# RunConfigure "i686-linux-android" "i686-linux-android28" "x86"
38# RunConfigure "x86_64-linux-android" "x86_64-linux-android28" "x86-64"
39