| 1 |
#!/bin/bash |
| 2 |
############################################################################### |
| 3 |
# BRLTTY - A background process providing access to the console screen (when in |
| 4 |
# text mode) for a blind person using a refreshable braille display. |
| 5 |
# |
| 6 |
# Copyright (C) 1995-2026 by The BRLTTY Developers. |
| 7 |
# |
| 8 |
# BRLTTY comes with ABSOLUTELY NO WARRANTY. |
| 9 |
# |
| 10 |
# This is free software, placed under the terms of the |
| 11 |
# GNU Lesser General Public License, as published by the Free Software |
| 12 |
# Foundation; either version 2.1 of the License, or (at your option) any |
| 13 |
# later version. Please see the file LICENSE-LGPL for details. |
| 14 |
# |
| 15 |
# Web Page: http://brltty.app/ |
| 16 |
# |
| 17 |
# This software is maintained by Dave Mielke <[email protected]>. |
| 18 |
############################################################################### |
| 19 |
|
| 20 |
. "`dirname "${0}"`/brltty-prologue.sh" |
| 21 |
|
| 22 |
ndkRootVariable=ANDROID_NDK |
| 23 |
|
| 24 |
showProgramUsagePurpose() { |
| 25 |
cat <<END_OF_PROGRAM_USAGE_PURPOSE |
| 26 |
Configure a BRLTTY build for the Android platform. |
| 27 |
END_OF_PROGRAM_USAGE_PURPOSE |
| 28 |
} |
| 29 |
|
| 30 |
showProgramUsageNotes() { |
| 31 |
cat <<END_OF_PROGRAM_USAGE_NOTES |
| 32 |
All of the options are passed through, unmodified, as additional options to the configure script. |
| 33 |
The ${ndkRootVariable} environment variable must point to the root directory for the Android NDK (native development kit). |
| 34 |
END_OF_PROGRAM_USAGE_NOTES |
| 35 |
} |
| 36 |
|
| 37 |
defaultToplevelABI="arm64-v8a" |
| 38 |
|
| 39 |
addProgramOption a string.ABI toplevelABI "the top-level's ABI" "${defaultToplevelABI}" |
| 40 |
addProgramOption n flag noToplevelConfigure "don't configure the top-level" |
| 41 |
addProgramOption o flag overwriteBuildProperties "overwrite existing ABI build properties" |
| 42 |
parseProgramArguments "${@}" |
| 43 |
set -e |
| 44 |
|
| 45 |
sourceRoot="${programDirectory}" |
| 46 |
buildRoot="${initialDirectory}" |
| 47 |
|
| 48 |
androidRoot="${buildRoot}/Android" |
| 49 |
ndkRoot="${androidRoot}/NDK" |
| 50 |
|
| 51 |
[ -d "${ndkRoot}" ] || { |
| 52 |
[ -n "${!ndkRootVariable}" ] || { |
| 53 |
semanticError "Android NDK directory not defined: ${ndkRoot}" |
| 54 |
} |
| 55 |
|
| 56 |
[ -f "${!ndkRootVariable}/ndk-build" ] || { |
| 57 |
semanticError "not an Android NDK: ${!ndkRootVariable}" |
| 58 |
} |
| 59 |
|
| 60 |
logNote "creating symbolic link: ${ndkRoot} -> ${!ndkRootVariable}" |
| 61 |
ln -s "${!ndkRootVariable}" "${ndkRoot}" || exit "${?}" |
| 62 |
} |
| 63 |
|
| 64 |
architecturesRoot="${androidRoot}/ABI" |
| 65 |
androidPlatform=android-21 |
| 66 |
|
| 67 |
prepareArchitecture() { |
| 68 |
local architecture="${1}" |
| 69 |
local system="${2}" |
| 70 |
local abi="${3}" |
| 71 |
local cFlags="${4}" |
| 72 |
local ldFlags="${5}" |
| 73 |
|
| 74 |
local abiRoot="${architecturesRoot}/${abi}" |
| 75 |
mkdir -p -- "${abiRoot}" |
| 76 |
local toolchainRoot="${abiRoot}/ToolChain" |
| 77 |
|
| 78 |
( set -e |
| 79 |
cd "${abiRoot}" |
| 80 |
local propertiesFile="build.properties" |
| 81 |
|
| 82 |
if [ -f "${propertiesFile}" ] |
| 83 |
then |
| 84 |
if "${overwriteBuildProperties}" |
| 85 |
then |
| 86 |
logWarning "overwriting ABI build properties: ${abi}" |
| 87 |
else |
| 88 |
logNote "ABI build properties already exist: ${abi}" |
| 89 |
return 0 |
| 90 |
fi |
| 91 |
else |
| 92 |
logTask "creating ABI build properties: ${abi}" |
| 93 |
fi |
| 94 |
|
| 95 |
: >"${propertiesFile}" |
| 96 |
set -- SOURCE "${sourceRoot}" NDK "${ndkRoot}" PLATFORM "${androidPlatform}" ARCH "${architecture}" ABI "${abi}" SYSTEM "${system}" TOOLCHAIN "${toolchainRoot}" CFLAGS "${cFlags}" LDFLAGS "${ldFlags}" |
| 97 |
|
| 98 |
while [ "${#}" -gt 0 ] |
| 99 |
do |
| 100 |
local variable="${1}" |
| 101 |
local value="${2}" |
| 102 |
shift 2 |
| 103 |
echo >>"${propertiesFile}" "BRLTTY_ANDROID_${variable}=${value}" |
| 104 |
done |
| 105 |
) |
| 106 |
} |
| 107 |
|
| 108 |
logNotice "preparing ABI build trees" |
| 109 |
prepareArchitecture arm arm-linux-androideabi armeabi-v7a "-mthumb" |
| 110 |
prepareArchitecture arm64 aarch64-linux-android arm64-v8a "" "-Wl,-z,max-page-size=16384" |
| 111 |
prepareArchitecture x86 i686-linux-android x86 |
| 112 |
prepareArchitecture x86_64 x86_64-linux-android x86_64 "" "-Wl,-z,max-page-size=16384" |
| 113 |
|
| 114 |
"${noToplevelConfigure}" || { |
| 115 |
[ -n "${toplevelABI}" ] || toplevelABI="${defaultToplevelABI}" |
| 116 |
logNotice "configuring top-level build for ${toplevelABI}" |
| 117 |
"${sourceRoot}/cfg-android-abi" -f "${toplevelABI}" |
| 118 |
} |
| 119 |
|
| 120 |
exit 0 |