1From 436f7594485e35523269e662c4b5dc3a2c10ff9b Mon Sep 17 00:00:00 2001 2From: Changqing Li <changqing.li@windriver.com> 3Date: Mon, 26 Nov 2018 09:19:17 +0800 4Subject: [PATCH] From 0000000000000000000000000000000000000000 Mon Sep 517 6 00:00:00 2001 From: Benjamin Marzinski <bmarzins@redhat.com> Date: Wed, 719 8 Apr 2017 06:10:01 -0500 Subject: [PATCH] RH: use rpm optflags if 9present 10 11Use the passed in optflags when compiling as an RPM, and keep the 12default flags as close as possible to the current fedora flags, while 13still being generic. 14 15Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com> 16 17Upstream-Status: Pending 18 19update this patch to new version 20 21Signed-off-by: Changqing Li <changqing.li@windriver.com> 22--- 23 Makefile.inc | 24 ++++++++++++++++-------- 24 1 file changed, 16 insertions(+), 8 deletions(-) 25 26diff --git a/Makefile.inc b/Makefile.inc 27index 42dbb5bf..55a06c60 100644 28--- a/Makefile.inc 29+++ b/Makefile.inc 30@@ -89,15 +89,23 @@ TEST_CC_OPTION = $(shell \ 31 echo "$(2)"; \ 32 fi) 33 34-STACKPROT := $(call TEST_CC_OPTION,-fstack-protector-strong,-fstack-protector) 35-ERROR_DISCARDED_QUALIFIERS := $(call TEST_CC_OPTION,-Werror=discarded-qualifiers,) 36-WNOCLOBBERED := $(call TEST_CC_OPTION,-Wno-clobbered,) 37+ifndef RPM_OPT_FLAGS 38+ STACKPROT := $(call TEST_CC_OPTION,-fstack-protector-strong,-fstack-protector) 39+ OPTFLAGS = -O2 -g -pipe -Wall -Werror=format-security \ 40+ -Wp,-D_FORTIFY_SOURCE=2 -fexceptions \ 41+ $(STACKPROT) --param=ssp-buffer-size=4 \ 42+ -grecord-gcc-switches 43+ ifeq ($(shell test -f /usr/lib/rpm/redhat/redhat-hardened-cc1 && echo 1),1) 44+ OPTFLAGS += -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 45+ endif 46+else 47+ OPTFLAGS = $(RPM_OPT_FLAGS) 48+endif 49+OPTFLAGS += -Wextra -Wstrict-prototypes -Wformat=2 -Werror=implicit-int \ 50+ -Werror=implicit-function-declaration -Wno-sign-compare \ 51+ -Wno-unused-parameter -Werror=cast-qual \ 52+ -Werror=discarded-qualifiers 53 54-OPTFLAGS = -O2 -g -pipe -Werror -Wall -Wextra -Wformat=2 -Werror=implicit-int \ 55- -Werror=implicit-function-declaration -Werror=format-security \ 56- $(WNOCLOBBERED) \ 57- -Werror=cast-qual $(ERROR_DISCARDED_QUALIFIERS) \ 58- $(STACKPROT) --param=ssp-buffer-size=4 59 CPPFLAGS := -Wp,-D_FORTIFY_SOURCE=2 60 CFLAGS := $(OPTFLAGS) -DBIN_DIR=\"$(bindir)\" -DLIB_STRING=\"${LIB}\" -DRUN_DIR=\"${RUN}\" \ 61 -MMD -MP $(CFLAGS) 62-- 632.17.1 64 65