PostgreSQL 18 中文参考文档(未翻译部分保留英文)🌐 切换到英文原版 →

17.4. 使用 Meson 构建 #

17.4.1. 快速上手
17.4.2. 详细步骤
17.4.3. Meson 构建选项
17.4.4. Meson 构建目标

官方推荐的现代化超高速构建系统,支持跨平台编译与原生 Windows 支持。

17.4.1. 快速上手 #

使用 Meson 与 Ninja 快速编译:

meson setup build --prefix=/usr/local/pgsql
ninja -C build
ninja -C build install

17.4.2. 详细步骤 #

  1. 配置构建目录

    运行 meson setup build。

  2. 并发编译

    运行 ninja -C build。

  3. 执行安装

    运行 ninja -C build install。

17.4.3. Meson 构建选项 #

17.4.3.1. 路径选项 #

--prefix #

主安装目录路径。

--bindir #

二进制安装路径。

--sysconfdir #

系统配置路径。

--libdir #

共享库目录。

--includedir #

头文件目录。

--datadir #

数据目录。

--localedir #

本地化语言目录。

--mandir #

手册目录。

17.4.3.2. 特性配置选项 #

-Dnls=enabled #

启用多语言支持。

-Dplperl=enabled #

启用 PL/Perl。

-Dplpython=enabled #

启用 PL/Python。

-Dpltcl=enabled #

启用 PL/Tcl。

-Dtcl_version=... #

指定 Tcl 版本。

-Dicu=enabled #

启用 ICU 支持。

-Dllvm=enabled #

启用 LLVM JIT 支持。

-Dlz4=enabled #

启用 LZ4 压缩支持。

-Dzstd=enabled #

启用 Zstandard 压缩支持。

-Dssl=openssl #

启用 SSL/TLS 支持。

-Dgssapi=enabled #

启用 GSSAPI 认证支持。

-Dldap=enabled #

启用 LDAP 认证支持。相关链接配置。

-Dpam=enabled #

启用 PAM 认证支持。

-Dbsd_auth=enabled #

启用 BSD 认证支持。

-Dsystemd=enabled #

启用 systemd 支持。

-Dbonjour=enabled #

启用 Bonjour 支持。

-Duuid=... #

指定 UUID 提供程序。

-Dlibcurl=enabled #

启用 libcurl 支持。

-Dliburing=enabled #

启用 io_uring 支持。

-Dlibnuma=enabled #

启用 NUMA 支持。

-Dlibxml=enabled #

启用 XML 解析支持。

-Dlibxslt=enabled #

启用 XSLT 支持。

-Dsepgsql=enabled #

启用 SELinux 支持。

17.4.3.3. 禁用特性选项 #

-Dreadline=disabled #

禁用 Readline 库。

-Dlibedit_preferred=true #

优先使用 libedit。

-Dzlib=disabled #

禁用 zlib。

17.4.3.4. 构建过程选项 #

-Dauto_features=... #

自动探测特性配置。

-Dbackend=... #

指定构建后端类型。

-Dc_args=... #

传递给 C 编译器的额外参数。

传递给链接器的额外参数。

-Dextra_include_dirs=... #

额外包含目录。

-Dextra_lib_dirs=... #

额外动态库目录。

-Dsystem_tzdata=... #

使用系统时区数据。

-Dextra_version=... #

版本字符串后缀。

-Drpath=... #

运行期共享库路径。

-Dbinary_name=... #

可执行文件重命名。

17.4.3.5. 文档构建选项 #

-Ddocs=... #

构建全部参考文档。

-Ddocs_pdf=... #

构建 PDF 格式文档。

-Ddocs_html_style=... #

HTML 网页样式设置。

17.4.3.6. 杂项配置选项 #

-Dpgport=... #

默认端口配置。

-Dkrb_srvnam=... #

Kerberos 服务名。

-Dsegsize=... #

数据段物理大小。

-Dblocksize=... #

数据块页面大小。

-Dwal_blocksize=... #

WAL 日志块尺寸。

17.4.3.7. 开发与调试选项 #

-Dbuildtype=... #

构建类型(debug、release 等)。

-Ddebug=... #

开启调试符号。

-Doptimization=... #

编译器优化级别。

-Dwerror=... #

将所有编译警告视为致命错误。

-Dcassert=... #

启用 C 语言断言检查。

-Dtap_tests=... #

启用 TAP 自动化回归测试。

-Dpg_test_extra=... #

运行额外的扩展测试套件。

-Db_coverage=... #

生成代码覆盖率分析报告。

-Ddtrace=... #

启用 DTrace 探测点。

-Dinjection_points=... #

启用错误注入测试点。

-Dsegsize_blocks=... #

按数据块数设置段大小。

17.4.4. Meson 构建目标 #

17.4.4.1. Code Targets #

all #

Build everything other than documentation

backend #

Build backend and related modules

bin #

Build frontend binaries

contrib #

Build contrib modules

pl #

Build procedural languages

17.4.4.2. Developer Targets #

reformat-dat-files #

Rewrite catalog data files into standard format

expand-dat-files #

Expand all data files to include defaults

update-unicode #

Update unicode data to new version

17.4.4.3. Documentation Targets #

html #

Build documentation in multi-page HTML format

man #

Build documentation in man page format

docs #

Build documentation in multi-page HTML and man page format

doc/src/sgml/postgres-A4.pdf #

Build documentation in PDF format, with A4 pages

doc/src/sgml/postgres-US.pdf #

Build documentation in PDF format, with US letter pages

doc/src/sgml/postgres.html #

Build documentation in single-page HTML format

alldocs #

Build documentation in all supported formats

17.4.4.4. Installation Targets #

install #

Install postgres, excluding documentation

install-docs #

Install documentation in multi-page HTML and man page formats

install-html #

Install documentation in multi-page HTML format

install-man #

Install documentation in man page format

install-quiet #

Like "install", but installed files are not displayed

install-world #

Install postgres, including multi-page HTML and man page documentation

uninstall #

Remove installed files

17.4.4.5. Other Targets #

clean #

Remove all build products

test #

Run all enabled tests (including contrib)

world #

Build everything, including documentation

help #

List important targets