From: Brian Paul The Meson build system is generally considered stable and ready
-for production For general information about Meson see the
+Meson website. The meson build is tested on Linux, macOS, Cygwin and Haiku, FreeBSD,
+ Mesa's Meson build system is generally considered stable and ready
+for production. The Meson build of Mesa is tested on Linux, macOS, Cygwin and 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: Mesa requires Meson >= 0.45.0 to build.
Some older versions of meson do not check that they are too old and will error
out in odd ways.
You'll also need Ninja.
+If it's not already installed, use apt-get or dnf to install
+the ninja-build package.
+
The meson program is used to configure the source directory and generates
either a ninja build file or Visual Studio® build files. The latter must
-be enabled via the
+Meson only supports out-of-tree builds, and must be passed a
directory to put built and generated sources into. We'll call that directory
-"build" for examples.
+"build" here.
+It's recommended to create a
+
+separate build directory for each configuration you might want to use.
+Compilation and Installation using Meson
-1. Basic Usage
+1. Introduction
-
+sudo apt-get install meson # Ubuntu
+
+or
+
+sudo dnf install meson # Fedora
+
+
2. Basic Usage
+
--backend
switch, as ninja is the default backend on all
-operating systems. Meson only supports out-of-tree builds, and must be passed a
+be enabled via the --backend
switch, as ninja is the default
+backend on all
+operating systems.
+
Basic configuration is done with:
+- meson build/ +meson build/
-To see a description of your options you can run meson configure
-along with a build directory to view the selected options for. This will show
-your meson global arguments and project arguments, along with their defaults
-and your local settings.
+This will create the build directory.
+If any dependencies are missing, you can install them, or try to remove
+the dependency with a Meson configuration option (see below).
+
+To review the options which Meson chose, run:
++meson configure build/ +
-Meson does not currently support listing options before configure a build
-directory, but this feature is being discussed upstream.
+Meson does not currently support listing configuration options before
+running "meson build/" but this feature is being discussed upstream.
For now, we have a bin/meson-options.py
script that prints
the options for you.
If that script doesn't work for some reason, you can always look in the
meson_options.txt
file at the root of the project.
- meson configure build/ --
-With additional arguments meson configure
is used to change
-options on already configured build directory. All options passed to this
-command are in the form -D "command"="value"
.
+With additional arguments meson configure
can be used to change
+options for a previously configured build directory.
+All options passed to this command are in the form
+-D "option"="value"
.
+For example:
- meson configure build/ -Dprefix=/tmp/install -Dglx=true +meson configure build/ -Dprefix=/tmp/install -Dglx=true
@@ -88,33 +128,59 @@ and brackets to represent an empty list (-D platforms=[]
).
Once you've run the initial meson
command successfully you can use
-your configured backend to build the project. With ninja, the -C option can be
-be used to point at a directory to build.
+your configured backend to build the project in your build directory:
- ninja -C build/ +ninja -C build/
-Without arguments, it will produce libGL.so and/or several other libraries
-depending on the options you have chosen. Later, if you want to rebuild for a
-different configuration, you should run ninja clean
before
-changing the configuration, or create a new out of tree build directory for
-each configuration you want to build
-as
-recommended in the documentation
+The next step is to install the Mesa libraries, drivers, etc.
+This also finishes up some final steps of the build process (such as creating
+symbolic links for drivers). To install:
+ninja -C build/ install ++
-Autotools automatically updates translation files as part of the build process,
-meson does not do this. Instead if you want translated drirc files you will need
-to invoke non-default targets for ninja to update them:
-ninja -C build/ xmlpool-pot xmlpool-update-po xmlpool-gmo
+Note: autotools automatically updates 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 ++ +
Environment Variables
+Meson default to installing libGL.so in your system's main lib/ directory +and DRI drivers to a dri/ subdirectory. +
++Developers will often want to install Mesa to a testing directory rather +than the system library directory. +This can be done with the --prefix option. For example: +
+
+meson --prefix="${PWD}/build/install" build/
+
++will put the final libraries and drivers into the build/install/ +directory. +Then you can set LD_LIBRARY_PATH and LIBGL_DRIVERS_PATH to that location +to run/test the driver. +
+Meson supports the standard CC and CXX environment variables for changing the default compiler. Meson does support CFLAGS, CXXFLAGS, etc. But their use is discouraged because of the many caveats in using them. Instead it @@ -144,7 +210,7 @@ the popular compilers, a complete list is available
LLVM
Meson includes upstream logic to wrap llvm-config using its standard dependency interface.
buildtype
; setting the latter to
Meson supports cross-compilation by specifying a number of binary paths and