Blame SOURCES/0021-RH-use-rpm-optflags-if-present.patch

5c2e41
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
5c2e41
From: Benjamin Marzinski <bmarzins@redhat.com>
5c2e41
Date: Wed, 19 Apr 2017 06:10:01 -0500
5c2e41
Subject: [PATCH] RH: use rpm optflags if present
5c2e41
5c2e41
Use the passed in optflags when compiling as an RPM, and keep the
5c2e41
default flags as close as possible to the current fedora flags, while
5c2e41
still being generic.
5c2e41
5c2e41
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
5c2e41
---
5c2e41
 Makefile.inc | 24 ++++++++++++++++--------
5c2e41
 1 file changed, 16 insertions(+), 8 deletions(-)
5c2e41
5c2e41
diff --git a/Makefile.inc b/Makefile.inc
a1c519
index 2f0bcea..b98800a 100644
5c2e41
--- a/Makefile.inc
5c2e41
+++ b/Makefile.inc
a1c519
@@ -83,15 +83,23 @@ TEST_CC_OPTION = $(shell \
5c2e41
 		echo "$(2)"; \
5c2e41
 	fi)
5c2e41
 
5c2e41
-STACKPROT := $(call TEST_CC_OPTION,-fstack-protector-strong,-fstack-protector)
5c2e41
 ERROR_DISCARDED_QUALIFIERS := $(call TEST_CC_OPTION,-Werror=discarded-qualifiers,)
5c2e41
-
5c2e41
-OPTFLAGS	= -O2 -g -pipe -Wall -Wextra -Wformat=2 -Werror=implicit-int \
5c2e41
-		  -Werror=implicit-function-declaration -Werror=format-security \
5c2e41
-		  -Wno-sign-compare -Wno-unused-parameter -Wno-clobbered \
5c2e41
-		  -Werror=cast-qual $(ERROR_DISCARDED_QUALIFIERS) \
5c2e41
-		  -Wp,-D_FORTIFY_SOURCE=2 $(STACKPROT) \
5c2e41
-		  --param=ssp-buffer-size=4
5c2e41
+ifndef RPM_OPT_FLAGS
5c2e41
+	STACKPROT := $(call TEST_CC_OPTION,-fstack-protector-strong,-fstack-protector)
5c2e41
+	OPTFLAGS	= -O2 -g -pipe -Wall -Werror=format-security \
5c2e41
+			  -Wp,-D_FORTIFY_SOURCE=2 -fexceptions \
5c2e41
+			  $(STACKPROT) --param=ssp-buffer-size=4 \
5c2e41
+			  -grecord-gcc-switches
5c2e41
+	ifeq ($(shell test -f /usr/lib/rpm/redhat/redhat-hardened-cc1 && echo 1),1)
5c2e41
+		OPTFLAGS += -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1
5c2e41
+	endif
5c2e41
+else
5c2e41
+	OPTFLAGS = $(RPM_OPT_FLAGS)
5c2e41
+endif
5c2e41
+OPTFLAGS	+= -Wextra -Wstrict-prototypes -Wformat=2 -Werror=implicit-int \
5c2e41
+		   -Werror=implicit-function-declaration -Wno-sign-compare \
5c2e41
+		   -Wno-unused-parameter $(ERROR_DISCARDED_QUALIFIERS) \
5c2e41
+		   -Werror=cast-qual
5c2e41
 
5c2e41
 CFLAGS		:= $(OPTFLAGS) -DBIN_DIR=\"$(bindir)\" -DLIB_STRING=\"${LIB}\" -DRUN_DIR=\"${RUN}\" \
5c2e41
 		   -MMD -MP $(CFLAGS)
5c2e41
-- 
a1c519
2.17.2
5c2e41