linux下使用交叉编译工具链编译Perl2
PCRE-Perl2交叉编译
PCRE下载
PCRE库有两个主要版本,目前正在持续更新的PCRE2 版本于 2015 年发布,目前已经到了 10.47 版本。
较旧但仍被广泛部署的 PCRE(Perl Compatible Regular Expressions)库最初发布于 1997 年,当前版本为 8.45。该版本的 PCRE 现已进入生命周期终结(End of Life, EOL)阶段,不再进行主动维护。
预计 8.45 将是原始 PCRE 库的最后一个正式版本。因此,新项目应使用 PCRE2(即 PCRE 的第二代版本),它提供了更现代的 API、更好的性能、更强的安全性以及持续的维护支持。
尽管如此,原始 PCRE(v8.x)仍在许多遗留系统和部分平台上广泛存在,包括某些出于兼容性考虑而继续沿用它的服务或发行版。在这些环境中,短期内可能仍需依赖 PCRE 8.x,但从长远来看,迁移到 PCRE2 是推荐的做法。
可以通过以下方式获取 PCRE 库的源代码:
PCRE2(推荐,当前活跃维护版本)
-
通过 Git 克隆源码:
git clone https://github.com/PCRE2Project/pcre2.git
注意:PCRE2 的所有官方发布和更新仅在 GitHub 上维护,不再同步到其他平台。
⚠️原始 PCRE(v8.x,已停止维护)
- 仅可通过非官方镜像下载(例如 SourceForge):
https://sourceforge.net/projects/pcre/files/
此版本已不再更新,仅适用于遗留系统兼容需求。
已弃用的资源
- 原官方 FTP 站点
ftp.pcre.org已永久关闭。 - SourceForge 不再同步 PCRE2 的新版本。
任何自动下载 PCRE 源代码的脚本(如构建或 CI 脚本)应改用 GitHub 的 HTTPS 或 Git 方式,例如:
# 推荐:从 GitHub 获取 PCRE2
wget https://github.com/PCRE2Project/pcre2/archive/refs/tags/pcre2-10.45.tar.gz
# 或
git clone --depth 1 --branch pcre2-10.45 https://github.com/PCRE2Project/pcre2.git
避免依赖已停用的 FTP 或过时的 SourceForge 链接,以确保构建的可靠性和安全性。
以下载的最新版本pcre2-10.47.tar.gz为例:
pcre2-10.47.tar.gz
#解压并进入libssh-0.10.6目录
tar -zxvf pcre2-10.47.tar.gz
cd pcre2-10.47/
编译说明
在非类 Unix 系统上构建 PCRE2
对于非类 Unix 系统,请阅读源码包中的 NON-AUTOTOOLS-BUILD 文件。
不过,如果您的系统支持 configure 和 make(例如某些类 Unix 环境),您仍可像在标准 Unix 系统上一样使用 autotools 构建 PCRE2。该文件也包含针对一些特殊 Unix 环境(如 EBCDIC 大型机)的构建说明。
PCRE2 也支持通过 CMake 进行配置,可通过命令行、图形界面等方式运行 CMake,生成 Makefile、Visual Studio 解决方案等。有关 CMake 的详细信息,请参阅 NON-AUTOTOOLS-BUILD 文件。
PCRE2 已在众多操作系统上成功编译。只要您的系统具备 C99 或更高版本的 C 编译器及标准库,通常都能顺利构建 PCRE2。
不使用 Autotools 构建 PCRE2
在某些环境(包括部分 Unix 或类 Unix 系统)中,autotools(尤其是 libtool)可能存在问题。请参考 NON-AUTOTOOLS-BUILD 文件,了解如何在不依赖 autotools 的情况下构建 PCRE2。
使用 Autotools 构建 PCRE2
以下说明基于广泛使用的 “configure; make; make install”(autotools)流程。
- 如果您下载的是 官方发布的 tarball(如
pcre2-10.xx.tar.gz),进入解压后的目录后,直接运行./configure即可。 - 如果您是从 GitHub 克隆的源码,则必须先运行
./autogen.sh脚本来生成configure脚本(需已安装 autotools 工具链)。
在非类 Unix 系统上构建 PCRE2
对于非类 Unix 系统,请阅读源码包中的 NON-AUTOTOOLS-BUILD 文件。
不过,如果您的系统支持 configure 和 make(例如某些类 Unix 环境),您仍可像在标准 Unix 系统上一样使用 autotools 构建 PCRE2。该文件也包含针对一些特殊 Unix 环境(如 EBCDIC 大型机)的构建说明。
PCRE2 也支持通过 CMake 进行配置,可通过命令行、图形界面等方式运行 CMake,生成 Makefile、Visual Studio 解决方案等。有关 CMake 的详细信息,请参阅 NON-AUTOTOOLS-BUILD 文件。
PCRE2 已在众多操作系统上成功编译。只要您的系统具备 C99 或更高版本的 C 编译器及标准库,通常都能顺利构建 PCRE2。
不使用 Autotools 构建 PCRE2
在某些环境(包括部分 Unix 或类 Unix 系统)中,autotools(尤其是 libtool)可能存在问题。请参考 NON-AUTOTOOLS-BUILD 文件,了解如何在不依赖 autotools 的情况下构建 PCRE2。
使用 Autotools 构建 PCRE2
以下说明基于广泛使用的 “configure; make; make install”(autotools)流程。
- 如果您下载的是 官方发布的 tarball(如
pcre2-10.xx.tar.gz),进入解压后的目录后,直接运行./configure即可。 - 如果您是从 GitHub 克隆的源码,则必须先运行
./autogen.sh脚本来生成configure脚本(需已安装 autotools 工具链)。
常见用法示例:
# 自定义编译选项和安装路径
CFLAGS='-O2 -Wall' ./configure --prefix=/opt/local
CFLAGS指定编译器标志;--prefix指定安装前缀(默认为/usr/local)。
异地构建(Out-of-tree build):
这会在 /build/pcre2 中生成所有构建文件,保持源码目录干净。
⚠️ 注意:PCRE2 是用 C 编写的,通常作为 C 库构建。虽然理论上可作为 C++ 库使用,但官方构建系统不提供专门支持。
可选构建特性(通过 configure 选项控制)
1. 静态/共享库
-
默认同时构建静态库(
.a)和共享库(.so/.dll)。 -
--disable-shared:仅构建静态库。 -
--disable-static:仅构建共享库。 -
若希望生成的工具(如 pcre2grep)完全静态链接:
LDFLAGS=--static ./configure --disable-shared需确保所有依赖库均有静态版本可用。
-
--disable-symvers:禁用共享库的符号版本控制(symbol versioning)。
2. 字符宽度支持
- 默认仅构建 8-bit 库(处理字节字符串)。
--enable-pcre2-16:启用 16-bit 库(处理 UTF-16)。--enable-pcre2-32:启用 32-bit 库(处理 UTF-32)。--disable-pcre2-8:禁用 8-bit 库(仅当不需要时使用)。
3. JIT(即时编译)加速
-
--enable-jit:启用 JIT 支持(显著提升匹配性能,但仅支持特定 CPU 架构)。 -
--enable-jit=auto:自动检测硬件是否支持 JIT。 -
在 SELinux 环境下,若需兼容可执行内存分配:
--enable-jit --enable-jit-sealloc⚠️ 警告:
--enable-jit-sealloc是实验性功能!不支持fork(),且磁盘空间不足时可能崩溃。
4. Unicode 支持
-
默认启用 Unicode(UTF-8/16/32)。
-
–disable-unicode:禁用 Unicode,减小库体积。
注意:
- 同一构建中所有库必须统一启用或禁用 Unicode;
- 启用
--enable-ebcdic时必须同时使用--disable-unicode。
即使启用了 Unicode,运行时仍需显式开启 UTF 模式(通过 PCRE2_UTF 选项或模式前缀 (*UTF))。
此外,\P、\p、\X 等 Unicode 属性序列仅在启用 Unicode 时有效。
5. 换行符处理
- 默认以 LF(
\n)为行结束符。 - 可通过以下选项更改默认行为:
--enable-newline-is-cr(CR)--enable-newline-is-lf(LF)--enable-newline-is-crlf(CRLF)--enable-newline-is-anycrlf(CR、LF、CRLF)--enable-newline-is-any(任意 Unicode 换行符)--enable-newline-is-nul(NUL 字符)
运行时可通过 API 覆盖此默认设置。
6. \R 行结束符匹配
- 默认
\R匹配任意 Unicode 行结束符。 --enable-bsr-anycrlf:限制\R仅匹配 CR、LF 或 CRLF。
7. 禁用 \C 转义序列
-
\C在 UTF 模式下会破坏多字节字符,存在风险。 -
--enable-never-backslash-C:彻底禁用\C。应用程序也可在调用
pcre2_compile()时传入PCRE2_NEVER_BACKSLASH_C临时禁用。
8. 资源限制(防止 DoS)
| 选项 | 默认值 | 说明 |
|---|---|---|
--with-parens-nest-limit=N |
250 | 模式中括号嵌套深度上限 |
--with-match-limit=N |
10,000,000 | 单次匹配的最大“匹配步数” |
--with-match-limit-depth=N |
10,000,000 | 回溯/函数调用嵌套深度上限 |
--with-heap-limit=N |
无限制 | 堆内存使用上限(单位:KiB,仅解释器模式生效) |
所有限制均可在运行时通过 API 覆盖。
9. 内部链接大小(Link Size)
- 8-bit 库默认使用 2 字节偏移量(最大模式约 64 KiB)。
--with-link-size=3或4:增大偏移量以支持更大模式(但会降低性能)。- 32-bit 库始终使用 4 字节偏移量,此选项无效。
10. 可变长度 Lookbehind 限制
-
默认最大可变 lookbehind 长度为 255 字符。
-
--with-max-varlookbehind=N:调整此限制。
固定长度 lookbehind 不受此限制。
11. 字符表(Character Tables)
-
默认使用内置 ASCII 表。
-
--enable-rebuild-chartables:构建时根据当前 locale 生成pcre2_chartables.c。在 EBCDIC 系统中通常需要此选项。
12. EBCDIC 支持
--enable-ebcdic --disable-unicode:为 EBCDIC 系统构建(必须禁用 Unicode)。--enable-ebcdic-nl25:指定 NL 字符为0x25(默认0x15)。--enable-ebcdic-ignoring-compiler:强制使用 EBCDIC 1047 编码表,忽略编译器代码页。
⚠️ 启用 EBCDIC 后,PCRE2 仅能处理 EBCDIC 数据,无法同时支持 ASCII/UTF。
13. 调试与测试支持
-
--enable-debug:包含额外调试代码(供维护者使用)。 -
--enable-valgrind:添加 Valgrind 内存注解,便于检测非法访问。 -
--enable-coverage:启用代码覆盖率分析(需 lcov + gcc,配合make coverage使用)。使用 ccache 时需设置
CCACHE_DISABLE=1。
14. pcre2grep 增强功能
- 自动启用 JIT(除非指定
--disable-pcre2grep-jit)。 --disable-pcre2grep-callout:禁用 callout 外部程序调用。--enable-pcre2grep-libz/--enable-pcre2grep-libbz2:支持读取.gz/.bz2压缩文件。--with-pcre2grep-bufsize=N:设置内部缓冲区初始大小(默认 20480 字节)。--with-pcre2grep-max-bufsize=N:设置缓冲区最大大小(默认 1048576 字节)。
15. pcre2test 交互增强
-
--enable-pcre2test-libreadline:启用 readline 支持(提供历史记录和行编辑)。 -
--enable-pcre2test-libedit:使用 BSD 许可的 libedit 替代 GPL 的 libreadline。若链接 readline 时报错缺少
tgetstr等函数,需额外链接-lncurses。
16. 格式化修饰符兼容性
- 默认在 C99 环境中使用
%zu/%td。 --disable-percent-zt:改用%lu并强制类型转换(用于不兼容 C99 的环境)。
17. 模糊测试(Fuzzing)支持
-
--enable-fuzz-support:构建libpcre2-fuzzsupport.a和pcre2fuzzcheck-{8,16,32}工具。用于与 AFL、libFuzzer 等模糊测试框架集成。
18. 递归栈优化(已废弃)
- 旧版
--disable-stack-for-recursion选项现已无效(因pcre2_match()已全面改用堆内存进行回溯)。
进入目录后,输入./configure -h即可得知相关编译选项。
configure文件说明
以下是每个配置选项的详细说明:
英文说明:
`configure' configures PCRE2 10.47 to adapt to many kinds of systems.
Usage: ./configure [OPTION]... [VAR=VALUE]...
To assign environment variables (e.g., CC, CFLAGS...), specify them as
VAR=VALUE. See below for descriptions of some of the useful variables.
Defaults for the options are specified in brackets.
Configuration:
-h, --help display this help and exit
--help=short display options specific to this package
--help=recursive display the short help of all the included packages
-V, --version display version information and exit
-q, --quiet, --silent do not print `checking ...' messages
--cache-file=FILE cache test results in FILE [disabled]
-C, --config-cache alias for `--cache-file=config.cache'
-n, --no-create do not create output files
--srcdir=DIR find the sources in DIR [configure dir or `..']
Installation directories:
--prefix=PREFIX install architecture-independent files in PREFIX
[/usr/local]
--exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
[PREFIX]
By default, `make install' will install all the files in
`/usr/local/bin', `/usr/local/lib' etc. You can specify
an installation prefix other than `/usr/local' using `--prefix',
for instance `--prefix=$HOME'.
For better control, use the options below.
Fine tuning of the installation directories:
--bindir=DIR user executables [EPREFIX/bin]
--sbindir=DIR system admin executables [EPREFIX/sbin]
--libexecdir=DIR program executables [EPREFIX/libexec]
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
--runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run]
--libdir=DIR object code libraries [EPREFIX/lib]
--includedir=DIR C header files [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc [/usr/include]
--datarootdir=DIR read-only arch.-independent data root [PREFIX/share]
--datadir=DIR read-only architecture-independent data [DATAROOTDIR]
--infodir=DIR info documentation [DATAROOTDIR/info]
--localedir=DIR locale-dependent data [DATAROOTDIR/locale]
--mandir=DIR man documentation [DATAROOTDIR/man]
--docdir=DIR documentation root [DATAROOTDIR/doc/pcre2]
--htmldir=DIR html documentation [DOCDIR]
--dvidir=DIR dvi documentation [DOCDIR]
--pdfdir=DIR pdf documentation [DOCDIR]
--psdir=DIR ps documentation [DOCDIR]
Program names:
--program-prefix=PREFIX prepend PREFIX to installed program names
--program-suffix=SUFFIX append SUFFIX to installed program names
--program-transform-name=PROGRAM run sed PROGRAM on installed program names
System types:
--build=BUILD configure for building on BUILD [guessed]
--host=HOST cross-compile to build programs to run on HOST [BUILD]
Optional Features:
--disable-option-checking ignore unrecognized --enable/--with options
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
--enable-silent-rules less verbose build output (undo: "make V=1")
--disable-silent-rules verbose build output (undo: "make V=0")
--enable-maintainer-mode
enable make rules and dependencies not useful (and
sometimes confusing) to the casual installer
--enable-dependency-tracking
do not reject slow dependency extractors
--disable-dependency-tracking
speeds up one-time build
--enable-shared[=PKGS] build shared libraries [default=yes]
--enable-static[=PKGS] build static libraries [default=yes]
--enable-fast-install[=PKGS]
optimize for fast installation [default=yes]
--disable-libtool-lock avoid locking (might break parallel builds)
--disable-largefile omit support for large files
--disable-symvers disable library symbol versioning [default=auto]
--disable-pcre2-8 disable 8 bit character support
--enable-pcre2-16 enable 16 bit character support
--enable-pcre2-32 enable 32 bit character support
--enable-debug enable debugging code
--enable-jit enable Just-In-Time compiling support
--enable-jit-sealloc enable SELinux compatible execmem allocator in JIT
(experimental)
--disable-pcre2grep-jit disable JIT support in pcre2grep
--disable-pcre2grep-callout
disable callout script support in pcre2grep
--disable-pcre2grep-callout-fork
disable callout script fork support in pcre2grep
--enable-rebuild-chartables
rebuild character tables in current locale
--disable-unicode disable Unicode support
--enable-newline-is-cr use CR as newline character
--enable-newline-is-lf use LF as newline character (default)
--enable-newline-is-crlf
use CRLF as newline sequence
--enable-newline-is-anycrlf
use CR, LF, or CRLF as newline sequence
--enable-newline-is-any use any valid Unicode newline sequence
--enable-newline-is-nul use NUL (binary zero) as newline character
--enable-bsr-anycrlf \R matches only CR, LF, CRLF by default
--enable-never-backslash-C
use of \C causes an error
--enable-ebcdic assume EBCDIC coding rather than ASCII; incompatible
with --enable-unicode; use only in (uncommon) EBCDIC
environments
--enable-ebcdic-nl25 set EBCDIC code for NL to 0x25 instead of 0x15; it
implies --enable-ebcdic
--enable-ebcdic-ignoring-compiler
force EBCDIC 1047 using numeric literals rather than
C character literals; it implies --enable-ebcdic
--enable-pcre2grep-libz link pcre2grep with libz to handle .gz files
--enable-pcre2grep-libbz2
link pcre2grep with libbz2 to handle .bz2 files
--enable-pcre2test-libedit
link pcre2test with libedit
--enable-pcre2test-libreadline
link pcre2test with libreadline
--enable-valgrind enable valgrind support
--enable-coverage enable code coverage reports using gcov
--enable-fuzz-support enable fuzzer support
--enable-diff-fuzz-support
enable differential fuzzer support
--disable-percent-zt disable the use of z and t formatting modifiers
--enable-Werror Add -Werror to CFLAGS (GCC/Clang style); if -Werror
is passed to ./configure via CFLAGS it interferes
with feature detection
--enable-errwarn Add -errwarn=%all to CFLAGS (Sun cc style)
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
--with-pic[=PKGS] try to use only PIC/non-PIC objects [default=use
both]
--with-aix-soname=aix|svr4|both
shared library versioning (aka "SONAME") variant to
provide on AIX, [default=aix].
--with-gnu-ld assume the C compiler uses GNU ld [default=no]
--with-sysroot[=DIR] Search for dependent libraries within DIR (or the
compiler's sysroot if not specified).
--with-pcre2grep-bufsize=N
pcre2grep initial buffer size (default=20480,
minimum=8192)
--with-pcre2grep-max-bufsize=N
pcre2grep maximum buffer size (default=1048576,
minimum=8192)
--with-link-size=N internal link size (2, 3, or 4 allowed; default=2)
--with-max-varlookbehind=N
maximum length of variable lookbehind (default=255)
--with-parens-nest-limit=N
nested parentheses limit (default=250)
--with-heap-limit=N default limit on heap memory (kibibytes,
default=20000000)
--with-match-limit=N default limit on internal looping (default=10000000)
--with-match-limit-depth=N
default limit on match tree depth
(default=MATCH_LIMIT)
Some influential environment variables:
CC C compiler command
CFLAGS C compiler flags
LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
nonstandard directory <lib dir>
LIBS libraries to pass to the linker, e.g. -l<library>
CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
you have headers in a nonstandard directory <include dir>
LT_SYS_LIBRARY_PATH
User-defined run-time library search path.
CPP C preprocessor
PKG_CONFIG path to pkg-config utility
PKG_CONFIG_PATH
directories to add to pkg-config's search path
PKG_CONFIG_LIBDIR
path overriding pkg-config's built-in search path
VALGRIND_CFLAGS
C compiler flags for VALGRIND, overriding pkg-config
VALGRIND_LIBS
linker flags for VALGRIND, overriding pkg-config
LCOV the ltp lcov program
GENHTML the ltp genhtml program
Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.
Report bugs to the package provider.
中文说明:
`configure' 用于配置 PCRE2 10.47,使其适应多种系统。
用法:./configure [选项]... [变量=值]...
要设置环境变量(例如 CC、CFLAGS 等),请以 VAR=VALUE 的形式指定。下方列出了一些有用变量的说明。
选项的默认值在方括号中注明。
配置选项:
-h, --help 显示此帮助信息并退出
--help=short 显示本软件包特有的选项
--help=recursive 显示所有包含软件包的简短帮助
-V, --version 显示版本信息并退出
-q, --quiet, --silent 不打印“checking ...”消息
--cache-file=FILE 文件 将测试结果缓存到文件中 [禁用]
-C, --config-cache --cache-file=config.cache 的别名
-n, --no-create 不创建输出文件
--srcdir=DIR 在指定目录中查找源码 [configure 所在目录或其上一级]
安装目录:
--prefix=PREFIX 将与体系结构无关的文件安装到 PREFIX [/usr/local]
--exec-prefix=EPREFIX 将与体系结构相关的文件安装到 EPREFIX [PREFIX]
默认情况下,“make install”会将所有文件安装到 /usr/local/bin、/usr/local/lib 等目录。
您可以使用 --prefix 指定不同于 /usr/local 的安装前缀,例如 --prefix= $ HOME。
如需更精细的控制,请使用以下选项。
安装目录的精细调整:
--bindir=DIR 用户可执行程序 [EPREFIX/bin]
--sbindir=DIR 系统管理员可执行程序 [EPREFIX/sbin]
--libexecdir=DIR 程序可执行文件 [EPREFIX/libexec]
--sysconfdir=DIR 只读的单机数据 [PREFIX/etc]
--sharedstatedir=DIR 可修改的、与体系结构无关的数据 [PREFIX/com]
--localstatedir=DIR 可修改的单机数据 [PREFIX/var]
--runstatedir=DIR 可修改的每进程数据 [LOCALSTATEDIR/run]
--libdir=DIR 目标代码库 [EPREFIX/lib]
--includedir=DIR C 头文件 [PREFIX/include]
--oldincludedir=DIR 非 GCC 使用的 C 头文件 [/usr/include]
--datarootdir=DIR 只读的、与体系结构无关的数据根目录 [PREFIX/share]
--datadir=DIR 只读的、与体系结构无关的数据 [DATAROOTDIR]
--infodir=DIR info文档 [DATAROOTDIR/info]
--localedir=DIR 本地化相关数据 [DATAROOTDIR/locale]
--mandir=DIR 手册文档 [DATAROOTDIR/man]
--docdir=DIR 文档根目录 [DATAROOTDIR/doc/pcre2]
--htmldir=DIR HTML 文档 [DOCDIR]
--dvidir=DIR DVI 文档 [DOCDIR]
--pdfdir=DIR PDF 文档 [DOCDIR]
--psdir=DIR PS 文档 [DOCDIR]
程序名称:
--program-prefix=PREFIX 为已安装的程序名添加前缀 PREFIX
--program-suffix=SUFFIX 为已安装的程序名添加后缀 SUFFIX
--program-transform-name=PROGRAM 对已安装的程序名运行 sed PROGRAM
系统类型:
--build=BUILD 配置在 BUILD 上进行构建 [自动检测]
--host=HOST 交叉编译,生成在 HOST 上运行的程序 [BUILD]
可选功能:
--disable-option-checking 忽略无法识别的 --enable/--with 选项
--disable-FEATURE 不包含 FEATURE(等同于 --enable-FEATURE=no)
--enable-FEATURE[=ARG] 包含 FEATURE [ARG=yes]
--enable-silent-rules 构建输出更简洁(取消:make V=1)
--disable-silent-rules 构建输出更详细(取消:make V=0)
--enable-maintainer-mode
启用对普通安装者无用(有时会造成混淆)的 make 规则和依赖项
--enable-dependency-tracking
不拒绝较慢的依赖提取器
--disable-dependency-tracking
加快一次性构建速度
--enable-shared[=PKGS] 构建共享库 [default=yes]
--enable-static[=PKGS] 构建静态库 [default=yes]
--enable-fast-install[=PKGS]
优化以加快安装速度 [default=yes]
--disable-libtool-lock 避免锁定(可能破坏并行构建)
--disable-largefile 省略对大文件的支持
--disable-symvers 禁用库符号版本控制 [default=auto]
--disable-pcre2-8 禁用 8 位字符支持
--enable-pcre2-16 启用 16 位字符支持
--enable-pcre2-32 启用 32 位字符支持
--enable-debug 启用调试代码
--enable-jit 启用即时编译(JIT)支持
--enable-jit-sealloc 在 JIT 中启用 SELinux 兼容的 execmem 分配器(实验性)
--disable-pcre2grep-jit 禁用 pcre2grep 中的 JIT 支持
--disable-pcre2grep-callout
禁用 pcre2grep 中的 callout 脚本支持
--disable-pcre2grep-callout-fork
禁用 pcre2grep 中的 callout 脚本 fork 支持
--enable-rebuild-chartables
在当前 locale 下重建字符表
--disable-unicode 禁用 Unicode 支持
--enable-newline-is-cr 使用 CR 作为换行符
--enable-newline-is-lf 使用 LF 作为换行符(default)
--enable-newline-is-crlf
使用 CRLF 作为换行序列
--enable-newline-is-anycrlf
使用 CR、LF 或 CRLF 作为换行序列
--enable-newline-is-any 使用任意有效的 Unicode 换行序列
--enable-newline-is-nul 使用 NUL(二进制零)作为换行符
--enable-bsr-anycrlf \R 默认仅匹配 CR、LF、CRLF
--enable-never-backslash-C
使用 \C 会导致错误
--enable-ebcdic 假设使用 EBCDIC 编码而非 ASCII;与 --enable-unicode 不兼容;
仅用于(罕见的)EBCDIC 环境
--enable-ebcdic-nl25 将 EBCDIC 中 NL 的编码设为 0x25 而非 0x15;隐含 --enable-ebcdic
--enable-ebcdic-ignoring-compiler
强制使用 EBCDIC 1047,通过数值字面量而非 C 字符字面量;
C隐含 --enable-ebcdic
--enable-pcre2grep-libz 将 pcre2grep 与 libz 链接以处理 .gz 文件
--enable-pcre2grep-libbz2
将 pcre2grep 与 libbz2 链接以处理 .bz2 文件
--enable-pcre2test-libedit
将 pcre2test 与 libedit 链接
--enable-pcre2test-libreadline
将 pcre2test 与 libreadline 链接
--enable-valgrind 启用 valgrind 支持
--enable-coverage 启用使用 gcov 的代码覆盖率报告
--enable-fuzz-support 启用模糊测试支持
--enable-diff-fuzz-support
启用差异模糊测试支持
--disable-percent-zt 禁用 z 和 t 格式修饰符的使用
--enable-Werror 在 CFLAGS 中添加 -Werror(适用于 GCC/Clang);
如果通过 CFLAGS 向 ./configure 传递 -Werror,会干扰特性检测
--enable-errwarn 在 CFLAGS 中添加 -errwarn=%all(适用于 Sun cc)
可选软件包:
--with-PACKAGE[=ARG] 使用 PACKAGE [ARG=yes]
--without-PACKAGE 不使用 PACKAGE(等同于 --with-PACKAGE=no)
--with-pic[=PKGS] 尝试仅使用 PIC/non-PIC 对象 [default=use both]
--with-aix-soname=aix|svr4|both
在 AIX 上提供的共享库版本(即“SONAME”)变体 [default=aix]
--with-gnu-ld 假设 C 编译器使用 GNU ld [default=no]
--with-sysroot[=DIR] 在 DIR 内(或编译器的 sysroot,若未指定)搜索依赖库
--with-pcre2grep-bufsize=N
pcre2grep 初始缓冲区大小 (default=20480,minimum=8192)
--with-pcre2grep-max-bufsize=N
pcre2grep 最大缓冲区大小 (default=1048576,minimum=8192)
--with-link-size=N 内部链接大小(允许 2、3 或 4;default=2)
--with-max-varlookbehind=N
可变长 lookbehind 的最大长度(default=255)
--with-parens-nest-limit=N
嵌套括号层数限制 (default=250)
--with-heap-limit=N 堆内存默认限制 (单位:kibibytes,default=20000000)
--with-match-limit=N 内部循环默认限制 (default=10000000)
--with-match-limit-depth=N
匹配树深度默认限制
(default=MATCH_LIMIT)
一些有影响的环境变量:
CC C 编译器命令
CFLAGS C 编译器标志
LDFLAGS 链接器标志,例如当库位于非标准目录 时使用 -L
LIBS 传递给链接器的库,例如 -l
CPPFLAGS (Objective) C/C++ 预处理器标志,例如当头文件位于非标准目录 时使用 -I
LT_SYS_LIBRARY_PATH
用户定义的运行时库搜索路径
CPP C 预处理器
PKG_CONFIG pkg-config 工具的路径
PKG_CONFIG_PATH
添加到 pkg-config 搜索路径的目录
PKG_CONFIG_LIBDIR
覆盖 pkg-config 内置搜索路径的路径
VALGRIND_CFLAGS
VALGRIND 的 C 编译器标志,覆盖 pkg-config 的设置
VALGRIND_LIBS
VALGRIND 的链接器标志,覆盖 pkg-config 的设置
LCOV ltp lcov 程序
GENHTML ltp genhtml 程序
使用这些变量可覆盖 configure 的选择,或帮助它找到具有非标准名称/位置的库和程序。
请向软件包提供者报告 bug。
PCRE-perl2的交叉编译
通过以上配置说明,可以根据我们的需求编译出perl库。
以龙芯交叉编译工具进行说明,Linux平台下编译,编译为静态库,工具链路径:
/opt/loongson-gnu-toolchain-13.2/bin
静态库存放路径:
/root/workspace/lib_libary
那么配置configure时输入以下指令后直接make即可进行编译:
#按照configure进行配置
./configure --host=loongarch64-unknown-linux-gnu --prefix=/root/workspace/lib_libary CC=/opt/loongson-gnu-toolchain-13.2/bin/loongarch64-unknown-linux-gnu-gcc --disable-shared
#执行make指令编译
make
make install
编译完成并安装后,会在目录/root/workspace/lib_libary下会生成如下文件夹:
cd /root/workspace/svn_code/lib_libary
ls
bin include lib share
其中编译好的静态库会在lib文件夹下,由于没有编译动态库,所以没有动态库文件。
清理编译内容:
make clean
更多推荐
所有评论(0)