From 73b594851aaf5cee291f805b50bf565334d44c2c Mon Sep 17 00:00:00 2001 From: Fred Morcos Date: Mon, 3 Aug 2026 21:40:27 +0200 Subject: [PATCH] meson: pcre --- meson.build | 1 + meson.options | 1 + meson/pcre/meson.build | 25 +++++++++++++++++++++++++ 3 files changed, 27 insertions(+) create mode 100644 meson/pcre/meson.build diff --git a/meson.build b/meson.build index 714134631e..cf4a78fa5b 100644 --- a/meson.build +++ b/meson.build @@ -130,6 +130,7 @@ subdir('meson' / 'ssl') subdir('meson' / 'iconv') subdir('meson' / 'zlib') subdir('meson' / 'sodium') +subdir('meson' / 'pcre') dovecot_moduledir = get_option('moduledir') if dovecot_moduledir == '' diff --git a/meson.options b/meson.options index 0ff2937545..fa7280b4e5 100644 --- a/meson.options +++ b/meson.options @@ -14,3 +14,4 @@ option('random-source', type: 'string', value : '/dev/urandom', description: 'De option('ioloop', type: 'combo', choices: ['best', 'epoll', 'kqueue', 'poll', 'select'], value: 'best', description: 'I/O loop method to use (best for the fastest available)') option('notify', type: 'combo', choices: ['best', 'inotify', 'kqueue', 'none'], value: 'best', description: 'File system notification method to use (best for the fastest available)') option('sodium', type: 'feature', value: 'auto', description: 'Build with libsodium support (enables argon2)') +option('pcre', type: 'feature', value: 'auto', description: 'Build with libpcre2 support (enables regular expressions)') diff --git a/meson/pcre/meson.build b/meson/pcre/meson.build new file mode 100644 index 0000000000..6acc13b5d3 --- /dev/null +++ b/meson/pcre/meson.build @@ -0,0 +1,25 @@ +opt_pcre = get_option('pcre') +ext_pcre = dependency('libpcre2-32', required: opt_pcre) + +conf.set( + 'HAVE_LIBPCRE', + ext_pcre.found(), + description: 'Have libpcre2 backed regular expressions', +) + +if ext_pcre.found() + # pcre2.h needs PCRE2_CODE_UNIT_WIDTH before it will declare anything; 0 asks for the + # width-agnostic names. + conf.set( + 'HAVE_PCRE2_SUBSTITUTE_CALLOUT_BLOCK', + cc.has_header_symbol( + 'pcre2.h', + 'pcre2_substitute_callout_block', + prefix: '#define PCRE2_CODE_UNIT_WIDTH 0', + dependencies: ext_pcre, + ), + description: 'Have pcre2_substitute_callout_block', + ) +endif + +summary({'PCRE': ext_pcre}, section: 'Features')