Skip to content

Commit

Permalink
test build of zlib and libpng packages with cross compilation enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxython committed Jan 24, 2025
1 parent fcb3e09 commit f1eac4d
Show file tree
Hide file tree
Showing 14 changed files with 38 additions and 25 deletions.
3 changes: 3 additions & 0 deletions packages/libpng/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ TERMUX_PKG_DESCRIPTION="Official PNG reference library"
TERMUX_PKG_LICENSE="Libpng"
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION="1.6.45"
TERMUX_PKG_REVISION=1
TERMUX_PKG_SRCURL=https://download.sourceforge.net/libpng/libpng-$TERMUX_PKG_VERSION.tar.xz
TERMUX_PKG_SHA256=926485350139ffb51ef69760db35f78846c805fef3d59bfdcb2fba704663f370
TERMUX_PKG_AUTO_UPDATE=true
# TEST
TERMUX_PKG_BUILD32=true
TERMUX_PKG_DEPENDS="zlib"
TERMUX_PKG_BREAKS="libpng-dev"
TERMUX_PKG_REPLACES="libpng-dev"
Expand Down
17 changes: 11 additions & 6 deletions packages/zlib/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,16 @@ TERMUX_PKG_DESCRIPTION="Compression library implementing the deflate compression
TERMUX_PKG_LICENSE="ZLIB"
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION="1.3.1"
TERMUX_PKG_REVISION=1
TERMUX_PKG_SRCURL=https://github.com/madler/zlib/releases/download/v${TERMUX_PKG_VERSION}/zlib-${TERMUX_PKG_VERSION}.tar.xz
TERMUX_PKG_SHA256=38ef96b8dfe510d42707d9c781877914792541133e1870841463bfa73f883e32
TERMUX_PKG_AUTO_UPDATE=true
# TEST
TERMUX_PKG_BUILD32=true
TERMUX_PKG_BREAKS="ndk-sysroot (<< 19b-3), zlib-dev"
TERMUX_PKG_REPLACES="ndk-sysroot (<< 19b-3), zlib-dev"

termux_step_pre_configure() {
if [ "$TERMUX_ARCH" = "aarch64" ]; then
CFLAGS+=" -march=armv8-a+crc"
CXXFLAGS+=" -march=armv8-a+crc"
fi

# Fix relocation issues when linking with libz.a
CFLAGS+=" -fPIC"
CXXFLAGS+=" -fPIC"
Expand All @@ -24,5 +22,12 @@ termux_step_pre_configure() {
}

termux_step_configure() {
"$TERMUX_PKG_SRCDIR/configure" --prefix=$TERMUX_PREFIX --shared
local CFLAGS="${CFLAGS}"
local CXXFLAGS="${CXXFLAGS}"
if [ "$TERMUX_ARCH" = "aarch64" ]; then
CFLAGS+=" -march=armv8-a+crc"
CXXFLAGS+=" -march=armv8-a+crc"
fi

"$TERMUX_PKG_SRCDIR/configure" --prefix=$TERMUX_PREFIX --libdir=$TERMUX_LIB_PATH --shared
}
2 changes: 1 addition & 1 deletion scripts/build/configure/termux_step_configure_autotools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ termux_step_configure_autotools() {
env $AVOID_GNULIB "$TERMUX_PKG_SRCDIR/configure" \
--disable-dependency-tracking \
--prefix=$TERMUX_PREFIX \
--libdir=$TERMUX_PREFIX/lib \
--libdir=$TERMUX_LIB_PATH \
--sbindir=$TERMUX_PREFIX/bin \
--disable-rpath --disable-rpath-hack \
$HOST_FLAG \
Expand Down
2 changes: 1 addition & 1 deletion scripts/build/configure/termux_step_configure_cmake.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ termux_step_configure_cmake() {
-DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY \
-DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \
-DCMAKE_INSTALL_PREFIX=$TERMUX_PREFIX \
-DCMAKE_INSTALL_LIBDIR=$TERMUX_PREFIX/lib \
-DCMAKE_INSTALL_LIBDIR=$TERMUX_LIB_PATH \
-DCMAKE_MAKE_PROGRAM=$MAKE_PROGRAM_PATH \
-DCMAKE_SKIP_INSTALL_RPATH=ON \
-DCMAKE_USE_SYSTEM_LIBRARIES=True \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,12 @@ termux_step_configure_haskell_build() {
$TERMUX_HASKELL_OPTIMISATION \
--prefix="$TERMUX_PREFIX" \
--configure-option="$HOST_FLAG" \
--ghc-options="-optl-Wl,-rpath,$TERMUX_PREFIX/lib -optl-Wl,--enable-new-dtags" \
--ghc-options="-optl-Wl,-rpath,$TERMUX_LIB_PATH -optl-Wl,--enable-new-dtags" \
--with-compiler="$(command -v ghc)" \
--with-ghc-pkg="$(command -v ghc-pkg)" \
--with-hsc2hs="$(command -v hsc2hs)" \
--hsc2hs-option=--cross-compile \
--extra-lib-dirs="$TERMUX_PREFIX/lib" \
--extra-lib-dirs="$TERMUX_LIB_PATH" \
--extra-include-dirs="$TERMUX_PREFIX/include" \
--with-ld="$LD" \
--with-strip="$STRIP" \
Expand Down
2 changes: 1 addition & 1 deletion scripts/build/configure/termux_step_configure_meson.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ termux_step_configure_meson() {
$TERMUX_PKG_BUILDDIR \
--$(test "${TERMUX_PKG_MESON_NATIVE}" = "true" && echo "native-file" || echo "cross-file") $TERMUX_MESON_CROSSFILE \
--prefix $TERMUX_PREFIX \
--libdir lib \
--libdir $(test "${TERMUX_PKG_BUILD32}" = "true" && echo "lib32" || echo "lib") \
--buildtype ${_meson_buildtype} \
${_meson_stripflag} \
$TERMUX_PKG_EXTRA_CONFIGURE_ARGS \
Expand Down
2 changes: 1 addition & 1 deletion scripts/build/setup/termux_setup_golang.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@ termux_setup_golang() {
exit 1
fi

export GOROOT="$TERMUX_PREFIX/lib/go"
export GOROOT="$TERMUX_LIB_PATH/go"
fi
}
4 changes: 2 additions & 2 deletions scripts/build/termux_create_debian_subpackages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ termux_create_debian_subpackages() {
if [ "$TERMUX_PACKAGE_LIBRARY" = "glibc" ]; then
_ADD_PREFIX="glibc/"
fi
if [ "$TERMUX_PKG_NO_STATICSPLIT" = "false" ] && [[ -n $(shopt -s globstar; shopt -s nullglob; echo ${_ADD_PREFIX}lib/**/*.a) ]]; then
if [ "$TERMUX_PKG_NO_STATICSPLIT" = "false" ] && [[ -n $(shopt -s globstar; shopt -s nullglob; echo ${_ADD_PREFIX}lib{,32}/**/*.a) ]]; then
# Add virtual -static sub package if there are include files:
local _STATIC_SUBPACKAGE_FILE=$TERMUX_PKG_TMPDIR/${TERMUX_PKG_NAME}-static.subpackage.sh
echo TERMUX_SUBPKG_INCLUDE=\"$(find ${_ADD_PREFIX}lib -name '*.a' -o -name '*.la') $TERMUX_PKG_STATICSPLIT_EXTRA_PATTERNS\" > "$_STATIC_SUBPACKAGE_FILE"
echo TERMUX_SUBPKG_INCLUDE=\"$(find ${_ADD_PREFIX}lib{,32} -name '*.a' -o -name '*.la') $TERMUX_PKG_STATICSPLIT_EXTRA_PATTERNS\" > "$_STATIC_SUBPACKAGE_FILE"
echo "TERMUX_SUBPKG_DESCRIPTION=\"Static libraries for ${TERMUX_PKG_NAME}\"" >> "$_STATIC_SUBPACKAGE_FILE"
fi

Expand Down
4 changes: 2 additions & 2 deletions scripts/build/termux_create_pacman_subpackages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ termux_create_pacman_subpackages() {
if [ "$TERMUX_PACKAGE_LIBRARY" = "glibc" ]; then
_ADD_PREFIX="glibc/"
fi
if [ "$TERMUX_PKG_NO_STATICSPLIT" = "false" ] && [[ -n $(shopt -s globstar; shopt -s nullglob; echo ${_ADD_PREFIX}lib/**/*.a) ]]; then
if [ "$TERMUX_PKG_NO_STATICSPLIT" = "false" ] && [[ -n $(shopt -s globstar; shopt -s nullglob; echo ${_ADD_PREFIX}lib{,32}/**/*.a) ]]; then
# Add virtual -static sub package if there are include files:
local _STATIC_SUBPACKAGE_FILE=$TERMUX_PKG_TMPDIR/${TERMUX_PKG_NAME}-static.subpackage.sh
echo TERMUX_SUBPKG_INCLUDE=\"$(find ${_ADD_PREFIX}lib -name '*.a' -o -name '*.la') $TERMUX_PKG_STATICSPLIT_EXTRA_PATTERNS\" > "$_STATIC_SUBPACKAGE_FILE"
echo TERMUX_SUBPKG_INCLUDE=\"$(find ${_ADD_PREFIX}lib{,32} -name '*.a' -o -name '*.la') $TERMUX_PKG_STATICSPLIT_EXTRA_PATTERNS\" > "$_STATIC_SUBPACKAGE_FILE"
echo "TERMUX_SUBPKG_DESCRIPTION=\"Static libraries for ${TERMUX_PKG_NAME}\"" >> "$_STATIC_SUBPACKAGE_FILE"
fi

Expand Down
4 changes: 2 additions & 2 deletions scripts/build/termux_step_massage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ termux_step_massage() {
if [ "$TERMUX_PKG_NO_STRIP" != "true" ] && [ "$TERMUX_DEBUG_BUILD" = "false" ]; then
# Strip binaries. file(1) may fail for certain unusual files, so disable pipefail.
set +e +o pipefail
find . \( -path "./bin/*" -o -path "./lib/*" -o -path "./libexec/*" \) -type f |
find . \( -path "./bin/*" -o -path "./lib/*" -o -path "./lib32/*" -o -path "./libexec/*" \) -type f |
xargs -r file | grep -E "ELF .+ (executable|shared object)" | cut -f 1 -d : |
xargs -r "$STRIP" --strip-unneeded --preserve-dates
set -e -o pipefail
fi

if [ "$TERMUX_PKG_NO_ELF_CLEANER" != "true" ]; then
# Remove entries unsupported by Android's linker:
find . \( -path "./bin/*" -o -path "./lib/*" -o -path "./libexec/*" -o -path "./opt/*" \) -type f -print0 | xargs -r -0 \
find . \( -path "./bin/*" -o -path "./lib/*" -o -path "./lib32/*" -o -path "./libexec/*" -o -path "./opt/*" \) -type f -print0 | xargs -r -0 \
"$TERMUX_ELF_CLEANER" --api-level $TERMUX_PKG_API_LEVEL
fi
fi
Expand Down
1 change: 1 addition & 0 deletions scripts/build/termux_step_setup_toolchain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ termux_step_setup_build32_environment() {
TERMUX_LIB_PATH="$TERMUX_LIB32_PATH"
TERMUX_PKG_BUILDDIR="$TERMUX_PKG_BUILD32DIR"
termux_step_setup_arch_variables
termux_step_setup_pkg_config_libdir
termux_step_setup_toolchain
cd $TERMUX_PKG_BUILDDIR
}
6 changes: 5 additions & 1 deletion scripts/build/termux_step_start_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ termux_step_start_build() {
test -t 1 && printf "\033]0;%s...\007" "$TERMUX_PKG_NAME"

# Avoid exporting PKG_CONFIG_LIBDIR until after termux_step_host_build.
export TERMUX_PKG_CONFIG_LIBDIR=$TERMUX_PREFIX/lib/pkgconfig:$TERMUX_PREFIX/share/pkgconfig
termux_step_setup_pkg_config_libdir

if [ "$TERMUX_PKG_BUILD_IN_SRC" = "true" ]; then
echo "Building in src due to TERMUX_PKG_BUILD_IN_SRC being set to true" > "$TERMUX_PKG_BUILDDIR/BUILDING_IN_SRC.txt"
Expand Down Expand Up @@ -126,3 +126,7 @@ termux_step_start_build() {
done
fi
}

termux_step_setup_pkg_config_libdir() {
export TERMUX_PKG_CONFIG_LIBDIR=$TERMUX_LIB_PATH/pkgconfig:$TERMUX_PREFIX/share/pkgconfig
}
6 changes: 3 additions & 3 deletions scripts/build/toolchain/termux_setup_toolchain_23c.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
termux_setup_toolchain_23c() {
export CFLAGS=""
export CPPFLAGS=""
export LDFLAGS="-L${TERMUX_PREFIX}/lib"
export LDFLAGS="-L${TERMUX_LIB_PATH}"

export AS=$TERMUX_HOST_PLATFORM-clang
export CC=$TERMUX_HOST_PLATFORM-clang
Expand Down Expand Up @@ -31,7 +31,7 @@ termux_setup_toolchain_23c() {
if [ $TERMUX_ARCH = arm ]; then
CCTERMUX_HOST_PLATFORM=armv7a-linux-androideabi$TERMUX_PKG_API_LEVEL
fi
LDFLAGS+=" -Wl,-rpath=$TERMUX_PREFIX/lib"
LDFLAGS+=" -Wl,-rpath=$TERMUX_LIB_PATH"
else
export CC_FOR_BUILD=$CC
# Some build scripts use environment variable 'PKG_CONFIG', so
Expand Down Expand Up @@ -100,7 +100,7 @@ termux_setup_toolchain_23c() {
fi
local env_host="${CARGO_TARGET_NAME//-/_}"
export CARGO_TARGET_${env_host@U}_LINKER="${CC}"
export CARGO_TARGET_${env_host@U}_RUSTFLAGS="-L${TERMUX_PREFIX}/lib -C link-arg=-Wl,-rpath=${TERMUX_PREFIX}/lib -C link-arg=-Wl,--enable-new-dtags"
export CARGO_TARGET_${env_host@U}_RUSTFLAGS="-L${TERMUX_LIB_PATH} -C link-arg=-Wl,-rpath=${TERMUX_LIB_PATH} -C link-arg=-Wl,--enable-new-dtags"
export CFLAGS_${env_host}="${CPPFLAGS} ${CFLAGS}"

export ac_cv_func_getpwent=no
Expand Down
6 changes: 3 additions & 3 deletions scripts/build/toolchain/termux_setup_toolchain_27c.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
termux_setup_toolchain_27c() {
export CFLAGS=""
export CPPFLAGS=""
export LDFLAGS="-L${TERMUX_PREFIX}/lib"
export LDFLAGS="-L${TERMUX_LIB_PATH}"

export AS=$TERMUX_HOST_PLATFORM-clang
export CC=$TERMUX_HOST_PLATFORM-clang
Expand Down Expand Up @@ -31,7 +31,7 @@ termux_setup_toolchain_27c() {
if [ $TERMUX_ARCH = arm ]; then
CCTERMUX_HOST_PLATFORM=armv7a-linux-androideabi$TERMUX_PKG_API_LEVEL
fi
LDFLAGS+=" -Wl,-rpath=$TERMUX_PREFIX/lib"
LDFLAGS+=" -Wl,-rpath=$TERMUX_LIB_PATH"
else
export CC_FOR_BUILD=$CC
# Some build scripts use environment variable 'PKG_CONFIG', so
Expand Down Expand Up @@ -101,7 +101,7 @@ termux_setup_toolchain_27c() {
fi
local env_host="${CARGO_TARGET_NAME//-/_}"
export CARGO_TARGET_${env_host@U}_LINKER="${CC}"
export CARGO_TARGET_${env_host@U}_RUSTFLAGS="-L${TERMUX_PREFIX}/lib -C link-arg=-Wl,-rpath=${TERMUX_PREFIX}/lib -C link-arg=-Wl,--enable-new-dtags"
export CARGO_TARGET_${env_host@U}_RUSTFLAGS="-L${TERMUX_LIB_PATH} -C link-arg=-Wl,-rpath=${TERMUX_LIB_PATH} -C link-arg=-Wl,--enable-new-dtags"
export CFLAGS_${env_host}="${CPPFLAGS} ${CFLAGS}"

export ac_cv_func_getpwent=no
Expand Down

0 comments on commit f1eac4d

Please sign in to comment.