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

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