From b9001a654dd97ea63572ff52ab43caa60be4fc19 Mon Sep 17 00:00:00 2001
From: Nazir Bilal Yavuz <byavuz81@gmail.com>
Date: Sat, 29 Nov 2025 19:06:28 +0300
Subject: [PATCH v3 3/3] meson: Add icu_flags option

---
 src/makefiles/meson.build        | 4 ++--
 meson_options.txt                | 3 +++
 src/tools/pginclude/headerscheck | 2 +-
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/makefiles/meson.build b/src/makefiles/meson.build
index 3c732a94653..5046e9cb496 100644
--- a/src/makefiles/meson.build
+++ b/src/makefiles/meson.build
@@ -116,6 +116,8 @@ pgxs_kv = {
   'BITCODE_CFLAGS': '',
   'BITCODE_CXXFLAGS': '',
 
+  'ICU_CFLAGS': get_option('icu_cflags'),
+
   'BISONFLAGS': ' '.join(bison_flags),
   'FLEXFLAGS': ' '.join(flex_flags),
 
@@ -155,8 +157,6 @@ pgxs_bins = {
 }
 
 pgxs_empty = [
-  'ICU_CFLAGS', # needs to be added, included by public server headers
-
   # hard to see why we'd need either?
   'ZIC',
   'TCLSH',
diff --git a/meson_options.txt b/meson_options.txt
index 06bf5627d3c..ca79e117d09 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -70,6 +70,9 @@ option('darwin_sysroot', type: 'string', value: '',
 option('rpath', type: 'boolean', value: true,
   description: 'Embed shared library search path in executables')
 
+option('icu_cflags', type: 'string', value: '',
+  description: 'C compiler flags for ICU, overriding pkg-config')
+
 
 # External dependencies
 
diff --git a/src/tools/pginclude/headerscheck b/src/tools/pginclude/headerscheck
index a96a462a5ef..1a589e4b13c 100755
--- a/src/tools/pginclude/headerscheck
+++ b/src/tools/pginclude/headerscheck
@@ -44,7 +44,7 @@ CXXFLAGS=${CXXFLAGS:- -fsyntax-only -Wall}
 MGLOB="$builddir/src/Makefile.global"
 CPPFLAGS=`sed -n 's/^CPPFLAGS[ 	]*=[ 	]*//p' "$MGLOB"`
 CFLAGS=`sed -n 's/^CFLAGS[ 	]*=[ 	]*//p' "$MGLOB"`
-ICU_CFLAGS=`sed -n 's/^ICU_CFLAGS[ 	]*=[ 	]*//p' "$MGLOB"`
+ICU_CFLAGS=`sed -n 's/^ICU_CFLAGS[[:space:]]*=[[:space:]]*//p' "$MGLOB"`
 CC=`sed -n 's/^CC[ 	]*=[ 	]*//p' "$MGLOB"`
 CXX=`sed -n 's/^CXX[ 	]*=[ 	]*//p' "$MGLOB"`
 PG_SYSROOT=`sed -n 's/^PG_SYSROOT[ 	]*=[ 	]*//p' "$MGLOB"`
-- 
2.51.0

