[OE-core] [PATCH 1/9] meson: add a recipe and class from meta-oe

2018-01-04 Thread Alexander Kanavin
The original recipe has been provided and improved by:

Ross Burton 
Ricardo Ribalda Delgado 
Adam C. Foltzer 
Peter Kjellerstedt 
Linus Svensson 

I have added  patches to fix up gtk-doc and
gobject-introspection in cross-compilation environments,
and also change the order of linker arguments to replicate
autotools more closely (and fix linking errors in some corner
cases).

Signed-off-by: Alexander Kanavin 
---
 meta/classes/meson.bbclass | 108 
 ...s-move-cross_args-in-front-of-output_args.patch |  30 ++
 ...ix-issues-that-arise-when-cross-compiling.patch | 113 +
 ...rospection-determine-g-ir-scanner-and-g-i.patch |  42 
 meta/recipes-devtools/meson/meson_0.44.0.bb|  20 
 5 files changed, 313 insertions(+)
 create mode 100644 meta/classes/meson.bbclass
 create mode 100644 
meta/recipes-devtools/meson/meson/0001-Linker-rules-move-cross_args-in-front-of-output_args.patch
 create mode 100644 
meta/recipes-devtools/meson/meson/0001-gtkdoc-fix-issues-that-arise-when-cross-compiling.patch
 create mode 100644 
meta/recipes-devtools/meson/meson/0002-gobject-introspection-determine-g-ir-scanner-and-g-i.patch
 create mode 100644 meta/recipes-devtools/meson/meson_0.44.0.bb

diff --git a/meta/classes/meson.bbclass b/meta/classes/meson.bbclass
new file mode 100644
index 000..5953b5d698c
--- /dev/null
+++ b/meta/classes/meson.bbclass
@@ -0,0 +1,108 @@
+inherit python3native
+
+DEPENDS_append = " meson-native ninja-native"
+
+# As Meson enforces out-of-tree builds we can just use cleandirs
+B = "${WORKDIR}/build"
+do_configure[cleandirs] = "${B}"
+
+# Where the meson.build build configuration is
+MESON_SOURCEPATH = "${S}"
+
+# These variables in the environment override meson's *native* tools settings.
+# We have to unset them, so that meson doesn't pick up the cross tools and
+# use them for native builds.
+unset CC
+unset CXX
+unset AR
+
+def noprefix(var, d):
+return d.getVar(var).replace(d.getVar('prefix') + '/', '', 1)
+
+MESONOPTS = " --prefix ${prefix} \
+  --bindir ${@noprefix('bindir', d)} \
+  --sbindir ${@noprefix('sbindir', d)} \
+  --datadir ${@noprefix('datadir', d)} \
+  --libdir ${@noprefix('libdir', d)} \
+  --libexecdir ${@noprefix('libexecdir', d)} \
+  --includedir ${@noprefix('includedir', d)} \
+  --mandir ${@noprefix('mandir', d)} \
+  --infodir ${@noprefix('infodir', d)} \
+  --sysconfdir ${sysconfdir} \
+  --localstatedir ${localstatedir} \
+  --sharedstatedir ${sharedstatedir}"
+
+MESON_C_ARGS = "${TARGET_CC_ARCH}${TOOLCHAIN_OPTIONS}"
+MESON_LINK_ARGS = "${MESON_C_ARGS} ${LDFLAGS}"
+
+# both are required but not used by meson
+MESON_HOST_ENDIAN = "bogus-endian"
+MESON_TARGET_ENDIAN = "bogus-endian"
+
+EXTRA_OEMESON += "${PACKAGECONFIG_CONFARGS}"
+
+MESON_CROSS_FILE = ""
+MESON_CROSS_FILE_class-target = "--cross-file ${WORKDIR}/meson.cross"
+
+def meson_array(var, d):
+return "', '".join(d.getVar(var).split()).join(("'", "'"))
+
+addtask write_config before do_configure
+do_write_config[vardeps] += "MESON_C_ARGS TOOLCHAIN_OPTIONS"
+do_write_config() {
+# This needs to be Py to split the args into single-element lists
+cat >${WORKDIR}/meson.cross <
+Date: Fri, 17 Nov 2017 13:18:28 +0200
+Subject: [PATCH] Linker rules: move {cross_args} in front of {output_args}
+
+The previous order was found to break linking in some cases
+(e.g. when -no-pic -fno-PIC was present in {cross_args}.
+
+Upstream-Status: Pending
+Signed-off-by: Alexander Kanavin 
+---
+ mesonbuild/backend/ninjabackend.py | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/mesonbuild/backend/ninjabackend.py 
b/mesonbuild/backend/ninjabackend.py
+index bb281e1..969b70e 100644
+--- a/mesonbuild/backend/ninjabackend.py
 b/mesonbuild/backend/ninjabackend.py
+@@ -1501,7 +1501,7 @@ int dummy;
+  rspfile_content = $ARGS  {output_args} $in $LINK_ARGS {cross_args} $aliasing
+ '''
+ else:
+-command_template = ' command = {executable} $ARGS 
{output_args} $in $LINK_ARGS {cross_args} $aliasing\n'
++command_template = ' command = {executable} $ARGS 
{cross_args} {output_args} $in $LINK_ARGS $aliasing\n'
+ command = command_template.format(
+ executable=' '.join(compiler.get_linker_exelist()),
+ cross_args=' '.join(cross_args),
+-- 
+2.15.0
+
diff --git 
a/meta/recipes-devtools/meson/meson/0001-gtkdoc-fix-issues-that-arise-when-cross-compiling.patch
 
b/meta/recipes-devtools/meson/meson/0001-gtkdoc-fix-issues-that-arise-when-cross-compiling.patch
new file mode 100644
index 000..1912e94358e

[OE-core] [PATCH 1/9] meson: add a recipe and class from meta-oe

2017-12-21 Thread Alexander Kanavin
The original recipe has been provided and improved by:

Ross Burton 
Ricardo Ribalda Delgado 
Adam C. Foltzer 
Peter Kjellerstedt 
Linus Svensson 

I have added  patches to fix up gtk-doc and
gobject-introspection in cross-compilation environments,
and also change the order of linker arguments to replicate
autotools more closely (and fix linking errors in some corner
cases).

Signed-off-by: Alexander Kanavin 
---
 meta/classes/meson.bbclass | 108 
 ...s-move-cross_args-in-front-of-output_args.patch |  30 ++
 ...ix-issues-that-arise-when-cross-compiling.patch | 113 +
 ...rospection-determine-g-ir-scanner-and-g-i.patch |  42 
 meta/recipes-devtools/meson/meson_0.44.0.bb|  20 
 5 files changed, 313 insertions(+)
 create mode 100644 meta/classes/meson.bbclass
 create mode 100644 
meta/recipes-devtools/meson/meson/0001-Linker-rules-move-cross_args-in-front-of-output_args.patch
 create mode 100644 
meta/recipes-devtools/meson/meson/0001-gtkdoc-fix-issues-that-arise-when-cross-compiling.patch
 create mode 100644 
meta/recipes-devtools/meson/meson/0002-gobject-introspection-determine-g-ir-scanner-and-g-i.patch
 create mode 100644 meta/recipes-devtools/meson/meson_0.44.0.bb

diff --git a/meta/classes/meson.bbclass b/meta/classes/meson.bbclass
new file mode 100644
index 000..5953b5d698c
--- /dev/null
+++ b/meta/classes/meson.bbclass
@@ -0,0 +1,108 @@
+inherit python3native
+
+DEPENDS_append = " meson-native ninja-native"
+
+# As Meson enforces out-of-tree builds we can just use cleandirs
+B = "${WORKDIR}/build"
+do_configure[cleandirs] = "${B}"
+
+# Where the meson.build build configuration is
+MESON_SOURCEPATH = "${S}"
+
+# These variables in the environment override meson's *native* tools settings.
+# We have to unset them, so that meson doesn't pick up the cross tools and
+# use them for native builds.
+unset CC
+unset CXX
+unset AR
+
+def noprefix(var, d):
+return d.getVar(var).replace(d.getVar('prefix') + '/', '', 1)
+
+MESONOPTS = " --prefix ${prefix} \
+  --bindir ${@noprefix('bindir', d)} \
+  --sbindir ${@noprefix('sbindir', d)} \
+  --datadir ${@noprefix('datadir', d)} \
+  --libdir ${@noprefix('libdir', d)} \
+  --libexecdir ${@noprefix('libexecdir', d)} \
+  --includedir ${@noprefix('includedir', d)} \
+  --mandir ${@noprefix('mandir', d)} \
+  --infodir ${@noprefix('infodir', d)} \
+  --sysconfdir ${sysconfdir} \
+  --localstatedir ${localstatedir} \
+  --sharedstatedir ${sharedstatedir}"
+
+MESON_C_ARGS = "${TARGET_CC_ARCH}${TOOLCHAIN_OPTIONS}"
+MESON_LINK_ARGS = "${MESON_C_ARGS} ${LDFLAGS}"
+
+# both are required but not used by meson
+MESON_HOST_ENDIAN = "bogus-endian"
+MESON_TARGET_ENDIAN = "bogus-endian"
+
+EXTRA_OEMESON += "${PACKAGECONFIG_CONFARGS}"
+
+MESON_CROSS_FILE = ""
+MESON_CROSS_FILE_class-target = "--cross-file ${WORKDIR}/meson.cross"
+
+def meson_array(var, d):
+return "', '".join(d.getVar(var).split()).join(("'", "'"))
+
+addtask write_config before do_configure
+do_write_config[vardeps] += "MESON_C_ARGS TOOLCHAIN_OPTIONS"
+do_write_config() {
+# This needs to be Py to split the args into single-element lists
+cat >${WORKDIR}/meson.cross <
+Date: Fri, 17 Nov 2017 13:18:28 +0200
+Subject: [PATCH] Linker rules: move {cross_args} in front of {output_args}
+
+The previous order was found to break linking in some cases
+(e.g. when -no-pic -fno-PIC was present in {cross_args}.
+
+Upstream-Status: Pending
+Signed-off-by: Alexander Kanavin 
+---
+ mesonbuild/backend/ninjabackend.py | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/mesonbuild/backend/ninjabackend.py 
b/mesonbuild/backend/ninjabackend.py
+index bb281e1..969b70e 100644
+--- a/mesonbuild/backend/ninjabackend.py
 b/mesonbuild/backend/ninjabackend.py
+@@ -1501,7 +1501,7 @@ int dummy;
+  rspfile_content = $ARGS  {output_args} $in $LINK_ARGS {cross_args} $aliasing
+ '''
+ else:
+-command_template = ' command = {executable} $ARGS 
{output_args} $in $LINK_ARGS {cross_args} $aliasing\n'
++command_template = ' command = {executable} $ARGS 
{cross_args} {output_args} $in $LINK_ARGS $aliasing\n'
+ command = command_template.format(
+ executable=' '.join(compiler.get_linker_exelist()),
+ cross_args=' '.join(cross_args),
+-- 
+2.15.0
+
diff --git 
a/meta/recipes-devtools/meson/meson/0001-gtkdoc-fix-issues-that-arise-when-cross-compiling.patch
 
b/meta/recipes-devtools/meson/meson/0001-gtkdoc-fix-issues-that-arise-when-cross-compiling.patch
new file mode 100644
index 000..1912e94358e

Re: [OE-core] [PATCH 1/9] meson: add a recipe and class from meta-oe

2017-12-15 Thread Alexander Kanavin

On 12/15/2017 06:01 PM, Linus Svensson wrote:

 From mesonbuild.com:
target machine is the machine on which the compiled binary's output will 
run

(this is only meaningful for programs such as compilers that, when run,
produce object code for a different CPU than what the program is being 
run on)


Guys... you are arguing over nothing. As I said, endianness definition 
is not used anywhere in meson, although it's required to be present in 
the config. The latest patchset sets it to a bogus value :)


Alex
--
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


Re: [OE-core] [PATCH 1/9] meson: add a recipe and class from meta-oe

2017-12-15 Thread Linus Svensson

On 12/15/2017 04:29 PM, André Draszik wrote:

On Thu, 2017-12-07 at 11:27 -0800, Andre McCurdy wrote:

+MESON_TARGET_ENDIAN = "${@bb.utils.contains('TUNE_FEATURES',
'bigendian', 'big', 'little', d)}"

This won't work for all targets (e.g. PowerPC is big endian but
doesn't include "bigendian" in TUNE_FEATURES). To determine the
endianness of the target, use SITEINFO_ENDIANNESS instead.

${MESON_TARGET_ENDIAN} is used inside a [target_machine] statement, though.
Not sure about the naming and intention here...

meson define host,target and build the same way as autotools do.
meson will fetch information about the build machine from the environment
and host/target is specified in the cross-file. The intention with this
statement is to specify the endianness for the target system. Is that
information available in oe?

From mesonbuild.com:
target machine is the machine on which the compiled binary's output will run
(this is only meaningful for programs such as compilers that, when run,
produce object code for a different CPU than what the program is being 
run on)


/Linus
--
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


Re: [OE-core] [PATCH 1/9] meson: add a recipe and class from meta-oe

2017-12-15 Thread André Draszik
On Thu, 2017-12-07 at 11:27 -0800, Andre McCurdy wrote:
> On Fri, Nov 17, 2017 at 4:02 AM, Alexander Kanavin
>  wrote:
> > +
> > +MESON_HOST_ENDIAN = "${@bb.utils.contains('SITEINFO_ENDIANNESS', 'be',
> > 'big', 'little', d)}"
> 
> SITEINFO_ENDIANNESS returns the endianness of the target, not the
> host.

Isn't the host what you call target? When cross-compiling, the host machine
normally refers to the system where the built programs will be run, and
target machine to where the a compiler will run, in case a compiler is being
(cross-)compiled.

${MESON_HOST_ENDIAN} is used inside the [host_machine] statement, so this
looks right.

> [...]

> 
> > +MESON_TARGET_ENDIAN = "${@bb.utils.contains('TUNE_FEATURES',
> > 'bigendian', 'big', 'little', d)}"
> 
> This won't work for all targets (e.g. PowerPC is big endian but
> doesn't include "bigendian" in TUNE_FEATURES). To determine the
> endianness of the target, use SITEINFO_ENDIANNESS instead.

${MESON_TARGET_ENDIAN} is used inside a [target_machine] statement, though.
Not sure about the naming and intention here...


Cheers,
Andre'

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


Re: [OE-core] [PATCH 1/9] meson: add a recipe and class from meta-oe

2017-12-15 Thread Alexander Kanavin

On 12/07/2017 09:27 PM, Andre McCurdy wrote:

On Fri, Nov 17, 2017 at 4:02 AM, Alexander Kanavin
 wrote:

+
+MESON_HOST_ENDIAN = "${@bb.utils.contains('SITEINFO_ENDIANNESS', 'be', 'big', 
'little', d)}"


SITEINFO_ENDIANNESS returns the endianness of the target, not the
host. Perhaps this is just a confusingly named variable though? (it
doesn't make much sense to expect the user to tell the build system
what endianness it's running on, the build system should be able to
determine that on it's own).


+MESON_TARGET_ENDIAN = "${@bb.utils.contains('TUNE_FEATURES', 'bigendian', 'big', 
'little', d)}"


This won't work for all targets (e.g. PowerPC is big endian but
doesn't include "bigendian" in TUNE_FEATURES). To determine the
endianness of the target, use SITEINFO_ENDIANNESS instead.




I have reviewed the source code of meson for uses of the endian 
parameter and couldn't find any whatsoever. Its presence in config file 
is however enforced. I'll set both of these to 'bogus-endian' and see if 
that makes any difference.



Alex
--
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


Re: [OE-core] [PATCH 1/9] meson: add a recipe and class from meta-oe

2017-12-15 Thread Alexander Kanavin

On 12/07/2017 05:06 PM, Peter Kjellerstedt wrote:


+return d.getVar(var, True).replace(d.getVar('prefix', True) + '/', '', 1)


Remove the True argument to d.getVar().

+return "', '".join(d.getVar(var, True).split()).join(("'", "'"))


Remove True here as well.


Thanks, done.

Alex
--
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


Re: [OE-core] [PATCH 1/9] meson: add a recipe and class from meta-oe

2017-12-07 Thread Andre McCurdy
On Fri, Nov 17, 2017 at 4:02 AM, Alexander Kanavin
 wrote:
> +
> +MESON_HOST_ENDIAN = "${@bb.utils.contains('SITEINFO_ENDIANNESS', 'be', 
> 'big', 'little', d)}"

SITEINFO_ENDIANNESS returns the endianness of the target, not the
host. Perhaps this is just a confusingly named variable though? (it
doesn't make much sense to expect the user to tell the build system
what endianness it's running on, the build system should be able to
determine that on it's own).

> +MESON_TARGET_ENDIAN = "${@bb.utils.contains('TUNE_FEATURES', 'bigendian', 
> 'big', 'little', d)}"

This won't work for all targets (e.g. PowerPC is big endian but
doesn't include "bigendian" in TUNE_FEATURES). To determine the
endianness of the target, use SITEINFO_ENDIANNESS instead.
-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


Re: [OE-core] [PATCH 1/9] meson: add a recipe and class from meta-oe

2017-12-07 Thread Peter Kjellerstedt
> -Original Message-
> From: openembedded-core-boun...@lists.openembedded.org 
> [mailto:openembedded-core-boun...@lists.openembedded.org] On Behalf Of 
> Alexander Kanavin
> Sent: den 17 november 2017 13:03
> To: openembedded-core@lists.openembedded.org
> Subject: [OE-core] [PATCH 1/9] meson: add a recipe and class from meta-oe
> 
> The original recipe has been provided and improved by:
> 
> Ross Burton <ross.bur...@intel.com>
> Ricardo Ribalda Delgado <ricardo.riba...@gmail.com>
> Adam C. Foltzer <acfolt...@galois.com>
> Peter Kjellerstedt <peter.kjellerst...@axis.com>
> Linus Svensson <linu...@axis.com>
> 
> I have added  patches to fix up gtk-doc and
> gobject-introspection in cross-compilation environments,
> and also change the order of linker arguments to replicate
> autotools more closely (and fix linking errors in some corner
> cases).
> 
> Signed-off-by: Alexander Kanavin <alexander.kana...@linux.intel.com>
> ---
>  meta/classes/meson.bbclass | 107 +++
>  ...s-move-cross_args-in-front-of-output_args.patch |  30 ++
>  ...ix-issues-that-arise-when-cross-compiling.patch | 113 
> +
>  ...rospection-determine-g-ir-scanner-and-g-i.patch |  41 
>  meta/recipes-devtools/meson/meson_0.43.0.bb|  20 
>  5 files changed, 311 insertions(+)
>  create mode 100644 meta/classes/meson.bbclass
>  create mode 100644 
> meta/recipes-devtools/meson/meson/0001-Linker-rules-move-cross_args-in-front-of-output_args.patch
>  create mode 100644 
> meta/recipes-devtools/meson/meson/0001-gtkdoc-fix-issues-that-arise-when-cross-compiling.patch
>  create mode 100644 
> meta/recipes-devtools/meson/meson/0002-gobject-introspection-determine-g-ir-scanner-and-g-i.patch
>  create mode 100644 meta/recipes-devtools/meson/meson_0.43.0.bb
> 
> diff --git a/meta/classes/meson.bbclass b/meta/classes/meson.bbclass
> new file mode 100644
> index 000..64553cd8f3d
> --- /dev/null
> +++ b/meta/classes/meson.bbclass
> @@ -0,0 +1,107 @@
> +inherit python3native
> +
> +DEPENDS_append = " meson-native ninja-native"
> +
> +# As Meson enforces out-of-tree builds we can just use cleandirs
> +B = "${WORKDIR}/build"
> +do_configure[cleandirs] = "${B}"
> +
> +# Where the meson.build build configuration is
> +MESON_SOURCEPATH = "${S}"
> +
> +# These variables in the environment override meson's *native* tools 
> settings.
> +# We have to unset them, so that meson doesn't pick up the cross tools and
> +# use them for native builds.
> +unset CC
> +unset CXX
> +unset AR
> +
> +def noprefix(var, d):
> +return d.getVar(var, True).replace(d.getVar('prefix', True) + '/', '', 1)

Remove the True argument to d.getVar().

> +
> +MESONOPTS = " --prefix ${prefix} \
> +  --bindir ${@noprefix('bindir', d)} \
> +  --sbindir ${@noprefix('sbindir', d)} \
> +  --datadir ${@noprefix('datadir', d)} \
> +  --libdir ${@noprefix('libdir', d)} \
> +  --libexecdir ${@noprefix('libexecdir', d)} \
> +  --includedir ${@noprefix('includedir', d)} \
> +  --mandir ${@noprefix('mandir', d)} \
> +  --infodir ${@noprefix('infodir', d)} \
> +  --sysconfdir ${sysconfdir} \
> +  --localstatedir ${localstatedir} \
> +  --sharedstatedir ${sharedstatedir}"
> +
> +MESON_C_ARGS = "${TARGET_CC_ARCH}${TOOLCHAIN_OPTIONS}"
> +MESON_LINK_ARGS = "${MESON_C_ARGS} ${LDFLAGS}"
> +
> +MESON_HOST_ENDIAN = "${@bb.utils.contains('SITEINFO_ENDIANNESS', 'be','big', 
> 'little', d)}"
> +MESON_TARGET_ENDIAN = "${@bb.utils.contains('TUNE_FEATURES', 'bigendian', 
> 'big', 'little', d)}"
> +
> +EXTRA_OEMESON += "${PACKAGECONFIG_CONFARGS}"
> +
> +MESON_CROSS_FILE = ""
> +MESON_CROSS_FILE_class-target = "--cross-file ${WORKDIR}/meson.cross"
> +
> +def meson_array(var, d):
> +return "', '".join(d.getVar(var, True).split()).join(("'", "'"))

Remove True here as well.

//Peter

-- 
___
Openembedded-core mailing list
Openembedded-core@lists.openembedded.org
http://lists.openembedded.org/mailman/listinfo/openembedded-core


[OE-core] [PATCH 1/9] meson: add a recipe and class from meta-oe

2017-11-17 Thread Alexander Kanavin
The original recipe has been provided and improved by:

Ross Burton 
Ricardo Ribalda Delgado 
Adam C. Foltzer 
Peter Kjellerstedt 
Linus Svensson 

I have added  patches to fix up gtk-doc and
gobject-introspection in cross-compilation environments,
and also change the order of linker arguments to replicate
autotools more closely (and fix linking errors in some corner
cases).

Signed-off-by: Alexander Kanavin 
---
 meta/classes/meson.bbclass | 107 +++
 ...s-move-cross_args-in-front-of-output_args.patch |  30 ++
 ...ix-issues-that-arise-when-cross-compiling.patch | 113 +
 ...rospection-determine-g-ir-scanner-and-g-i.patch |  41 
 meta/recipes-devtools/meson/meson_0.43.0.bb|  20 
 5 files changed, 311 insertions(+)
 create mode 100644 meta/classes/meson.bbclass
 create mode 100644 
meta/recipes-devtools/meson/meson/0001-Linker-rules-move-cross_args-in-front-of-output_args.patch
 create mode 100644 
meta/recipes-devtools/meson/meson/0001-gtkdoc-fix-issues-that-arise-when-cross-compiling.patch
 create mode 100644 
meta/recipes-devtools/meson/meson/0002-gobject-introspection-determine-g-ir-scanner-and-g-i.patch
 create mode 100644 meta/recipes-devtools/meson/meson_0.43.0.bb

diff --git a/meta/classes/meson.bbclass b/meta/classes/meson.bbclass
new file mode 100644
index 000..64553cd8f3d
--- /dev/null
+++ b/meta/classes/meson.bbclass
@@ -0,0 +1,107 @@
+inherit python3native
+
+DEPENDS_append = " meson-native ninja-native"
+
+# As Meson enforces out-of-tree builds we can just use cleandirs
+B = "${WORKDIR}/build"
+do_configure[cleandirs] = "${B}"
+
+# Where the meson.build build configuration is
+MESON_SOURCEPATH = "${S}"
+
+# These variables in the environment override meson's *native* tools settings.
+# We have to unset them, so that meson doesn't pick up the cross tools and
+# use them for native builds.
+unset CC
+unset CXX
+unset AR
+
+def noprefix(var, d):
+return d.getVar(var, True).replace(d.getVar('prefix', True) + '/', '', 1)
+
+MESONOPTS = " --prefix ${prefix} \
+  --bindir ${@noprefix('bindir', d)} \
+  --sbindir ${@noprefix('sbindir', d)} \
+  --datadir ${@noprefix('datadir', d)} \
+  --libdir ${@noprefix('libdir', d)} \
+  --libexecdir ${@noprefix('libexecdir', d)} \
+  --includedir ${@noprefix('includedir', d)} \
+  --mandir ${@noprefix('mandir', d)} \
+  --infodir ${@noprefix('infodir', d)} \
+  --sysconfdir ${sysconfdir} \
+  --localstatedir ${localstatedir} \
+  --sharedstatedir ${sharedstatedir}"
+
+MESON_C_ARGS = "${TARGET_CC_ARCH}${TOOLCHAIN_OPTIONS}"
+MESON_LINK_ARGS = "${MESON_C_ARGS} ${LDFLAGS}"
+
+MESON_HOST_ENDIAN = "${@bb.utils.contains('SITEINFO_ENDIANNESS', 'be', 'big', 
'little', d)}"
+MESON_TARGET_ENDIAN = "${@bb.utils.contains('TUNE_FEATURES', 'bigendian', 
'big', 'little', d)}"
+
+EXTRA_OEMESON += "${PACKAGECONFIG_CONFARGS}"
+
+MESON_CROSS_FILE = ""
+MESON_CROSS_FILE_class-target = "--cross-file ${WORKDIR}/meson.cross"
+
+def meson_array(var, d):
+return "', '".join(d.getVar(var, True).split()).join(("'", "'"))
+
+addtask write_config before do_configure
+do_write_config[vardeps] += "MESON_C_ARGS TOOLCHAIN_OPTIONS"
+do_write_config() {
+# This needs to be Py to split the args into single-element lists
+cat >${WORKDIR}/meson.cross <
+Date: Fri, 17 Nov 2017 13:18:28 +0200
+Subject: [PATCH] Linker rules: move {cross_args} in front of {output_args}
+
+The previous order was found to break linking in some cases
+(e.g. when -no-pic -fno-PIC was present in {cross_args}.
+
+Upstream-Status: Pending
+Signed-off-by: Alexander Kanavin 
+---
+ mesonbuild/backend/ninjabackend.py | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/mesonbuild/backend/ninjabackend.py 
b/mesonbuild/backend/ninjabackend.py
+index bb281e1..969b70e 100644
+--- a/mesonbuild/backend/ninjabackend.py
 b/mesonbuild/backend/ninjabackend.py
+@@ -1501,7 +1501,7 @@ int dummy;
+  rspfile_content = $ARGS  {output_args} $in $LINK_ARGS {cross_args} $aliasing
+ '''
+ else:
+-command_template = ' command = {executable} $ARGS 
{output_args} $in $LINK_ARGS {cross_args} $aliasing\n'
++command_template = ' command = {executable} $ARGS 
{cross_args} {output_args} $in $LINK_ARGS $aliasing\n'
+ command = command_template.format(
+ executable=' '.join(compiler.get_linker_exelist()),
+ cross_args=' '.join(cross_args),
+-- 
+2.15.0
+
diff --git 
a/meta/recipes-devtools/meson/meson/0001-gtkdoc-fix-issues-that-arise-when-cross-compiling.patch