From 08c74ad8191e533415b9ac9e532ebc63e9736fb2 Mon Sep 17 00:00:00 2001
From: Zhao Junwang <zhjwpku@gmail.com>
Date: Tue, 12 Dec 2023 18:02:29 +0800
Subject: [PATCH] [meson] expose buildtype debug/optimization info to pg_config

build system using configure set VAL_CFLAGS with debug and
optimization flags, so pg_config will show these infos. Some
extensions depend on the mechanism.

This patch exposes these flags.

Signed-off-by: Zhao Junwang <zhjwpku@gmail.com>
---
 meson.build | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/meson.build b/meson.build
index 52c2a37c41..b44f0e4587 100644
--- a/meson.build
+++ b/meson.build
@@ -115,6 +115,20 @@ cdata = configuration_data()
 
 
 
+###############################################################
+# Build type
+###############################################################
+build_type = get_option('buildtype')
+if build_type == 'debug'
+  cflags += ['-g', '-O0']
+elif build_type == 'debugoptimized'
+  cflags += ['-g', '-O2']
+elif build_type == 'release'
+  cflags += ['-O3']
+endif
+
+
+
 ###############################################################
 # Version and other metadata
 ###############################################################
@@ -1139,7 +1153,7 @@ if not get_option('readline').disabled()
 
     if not at_least_one_header_found
       error('''readline header not found
-If you have @0@ already installed, see meson-log/meson-log.txt for details on the
+If you have @0@ already installed, see meson-logs/meson-log.txt for details on the
 failure. It is possible the compiler isn't looking in the proper directory.
 Use -Dreadline=disabled to disable readline support.'''.format(readline_dep))
     endif
-- 
2.41.0

