Compilation and Installation Using Meson
========================================
-- `Introduction <#intro>`__
-- `Basic Usage <#basic>`__
-- `Advanced Usage <#advanced>`__
-- `Cross-compilation and 32-bit builds <#cross-compilation>`__
-
-.. _intro:
-
1. Introduction
---------------
**Mesa's Meson build system is generally considered stable and ready for
production.**
-**Mesa requires Meson >= 0.52.0 to build.**
+.. note::
+
+ Mesa requires Meson >= 0.52.0 to build.
+
+ If your distribution doesn't have something recent enough in its
+ repositories, you can `try the methods suggested here
+ <https://mesonbuild.com/Getting-meson.html>`__ to install the
+ current version of Meson.
The Meson build of Mesa is tested on Linux, macOS, Windows, Cygwin,
Haiku, FreeBSD, DragonflyBSD, NetBSD, and should work on OpenBSD.
If Meson is not already installed on your system, you can typically
install it with your package installer. For example:
-::
+.. code-block:: console
sudo apt-get install meson # Ubuntu
or
-::
+.. code-block:: console
sudo dnf install meson # Fedora
flex, and bison. The easiest way to install everything you need is with
`chocolatey <https://chocolatey.org/>`__.
-::
+.. code-block:: console
choco install python3 winflexbison pkgconfiglite
You can even use chocolatey to install mingw and ninja (ninja can be
used with MSVC as well)
-::
+.. code-block:: console
choco install ninja mingw
Then install meson using pip
-::
+.. code-block:: console
py -3 -m pip install meson mako
You may need to add the python3 scripts directory to your path for
meson.
-.. _basic:
-
2. Basic Usage
--------------
Basic configuration is done with:
-::
+.. code-block:: console
meson build/
To review the options which Meson chose, run:
-::
+.. code-block:: console
meson configure build/
options for a previously configured build directory. All options passed
to this command are in the form ``-D "option"="value"``. For example:
-::
+.. code-block:: console
meson configure build/ -Dprefix=/tmp/install -Dglx=true
Once you've run the initial ``meson`` command successfully you can use
your configured backend to build the project in your build directory:
-::
+.. code-block:: console
ninja -C build/
finishes up some final steps of the build process (such as creating
symbolic links for drivers). To install:
-::
+.. code-block:: console
ninja -C build/ install
-Note: autotools automatically updated translation files (used by the DRI
-configuration tool) as part of the build process, Meson does not do
-this. Instead, you will need do this:
-
-::
-
- ninja -C build/ xmlpool-pot xmlpool-update-po xmlpool-gmo
-
Windows specific instructions
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
want to use ICL or clang-cl with the vsbackend you will need meson
0.52.0 or greater. Older versions always use the microsoft compiler.
-.. _advanced:
-
3. Advanced Usage
-----------------
Installation Location
-~~~~~~~~~~~~~~~~~~~~~
+^^^^^^^^^^^^^^^^^^^^^
Meson default to installing libGL.so in your system's main lib/
directory and DRI drivers to a dri/ subdirectory.
than the system library directory. This can be done with the --prefix
option. For example:
-::
+.. code-block:: console
meson --prefix="${PWD}/build/install" build/
Meson also honors ``DESTDIR`` for installs.
Compiler Options
-~~~~~~~~~~~~~~~~
+^^^^^^^^^^^^^^^^
Meson supports the common CFLAGS, CXXFLAGS, etc. environment variables
but their use is discouraged because of the many caveats in using them.
-Instead, it is recomended to use ``-D${lang}_args`` and
+Instead, it is recommended to use ``-D${lang}_args`` and
``-D${lang}_link_args``. Among the benefits of these options is that
they are guaranteed to persist across rebuilds and reconfigurations.
This example sets -fmax-errors for compiling C sources and -DMAGIC=123
for C++ sources:
-::
+.. code-block:: console
meson builddir/ -Dc_args=-fmax-errors=10 -Dcpp_args=-DMAGIC=123
Compiler Specification
-~~~~~~~~~~~~~~~~~~~~~~
+^^^^^^^^^^^^^^^^^^^^^^
Meson supports the standard CC and CXX environment variables for
changing the default compiler. Note that Meson does not allow changing
This is an example of specifying the clang compilers and cleaning the
build directory before reconfiguring with an extra C option:
-::
+.. code-block:: console
CC=clang CXX=clang++ meson build-clang
ninja -C build-clang
`here <https://mesonbuild.com/Reference-tables.html#compiler-ids>`__.
LLVM
-~~~~
+^^^^
Meson includes upstream logic to wrap llvm-config using its standard
dependency interface.
``-Dcmake_module_path`` option in this meson version, which points to
the root of an alternative installation (the prefix). For example:
-::
+.. code-block:: console
meson builddir -Dcmake_module_path=/home/user/mycmake/prefix
Then configure meson:
-::
+.. code-block:: console
meson builddir/ --native-file custom-llvm.ini
windows), which will be searched for ``llvm-config``,
``llvm-config$version``, and ``llvm-config-$version``:
-::
+.. code-block:: console
PATH=/path/to/folder/with/llvm-config:$PATH meson build
Then configure meson:
-::
+.. code-block:: console
meson builddir/ --cross-file cross-llvm.ini
-See the `Cross Compilation <#cross-compilation>`__ section for more
+See the :ref:`Cross Compilation <cross-compilation>` section for more
information.
On windows (and in other cases), using llvm-config or cmake may be
It may also define:
- ``irbuilder_h``: a ``files()`` object pointing to llvm/IR/IRBuilder.h
- (this is requred for SWR)
+ (this is required for SWR)
- ``has_rtti``: a ``bool`` that declares whether LLVM was built with
RTTI. Defaults to true
in build failures.
``PKG_CONFIG_PATH``
-~~~~~~~~~~~~~~~~~~~
+^^^^^^^^^^^^^^^^^^^
The ``pkg-config`` utility is a hard requirement for configuring and
building Mesa on Unix-like systems. It is used to search for external
metadata in ``/usr/X11R6`` before the standard directories.
Options
-~~~~~~~
+^^^^^^^
One of the oddities of meson is that some options are different when
passed to the ``meson`` than to ``meson configure``. These options are