When PostgreSQL is built with
Meson, it installs a
pkg-config file named
postgresql-20-extension.pc. It provides
the same compilation flags that are used to build the server itself, so
that extensions can be built with Meson
against a given PostgreSQL installation. It is
also used internally to emit LLVM JIT
bitcode for the server and for selected contrib
modules.
The file is versioned by major release, so an extension can build against a specific PostgreSQL major version. It offers a Meson-based alternative to PGXS (Section 36.19), which uses make.
To use the
postgresql-20-extension.pc
infrastructure for your extension, you must write a simple
meson.build file. In the
meson.build file, you need to include the
postgresql-20-extension.pc
pkg-config file. Here is an example that builds an
extension module named isbn_issn, consisting of a
shared library containing some C code, an extension control file, an
SQL script, an include file (only needed if other
modules might need to access the extension functions without going via
SQL), and a documentation text file:
project('isbn_issn', 'c')
pg_ext = dependency('postgresql-20-extension-warnings')
isbn_issn_sources = files('isbn_issn.c')
isbn_issn = shared_module('isbn_issn',
isbn_issn_sources,
dependencies: pg_ext,
install_dir: pg_ext.get_variable(pkgconfig: 'dir_mod'),
)
install_data(
'isbn_issn.control',
'isbn_issn--1.0.sql',
install_dir: pg_ext.get_variable(pkgconfig: 'dir_data'),
)
install_headers(
'isbn_issn.h',
install_dir: pg_ext.get_variable(pkgconfig: 'dir_include'),
)
install_data(
'README.isbn_issn',
install_dir: pg_ext.get_variable(pkgconfig: 'dir_doc'),
)