Files
glfs/introduction/multilib/mesonfiles.xml
Zeckmathederg b6e0053e6a *: Remove <application> tags.
The application tag seemed to just put an extra space on either side of
the word(s) the tags surrounded and seemed to serve no purpose beyond
that. If it served the purpose of jhalfs, well this book is not
supported by jhalfs. The result of the tags just added space in both the
rendered output and in the XML files.

Now, when referring to a package name, we just say the name and don't
surround it via a tag. The only exception is using <command>,
<filename>, <xref>, or <ulink>.
2025-07-17 13:32:36 -06:00

141 lines
3.8 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
<!ENTITY % general-entities SYSTEM "../../general.ent">
%general-entities;
]>
<sect1 id="mesonfiles" xreflabel="Meson Toolchain Files">
<?dbhtml filename="mesonfiles.html"?>
<title>Meson Toolchain Files</title>
<sect2>
<title>Introduction to Meson Toolchain Files</title>
<para>
Most applications that rely on the Meson
build system have decent support for cross compilation, ie. compiling
32-bit binaries on a 64-bit system. It can be as easy as setting the
<envar>CC</envar>, <envar>CXX</envar>, and <envar>PKG_CONFIG_PATH
</envar> variables before using the <userinput>meson setup ..
</userinput> command to compile 32-bit binaries on a 64-bit system.
However, some projects are more complicated for many different
reasons, leading to the necessity of Meson
toolchain files. They specify compilers,
options that should be invoked, the pkg-conf
binary (or rather symlink that uses a certain personality file) to use,
<command>llvm-config</command> to use, etc. This is required for many
Meson projects, especially if you have followed BLFS before this book.
Therefore, this section should be considered a requirement.
</para>
<para>
There are two Meson files: the cross
toolchain file and the native toolchain file. There are different situations
for using either.
</para>
<bridgehead renderas="sect3">Meson Toolchain File Dependencies</bridgehead>
<bridgehead renderas="sect4">Required</bridgehead>
<para role="required">
<xref linkend="pkgconf"/> (runtime)
</para>
</sect2>
<sect2 role="installation">
<title>Creating the Cross Toolchain File</title>
<para>
Create the cross toolchain file by running the following commands as the
&root; user:
</para>
<screen role="root"><userinput>mkdir -pv /usr/share/meson/cross &amp;&amp;
cat &gt; /usr/share/meson/cross/lib32 &lt;&lt; "EOF"
<literal>[binaries]
c = ['gcc', '-m32']
cpp = ['g++', '-m32']
rust = ['rustc', '--target', 'i686-unknown-linux-gnu']
pkg-config = 'i686-pc-linux-gnu-pkg-config'
ar = '/usr/bin/ar'
strip = '/usr/bin/strip'
cups-config = 'cups-config'
llvm-config = 'llvm-config'
exe_wrapper = ''
[properties]
sizeof_void* = 4
sizeof_long = 4
[host_machine]
system = 'linux'
subsystem = 'linux'
kernel = 'linux'
cpu_family = 'x86'
cpu = 'i686'
endian = 'little'</literal>
EOF</userinput></screen>
</sect2>
<sect2 role="installation">
<title>Creating the Native Toolchain File</title>
<para>
Create the native toolchain file by running the following commands as the
&root; user:
</para>
<screen role="root"><userinput>mkdir -pv /usr/share/meson/native &amp;&amp;
cat &gt; /usr/share/meson/native/x86 &lt;&lt; "EOF"
<literal>[binaries]
c = ['gcc', '-m32']
cpp = ['g++', '-m32']
rust = ['rustc', '--target', 'i686-unknown-linux-gnu']
pkg-config = 'i686-pc-linux-gnu-pkg-config'
ar = '/usr/bin/ar'
strip = '/usr/bin/strip'
cups-config = 'cups-config'
llvm-config = 'llvm-config'
exe_wrapper = ''
[properties]
sizeof_void* = 4
sizeof_long = 4
[host_machine]
system = 'linux'
subsystem = 'linux'
kernel = 'linux'
cpu_family = 'x86'
cpu = 'i686'
endian = 'little'</literal>
EOF</userinput></screen>
</sect2>
<sect2>
<title>How to Use the File</title>
<para>
Instead of setting environment variables before invoking
<userinput>meson setup ..</userinput>, you can simply do:
</para>
<screen><userinput>meson setup .. --cross-file=lib32 &lt;other-options&gt;</userinput></screen>
<para>
Or...
</para>
<screen><userinput>meson setup .. --native-file=x86 &lt;other-options&gt;</userinput></screen>
</sect2>
</sect1>