disable package downloads for down
[termux-packages] / build-package.sh
CommitLineData
59f0d218
FF
1#!/bin/bash
2
59f0d218
FF
3set -e -o pipefail -u
4
7b1f1bd3
FF
5# Utility function to log an error message and exit with an error code.
6termux_error_exit() {
7 echo "ERROR: $*" 1>&2
a0057943 8 exit 1
7b1f1bd3 9}
2c1aa558 10
7b1f1bd3 11# Utility function to download a resource, optionally checking against a checksum.
19fb617a 12termux_download() {
7b1f1bd3
FF
13 local URL="$1"
14 local DESTINATION="$2"
c9d4e74f
FF
15
16 if [ -f "$DESTINATION" ] && [ $# = 3 ] && [ -n "$3" ]; then
17 # Keep existing file if checksum matches.
18 local EXISTING_CHECKSUM
19 EXISTING_CHECKSUM=$(sha256sum "$DESTINATION" | cut -f 1 -d ' ')
20 if [ "$EXISTING_CHECKSUM" = "$3" ]; then return; fi
21 fi
22
7b1f1bd3
FF
23 local TMPFILE
24 TMPFILE=$(mktemp "$TERMUX_PKG_TMPDIR/download.$TERMUX_PKG_NAME.XXXXXXXXX")
e239964b 25 echo "Downloading ${URL}"
7b1f1bd3 26 local TRYMAX=6
6ad2991c 27 for try in $(seq 1 $TRYMAX); do
e239964b 28 if curl -L --fail --retry 2 -o "$TMPFILE" "$URL"; then
7b1f1bd3
FF
29 local ACTUAL_CHECKSUM
30 ACTUAL_CHECKSUM=$(sha256sum "$TMPFILE" | cut -f 1 -d ' ')
31 if [ $# = 3 ] && [ -n "$3" ]; then
e239964b 32 # Optional checksum argument:
aea30235 33 local EXPECTED=$3
7b1f1bd3 34 if [ "$EXPECTED" != "$ACTUAL_CHECKSUM" ]; then
a75313ee
FF
35 >&2 printf "Wrong checksum for %s:\nExpected: %s\nActual: %s\n" \
36 "$URL" "$EXPECTED" "$ACTUAL_CHECKSUM"
aea30235
FF
37 exit 1
38 fi
e239964b 39 else
a75313ee
FF
40 printf "No validation of checksum for %s:\nActual: %s\n" \
41 "$URL" "$ACTUAL_CHECKSUM"
e239964b
FF
42 fi
43 mv "$TMPFILE" "$DESTINATION"
44 return
45 else
7b1f1bd3 46 echo "Download of $URL failed (attempt $try/$TRYMAX)" 1>&2
e239964b
FF
47 sleep 45
48 fi
49 done
50
7b1f1bd3
FF
51 termux_error_exit "Failed to download $URL"
52}
53
54# Utility function for golang-using packages to setup a go toolchain.
01e699d9 55termux_setup_golang() {
7b1f1bd3
FF
56 export GOOS=android
57 export CGO_ENABLED=1
58 export GO_LDFLAGS="-extldflags=-pie"
59 if [ "$TERMUX_ARCH" = "arm" ]; then
60 export GOARCH=arm
61 export GOARM=7
62 elif [ "$TERMUX_ARCH" = "i686" ]; then
63 export GOARCH=386
64 export GO386=sse2
65 elif [ "$TERMUX_ARCH" = "aarch64" ]; then
66 export GOARCH=arm64
67 elif [ "$TERMUX_ARCH" = "x86_64" ]; then
68 export GOARCH=amd64
69 else
70 termux_error_exit "Unsupported arch: $TERMUX_ARCH"
71 fi
72
a1a5fd7b 73 local TERMUX_GO_VERSION=go1.8.3
7b1f1bd3 74 local TERMUX_GO_PLATFORM=linux-amd64
7b1f1bd3 75
538812ae 76 local TERMUX_BUILDGO_FOLDER=$TERMUX_COMMON_CACHEDIR/${TERMUX_GO_VERSION}
7b1f1bd3
FF
77 export GOROOT=$TERMUX_BUILDGO_FOLDER
78 export PATH=$GOROOT/bin:$PATH
79
80 if [ -d "$TERMUX_BUILDGO_FOLDER" ]; then return; fi
81
82 local TERMUX_BUILDGO_TAR=$TERMUX_COMMON_CACHEDIR/${TERMUX_GO_VERSION}.${TERMUX_GO_PLATFORM}.tar.gz
83 rm -Rf "$TERMUX_COMMON_CACHEDIR/go" "$TERMUX_BUILDGO_FOLDER"
84 termux_download https://storage.googleapis.com/golang/${TERMUX_GO_VERSION}.${TERMUX_GO_PLATFORM}.tar.gz \
8c9b8a9a 85 "$TERMUX_BUILDGO_TAR" \
a1a5fd7b 86 1862f4c3d3907e59b04a757cfda0ea7aa9ef39274af99a784f5be843c80c6772
36c4069c 87
7b1f1bd3
FF
88 ( cd "$TERMUX_COMMON_CACHEDIR"; tar xf "$TERMUX_BUILDGO_TAR"; mv go "$TERMUX_BUILDGO_FOLDER"; rm "$TERMUX_BUILDGO_TAR" )
89}
90
bb8baaa2
FF
91# Utility function for cmake-built packages to setup a current cmake.
92termux_setup_cmake() {
d946e67c
FF
93 local TERMUX_CMAKE_MAJORVESION=3.9
94 local TERMUX_CMAKE_MINORVERSION="0-rc6"
bb8baaa2
FF
95 local TERMUX_CMAKE_VERSION=$TERMUX_CMAKE_MAJORVESION.$TERMUX_CMAKE_MINORVERSION
96 local TERMUX_CMAKE_TARNAME=cmake-${TERMUX_CMAKE_VERSION}-Linux-x86_64.tar.gz
97 local TERMUX_CMAKE_TARFILE=$TERMUX_PKG_TMPDIR/$TERMUX_CMAKE_TARNAME
98 local TERMUX_CMAKE_FOLDER=$TERMUX_COMMON_CACHEDIR/cmake-$TERMUX_CMAKE_VERSION
7048a1f2 99 if [ ! -d "$TERMUX_CMAKE_FOLDER" ]; then
bb8baaa2 100 termux_download https://cmake.org/files/v$TERMUX_CMAKE_MAJORVESION/$TERMUX_CMAKE_TARNAME \
7048a1f2 101 "$TERMUX_CMAKE_TARFILE" \
d946e67c 102 68456efed8207381c7724411558e7a3ed6503932f8f3127a3ba640e624026b1a
7048a1f2
FF
103 rm -Rf "$TERMUX_PKG_TMPDIR/cmake-${TERMUX_CMAKE_VERSION}-Linux-x86_64"
104 tar xf "$TERMUX_CMAKE_TARFILE" -C "$TERMUX_PKG_TMPDIR"
105 mv "$TERMUX_PKG_TMPDIR/cmake-${TERMUX_CMAKE_VERSION}-Linux-x86_64" \
106 "$TERMUX_CMAKE_FOLDER"
bb8baaa2
FF
107 fi
108 export PATH=$TERMUX_CMAKE_FOLDER/bin:$PATH
16087461 109 export CMAKE_INSTALL_ALWAYS=1
bb8baaa2
FF
110}
111
7b1f1bd3
FF
112# First step is to handle command-line arguments. Not to be overridden by packages.
113termux_step_handle_arguments() {
114 # shellcheck source=/dev/null
115 test -f "$HOME/.termuxrc" && source "$HOME/.termuxrc"
116
117 # Handle command-line arguments:
118 _show_usage () {
119 echo "Usage: ./build-package.sh [-a ARCH] [-d] [-D] PACKAGE"
120 echo "Build a package by creating a .deb file in the debs/ folder."
121 echo " -a The architecture to build for: aarch64(default), arm, i686, x86_64 or all."
122 echo " -d Build with debug symbols."
123 echo " -D Build a disabled package in disabled-packages/."
bc0560aa 124 echo " -f Force build even if package has already been built."
7b1f1bd3
FF
125 echo " -s Skip dependency check."
126 exit 1
127 }
bc0560aa 128 while getopts :a:hdDfs option; do
7b1f1bd3
FF
129 case "$option" in
130 a) TERMUX_ARCH="$OPTARG";;
131 h) _show_usage;;
132 d) TERMUX_DEBUG=true;;
133 D) local TERMUX_IS_DISABLED=true;;
bc0560aa 134 f) TERMUX_FORCE_BUILD=true;;
7b1f1bd3
FF
135 s) export TERMUX_SKIP_DEPCHECK=true;;
136 ?) termux_error_exit "./build-package.sh: illegal option -$OPTARG";;
137 esac
138 done
139 shift $((OPTIND-1))
140
141 if [ "$#" -ne 1 ]; then _show_usage; fi
142 unset -f _show_usage
143
144 # Handle 'all' arch:
145 if [ -n "${TERMUX_ARCH+x}" ] && [ "${TERMUX_ARCH}" = 'all' ]; then
adc0d548 146 for arch in 'aarch64' 'arm' 'i686' 'x86_64'; do
bc0560aa 147 ./build-package.sh ${TERMUX_FORCE_BUILD+-f} -a $arch "$1"
7b1f1bd3
FF
148 done
149 exit
150 fi
151
152 # Check the package to build:
153 TERMUX_PKG_NAME=$(basename "$1")
154 export TERMUX_SCRIPTDIR
155 TERMUX_SCRIPTDIR=$(cd "$(dirname "$0")"; pwd)
156 if [[ $1 == *"/"* ]]; then
157 # Path to directory which may be outside this repo:
158 if [ ! -d "$1" ]; then termux_error_exit "'$1' seems to be a path but is not a directory"; fi
159 export TERMUX_PKG_BUILDER_DIR
160 TERMUX_PKG_BUILDER_DIR=$(realpath "$1")
06b7f2ca
FF
161 # Skip depcheck for external package:
162 TERMUX_SKIP_DEPCHECK=true
7b1f1bd3
FF
163 else
164 # Package name:
165 if [ -n "${TERMUX_IS_DISABLED=""}" ]; then
166 export TERMUX_PKG_BUILDER_DIR=$TERMUX_SCRIPTDIR/disabled-packages/$TERMUX_PKG_NAME
167 else
168 export TERMUX_PKG_BUILDER_DIR=$TERMUX_SCRIPTDIR/packages/$TERMUX_PKG_NAME
169 fi
170 fi
171 TERMUX_PKG_BUILDER_SCRIPT=$TERMUX_PKG_BUILDER_DIR/build.sh
172 if test ! -f "$TERMUX_PKG_BUILDER_SCRIPT"; then
173 termux_error_exit "No build.sh script at package dir $TERMUX_PKG_BUILDER_DIR!"
174 fi
175}
176
177# Setup variables used by the build. Not to be overridden by packages.
178termux_step_setup_variables() {
179 : "${ANDROID_HOME:="${HOME}/lib/android-sdk"}"
180 : "${NDK:="${HOME}/lib/android-ndk"}"
4428ae3c 181 : "${TERMUX_MAKE_PROCESSES:="$(nproc)"}"
7b1f1bd3
FF
182 : "${TERMUX_TOPDIR:="$HOME/.termux-build"}"
183 : "${TERMUX_ARCH:="aarch64"}" # arm, aarch64, i686 or x86_64.
184 : "${TERMUX_PREFIX:="/data/data/com.termux/files/usr"}"
185 : "${TERMUX_ANDROID_HOME:="/data/data/com.termux/files/home"}"
186 : "${TERMUX_DEBUG:=""}"
272404e1 187 : "${TERMUX_PKG_API_LEVEL:="21"}"
8a478d7e 188 : "${TERMUX_ANDROID_BUILD_TOOLS_VERSION:="25.0.3"}"
ebd327b2 189 : "${TERMUX_NDK_VERSION:="15.1"}"
7b1f1bd3 190
10b023b8 191 if [ "x86_64" = "$TERMUX_ARCH" ] || [ "aarch64" = "$TERMUX_ARCH" ]; then
7b1f1bd3
FF
192 TERMUX_ARCH_BITS=64
193 else
194 TERMUX_ARCH_BITS=32
195 fi
196
197 TERMUX_HOST_PLATFORM="${TERMUX_ARCH}-linux-android"
198 if [ "$TERMUX_ARCH" = "arm" ]; then TERMUX_HOST_PLATFORM="${TERMUX_HOST_PLATFORM}eabi"; fi
199
200 if [ ! -d "$NDK" ]; then
201 termux_error_exit 'NDK not pointing at a directory!'
202 fi
203 if ! grep -s -q "Pkg.Revision = $TERMUX_NDK_VERSION" "$NDK/source.properties"; then
204 termux_error_exit "Wrong NDK version - we need $TERMUX_NDK_VERSION"
205 fi
206
2b0e9dc9
FF
207 # The build tuple that may be given to --build configure flag:
208 TERMUX_BUILD_TUPLE=$(sh "$TERMUX_SCRIPTDIR/scripts/config.guess")
209
7b1f1bd3
FF
210 # We do not put all of build-tools/$TERMUX_ANDROID_BUILD_TOOLS_VERSION/ into PATH
211 # to avoid stuff like arm-linux-androideabi-ld there to conflict with ones from
212 # the standalone toolchain.
213 TERMUX_DX=$ANDROID_HOME/build-tools/$TERMUX_ANDROID_BUILD_TOOLS_VERSION/dx
214 TERMUX_JACK=$ANDROID_HOME/build-tools/$TERMUX_ANDROID_BUILD_TOOLS_VERSION/jack.jar
215 TERMUX_JILL=$ANDROID_HOME/build-tools/$TERMUX_ANDROID_BUILD_TOOLS_VERSION/jill.jar
216
217 TERMUX_COMMON_CACHEDIR="$TERMUX_TOPDIR/_cache"
218 TERMUX_DEBDIR="$TERMUX_SCRIPTDIR/debs"
219 TERMUX_ELF_CLEANER=$TERMUX_COMMON_CACHEDIR/termux-elf-cleaner
220
7b1f1bd3
FF
221 export prefix=${TERMUX_PREFIX}
222 export PREFIX=${TERMUX_PREFIX}
7b1f1bd3
FF
223
224 TERMUX_PKG_BUILDDIR=$TERMUX_TOPDIR/$TERMUX_PKG_NAME/build
225 TERMUX_PKG_CACHEDIR=$TERMUX_TOPDIR/$TERMUX_PKG_NAME/cache
226 TERMUX_PKG_MASSAGEDIR=$TERMUX_TOPDIR/$TERMUX_PKG_NAME/massage
227 TERMUX_PKG_PACKAGEDIR=$TERMUX_TOPDIR/$TERMUX_PKG_NAME/package
228 TERMUX_PKG_SRCDIR=$TERMUX_TOPDIR/$TERMUX_PKG_NAME/src
229 TERMUX_PKG_SHA256=""
230 TERMUX_PKG_TMPDIR=$TERMUX_TOPDIR/$TERMUX_PKG_NAME/tmp
231 TERMUX_PKG_HOSTBUILD_DIR=$TERMUX_TOPDIR/$TERMUX_PKG_NAME/host-build
232 TERMUX_PKG_PLATFORM_INDEPENDENT=""
233 TERMUX_PKG_NO_DEVELSPLIT=""
af4dc416 234 TERMUX_PKG_REVISION="0" # http://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Version
7b1f1bd3
FF
235 TERMUX_PKG_EXTRA_CONFIGURE_ARGS=""
236 TERMUX_PKG_EXTRA_HOSTBUILD_CONFIGURE_ARGS=""
237 TERMUX_PKG_EXTRA_MAKE_ARGS=""
238 TERMUX_PKG_BUILD_IN_SRC=""
239 TERMUX_PKG_RM_AFTER_INSTALL=""
240 TERMUX_PKG_DEPENDS=""
241 TERMUX_PKG_HOMEPAGE=""
242 TERMUX_PKG_DESCRIPTION="FIXME:Add description"
243 TERMUX_PKG_FOLDERNAME=""
244 TERMUX_PKG_KEEP_STATIC_LIBRARIES="false"
245 TERMUX_PKG_ESSENTIAL=""
246 TERMUX_PKG_CONFLICTS="" # https://www.debian.org/doc/debian-policy/ch-relationships.html#s-conflicts
247 TERMUX_PKG_REPLACES=""
248 TERMUX_PKG_CONFFILES=""
249 TERMUX_PKG_INCLUDE_IN_DEVPACKAGE=""
250 TERMUX_PKG_DEVPACKAGE_DEPENDS=""
251 # Set if a host build should be done in TERMUX_PKG_HOSTBUILD_DIR:
252 TERMUX_PKG_HOSTBUILD=""
253 TERMUX_PKG_MAINTAINER="Fredrik Fornwall @fornwall"
2f0de587 254 TERMUX_PKG_CLANG=yes # does nothing for cmake based packages. clang is chosen by cmake
58f7a21c 255 TERMUX_PKG_FORCE_CMAKE=no # if the package has autotools as well as cmake, then set this to prefer cmake
7b1f1bd3
FF
256
257 unset CFLAGS CPPFLAGS LDFLAGS CXXFLAGS
258}
259
260# Save away and restore build setups which may change between builds.
261termux_step_handle_buildarch() {
262 # If $TERMUX_PREFIX already exists, it may have been built for a different arch
263 local TERMUX_ARCH_FILE=/data/TERMUX_ARCH
264 if [ -f "${TERMUX_ARCH_FILE}" ]; then
265 local TERMUX_PREVIOUS_ARCH
266 TERMUX_PREVIOUS_ARCH=$(cat $TERMUX_ARCH_FILE)
267 if [ "$TERMUX_PREVIOUS_ARCH" != "$TERMUX_ARCH" ]; then
268 local TERMUX_DATA_BACKUPDIRS=$TERMUX_TOPDIR/_databackups
269 mkdir -p "$TERMUX_DATA_BACKUPDIRS"
270 local TERMUX_DATA_PREVIOUS_BACKUPDIR=$TERMUX_DATA_BACKUPDIRS/$TERMUX_PREVIOUS_ARCH
271 local TERMUX_DATA_CURRENT_BACKUPDIR=$TERMUX_DATA_BACKUPDIRS/$TERMUX_ARCH
272 # Save current /data (removing old backup if any)
273 if test -e "$TERMUX_DATA_PREVIOUS_BACKUPDIR"; then
274 termux_error_exit "Directory already exists"
275 fi
d7310004
FF
276 if [ -d /data/data ]; then
277 mv /data/data "$TERMUX_DATA_PREVIOUS_BACKUPDIR"
278 fi
7b1f1bd3
FF
279 # Restore new one (if any)
280 if [ -d "$TERMUX_DATA_CURRENT_BACKUPDIR" ]; then
281 mv "$TERMUX_DATA_CURRENT_BACKUPDIR" /data/data
282 fi
283 fi
284 fi
285
286 # Keep track of current arch we are building for.
287 echo "$TERMUX_ARCH" > $TERMUX_ARCH_FILE
19fb617a
FF
288}
289
7b1f1bd3
FF
290# Source the package build script and start building. No to be overridden by packages.
291termux_step_start_build() {
292 # shellcheck source=/dev/null
293 source "$TERMUX_PKG_BUILDER_SCRIPT"
19fb617a 294
28c3a74a
FF
295 TERMUX_STANDALONE_TOOLCHAIN="$TERMUX_TOPDIR/_lib/${TERMUX_NDK_VERSION}-${TERMUX_ARCH}-${TERMUX_PKG_API_LEVEL}"
296 # Bump the below version if a change is made in toolchain setup to ensure
297 # that everyone gets an updated toolchain:
d946e67c 298 TERMUX_STANDALONE_TOOLCHAIN+="-v9"
28c3a74a 299
7b1f1bd3
FF
300 if [ -n "${TERMUX_PKG_BLACKLISTED_ARCHES:=""}" ] && [ "$TERMUX_PKG_BLACKLISTED_ARCHES" != "${TERMUX_PKG_BLACKLISTED_ARCHES/$TERMUX_ARCH/}" ]; then
301 echo "Skipping building $TERMUX_PKG_NAME for arch $TERMUX_ARCH"
302 exit 0
303 fi
304
305 if [ -z "${TERMUX_SKIP_DEPCHECK:=""}" ]; then
93ae139b
FF
306 local p TERMUX_ALL_DEPS
307 TERMUX_ALL_DEPS=$(./scripts/buildorder.py "$TERMUX_PKG_NAME")
308 for p in $TERMUX_ALL_DEPS; do
7b1f1bd3
FF
309 if [ "$p" != "$TERMUX_PKG_NAME" ]; then
310 echo "Building dependency $p if necessary..."
06e5ec1f
S
311 # TODO use apt and dpkg to install instead of building
312 # Add apt repository and key, update
313 # TODO move this install to Dockerfile
314 sudo apt-get update && sudo apt-get install -y software-properties-common
315 sudo add-apt-repository "deb [arch=all,$TERMUX_ARCH] http://termux.net stable main"
316 cat $TERMUX_SCRIPTDIR/packages/apt/trusted.gpg | sudo apt-key add -
317 sudo apt-get update && sudo dpkg --add-architecture $TERMUX_ARCH
58726460 318 #sudo apt-get -d install ${p}:${TERMUX_ARCH}
06e5ec1f 319 # TODO delete debug info
3229d546 320 echo "DEBUG"
06e5ec1f 321 ls -lah /var/cache/apt/archives
3229d546 322 echo "DEBUG"
06e5ec1f 323 # TODO figure out what the root is?
3229d546
S
324 #sudo dpkg --root $TERMUX_PREFIX --configure -a
325 #sudo dpkg --root $TERMUX_PREFIX -i /var/cache/apt/archives/${p}_*_${TERMUX_ARCH}.deb
7b1f1bd3
FF
326 ./build-package.sh -a $TERMUX_ARCH -s "$p"
327 fi
328 done
329 fi
2c1aa558 330
7b1f1bd3 331 TERMUX_PKG_FULLVERSION=$TERMUX_PKG_VERSION
af4dc416 332 if [ "$TERMUX_PKG_REVISION" != "0" ] || [ "$TERMUX_PKG_FULLVERSION" != "${TERMUX_PKG_FULLVERSION/-/}" ]; then
7b1f1bd3 333 # "0" is the default revision, so only include it if the upstream versions contains "-" itself
af4dc416 334 TERMUX_PKG_FULLVERSION+="-$TERMUX_PKG_REVISION"
7b1f1bd3 335 fi
59f0d218 336
bc0560aa
FF
337 if [ -z "$TERMUX_DEBUG" ] &&
338 [ -z "${TERMUX_FORCE_BUILD+x}" ] &&
339 [ -e "/data/data/.built-packages/$TERMUX_PKG_NAME" ]; then
7b1f1bd3
FF
340 if [ "$(cat "/data/data/.built-packages/$TERMUX_PKG_NAME")" = "$TERMUX_PKG_FULLVERSION" ]; then
341 echo "$TERMUX_PKG_NAME@$TERMUX_PKG_FULLVERSION built - skipping (rm /data/data/.built-packages/$TERMUX_PKG_NAME to force rebuild)"
342 exit 0
343 fi
344 fi
345
346 # Cleanup old state:
347 rm -Rf "$TERMUX_PKG_BUILDDIR" \
348 "$TERMUX_PKG_PACKAGEDIR" \
349 "$TERMUX_PKG_SRCDIR" \
350 "$TERMUX_PKG_TMPDIR" \
351 "$TERMUX_PKG_MASSAGEDIR"
352
353 # Ensure folders present (but not $TERMUX_PKG_SRCDIR, it will be created in build)
354 mkdir -p "$TERMUX_COMMON_CACHEDIR" \
355 "$TERMUX_DEBDIR" \
356 "$TERMUX_PKG_BUILDDIR" \
357 "$TERMUX_PKG_PACKAGEDIR" \
358 "$TERMUX_PKG_TMPDIR" \
359 "$TERMUX_PKG_CACHEDIR" \
360 "$TERMUX_PKG_MASSAGEDIR" \
7b1f1bd3
FF
361 $TERMUX_PREFIX/{bin,etc,lib,libexec,share,tmp,include}
362
363 # Make $TERMUX_PREFIX/bin/sh executable on the builder, so that build
364 # scripts can assume that it works on both builder and host later on:
365 ln -f -s /bin/sh "$TERMUX_PREFIX/bin/sh"
366
bd54a46a
FF
367 local TERMUX_ELF_CLEANER_SRC=$TERMUX_COMMON_CACHEDIR/termux-elf-cleaner.cpp
368 local TERMUX_ELF_CLEANER_VERSION=$(bash -c ". $TERMUX_SCRIPTDIR/packages/termux-elf-cleaner/build.sh; echo \$TERMUX_PKG_VERSION")
369 termux_download \
370 https://raw.githubusercontent.com/termux/termux-elf-cleaner/v$TERMUX_ELF_CLEANER_VERSION/termux-elf-cleaner.cpp \
371 $TERMUX_ELF_CLEANER_SRC \
372 11a38372f4d0e36b7556382c7ecffecae35cee8b68daaee2dbee025f758e17ee
7b1f1bd3
FF
373 if [ "$TERMUX_ELF_CLEANER_SRC" -nt "$TERMUX_ELF_CLEANER" ]; then
374 g++ -std=c++11 -Wall -Wextra -pedantic -Os "$TERMUX_ELF_CLEANER_SRC" -o "$TERMUX_ELF_CLEANER"
375 fi
376
377 if [ -n "$TERMUX_PKG_BUILD_IN_SRC" ]; then
378 echo "Building in src due to TERMUX_PKG_BUILD_IN_SRC being set" > "$TERMUX_PKG_BUILDDIR/BUILDING_IN_SRC.txt"
379 TERMUX_PKG_BUILDDIR=$TERMUX_PKG_SRCDIR
380 fi
381
382 echo "termux - building $TERMUX_PKG_NAME for arch $TERMUX_ARCH..."
383 test -t 1 && printf "\033]0;%s...\007" "$TERMUX_PKG_NAME"
384
0dc0e842
FF
385 # Avoid exporting PKG_CONFIG_LIBDIR until after termux_step_host_build.
386 export TERMUX_PKG_CONFIG_LIBDIR=$TERMUX_PREFIX/lib/pkgconfig
387 # Add a pkg-config file for the system zlib.
b833ad7a 388 mkdir -p "$TERMUX_PKG_CONFIG_LIBDIR"
0dc0e842 389 cat > "$TERMUX_PKG_CONFIG_LIBDIR/zlib.pc" <<-HERE
7b1f1bd3
FF
390 Name: zlib
391 Description: zlib compression library
392 Version: 1.2.8
393 Requires:
394 Libs: -lz
395 HERE
396
397 # Keep track of when build started so we can see what files have been created.
398 # We start by sleeping so that any generated files above (such as zlib.pc) get
399 # an older timestamp than the TERMUX_BUILD_TS_FILE.
400 sleep 1
401 TERMUX_BUILD_TS_FILE=$TERMUX_PKG_TMPDIR/timestamp_$TERMUX_PKG_NAME
402 touch "$TERMUX_BUILD_TS_FILE"
403}
404
405# Run just after sourcing $TERMUX_PKG_BUILDER_SCRIPT. May be overridden by packages.
01e699d9 406termux_step_extract_package() {
7b1f1bd3
FF
407 if [ -z "${TERMUX_PKG_SRCURL:=""}" ]; then
408 mkdir -p "$TERMUX_PKG_SRCDIR"
409 return
410 fi
411 cd "$TERMUX_PKG_TMPDIR"
412 local filename
413 filename=$(basename "$TERMUX_PKG_SRCURL")
414 local file="$TERMUX_PKG_CACHEDIR/$filename"
c9d4e74f 415 termux_download "$TERMUX_PKG_SRCURL" "$file" "$TERMUX_PKG_SHA256"
e239964b 416
59f0d218 417 if [ "x$TERMUX_PKG_FOLDERNAME" = "x" ]; then
977221ff 418 folder="${filename%%.t*}" && folder="${folder%%.zip}"
dd54dd13 419 folder="${folder/_/-}" # dpkg uses _ in tar filename, but - in folder
59f0d218
FF
420 else
421 folder=$TERMUX_PKG_FOLDERNAME
422 fi
423 rm -Rf $folder
7b1f1bd3
FF
424 if [ "${file##*.}" = zip ]; then
425 unzip -q "$file"
59f0d218 426 else
2f122eed 427 tar xf "$file"
59f0d218 428 fi
7b1f1bd3 429 mv $folder "$TERMUX_PKG_SRCDIR"
59f0d218
FF
430}
431
7b1f1bd3 432# Hook for packages to act just after the package has been extracted.
508fa73c 433# Invoked in $TERMUX_PKG_SRCDIR.
01e699d9 434termux_step_post_extract_package() {
59f0d218
FF
435 return
436}
437
7b1f1bd3
FF
438# Optional host build. Not to be overridden by packages.
439termux_step_handle_hostbuild() {
440 if [ "x$TERMUX_PKG_HOSTBUILD" = "x" ]; then return; fi
93ae139b 441
7b1f1bd3
FF
442 cd "$TERMUX_PKG_SRCDIR"
443 for patch in $TERMUX_PKG_BUILDER_DIR/*.patch.beforehostbuild; do
444 test -f "$patch" && sed "s%\@TERMUX_PREFIX\@%${TERMUX_PREFIX}%g" "$patch" | patch --silent -p1
445 done
93ae139b
FF
446
447 local TERMUX_HOSTBUILD_MARKER="$TERMUX_PKG_HOSTBUILD_DIR/TERMUX_BUILT_FOR_$TERMUX_PKG_VERSION"
448 if [ ! -f "$TERMUX_HOSTBUILD_MARKER" ]; then
449 rm -Rf "$TERMUX_PKG_HOSTBUILD_DIR"
450 mkdir -p "$TERMUX_PKG_HOSTBUILD_DIR"
7b1f1bd3
FF
451 cd "$TERMUX_PKG_HOSTBUILD_DIR"
452 termux_step_host_build
93ae139b 453 touch "$TERMUX_HOSTBUILD_MARKER"
7b1f1bd3
FF
454 fi
455}
456
59f0d218
FF
457# Perform a host build. Will be called in $TERMUX_PKG_HOSTBUILD_DIR.
458# After termux_step_post_extract_package() and before termux_step_patch_package()
01e699d9 459termux_step_host_build() {
7b1f1bd3 460 "$TERMUX_PKG_SRCDIR/configure" ${TERMUX_PKG_EXTRA_HOSTBUILD_CONFIGURE_ARGS}
4663ac70 461 make -j $TERMUX_MAKE_PROCESSES
59f0d218
FF
462}
463
7b1f1bd3
FF
464# Setup a standalone Android NDK toolchain. Not to be overridden by packages.
465termux_step_setup_toolchain() {
466 # We put this after system PATH to avoid picking up toolchain stripped python
467 export PATH=$PATH:$TERMUX_STANDALONE_TOOLCHAIN/bin
468
272404e1 469 export CFLAGS=""
619b9664
FF
470 export LDFLAGS="-L${TERMUX_PREFIX}/lib"
471
7b1f1bd3
FF
472 if [ "$TERMUX_PKG_CLANG" = "no" ]; then
473 export AS=${TERMUX_HOST_PLATFORM}-gcc
474 export CC=$TERMUX_HOST_PLATFORM-gcc
475 export CXX=$TERMUX_HOST_PLATFORM-g++
619b9664
FF
476 LDFLAGS+=" -specs=$TERMUX_SCRIPTDIR/termux.spec"
477 CFLAGS+=" -specs=$TERMUX_SCRIPTDIR/termux.spec"
7b1f1bd3 478 else
2f0de587 479 export AS=${TERMUX_HOST_PLATFORM}-clang
7b1f1bd3
FF
480 export CC=$TERMUX_HOST_PLATFORM-clang
481 export CXX=$TERMUX_HOST_PLATFORM-clang++
7b1f1bd3 482 fi
619b9664
FF
483
484 export AR=$TERMUX_HOST_PLATFORM-ar
7b1f1bd3
FF
485 export CPP=${TERMUX_HOST_PLATFORM}-cpp
486 export CC_FOR_BUILD=gcc
487 export LD=$TERMUX_HOST_PLATFORM-ld
488 export OBJDUMP=$TERMUX_HOST_PLATFORM-objdump
489 # Setup pkg-config for cross-compiling:
490 export PKG_CONFIG=$TERMUX_STANDALONE_TOOLCHAIN/bin/${TERMUX_HOST_PLATFORM}-pkg-config
491 export RANLIB=$TERMUX_HOST_PLATFORM-ranlib
492 export READELF=$TERMUX_HOST_PLATFORM-readelf
493 export STRIP=$TERMUX_HOST_PLATFORM-strip
494
7b1f1bd3
FF
495 # Android 7 started to support DT_RUNPATH (but not DT_RPATH), so we may want
496 # LDFLAGS+="-Wl,-rpath=$TERMUX_PREFIX/lib -Wl,--enable-new-dtags"
497 # and no longer remove DT_RUNPATH in termux-elf-cleaner.
498
499 if [ "$TERMUX_ARCH" = "arm" ]; then
c9e68e0d
FF
500 # https://developer.android.com/ndk/guides/standalone_toolchain.html#abi_compatibility:
501 # "We recommend using the -mthumb compiler flag to force the generation of 16-bit Thumb-2 instructions".
502 # With r13 of the ndk ruby 2.4.0 segfaults when built on arm with clang without -mthumb.
503 CFLAGS+=" -march=armv7-a -mfpu=neon -mfloat-abi=softfp -mthumb"
7b1f1bd3
FF
504 LDFLAGS+=" -march=armv7-a -Wl,--fix-cortex-a8"
505 elif [ "$TERMUX_ARCH" = "i686" ]; then
506 # From $NDK/docs/CPU-ARCH-ABIS.html:
507 CFLAGS+=" -march=i686 -msse3 -mstackrealign -mfpmath=sse"
508 elif [ "$TERMUX_ARCH" = "aarch64" ]; then
0d1dde5f 509 :
7b1f1bd3
FF
510 elif [ "$TERMUX_ARCH" = "x86_64" ]; then
511 :
512 else
513 termux_error_exit "Invalid arch '$TERMUX_ARCH' - support arches are 'arm', 'i686', 'aarch64', 'x86_64'"
514 fi
515
516 if [ -n "$TERMUX_DEBUG" ]; then
517 CFLAGS+=" -g3 -O1 -fstack-protector --param ssp-buffer-size=4 -D_FORTIFY_SOURCE=2"
518 else
519 CFLAGS+=" -Os"
520 fi
521
522 export CXXFLAGS="$CFLAGS"
523 export CPPFLAGS="-I${TERMUX_PREFIX}/include"
524
525 if [ "$TERMUX_PKG_DEPENDS" != "${TERMUX_PKG_DEPENDS/libandroid-support/}" ]; then
526 # If using the android support library, link to it and include its headers as system headers:
527 CPPFLAGS+=" -isystem $TERMUX_PREFIX/include/libandroid-support"
528 LDFLAGS+=" -landroid-support"
529 fi
530
531 export ac_cv_func_getpwent=no
532 export ac_cv_func_getpwnam=no
533 export ac_cv_func_getpwuid=no
2173f730 534 export ac_cv_func_sigsetmask=no
7b1f1bd3
FF
535
536 if [ ! -d $TERMUX_STANDALONE_TOOLCHAIN ]; then
537 # Do not put toolchain in place until we are done with setup, to avoid having a half setup
538 # toolchain left in place if something goes wrong (or process is just aborted):
2f0de587 539 local _TERMUX_TOOLCHAIN_TMPDIR=${TERMUX_STANDALONE_TOOLCHAIN}-tmp
7b1f1bd3
FF
540 rm -Rf $_TERMUX_TOOLCHAIN_TMPDIR
541
542 local _NDK_ARCHNAME=$TERMUX_ARCH
543 if [ "$TERMUX_ARCH" = "aarch64" ]; then
544 _NDK_ARCHNAME=arm64
545 elif [ "$TERMUX_ARCH" = "i686" ]; then
546 _NDK_ARCHNAME=x86
547 fi
2f0de587 548
7b1f1bd3 549 "$NDK/build/tools/make_standalone_toolchain.py" \
272404e1 550 --api "$TERMUX_PKG_API_LEVEL" \
7b1f1bd3 551 --arch $_NDK_ARCHNAME \
d946e67c 552 --stl=libc++ \
7b1f1bd3
FF
553 --install-dir $_TERMUX_TOOLCHAIN_TMPDIR
554
d946e67c
FF
555 # Remove android-support header wrapping not needed on android-21:
556 rm -Rf $_TERMUX_TOOLCHAIN_TMPDIR/sysroot/usr/local
557
07884eae
FF
558 local wrapped plusplus CLANG_TARGET=$TERMUX_HOST_PLATFORM
559 if [ $TERMUX_ARCH = arm ]; then CLANG_TARGET=${CLANG_TARGET/arm-/armv7a-}; fi
560 for wrapped in ${TERMUX_HOST_PLATFORM}-clang clang; do
561 for plusplus in "" "++"; do
562 local FILE_TO_REPLACE=$_TERMUX_TOOLCHAIN_TMPDIR/bin/${wrapped}${plusplus}
563 if [ ! -f $FILE_TO_REPLACE ]; then
564 termux_error_exit "No toolchain file to override: $FILE_TO_REPLACE"
565 fi
7048a1f2 566 cp "$TERMUX_SCRIPTDIR/scripts/clang-pie-wrapper" $FILE_TO_REPLACE
58e38b47 567 sed -i "s/COMPILER/clang50$plusplus/" $FILE_TO_REPLACE
07884eae
FF
568 sed -i "s/CLANG_TARGET/$CLANG_TARGET/" $FILE_TO_REPLACE
569 done
2f0de587
FF
570 done
571
d946e67c 572 if [ "$TERMUX_ARCH" = "aarch64" ]; then
0d1dde5f
FF
573 # Use gold by default to work around https://github.com/android-ndk/ndk/issues/148
574 cp $_TERMUX_TOOLCHAIN_TMPDIR/bin/aarch64-linux-android-ld.gold \
575 $_TERMUX_TOOLCHAIN_TMPDIR/bin/aarch64-linux-android-ld
c8d1a650
FF
576 cp $_TERMUX_TOOLCHAIN_TMPDIR/aarch64-linux-android/bin/ld.gold \
577 $_TERMUX_TOOLCHAIN_TMPDIR/aarch64-linux-android/bin/ld
7b1f1bd3
FF
578 fi
579
580 cd $_TERMUX_TOOLCHAIN_TMPDIR/sysroot
581
d3e5452e 582 for f in $TERMUX_SCRIPTDIR/ndk-patches/*.patch; do
7b1f1bd3
FF
583 sed "s%\@TERMUX_PREFIX\@%${TERMUX_PREFIX}%g" "$f" | \
584 sed "s%\@TERMUX_HOME\@%${TERMUX_ANDROID_HOME}%g" | \
585 patch --silent -p1;
586 done
42562d13
FF
587 # elf.h: Taken from glibc since the elf.h in the NDK is lacking.
588 # sysexits.h: Header-only and used by a few programs.
589 # ifaddrs.h: Added in android-24 unified headers, use a inline implementation for now.
d04dc139 590 cp "$TERMUX_SCRIPTDIR"/ndk-patches/{elf.h,sysexits.h,ifaddrs.h} usr/include
7b1f1bd3 591
67d2d615
FF
592 # Remove <sys/shm.h> from the NDK in favour of that from the libandroid-shmem.
593 # Also remove <sys/sem.h> as it doesn't work for non-root.
d04dc139
FF
594 rm usr/include/sys/{shm.h,sem.h}
595
272404e1 596 sed -i "s/define __ANDROID_API__ __ANDROID_API_FUTURE__/define __ANDROID_API__ $TERMUX_PKG_API_LEVEL/" \
d04dc139 597 usr/include/android/api-level.h
f39b87c2 598
b26283d4
FF
599 local _LIBDIR=usr/lib
600 if [ $TERMUX_ARCH = x86_64 ]; then _LIBDIR+=64; fi
601 $TERMUX_ELF_CLEANER $_LIBDIR/*.so
7b1f1bd3
FF
602
603 # zlib is really version 1.2.8 in the Android platform (at least
604 # starting from Android 5), not older as the NDK headers claim.
605 for file in zconf.h zlib.h; do
d04dc139 606 curl -o usr/include/$file \
7b1f1bd3
FF
607 https://raw.githubusercontent.com/madler/zlib/v1.2.8/$file
608 done
609 unset file
610
611 mv $_TERMUX_TOOLCHAIN_TMPDIR $TERMUX_STANDALONE_TOOLCHAIN
612 fi
613
d946e67c
FF
614 local _STL_LIBFILE_NAME=libc++_shared.so
615 if [ ! -f $TERMUX_PREFIX/lib/libstdc++.so ] || [ `readlink $TERMUX_PREFIX/lib/libstdc++.so` != $_STL_LIBFILE_NAME ]; then
7b1f1bd3
FF
616 # Setup libgnustl_shared.so in $PREFIX/lib and libstdc++.so as a symlink to it,
617 # so that other C++ using packages links to it instead of the default android
618 # C++ library which does not support exceptions or STL:
619 # https://developer.android.com/ndk/guides/cpp-support.html
620 # We do however want to avoid installing this, to avoid problems where e.g.
621 # libm.so on some i686 devices links against libstdc++.so.
622 # The libgnustl_shared.so library will be packaged in the libgnustl package
623 # which is part of the base Termux installation.
624 mkdir -p "$TERMUX_PREFIX/lib"
625 cd "$TERMUX_PREFIX/lib"
d946e67c
FF
626
627 local _STL_LIBFILE=
7b1f1bd3 628 if [ "$TERMUX_ARCH" = arm ]; then
d946e67c 629 local _STL_LIBFILE=$TERMUX_STANDALONE_TOOLCHAIN/${TERMUX_HOST_PLATFORM}/lib/armv7-a/$_STL_LIBFILE_NAME
7b1f1bd3 630 elif [ "$TERMUX_ARCH" = x86_64 ]; then
d946e67c
FF
631 local _STL_LIBFILE=$TERMUX_STANDALONE_TOOLCHAIN/${TERMUX_HOST_PLATFORM}/lib64/$_STL_LIBFILE_NAME
632 else
633 local _STL_LIBFILE=$TERMUX_STANDALONE_TOOLCHAIN/${TERMUX_HOST_PLATFORM}/lib/$_STL_LIBFILE_NAME
7b1f1bd3 634 fi
d946e67c 635
7b1f1bd3 636 cp "$_STL_LIBFILE" .
d946e67c
FF
637 $STRIP --strip-unneeded $_STL_LIBFILE_NAME
638 $TERMUX_ELF_CLEANER $_STL_LIBFILE_NAME
639 ln -f -s $_STL_LIBFILE_NAME libstdc++.so
7b1f1bd3
FF
640 fi
641
0dc0e842 642 export PKG_CONFIG_LIBDIR="$TERMUX_PKG_CONFIG_LIBDIR"
7b1f1bd3
FF
643 # Create a pkg-config wrapper. We use path to host pkg-config to
644 # avoid picking up a cross-compiled pkg-config later on.
645 local _HOST_PKGCONFIG
646 _HOST_PKGCONFIG=$(which pkg-config)
647 mkdir -p $TERMUX_STANDALONE_TOOLCHAIN/bin "$PKG_CONFIG_LIBDIR"
648 cat > "$PKG_CONFIG" <<-HERE
649 #!/bin/sh
650 export PKG_CONFIG_DIR=
651 export PKG_CONFIG_LIBDIR=$PKG_CONFIG_LIBDIR
652 exec $_HOST_PKGCONFIG "\$@"
653 HERE
654 chmod +x "$PKG_CONFIG"
655}
656
2b0e9dc9 657# Apply all *.patch files for the package. Not to be overridden by packages.
01e699d9 658termux_step_patch_package() {
7b1f1bd3 659 cd "$TERMUX_PKG_SRCDIR"
8f7dda83 660 # Suffix patch with ".patch32" or ".patch64" to only apply for these bitnesses:
7106823d 661 shopt -s nullglob
8f7dda83 662 for patch in $TERMUX_PKG_BUILDER_DIR/*.patch{$TERMUX_ARCH_BITS,}; do
7b1f1bd3 663 test -f "$patch" && sed "s%\@TERMUX_PREFIX\@%${TERMUX_PREFIX}%g" "$patch" | \
dc6476e9 664 sed "s%\@TERMUX_HOME\@%${TERMUX_ANDROID_HOME}%g" | \
a0057943 665 patch --silent -p1
59f0d218 666 done
a599e41a 667 shopt -u nullglob
7106823d 668}
59f0d218 669
7106823d
VB
670# Replace autotools build-aux/config.{sub,guess} with ours to add android targets.
671termux_step_replace_guess_scripts () {
672 cd "$TERMUX_PKG_SRCDIR"
7b1f1bd3
FF
673 find . -name config.sub -exec chmod u+w '{}' \; -exec cp "$TERMUX_SCRIPTDIR/scripts/config.sub" '{}' \;
674 find . -name config.guess -exec chmod u+w '{}' \; -exec cp "$TERMUX_SCRIPTDIR/scripts/config.guess" '{}' \;
59f0d218
FF
675}
676
7b1f1bd3 677# For package scripts to override. Called in $TERMUX_PKG_BUILDDIR.
01e699d9 678termux_step_pre_configure() {
7b1f1bd3 679 return
59f0d218
FF
680}
681
58f7a21c 682termux_step_configure_autotools () {
7b1f1bd3 683 if [ ! -e "$TERMUX_PKG_SRCDIR/configure" ]; then return; fi
59f0d218
FF
684
685 DISABLE_STATIC="--disable-static"
686 if [ "$TERMUX_PKG_EXTRA_CONFIGURE_ARGS" != "${TERMUX_PKG_EXTRA_CONFIGURE_ARGS/--enable-static/}" ]; then
687 # Do not --disable-static if package explicitly enables it (e.g. gdb needs enable-static to build)
688 DISABLE_STATIC=""
689 fi
690
691 DISABLE_NLS="--disable-nls"
692 if [ "$TERMUX_PKG_EXTRA_CONFIGURE_ARGS" != "${TERMUX_PKG_EXTRA_CONFIGURE_ARGS/--enable-nls/}" ]; then
693 # Do not --disable-nls if package explicitly enables it (for gettext itself)
694 DISABLE_NLS=""
695 fi
696
697 ENABLE_SHARED="--enable-shared"
698 if [ "$TERMUX_PKG_EXTRA_CONFIGURE_ARGS" != "${TERMUX_PKG_EXTRA_CONFIGURE_ARGS/--disable-shared/}" ]; then
699 ENABLE_SHARED=""
700 fi
701 HOST_FLAG="--host=$TERMUX_HOST_PLATFORM"
702 if [ "$TERMUX_PKG_EXTRA_CONFIGURE_ARGS" != "${TERMUX_PKG_EXTRA_CONFIGURE_ARGS/--host=/}" ]; then
703 HOST_FLAG=""
704 fi
66926ecd
VB
705 LIBEXEC_FLAG="--libexecdir=$TERMUX_PREFIX/libexec"
706 if [ "$TERMUX_PKG_EXTRA_CONFIGURE_ARGS" != "${TERMUX_PKG_EXTRA_CONFIGURE_ARGS/--libexecdir=/}" ]; then
707 LIBEXEC_FLAG=""
708 fi
59f0d218
FF
709
710 # Some packages provides a $PKG-config script which some configure scripts pickup instead of pkg-config:
7b1f1bd3 711 mkdir "$TERMUX_PKG_TMPDIR/config-scripts"
59f0d218 712 for f in $TERMUX_PREFIX/bin/*config; do
7b1f1bd3 713 test -f "$f" && cp "$f" "$TERMUX_PKG_TMPDIR/config-scripts"
59f0d218 714 done
59f0d218
FF
715 export PATH=$TERMUX_PKG_TMPDIR/config-scripts:$PATH
716
00d9769e
FF
717 # Avoid gnulib wrapping of functions when cross compiling. See
718 # http://wiki.osdev.org/Cross-Porting_Software#Gnulib
719 # https://gitlab.com/sortix/sortix/wikis/Gnulib
720 # https://github.com/termux/termux-packages/issues/76
721 local AVOID_GNULIB=""
0dc0e842
FF
722 AVOID_GNULIB+=" ac_cv_func_calloc_0_nonnull=yes"
723 AVOID_GNULIB+=" ac_cv_func_chown_works=yes"
724 AVOID_GNULIB+=" ac_cv_func_getgroups_works=yes"
00d9769e
FF
725 AVOID_GNULIB+=" ac_cv_func_malloc_0_nonnull=yes"
726 AVOID_GNULIB+=" ac_cv_func_realloc_0_nonnull=yes"
727 AVOID_GNULIB+=" am_cv_func_working_getline=yes"
728 AVOID_GNULIB+=" gl_cv_func_dup2_works=yes"
729 AVOID_GNULIB+=" gl_cv_func_fcntl_f_dupfd_cloexec=yes"
730 AVOID_GNULIB+=" gl_cv_func_fcntl_f_dupfd_works=yes"
542aab6b 731 AVOID_GNULIB+=" gl_cv_func_fnmatch_posix=yes"
00d9769e
FF
732 AVOID_GNULIB+=" gl_cv_func_getcwd_abort_bug=no"
733 AVOID_GNULIB+=" gl_cv_func_getcwd_null=yes"
734 AVOID_GNULIB+=" gl_cv_func_getcwd_path_max=yes"
735 AVOID_GNULIB+=" gl_cv_func_getcwd_posix_signature=yes"
736 AVOID_GNULIB+=" gl_cv_func_gettimeofday_clobber=no"
737 AVOID_GNULIB+=" gl_cv_func_gettimeofday_posix_signature=yes"
738 AVOID_GNULIB+=" gl_cv_func_link_works=yes"
739 AVOID_GNULIB+=" gl_cv_func_lstat_dereferences_slashed_symlink=yes"
542aab6b 740 AVOID_GNULIB+=" gl_cv_func_malloc_0_nonnull=yes"
00d9769e
FF
741 AVOID_GNULIB+=" gl_cv_func_memchr_works=yes"
742 AVOID_GNULIB+=" gl_cv_func_mkdir_trailing_dot_works=yes"
743 AVOID_GNULIB+=" gl_cv_func_mkdir_trailing_slash_works=yes"
0dc0e842 744 AVOID_GNULIB+=" gl_cv_func_mkfifo_works=yes"
ea41b461 745 AVOID_GNULIB+=" gl_cv_func_realpath_works=yes"
00d9769e 746 AVOID_GNULIB+=" gl_cv_func_select_detects_ebadf=yes"
542aab6b 747 AVOID_GNULIB+=" gl_cv_func_snprintf_posix=yes"
00d9769e 748 AVOID_GNULIB+=" gl_cv_func_snprintf_retval_c99=yes"
542aab6b 749 AVOID_GNULIB+=" gl_cv_func_snprintf_truncation_c99=yes"
00d9769e
FF
750 AVOID_GNULIB+=" gl_cv_func_stat_dir_slash=yes"
751 AVOID_GNULIB+=" gl_cv_func_stat_file_slash=yes"
752 AVOID_GNULIB+=" gl_cv_func_strerror_0_works=yes"
753 AVOID_GNULIB+=" gl_cv_func_symlink_works=yes"
754 AVOID_GNULIB+=" gl_cv_func_tzset_clobber=no"
755 AVOID_GNULIB+=" gl_cv_func_unlink_honors_slashes=yes"
756 AVOID_GNULIB+=" gl_cv_func_unlink_honors_slashes=yes"
542aab6b
FF
757 AVOID_GNULIB+=" gl_cv_func_vsnprintf_posix=yes"
758 AVOID_GNULIB+=" gl_cv_func_vsnprintf_zerosize_c99=yes"
00d9769e
FF
759 AVOID_GNULIB+=" gl_cv_func_wcwidth_works=yes"
760 AVOID_GNULIB+=" gl_cv_func_working_getdelim=yes"
761 AVOID_GNULIB+=" gl_cv_func_working_mkstemp=yes"
762 AVOID_GNULIB+=" gl_cv_func_working_mktime=yes"
763 AVOID_GNULIB+=" gl_cv_func_working_strerror=yes"
764 AVOID_GNULIB+=" gl_cv_header_working_fcntl_h=yes"
f7d044c2 765 AVOID_GNULIB+=" gl_cv_C_locale_sans_EILSEQ=yes"
00d9769e
FF
766
767 # NOTE: We do not want to quote AVOID_GNULIB as we want word expansion.
768 env $AVOID_GNULIB "$TERMUX_PKG_SRCDIR/configure" \
59f0d218
FF
769 --disable-dependency-tracking \
770 --prefix=$TERMUX_PREFIX \
7b1f1bd3 771 --disable-rpath --disable-rpath-hack \
59f0d218
FF
772 $HOST_FLAG \
773 $TERMUX_PKG_EXTRA_CONFIGURE_ARGS \
774 $DISABLE_NLS \
775 $ENABLE_SHARED \
776 $DISABLE_STATIC \
66926ecd 777 $LIBEXEC_FLAG
59f0d218
FF
778}
779
58f7a21c
VB
780termux_step_configure_cmake () {
781 termux_setup_cmake
782
58f7a21c
VB
783 local TOOLCHAIN_ARGS="-DCMAKE_ANDROID_STANDALONE_TOOLCHAIN=$TERMUX_STANDALONE_TOOLCHAIN"
784 local BUILD_TYPE=MinSizeRel
785 test -n "$TERMUX_DEBUG" && BUILD_TYPE=Debug
786
787 local CMAKE_PROC=$TERMUX_ARCH
788 test $CMAKE_PROC == "arm" && CMAKE_PROC='armv7-a'
789
2f0de587
FF
790 # XXX: CMAKE_{AR,RANLIB} needed for at least jsoncpp build to not
791 # pick up cross compiled binutils tool in $PREFIX/bin:
7048a1f2
FF
792 cmake -G 'Unix Makefiles' "$TERMUX_PKG_SRCDIR" \
793 -DCMAKE_AR="$(which $AR)" \
d946e67c 794 -DCMAKE_UNAME="$(which uname)" \
7048a1f2 795 -DCMAKE_RANLIB="$(which $RANLIB)" \
58f7a21c
VB
796 -DCMAKE_BUILD_TYPE=$BUILD_TYPE \
797 -DCMAKE_CROSSCOMPILING=True \
798 -DCMAKE_C_FLAGS="$CFLAGS $CPPFLAGS" \
2f0de587 799 -DCMAKE_CXX_FLAGS="$CXXFLAGS $CPPFLAGS" \
58f7a21c
VB
800 -DCMAKE_LINKER="$TERMUX_STANDALONE_TOOLCHAIN/bin/$LD $LDFLAGS" \
801 -DCMAKE_FIND_ROOT_PATH=$TERMUX_PREFIX \
802 -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY \
803 -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \
804 -DCMAKE_INSTALL_PREFIX=$TERMUX_PREFIX \
805 -DCMAKE_MAKE_PROGRAM=`which make` \
806 -DCMAKE_SYSTEM_PROCESSOR=$CMAKE_PROC \
807 -DCMAKE_SYSTEM_NAME=Android \
808 -DCMAKE_SYSTEM_VERSION=21 \
809 -DCMAKE_SKIP_INSTALL_RPATH=ON \
810 -DCMAKE_USE_SYSTEM_LIBRARIES=True \
811 -DBUILD_TESTING=OFF \
812 $TERMUX_PKG_EXTRA_CONFIGURE_ARGS $TOOLCHAIN_ARGS
813}
814
815termux_step_configure () {
2f0de587 816 if [ "$TERMUX_PKG_FORCE_CMAKE" == 'no' ] && [ -f "$TERMUX_PKG_SRCDIR/configure" ]; then
58f7a21c
VB
817 termux_step_configure_autotools
818 elif [ -f "$TERMUX_PKG_SRCDIR/CMakeLists.txt" ]; then
819 termux_step_configure_cmake
820 fi
821}
822
823termux_step_post_configure () {
7b1f1bd3 824 return
59f0d218
FF
825}
826
01e699d9 827termux_step_make() {
caf5d0df 828 if ls ./*akefile &> /dev/null; then
7b1f1bd3
FF
829 if [ -z "$TERMUX_PKG_EXTRA_MAKE_ARGS" ]; then
830 make -j $TERMUX_MAKE_PROCESSES
831 else
2f0de587 832 make -j $TERMUX_MAKE_PROCESSES ${TERMUX_PKG_EXTRA_MAKE_ARGS}
7b1f1bd3
FF
833 fi
834 fi
59f0d218
FF
835}
836
01e699d9 837termux_step_make_install() {
caf5d0df 838 if ls ./*akefile &> /dev/null; then
dd54dd13 839 : "${TERMUX_PKG_MAKE_INSTALL_TARGET:="install"}"
7b1f1bd3
FF
840 # Some packages have problem with parallell install, and it does not buy much, so use -j 1.
841 if [ -z "$TERMUX_PKG_EXTRA_MAKE_ARGS" ]; then
842 make -j 1 ${TERMUX_PKG_MAKE_INSTALL_TARGET}
843 else
844 make -j 1 ${TERMUX_PKG_EXTRA_MAKE_ARGS} ${TERMUX_PKG_MAKE_INSTALL_TARGET}
845 fi
846 fi
59f0d218
FF
847}
848
7b1f1bd3 849# Hook function for package scripts to override.
01e699d9 850termux_step_post_make_install() {
7b1f1bd3 851 return
59f0d218
FF
852}
853
01e699d9 854termux_step_extract_into_massagedir() {
7b1f1bd3 855 local TARBALL_ORIG=$TERMUX_PKG_PACKAGEDIR/${TERMUX_PKG_NAME}_orig.tar.gz
59f0d218
FF
856
857 # Build diff tar with what has changed during the build:
858 cd $TERMUX_PREFIX
2f122eed 859 tar -N "$TERMUX_BUILD_TS_FILE" -czf "$TARBALL_ORIG" .
59f0d218
FF
860
861 # Extract tar in order to massage it
7b1f1bd3
FF
862 mkdir -p "$TERMUX_PKG_MASSAGEDIR/$TERMUX_PREFIX"
863 cd "$TERMUX_PKG_MASSAGEDIR/$TERMUX_PREFIX"
2f122eed 864 tar xf "$TARBALL_ORIG"
7b1f1bd3 865 rm "$TARBALL_ORIG"
59f0d218
FF
866}
867
01e699d9 868termux_step_massage() {
7b1f1bd3 869 cd "$TERMUX_PKG_MASSAGEDIR/$TERMUX_PREFIX"
59f0d218
FF
870
871 # Remove lib/charset.alias which is installed by gettext-using packages:
872 rm -f lib/charset.alias
a0c80d57 873
59f0d218
FF
874 # Remove non-english man pages:
875 test -d share/man && (cd share/man; for f in `ls | grep -v man`; do rm -Rf $f; done )
a0c80d57 876
7b1f1bd3 877 if [ -z "${TERMUX_PKG_KEEP_INFOPAGES+x}" ]; then
a0c80d57
FF
878 # Remove info pages:
879 rm -Rf share/info
880 fi
881
9db621c0
FF
882 # Remove locale files we're not interested in::
883 rm -Rf share/locale
7b1f1bd3 884 if [ -z "${TERMUX_PKG_KEEP_SHARE_DOC+x}" ]; then
9db621c0
FF
885 # Remove info pages:
886 rm -Rf share/doc
887 fi
a0c80d57 888
59f0d218
FF
889 # Remove old kept libraries (readline):
890 find . -name '*.old' -delete
a0c80d57
FF
891
892 # Remove static libraries:
59f0d218
FF
893 if [ $TERMUX_PKG_KEEP_STATIC_LIBRARIES = "false" ]; then
894 find . -name '*.a' -delete
895 find . -name '*.la' -delete
896 fi
897
1d678bce 898 # Move over sbin to bin:
7b1f1bd3 899 for file in sbin/*; do if test -f "$file"; then mv "$file" bin/; fi; done
59f0d218 900
174285d9 901 # Remove world permissions and add write permissions.
40534bae
FF
902 # The -f flag is used to suppress warnings about dangling symlinks (such
903 # as ones to /system/... which may not exist on the build machine):
174285d9
FF
904 find . -exec chmod -f u+w,g-rwx,o-rwx \{\} \;
905
59f0d218 906 if [ "$TERMUX_DEBUG" = "" ]; then
e5b151a0
FF
907 # Strip binaries. file(1) may fail for certain unusual files, so disable pipefail.
908 set +e +o pipefail
909 find . -type f | xargs -r file | grep -E "(executable|shared object)" | grep ELF | cut -f 1 -d : | \
7b1f1bd3 910 xargs -r "$STRIP" --strip-unneeded --preserve-dates
e5b151a0 911 set -e -o pipefail
59f0d218 912 fi
1d678bce 913 # Remove DT_ entries which the android 5.1 linker warns about:
7b1f1bd3 914 find . -type f -print0 | xargs -r -0 "$TERMUX_ELF_CLEANER"
1d678bce
FF
915
916 # Fix shebang paths:
6b56911d
FF
917 while IFS= read -r -d '' file
918 do
919 head -c 100 "$file" | grep -E "^#\!.*\\/bin\\/.*" | grep -q -E -v "^#\! ?\\/system" && sed --follow-symlinks -i -E "1 s@^#\!(.*)/bin/(.*)@#\!$TERMUX_PREFIX/bin/\2@" "$file"
920 done < <(find -L . -type f -print0)
59f0d218
FF
921
922 test ! -z "$TERMUX_PKG_RM_AFTER_INSTALL" && rm -Rf $TERMUX_PKG_RM_AFTER_INSTALL
923
924 find . -type d -empty -delete # Remove empty directories
925
7b1f1bd3
FF
926 # Sub packages:
927 if [ -d include ] && [ -z "${TERMUX_PKG_NO_DEVELSPLIT}" ]; then
928 # Add virtual -dev sub package if there are include files:
929 local _DEVEL_SUBPACKAGE_FILE=$TERMUX_PKG_TMPDIR/${TERMUX_PKG_NAME}-dev.subpackage.sh
38a5614f 930 echo TERMUX_SUBPKG_INCLUDE=\"include share/vala share/man/man3 lib/pkgconfig share/aclocal lib/cmake $TERMUX_PKG_INCLUDE_IN_DEVPACKAGE\" > "$_DEVEL_SUBPACKAGE_FILE"
dd54dd13 931 echo "TERMUX_SUBPKG_DESCRIPTION=\"Development files for ${TERMUX_PKG_NAME}\"" >> "$_DEVEL_SUBPACKAGE_FILE"
28dc0ace 932 if [ -n "$TERMUX_PKG_DEVPACKAGE_DEPENDS" ]; then
6b56911d 933 echo "TERMUX_SUBPKG_DEPENDS=\"$TERMUX_PKG_NAME,$TERMUX_PKG_DEVPACKAGE_DEPENDS\"" >> "$_DEVEL_SUBPACKAGE_FILE"
28dc0ace 934 else
01e699d9 935 echo "TERMUX_SUBPKG_DEPENDS=\"$TERMUX_PKG_NAME\"" >> "$_DEVEL_SUBPACKAGE_FILE"
28dc0ace 936 fi
7b1f1bd3
FF
937 fi
938 # Now build all sub packages
939 rm -Rf "$TERMUX_TOPDIR/$TERMUX_PKG_NAME/subpackages"
59f0d218 940 for subpackage in $TERMUX_PKG_BUILDER_DIR/*.subpackage.sh $TERMUX_PKG_TMPDIR/*subpackage.sh; do
7b1f1bd3
FF
941 test ! -f "$subpackage" && continue
942 local SUB_PKG_NAME
943 SUB_PKG_NAME=$(basename "$subpackage" .subpackage.sh)
944 # Default value is same as main package, but sub package may override:
945 local TERMUX_SUBPKG_PLATFORM_INDEPENDENT=$TERMUX_PKG_PLATFORM_INDEPENDENT
946 local SUB_PKG_DIR=$TERMUX_TOPDIR/$TERMUX_PKG_NAME/subpackages/$SUB_PKG_NAME
947 local TERMUX_SUBPKG_DEPENDS=""
948 local TERMUX_SUBPKG_CONFLICTS=""
0d1a1c8e 949 local TERMUX_SUBPKG_CONFFILES=""
7b1f1bd3
FF
950 local SUB_PKG_MASSAGE_DIR=$SUB_PKG_DIR/massage/$TERMUX_PREFIX
951 local SUB_PKG_PACKAGE_DIR=$SUB_PKG_DIR/package
952 mkdir -p "$SUB_PKG_MASSAGE_DIR" "$SUB_PKG_PACKAGE_DIR"
953
954 # shellcheck source=/dev/null
955 source $subpackage
956
957 for includeset in $TERMUX_SUBPKG_INCLUDE; do
958 local _INCLUDE_DIRSET
959 _INCLUDE_DIRSET=$(dirname "$includeset")
960 test "$_INCLUDE_DIRSET" = "." && _INCLUDE_DIRSET=""
961 if [ -e "$includeset" ] || [ -L "$includeset" ]; then
4432ca97 962 # Add the -L clause to handle relative symbolic links:
7b1f1bd3
FF
963 mkdir -p "$SUB_PKG_MASSAGE_DIR/$_INCLUDE_DIRSET"
964 mv "$includeset" "$SUB_PKG_MASSAGE_DIR/$_INCLUDE_DIRSET"
965 fi
966 done
59f0d218 967
7b1f1bd3
FF
968 local SUB_PKG_ARCH=$TERMUX_ARCH
969 test -n "$TERMUX_SUBPKG_PLATFORM_INDEPENDENT" && SUB_PKG_ARCH=all
59f0d218 970
7b1f1bd3
FF
971 cd "$SUB_PKG_DIR/massage"
972 local SUB_PKG_INSTALLSIZE
973 SUB_PKG_INSTALLSIZE=$(du -sk . | cut -f 1)
2f122eed 974 tar -cJf "$SUB_PKG_PACKAGE_DIR/data.tar.xz" .
59f0d218 975
7b1f1bd3 976 mkdir -p DEBIAN
59f0d218 977 cd DEBIAN
7b1f1bd3
FF
978 cat > control <<-HERE
979 Package: $SUB_PKG_NAME
980 Architecture: ${SUB_PKG_ARCH}
981 Installed-Size: ${SUB_PKG_INSTALLSIZE}
982 Maintainer: $TERMUX_PKG_MAINTAINER
983 Version: $TERMUX_PKG_FULLVERSION
984 Description: $TERMUX_SUBPKG_DESCRIPTION
985 Homepage: $TERMUX_PKG_HOMEPAGE
986 HERE
987 test ! -z "$TERMUX_SUBPKG_DEPENDS" && echo "Depends: $TERMUX_SUBPKG_DEPENDS" >> control
988 test ! -z "$TERMUX_SUBPKG_CONFLICTS" && echo "Conflicts: $TERMUX_SUBPKG_CONFLICTS" >> control
2f122eed 989 tar -cJf "$SUB_PKG_PACKAGE_DIR/control.tar.xz" .
7b1f1bd3 990
cc7bcfa2
VB
991 for f in $TERMUX_SUBPKG_CONFFILES; do echo "$TERMUX_PREFIX/$f" >> conffiles; done
992
7b1f1bd3
FF
993 # Create the actual .deb file:
994 TERMUX_SUBPKG_DEBFILE=$TERMUX_DEBDIR/${SUB_PKG_NAME}_${TERMUX_PKG_FULLVERSION}_${SUB_PKG_ARCH}.deb
995 test ! -f "$TERMUX_COMMON_CACHEDIR/debian-binary" && echo "2.0" > "$TERMUX_COMMON_CACHEDIR/debian-binary"
996 ar cr "$TERMUX_SUBPKG_DEBFILE" \
997 "$TERMUX_COMMON_CACHEDIR/debian-binary" \
998 "$SUB_PKG_PACKAGE_DIR/control.tar.xz" \
999 "$SUB_PKG_PACKAGE_DIR/data.tar.xz"
1000
1001 # Go back to main package:
1002 cd "$TERMUX_PKG_MASSAGEDIR/$TERMUX_PREFIX"
59f0d218
FF
1003 done
1004
1005 # .. remove empty directories (NOTE: keep this last):
1006 find . -type d -empty -delete
7b1f1bd3
FF
1007 # Make sure user can read and write all files (problem with dpkg otherwise):
1008 chmod -R u+rw .
59f0d218
FF
1009}
1010
01e699d9 1011termux_step_post_massage() {
7b1f1bd3 1012 return
59f0d218
FF
1013}
1014
7b1f1bd3
FF
1015# Create data.tar.gz with files to package. Not to be overridden by package scripts.
1016termux_step_create_datatar() {
1017 # Create data tarball containing files to package:
1018 cd "$TERMUX_PKG_MASSAGEDIR"
46fe48b3
FF
1019
1020 local HARDLINKS="$(find . -type f -links +1)"
1021 if [ -n "$HARDLINKS" ]; then
1022 termux_error_exit "Package contains hard links: $HARDLINKS"
1023 fi
1024
7b1f1bd3
FF
1025 if [ -z "${TERMUX_PKG_METAPACKAGE+x}" ] && [ "$(find . -type f)" = "" ]; then
1026 termux_error_exit "No files in package"
f6a56287 1027 fi
2f122eed 1028 tar -cJf "$TERMUX_PKG_PACKAGEDIR/data.tar.xz" .
7b1f1bd3 1029}
f6a56287 1030
01e699d9 1031termux_step_create_debscripts() {
7b1f1bd3 1032 return
3a189d89
FF
1033}
1034
7b1f1bd3
FF
1035# Create the build deb file. Not to be overridden by package scripts.
1036termux_step_create_debfile() {
1037 # Get install size. This will be written as the "Installed-Size" deb field so is measured in 1024-byte blocks:
1038 local TERMUX_PKG_INSTALLSIZE
1039 TERMUX_PKG_INSTALLSIZE=$(du -sk . | cut -f 1)
1040
1041 # From here on TERMUX_ARCH is set to "all" if TERMUX_PKG_PLATFORM_INDEPENDENT is set by the package
1042 test -n "$TERMUX_PKG_PLATFORM_INDEPENDENT" && TERMUX_ARCH=all
1043
1044 mkdir -p DEBIAN
1045 cat > DEBIAN/control <<-HERE
1046 Package: $TERMUX_PKG_NAME
1047 Architecture: ${TERMUX_ARCH}
1048 Installed-Size: ${TERMUX_PKG_INSTALLSIZE}
1049 Maintainer: $TERMUX_PKG_MAINTAINER
1050 Version: $TERMUX_PKG_FULLVERSION
1051 Description: $TERMUX_PKG_DESCRIPTION
1052 Homepage: $TERMUX_PKG_HOMEPAGE
1053 HERE
1054 test ! -z "$TERMUX_PKG_DEPENDS" && echo "Depends: $TERMUX_PKG_DEPENDS" >> DEBIAN/control
1055 test ! -z "$TERMUX_PKG_ESSENTIAL" && echo "Essential: yes" >> DEBIAN/control
1056 test ! -z "$TERMUX_PKG_CONFLICTS" && echo "Conflicts: $TERMUX_PKG_CONFLICTS" >> DEBIAN/control
1057 test ! -z "$TERMUX_PKG_REPLACES" && echo "Replaces: $TERMUX_PKG_REPLACES" >> DEBIAN/control
1058
1059 # Create DEBIAN/conffiles (see https://www.debian.org/doc/debian-policy/ap-pkg-conffiles.html):
1060 for f in $TERMUX_PKG_CONFFILES; do echo "$TERMUX_PREFIX/$f" >> DEBIAN/conffiles; done
1061
1062 # Allow packages to create arbitrary control files.
1063 # XXX: Should be done in a better way without a function?
1064 cd DEBIAN
1065 termux_step_create_debscripts
1066
1067 # Create control.tar.xz
2f122eed 1068 tar -cJf "$TERMUX_PKG_PACKAGEDIR/control.tar.xz" .
7b1f1bd3
FF
1069
1070 test ! -f "$TERMUX_COMMON_CACHEDIR/debian-binary" && echo "2.0" > "$TERMUX_COMMON_CACHEDIR/debian-binary"
1071 TERMUX_PKG_DEBFILE=$TERMUX_DEBDIR/${TERMUX_PKG_NAME}_${TERMUX_PKG_FULLVERSION}_${TERMUX_ARCH}.deb
1072 # Create the actual .deb file:
1073 ar cr "$TERMUX_PKG_DEBFILE" \
1074 "$TERMUX_COMMON_CACHEDIR/debian-binary" \
1075 "$TERMUX_PKG_PACKAGEDIR/control.tar.xz" \
1076 "$TERMUX_PKG_PACKAGEDIR/data.tar.xz"
1077}
59f0d218 1078
7b1f1bd3
FF
1079# Finish the build. Not to be overridden by package scripts.
1080termux_step_finish_build() {
1081 echo "termux - build of '$TERMUX_PKG_NAME' done"
1082 test -t 1 && printf "\033]0;%s - DONE\007" "$TERMUX_PKG_NAME"
1083 mkdir -p /data/data/.built-packages
1084 echo "$TERMUX_PKG_FULLVERSION" > "/data/data/.built-packages/$TERMUX_PKG_NAME"
9a104bda 1085 exit 0
7b1f1bd3 1086}
2497d957 1087
7b1f1bd3
FF
1088termux_step_handle_arguments "$@"
1089termux_step_setup_variables
1090termux_step_handle_buildarch
1091termux_step_start_build
59f0d218 1092termux_step_extract_package
508fa73c 1093cd "$TERMUX_PKG_SRCDIR"
59f0d218 1094termux_step_post_extract_package
7b1f1bd3
FF
1095termux_step_handle_hostbuild
1096termux_step_setup_toolchain
59f0d218 1097termux_step_patch_package
7106823d 1098termux_step_replace_guess_scripts
ca7699c1 1099cd "$TERMUX_PKG_SRCDIR"
59f0d218 1100termux_step_pre_configure
7b1f1bd3 1101cd "$TERMUX_PKG_BUILDDIR"
59f0d218 1102termux_step_configure
7b1f1bd3 1103cd "$TERMUX_PKG_BUILDDIR"
59f0d218 1104termux_step_post_configure
7b1f1bd3 1105cd "$TERMUX_PKG_BUILDDIR"
59f0d218 1106termux_step_make
7b1f1bd3 1107cd "$TERMUX_PKG_BUILDDIR"
59f0d218 1108termux_step_make_install
7b1f1bd3 1109cd "$TERMUX_PKG_BUILDDIR"
59f0d218 1110termux_step_post_make_install
7b1f1bd3 1111cd "$TERMUX_PKG_MASSAGEDIR"
59f0d218 1112termux_step_extract_into_massagedir
7b1f1bd3 1113cd "$TERMUX_PKG_MASSAGEDIR"
59f0d218 1114termux_step_massage
7b1f1bd3 1115cd "$TERMUX_PKG_MASSAGEDIR/$TERMUX_PREFIX"
59f0d218 1116termux_step_post_massage
7b1f1bd3
FF
1117termux_step_create_datatar
1118termux_step_create_debfile
1119termux_step_finish_build