97b348502c
following https://mesonbuild.com/Cross-compilation.html - host_machine is our XBPS_TARGET_MACHINE - build_machine is our XBPS_MACHINE, and meson can find out the details on it's own - also don't include -musl in the CPU because meson doesn't recognize it and projects like Mesa (LibGL) don't enable optimizations for it - cpu_family and cpu are different, they need to be set properly: - armv* is arm - mips* is mips - i686 is x86 - x86_64 is x86_64 - aarch64 is aarch64
91 lines
2.3 KiB
Bash
91 lines
2.3 KiB
Bash
#
|
|
# This helper is for templates using meson.
|
|
#
|
|
do_configure() {
|
|
: ${meson_cmd:=meson}
|
|
: ${meson_builddir:=build}
|
|
: ${meson_crossfile:=xbps_meson.cross}
|
|
|
|
if [ "$CROSS_BUILD" ]; then
|
|
_MESON_TARGET_ENDIAN=little
|
|
# drop the -musl suffix to the target cpu, meson doesn't recognize it
|
|
_MESON_TARGET_CPU=${XBPS_TARGET_MACHINE/-musl/}
|
|
case "$XBPS_TARGET_MACHINE" in
|
|
mips|mips-musl|mipshf-musl)
|
|
_MESON_TARGET_ENDIAN=big
|
|
_MESON_CPU_FAMILY=mips
|
|
;;
|
|
armv*)
|
|
_MESON_CPU_FAMILY=arm
|
|
;;
|
|
i686*)
|
|
_MESON_CPU_FAMILY=x86
|
|
;;
|
|
*)
|
|
# if we reached here that means that the cpu and cpu_family
|
|
# are the same like 'x86_64' and 'aarch64'
|
|
_MESON_CPU_FAMILY=${_MESON_TARGET_CPU}
|
|
;;
|
|
esac
|
|
|
|
# Record cross-compiling information in cross file.
|
|
# CFLAGS and LDFLAGS must be set as c_args and c_link_args.
|
|
cat > ${meson_crossfile} <<EOF
|
|
[binaries]
|
|
c = '${CC}'
|
|
cpp = '${CXX}'
|
|
ar = '${AR}'
|
|
ld = '${LD}'
|
|
strip = '${STRIP}'
|
|
readelf = '${READELF}'
|
|
pkgconfig = 'pkg-config'
|
|
|
|
[properties]
|
|
needs_exe_wrapper = true
|
|
c_args = ['$(echo ${CFLAGS} | sed -r "s/\s+/','/g")']
|
|
c_link_args = ['$(echo ${LDFLAGS} | sed -r "s/\s+/','/g")']
|
|
|
|
cpp_args = ['$(echo ${CXXFLAGS} | sed -r "s/\s+/','/g")']
|
|
cpp_link_args = ['$(echo ${LDFLAGS} | sed -r "s/\s+/','/g")']
|
|
|
|
[host_machine]
|
|
system = 'linux'
|
|
cpu_family = '${_MESON_CPU_FAMILY}'
|
|
cpu = '${_MESON_TARGET_CPU}'
|
|
endian = '${_MESON_TARGET_ENDIAN}'
|
|
EOF
|
|
configure_args+=" --cross-file=${meson_crossfile}"
|
|
|
|
# Meson tries to compile natively with CC, CXX, so when cross
|
|
# compiling, we need to set those to the host versions.
|
|
export CC=${CC_host} CXX=${CXX_host}
|
|
|
|
unset _MESON_TARGET_CPU _MESON_TARGET_ENDIAN
|
|
fi
|
|
|
|
${meson_cmd} --prefix=/usr --buildtype=plain ${configure_args} . ${meson_builddir}
|
|
}
|
|
|
|
do_build() {
|
|
: ${make_cmd:=ninja}
|
|
: ${make_build_target:=all}
|
|
: ${meson_builddir:=build}
|
|
|
|
${make_cmd} -C ${meson_builddir} ${makejobs} ${make_build_args} ${make_build_target}
|
|
}
|
|
|
|
do_check() {
|
|
: ${make_cmd:=ninja}
|
|
: ${make_check_target:=test}
|
|
: ${meson_builddir:=build}
|
|
|
|
${make_cmd} -C ${meson_builddir} ${makejobs} ${make_check_args} ${make_check_target}
|
|
}
|
|
|
|
do_install() {
|
|
: ${make_cmd:=ninja}
|
|
: ${make_install_target:=install}
|
|
: ${meson_builddir:=build}
|
|
|
|
DESTDIR=${DESTDIR} ${make_cmd} -C ${meson_builddir} ${make_install_args} ${make_install_target}
|
|
}
|