From c70c4e367da8fb9d8874a525606a52b7459b0207 Mon Sep 17 00:00:00 2001
From: Bruce Momjian <bruce@momjian.us>
Date: Sun, 3 Oct 1999 18:05:04 +0000
Subject: [PATCH] I hope this is what you had in mind: --enable-debug adds -g
 (unconditionally) --disable-debug removes -g (if it was already in there
 somehow) (giving neither does nothing)

Since none of the templates default CFLAGS with a -g you're not likely
to
end up with two -g flags. Not that they'd hurt though.

It doesn't do anything about C++.

Peter Eisentraut
---
 src/configure.in | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/src/configure.in b/src/configure.in
index c0a7d5f4854..a02a46778f6 100644
--- a/src/configure.in
+++ b/src/configure.in
@@ -411,6 +411,27 @@ echo "- setting CPPFLAGS=$CPPFLAGS"
 LDFLAGS="$LDFLAGS $PGSQL_LDFLAGS"
 echo "- setting LDFLAGS=$LDFLAGS"
 
+dnl --enable-debug adds -g to compiler flags
+dnl --disable-debug will forcefully remove it
+AC_MSG_CHECKING(setting debug compiler flag)
+AC_ARG_ENABLE(
+    debug,
+    [  --enable-debug          build with debugging symbols (-g) ],
+    [
+        case "$enableval" in
+	y | ye | yes)
+            CFLAGS="$CFLAGS -g"
+            AC_MSG_RESULT(enabled)
+            ;;
+        *)
+            CFLAGS=`echo "$CFLAGS" | sed -e 's/ -g/ /g' | sed -e 's/^-g//'`
+            AC_MSG_RESULT(disabled)
+            ;;
+        esac            
+   ],
+   AC_MSG_RESULT(using default)
+)
+
 # Assume system is ELF if it predefines __ELF__ as 1,
 # otherwise believe "elf" setting from check of host_os above.
 AC_EGREP_CPP(yes,
-- 
GitLab