Merge pull request #7801 from pbui/meson-cross

meson: add preliminary support for cross compilation
This commit is contained in:
Enno Boland 2017-09-26 09:34:01 +02:00 committed by GitHub
commit daa28fbae0
1 changed files with 48 additions and 0 deletions

View File

@ -4,6 +4,54 @@
do_configure() {
: ${meson_cmd:=meson}
: ${meson_builddir:=build}
: ${meson_crossfile:=xbps_meson.cross}
if [ "$CROSS_BUILD" ]; then
_MESON_TARGET_ENDIAN=little
_MESON_TARGET_CPU=${XBPS_TARGET_MACHINE}
case "$XBPS_TARGET_MACHINE" in
mips|mips-musl)
_MESON_TARGET_ENDIAN=big
;;
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")']
[host_machine]
system = 'linux'
cpu_family = '${XBPS_MACHINE}'
cpu = '${XBPS_MACHINE}'
endian = 'little'
[target_machine]
system = 'linux'
cpu_family = '${_MESON_TARGET_CPU}'
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}
}