configure: generate Meson cross file

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
Marc-André Lureau 2019-07-13 01:47:54 +04:00 committed by Paolo Bonzini
parent a56650518f
commit fc92989286
2 changed files with 69 additions and 10 deletions

72
configure vendored
View File

@ -8630,21 +8630,75 @@ echo >> "$iotests_common_env"
echo "export PYTHON='$python'" >> "$iotests_common_env"
if test "$skip_meson" = no; then
cross="config-meson.cross.new"
meson_quote() {
echo "['$(echo $* | sed "s/ /','/g")']"
}
echo "# Automatically generated by configure - do not modify" > $cross
echo "[properties]" >> $cross
test -z "$cxx" && echo "link_language = 'c'" >> $cross
echo "[binaries]" >> $cross
echo "c = $(meson_quote $cc)" >> $cross
test -n "$cxx" && echo "cpp = $(meson_quote $cxx)" >> $cross
echo "ar = $(meson_quote $ar)" >> $cross
echo "nm = $(meson_quote $nm)" >> $cross
echo "pkgconfig = $(meson_quote $pkg_config_exe)" >> $cross
echo "ranlib = $(meson_quote $ranlib)" >> $cross
echo "strip = $(meson_quote $strip)" >> $cross
echo "windres = $(meson_quote $windres)" >> $cross
if test -n "$cross_prefix"; then
cross_arg="--cross-file config-meson.cross"
# Hack: Meson expects an absolute path for the *build* machine
# for the prefix, so add a slash in front of a Windows path that
# includes a drive letter.
#
# See https://github.com/mesonbuild/meson/issues/7577.
echo "[host_machine]" >> $cross
if test "$mingw32" = "yes" ; then
echo "system = 'windows'" >> $cross
case $prefix in
?:*) pre_prefix=/ ;;
esac
fi
case "$ARCH" in
i386|x86_64)
echo "cpu_family = 'x86'" >> $cross
;;
ppc64le)
echo "cpu_family = 'ppc64'" >> $cross
;;
*)
echo "cpu_family = '$ARCH'" >> $cross
;;
esac
echo "cpu = '$cpu'" >> $cross
if test "$bigendian" = "yes" ; then
echo "endian = 'big'" >> $cross
else
echo "endian = 'little'" >> $cross
fi
else
cross_arg="--native-file config-meson.cross"
fi
mv $cross config-meson.cross
rm -rf meson-private meson-info meson-logs
NINJA=$PWD/ninjatool $meson setup \
--prefix "$prefix" \
--libdir "$libdir" \
--libexecdir "$libexecdir" \
--bindir "$bindir" \
--includedir "$includedir" \
--datadir "$datadir" \
--mandir "$mandir" \
--sysconfdir "$sysconfdir" \
--localstatedir "$local_statedir" \
--prefix "${pre_prefix}$prefix" \
--libdir "${pre_prefix}$libdir" \
--libexecdir "${pre_prefix}$libexecdir" \
--bindir "${pre_prefix}$bindir" \
--includedir "${pre_prefix}$includedir" \
--datadir "${pre_prefix}$datadir" \
--mandir "${pre_prefix}$mandir" \
--sysconfdir "${pre_prefix}$sysconfdir" \
--localstatedir "${pre_prefix}$local_statedir" \
-Doptimization=$(if test "$debug" = yes; then echo 0; else echo 2; fi) \
-Ddebug=$(if test "$debug_info" = yes; then echo true; else echo false; fi) \
-Dwerror=$(if test "$werror" = yes; then echo true; else echo false; fi) \
-Dstrip=$(if test "$strip_opt" = yes; then echo true; else echo false; fi) \
$cross_arg \
"$PWD" "$source_path"
if test "$?" -ne 0 ; then

View File

@ -15,7 +15,12 @@ add_project_link_arguments(config_host['QEMU_LDFLAGS'].split(),
add_project_arguments(config_host['QEMU_INCLUDES'].split(),
language: ['c', 'cpp', 'objc'])
add_languages('cpp', required: false, native: false)
python = import('python').find_installation()
link_language = meson.get_external_property('link_language', 'cpp')
if link_language == 'cpp'
add_languages('cpp', required: true, native: false)
endif
if host_machine.system() == 'darwin'
add_languages('objc', required: false, native: false)
endif