|description||old command||new command||comment|
|set up build tree||./configure [<options>]||meson setup [<options>] [<build dir>] <source-dir>||meson only supports building out of tree|
|set up build tree for visual studio||perl src/tools/msvc/mkvcbuild.pl||meson setup --backend vs [<options>] [<build dir>] <source-dir>||configures build tree for one build type (debug or release or ...)|
|show configure options||./configure --help||meson configure||shows options built into meson and PostgreSQL specific options|
|set configure options||./configure --prefix=DIR, --$somedir=DIR, --with-$option, --enable-$feature||meson setup|configure -D$option=$value||options can be set when setting up build tree (setup) and in existing build tree (configure)|
|enable debug symbols||./configure --enable-debug||meson configure|setup -Ddebug=true|
|specify compiler||CC=compiler ./configure||CC=compiler meson setup||CC is only checked during meson setup, not with meson configure|
|set CFLAGS||CFLAGS=options ./configure||meson configure|setup -Dc_args=options||CFLAGS is also checked, but only for meson setup|
|build||make -s||ninja||ninja uses parallelism by default, launch from the root of the build tree.|
|build, showing compiler commands||make||ninja -v||ninja uses parallelism by default, launch from the root of the build tree.|
|install all the binaries and libraries||make install||ninja install||use meson install --quiet for a less verbose experience|
|clean build||make clean||ninja clean||ninja uses parallelism by default, launch from the root of the build tree.|
|run all tests||make check-world||meson test||runs all test, using parallelism by default|
|build documentation||cd doc/ && make html && make man||ninja docs||Builds html documentation and man pages|
|run main regression tests||make check||meson test --suite setup --suite regress|
|list tests||meson test --list|
PostgreSQL devel documentation
ninja tries to run from the root of the build directory. If you are not in the build directory, you can use the "-C" flag to have ninja "change directory" and run from there, e.g.:
ninja -C $builddir
Debian / Ubuntu:
apt-get update && apt-get install -y meson ninja-build
dnf -y install meson ninja-build
dnf -y install dnf-plugins-core dnf config-manager --set-enabled powertools dnf -y install meson ninja-build
RHEL 9 (tested on Rocky Linux 9):
dnf -y install dnf-plugins-core dnf config-manager --set-enabled crb dnf -y install meson
sudo port install meson
Arguments to meson setup/configure to find MacPorts libraries:
meson setup -Dpkg_config_path=/opt/local/lib/pkgconfig -Dextra_lib_dirs=/opt/local/lib/ -Dextra_include_dirs=/opt/local/include $builddir $sourcedir
brew install meson
Arguments to meson setup/configure to find Homebrew libraries:
meson setup -Dpkg_config_path=/opt/homebrew/lib/pkgconfig -Dextra_include_dirs=/opt/homebrew/include -Dextra_lib_dirs=/opt/homebrew/lib $builddir $sourcedir
meson setup -Dpkg_config_path=/usr/local/lib/pkgconfig -Dextra_include_dirs=/usr/local/include -Dextra_lib_dirs=/usr/local/lib $builddir $sourcedir
Assuming python is installed, the easiest way to get meson and ninja is:
pip install meson ninja
Why and What
Autoconf is showing its age, fewer and fewer contributors know how to wrangle it. Recursive make has a lot of hard to resolve dependency issues and slow incremental rebuilds. Our home-grown MSVC buildsystem is hard to maintain for developers not using windows and runs tests serially. While these and other issues could individually be addressed with incremental improvements, together they seem best addressed by moving to a more modern buildsystem.
After evaluating different buildsystem choices, we chose to use meson, to a good degree based on the adoption by other open source projects.
We decided that it's more realistic to commit a relatively early version of the new buildsystem and mature it in tree.
The plan is to remove the msvc specific buildsystem in src/tools/msvc soon after reaching feature parity. However, we're not planning to remove the autoconf/make buildsystem in the near future. Likely we're going to keep at least the parts required for PGXS to keep working around until all supported versions build with meson.
Development tree, other resources
When building with ninja, the generated .ninja_log can be uploaded to ui.perfetto.dev, which is very helpful to visualize builds.