aports/main/meson/abuild-meson
Sertonix 5e4829548d main/meson: use --native-file in abuild-meson
Fixes cross compilation of apk-tools3. This is needed to counteract the
fact that abuild exports PKG_CONFIG_SYSROOT_DIR globally.
2025-02-12 17:26:20 +00:00

69 lines
1.7 KiB
Bash
Executable file

#!/bin/sh -e
# Highly opinionated wrapper for Alpine Linux packaging
. "${ABUILD_SHAREDIR:-/usr/share/abuild}"/functions.sh
# mostly taken from https://github.com/void-linux/void-packages/blob/22bf95cf356bf1a09212733d775d447d011f70b0/common/build-style/meson.sh
if [ "$CHOST" != "$CBUILD" ]; then
_meson_crossfile="abuild-meson.cross"
_meson_target_endian=little
# just the first part of the hostspec
_meson_target_cpu="$CARCH"
_meson_cpu_family="$CARCH"
case "$CARCH" in
arm*)
_meson_cpu_family=arm
;;
ppc64le)
_meson_cpu_family=ppc64
;;
s390x)
_meson_target_endian=big
;;
esac
cat > $_meson_crossfile <<-EOF
[binaries]
strip = '${CROSS_COMPILE}strip'
readelf = '${CROSS_COMPILE}readelf'
objcopy = '${CROSS_COMPILE}objcopy'
pkg-config = 'pkg-config'
[properties]
needs_exe_wrapper = true
sys_root = '$CBUILDROOT'
[host_machine]
system = 'linux'
cpu_family = '$_meson_cpu_family'
cpu = '$_meson_target_cpu'
endian = '$_meson_target_endian'
EOF
cat > abuild-meson.native <<-EOF
[properties]
sys_root = '/'
EOF
unset _meson_target_cpu _meson_target_endian _meson_cpu_family
fi
exec meson setup \
--prefix=/usr \
--libdir=/usr/lib \
--libexecdir=/usr/libexec \
--bindir=/usr/bin \
--sbindir=/usr/sbin \
--includedir=/usr/include \
--datadir=/usr/share \
--mandir=/usr/share/man \
--infodir=/usr/share/info \
--localedir=/usr/share/locale \
--sysconfdir=/etc \
--localstatedir=/var \
--sharedstatedir=/var/lib \
--buildtype=plain \
--auto-features=auto \
--wrap-mode=nodownload \
-Db_lto=false \
-Db_staticpic=true \
-Db_pie=true \
-Dpython.bytecompile=0 \
-Dwerror=false \
${_meson_crossfile:+--cross-file=$_meson_crossfile --native-file=abuild-meson.native} \
"$@"