Subject: [bug#76342] [PATCH] build: Pass CFLAGS, CPPFLAGS and LDFLAGS to CC.

From: Simon Josefsson <[email-masked]>
Date: Sun, 16 Feb 2025 18:21:41 +0100

Hi

The Debian QA linters noticed that some CC flags were missing, and this
patch fixes it.  It seems the default CFLAGS for me is '-O2 -g' when
running ./configure so I dropped those since they were added twice
otherwise.  Maye -Wall should be moved to a Makefile.am AM_CFLAGS (or
something), but the attached patch seems sufficient to silences Debian's
"blhc" tool which is my main concern.

https://salsa.debian.org/debian/shepherd/-/jobs/7100765

400:CFLAGS missing (-fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection): 			\ gcc -O2 -g -Wall -shared -fPIC -o "etc/crash-handler.so" "etc/crash-handler.c"
400:CPPFLAGS missing (-D_FORTIFY_SOURCE=2): 			\ gcc -O2 -g -Wall -shared -fPIC -o "etc/crash-handler.so" "etc/crash-handler.c"
400:LDFLAGS missing (-Wl,-z,relro): 			\ gcc -O2 -g -Wall -shared -fPIC -o "etc/crash-handler.so" "etc/crash-handler.c"

/Simon
From fdaeac0a71f3bdd1daaafffc46647f05e019ac10 Mon Sep 17 00:00:00 2001
From: Simon Josefsson <[email-masked]>
Date: Sun, 16 Feb 2025 16:11:04 +0100
Subject: [PATCH] build: Pass CFLAGS, CPPFLAGS and LDFLAGS to CC.

* Makefile.am (etc/crash-handler.so): Do it.

Signed-off-by: Simon Josefsson <[email-masked]>
---
 Makefile.am | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile.am b/Makefile.am
index aa2edd9..bc87404 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -107,7 +107,7 @@ install-crash-handler:
 
 etc/crash-handler.so: etc/crash-handler.c
 	$(AM_V_GEN)$(MKDIR_P) etc;			\
-	$(CC) -O2 -g -Wall -shared -fPIC -o "$@" "$^"
+	$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -Wall -shared -fPIC -o "$@" "$^"
 
 CLEANFILES += etc/crash-handler.so
 
-- 
2.48.1