[PULL 017/150] configure: generate Meson cross file

Paolo Bonzini posted 150 patches 5 years, 5 months ago
Maintainers: Max Reitz <mreitz@redhat.com>, Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>, Helge Deller <deller@gmx.de>, Aleksandar Rikalo <aleksandar.rikalo@syrmia.com>, Gerd Hoffmann <kraxel@redhat.com>, Thomas Huth <thuth@redhat.com>, Eduardo Habkost <ehabkost@redhat.com>, Amit Shah <amit@kernel.org>, "Edgar E. Iglesias" <edgar.iglesias@gmail.com>, Igor Mammedov <imammedo@redhat.com>, Riku Voipio <riku.voipio@iki.fi>, "Marc-André Lureau" <marcandre.lureau@redhat.com>, Halil Pasic <pasic@linux.ibm.com>, "Cédric Le Goater" <clg@kaod.org>, Aurelien Jarno <aurelien@aurel32.net>, Hannes Reinecke <hare@suse.com>, Michael Rolnik <mrolnik@gmail.com>, Cleber Rosa <crosa@redhat.com>, Michael Roth <mdroth@linux.vnet.ibm.com>, Raphael Norwitz <raphael.norwitz@nutanix.com>, Max Filippov <jcmvbkbc@gmail.com>, "Michael S. Tsirkin" <mst@redhat.com>, Andrzej Zaborowski <balrogg@gmail.com>, Stefano Stabellini <sstabellini@kernel.org>, Laurent Vivier <laurent@vivier.eu>, Bandan Das <bsd@redhat.com>, Palmer Dabbelt <palmer@dabbelt.com>, Alistair Francis <Alistair.Francis@wdc.com>, Stefan Berger <stefanb@linux.ibm.com>, Richard Henderson <rth@twiddle.net>, Alex Williamson <alex.williamson@redhat.com>, Yoshinori Sato <ysato@users.sourceforge.jp>, Su Hang <suhang16@mails.ucas.ac.cn>, Dmitry Fleytman <dmitry.fleytman@gmail.com>, Christian Schoenebeck <qemu_oss@crudebyte.com>, Joel Stanley <joel@jms.id.au>, Peter Maydell <peter.maydell@linaro.org>, Fam Zheng <fam@euphon.net>, Laurent Vivier <lvivier@redhat.com>, Juan Quintela <quintela@redhat.com>, Jason Wang <jasowang@redhat.com>, David Hildenbrand <david@redhat.com>, Markus Armbruster <armbru@redhat.com>, Laszlo Ersek <lersek@redhat.com>, Keith Busch <kbusch@kernel.org>, Ben Warren <ben@skyportsystems.com>, Christian Borntraeger <borntraeger@de.ibm.com>, "Alex Bennée" <alex.bennee@linaro.org>, Stefan Hajnoczi <stefanha@redhat.com>, Paul Durrant <paul@xen.org>, Greg Kurz <groug@kaod.org>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, "Daniel P. Berrangé" <berrange@redhat.com>, Aleksandar Markovic <aleksandar.qemu.devel@gmail.com>, Jiaxun Yang <jiaxun.yang@flygoat.com>, David Gibson <david@gibson.dropbear.id.au>, Paolo Bonzini <pbonzini@redhat.com>, "Philippe Mathieu-Daudé" <philmd@redhat.com>, Sagar Karandikar <sagark@eecs.berkeley.edu>, Sarah Harris <S.E.Harris@kent.ac.uk>, Artyom Tarasenko <atar4qemu@gmail.com>, Yuval Shaia <yuval.shaia.ml@gmail.com>, Anthony Perard <anthony.perard@citrix.com>, Kevin Wolf <kwolf@redhat.com>, Cornelia Huck <cohuck@redhat.com>, John Snow <jsnow@redhat.com>, Alexander Bulekov <alxndr@bu.edu>, Bastian Koppelmann <kbastian@mail.uni-paderborn.de>, "Dr. David Alan Gilbert" <dgilbert@redhat.com>, Stafford Horne <shorne@gmail.com>, Stefan Weil <sw@weilnetz.de>, Huacai Chen <chenhc@lemote.com>, Eric Blake <eblake@redhat.com>
There is a newer version of this series
[PULL 017/150] configure: generate Meson cross file
Posted by Paolo Bonzini 5 years, 5 months ago
From: Marc-André Lureau <marcandre.lureau@redhat.com>

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 configure | 70 ++++++++++++++++++++++++++++++++++++++++++++++++-------
 1 file changed, 61 insertions(+), 9 deletions(-)

diff --git a/configure b/configure
index e0a2d262ea..22b89a5e24 100755
--- a/configure
+++ b/configure
@@ -8580,24 +8580,76 @@ echo "# Automatically generated by configure - do not modify" > "$iotests_common
 echo >> "$iotests_common_env"
 echo "export PYTHON='$python'" >> "$iotests_common_env"
 
+cross="config-meson.cross.new"
+echo "# Automatically generated by configure - do not modify" > $cross
+echo "[binaries]" >> $cross
+echo "c = '$cc'" >> $cross
+echo "cpp = '$cxx'" >> $cross
+echo "ar = '$ar'" >> $cross
+echo "nm = '$nm'" >> $cross
+echo "pkgconfig = '$pkg_config_exe'" >> $cross
+echo "ranlib = '$ranlib'" >> $cross
+echo "strip = '$strip'" >> $cross
+echo "windres = '$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
+
+if test -f config-meson.cross && ! cmp $cross config-meson.cross >/dev/null 2>&1; then
+    rm -rf meson-private meson-info meson-logs
+fi
+mv $cross config-meson.cross
+
 if test -d meson-private && ! test -f meson-private/coredata.dat; then
   rm -rf meson-private meson-info meson-logs
 fi
 NINJA=$PWD/ninjatool $meson setup \
         $(if test -d meson-private/; then echo --reconfigure; fi) \
-        --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
-- 
2.26.2