1#!/bin/bash
2
3set -e
4
5if [[ "${TARGET_PRODUCT}" != "aosp_arm" ]]; then
6  # Some of the include paths below assume that this is an arm 32bit configure
7  # run.
8  echo "Run 'lunch aosp_arm-eng' first." >&2
9  exit 1
10fi
11
12cd $(dirname "$0")
13
14export CC="$(ls "${ANDROID_TOOLCHAIN}" | grep "\-gcc$" | grep -v kernel)"
15export LD="$(ls "${ANDROID_TOOLCHAIN}" | grep "\-ld$" | grep -v kernel)"
16
17T="${ANDROID_BUILD_TOP}"
18CFLAGS=(
19  "-isystem ${T}/external/libcxx/include"
20  "-isystem ${T}/bionic/libc/include/"
21  "-isystem ${T}/bionic/libc/arch-arm/include"
22  "-isystem ${T}/bionic/libc/kernel/android/uapi/"
23  "-isystem ${T}/bionic/libc/kernel/uapi/"
24  "-isystem ${T}/bionic/libc/kernel/uapi/asm-arm/"
25  "-isystem ${T}/bionic/libm/include"
26  "-isystem ${T}/build/core/combo/include/arch/linux-arm/"
27  "-fno-exceptions"
28  "-ffunction-sections"
29  "-fdata-sections"
30  "-fstack-protector"
31  "-fno-short-enums"
32  "-no-canonical-prefixes"
33  "-fmessage-length=0"
34  "-fomit-frame-pointer"
35  "-fPIC"
36  "-fno-strict-aliasing"
37  "-nostdlib"
38)
39
40./buildconf
41CFLAGS="${CFLAGS[@]}"
42./configure \
43  --host=arm-linux-androideabi \
44  CFLAGS="${CFLAGS}" \
45  LIBS="-lc" \
46  CPPFLAGS="${CFLAGS} -I${T}/external/zlib/src" \
47  LDFLAGS="-L${ANDROID_PRODUCT_OUT}/obj/lib/" \
48  --disable-ntlm-wb \
49  --enable-ipv6 \
50  --with-ssl="${T}/external/boringssl" \
51  --with-zlib \
52  --with-ca-path="/system/etc/security/cacerts"
53
54# Apply local changes to the default configure output.
55patch -p1 --no-backup-if-mismatch < local-configure.patch
56