Meson Packaging Guidelines
This document provides best practices for the usage of the Meson build system in Fedora packages. Meson is a build system (similar to automake) which can generate code for other lower-level build systems. For example, it can generate code for ninja. When packaging software which builds using Meson it’s important to use the %meson macros instead of %ninja or other lower-level build system macros directly. The backend used by Meson could change.
Available Macros
You will generally make use of these in your specs:
%meson-
Defines CFLAGS, LDFLAGS, etc. and calls
%__mesonwith appropriate parameters (--libdir=%{_libdir}and such). You can pass-Doption=valueto this macro in order to set options for the buildsystem. %meson_build-
An alias for
%ninja_build -C %{_vpath_builddir}. %meson_install-
An alias for
%ninja_install -C %{_vpath_builddir}. %meson_test-
An alias for
%ninja_test -C %{_vpath_builddir}.
It is rarely necessary (but permissible) to use or alter these:
%__meson-
The path to the meson executable
Also see Defining source and build directories.
Example RPM spec file
%global _vpath_srcdir sdk/%{name}/projects/meson
Name: angelscript
Version: 2.31.1
Release: 1%{?dist}
Summary: Flexible cross-platform scripting library
License: zlib
URL: https://www.angelcode.com/angelscript/
Source: %{url}sdk/files/%{name}_%{version}.zip
BuildRequires: meson
BuildRequires: gcc
%package devel
Summary: Development libraries and header files for %{name}
Requires: %{name}%{?_isa} = %{?epoch:%{epoch}:}%{version}-%{release}
%description devel
%{summary}.
%prep
%autosetup -c
%conf
%meson
%build
%meson_build
%install
%meson_install
%check
%meson_test
%files
%{_libdir}/lib%{name}.so.*
%files devel
%{_libdir}/lib%{name}.so
%{_includedir}/%{name}.h
NOTE: If building for < EPEL 10 then %meson should be in %build.
Want to help? Learn how to contribute to Fedora Docs ›