Blame SOURCES/0014-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
---
49190a
 Makefile.inc | 29 +++++++++++++++++++++--------
49190a
 1 file changed, 21 insertions(+), 8 deletions(-)
b7ef27
b7ef27
diff --git a/Makefile.inc b/Makefile.inc
49190a
index 034752d9..c2abd301 100644
b7ef27
--- a/Makefile.inc
b7ef27
+++ b/Makefile.inc
49190a
@@ -89,16 +89,29 @@ 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,)
49190a
 WNOCLOBBERED := $(call TEST_CC_OPTION,-Wno-clobbered -Wno-error=clobbered,)
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 \
49190a
+			  $(STACKPROT) -grecord-gcc-switches \
49190a
+			  -fasynchronous-unwind-tables
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
49190a
+	ifeq ($(shell test -f /usr/lib/rpm/redhat/redhat-annobin-cc1 && echo 1),1)
49190a
+		OPTFLAGS += -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1
49190a
+	endif
b7ef27
+else
b7ef27
+	OPTFLAGS = $(RPM_OPT_FLAGS)
b7ef27
+endif
49190a
+OPTFLAGS	+= -Werror -Wextra -Wstrict-prototypes -Wformat=2 \
49190a
+		   -Werror=implicit-int -Werror=implicit-function-declaration \
49190a
+		   $(WNOCLOBBERED) \
49190a
+		   -Werror=cast-qual $(ERROR_DISCARDED_QUALIFIERS) \
49190a
+		   --param=ssp-buffer-size=4
b7ef27
 
49190a
-OPTFLAGS	= -O2 -g -pipe -Werror -Wall -Wextra -Wformat=2 -Werror=implicit-int \
49190a
-		  -Werror=implicit-function-declaration -Werror=format-security \
49190a
-		  $(WNOCLOBBERED) \
49190a
-		  -Werror=cast-qual $(ERROR_DISCARDED_QUALIFIERS) \
49190a
-		  $(STACKPROT) --param=ssp-buffer-size=4
49190a
-CPPFLAGS	:= -Wp,-D_FORTIFY_SOURCE=2 
b7ef27
 CFLAGS		:= $(OPTFLAGS) -DBIN_DIR=\"$(bindir)\" -DLIB_STRING=\"${LIB}\" -DRUN_DIR=\"${RUN}\" \
b7ef27
 		   -MMD -MP $(CFLAGS)
49190a
 BIN_CFLAGS	= -fPIE -DPIE
49190a
@@ -135,4 +148,4 @@ check_file = $(shell \
49190a
 
49190a
 %.o:	%.c
49190a
 	@echo building $@ because of $?
49190a
-	$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
49190a
+	$(CC) $(CFLAGS) -c -o $@ $<
b7ef27
-- 
b7ef27
2.17.2
b7ef27