blob: 77dd96fee6c5f00f8ed62dde8e1bd1471215513d [file] [log] [blame]
Brad Bishop19323692019-04-05 15:28:33 -04001From 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 17
5 00:00:00 2001 From: Benjamin Marzinski <bmarzins@redhat.com> Date: Wed, 19
6 Apr 2017 06:10:01 -0500 Subject: [PATCH] RH: use rpm optflags if present
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08007
8Use the passed in optflags when compiling as an RPM, and keep the
9default flags as close as possible to the current fedora flags, while
10still being generic.
11
12Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
Brad Bishop19323692019-04-05 15:28:33 -040013
14Upstream-Status: Pending
15
16update this patch to new version
17
18Signed-off-by: Changqing Li <changqing.li@windriver.com>
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080019---
Brad Bishop19323692019-04-05 15:28:33 -040020 Makefile.inc | 25 ++++++++++++++++---------
21 1 file changed, 16 insertions(+), 9 deletions(-)
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080022
23diff --git a/Makefile.inc b/Makefile.inc
Brad Bishop19323692019-04-05 15:28:33 -040024index b86cba6..295afb9 100644
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080025--- a/Makefile.inc
26+++ b/Makefile.inc
Brad Bishop19323692019-04-05 15:28:33 -040027@@ -85,15 +85,22 @@ TEST_CC_OPTION = $(shell \
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080028 echo "$(2)"; \
29 fi)
30
31-STACKPROT := $(call TEST_CC_OPTION,-fstack-protector-strong,-fstack-protector)
Brad Bishop19323692019-04-05 15:28:33 -040032-ERROR_DISCARDED_QUALIFIERS := $(call TEST_CC_OPTION,-Werror=discarded-qualifiers,)
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080033-
34-OPTFLAGS = -O2 -g -pipe -Wall -Wextra -Wformat=2 -Werror=implicit-int \
35- -Werror=implicit-function-declaration -Werror=format-security \
36- -Wno-sign-compare -Wno-unused-parameter -Wno-clobbered \
Brad Bishop19323692019-04-05 15:28:33 -040037- -Werror=cast-qual $(ERROR_DISCARDED_QUALIFIERS) \
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080038- -Wp,-D_FORTIFY_SOURCE=2 $(STACKPROT) \
39- --param=ssp-buffer-size=4
40+ifndef RPM_OPT_FLAGS
Brad Bishop19323692019-04-05 15:28:33 -040041+ STACKPROT := $(call TEST_CC_OPTION,-fstack-protector-strong,-fstack-protector)
42+ OPTFLAGS = -O2 -g -pipe -Wall -Werror=format-security \
43+ -Wp,-D_FORTIFY_SOURCE=2 -fexceptions \
44+ $(STACKPROT) --param=ssp-buffer-size=4 \
45+ -grecord-gcc-switches
46+ ifeq ($(shell test -f /usr/lib/rpm/redhat/redhat-hardened-cc1 && echo 1),1)
47+ OPTFLAGS += -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1
48+ endif
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080049+else
Brad Bishop19323692019-04-05 15:28:33 -040050+ OPTFLAGS = $(RPM_OPT_FLAGS)
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080051+endif
Brad Bishop19323692019-04-05 15:28:33 -040052+OPTFLAGS += -Wextra -Wstrict-prototypes -Wformat=2 -Werror=implicit-int \
53+ -Werror=implicit-function-declaration -Wno-sign-compare \
54+ -Wno-unused-parameter -Werror=cast-qual \
55+ -Werror=discarded-qualifiers
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080056
57 CFLAGS := $(OPTFLAGS) -DBIN_DIR=\"$(bindir)\" -DLIB_STRING=\"${LIB}\" -DRUN_DIR=\"${RUN}\" \
58 -MMD -MP $(CFLAGS)
59--
602.7.4
61