This wiki was updated to MediaWiki 1.37. If you notice any issues, please report them to admin[at]

openSUSE:Build system recipes

Jump to: navigation, search

Whatever is about packaging should go to this category.


This page provides a cheat sheet of sorts for what code you need in .spec files to get a common software package with a particular build system built in a standardized fashion.

Build system in this context refers to the tools creating Makefiles and/or calling the compilers, not the Open Build Service system.

N.B.: Here is also some background statistics on build system preference for software in openSUSE.


RPM ships a number of convenience macros directly. The base recipe is:


The %configure macro will set CFLAGS, CXXFLAGS, FFLAGS to %optflags if they have not been previously set. To add in your own flags, put on a line before %configure:

export CPPFLAGS="-Dpreprocessor_options -Ihere"
export CFLAGS="%optflags -fwhatever"
export CXXFLAGS="%optflags -fwhateverplusplus"

(There is generally no need to switch to `./configure`!)

%make_build is a macro that is available starting rpm-4.12. It is equivalent to `make %{?_smp_mflags}`.

%make_install is a macro available starting rpm-4.10. It is equivalent to `make install DESTDIR="%{?buildroot}"`.

Avoid using %makeinstall (note: no underscore). That macro increases chances that badly-written software fails at installation. (For details, see [1].)

You can also use a separate build directory, for fun and profit (and finding software that fails to cope with it) [also not available on SLE11]:

%define _configure ../configure
mkdir obj
pushd obj/

%make_install -C obj


Using autoconf without automake in upstream software often has a lot of unexpected nasty surprises when hand-crafted Makefiles are used — most common errors are that variable assignment is not respected (e.g. setting CFLAGS killing important flags that render the product not compilable), and failure to pass flags to commands (e.g. not passing CPPFLAGS when invoking the CC command).

This may not apply, or only apply somewhat, or not apply, when Makefiles are autogenerated by another software (e.g. `scons autotools`). In any case, autoconf without automake is highly susceptible to bugs, hence no single recipe can cover significant ground. If the Makefiles reasonably behave like automake, see the automake section above.


Starting with openSUSE-13.1[2], the distribution provides a %cmake macro, sourced from /etc/rpm/macros.cmake (BuildRequires: cmake) that should set up the basic values for your need so the basic part should look like this:

%cmake \



You can also override few variables to get behaviour you want from cmake:

# build in someotherfolder rather than in build directory
%define __builddir someotherfolder
# use ninja instead of make
%define __builder ninja

Unfortunately, CMakeLists.txt files allow for many freedoms, so much that some software may just ignore some parameters. If that happens, perhaps some of the following extra flags may also need to be specified:

-DCMAKE_LD_FLAGS(:STRING)="-Wl,-z -Wl,defs"

There is also a cmake bug: Not specifying the :TYPE portion can lead to the portion after the '=' being ignored at times.

python (

See also: openSUSE:Packaging Python




%pyunittest -v

%files %python_files


The no-frills boilerplate:

qmake-qt5 QMAKE_CFLAGS+="%optflags" QMAKE_CXXFLAGS+="%optflags" QMAKE_STRIP="/bin/true"
%make_build / make %{?_smp_mflags} as with automake (see above)

make install INSTALL_ROOT="%buildroot"

qmake can be found in the package libqt5-qtbase-devel.

For everything else

See for when there is a macro or other dedicated instructions (Perl, Python, ...)