blob: 9330bf07018f9ade2c55ddf25649a1e35b089207 [file] [log] [blame]
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08001From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2From: Benjamin Marzinski <bmarzins@redhat.com>
3Date: Wed, 19 Apr 2017 06:10:01 -0500
4Subject: [PATCH] RH: use rpm optflags if present
5
6Use the passed in optflags when compiling as an RPM, and keep the
7default flags as close as possible to the current fedora flags, while
8still being generic.
9
10Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
11---
12 Makefile.inc | 24 ++++++++++++++++--------
13 1 file changed, 16 insertions(+), 8 deletions(-)
14
15diff --git a/Makefile.inc b/Makefile.inc
16index 0b271ea..5ff69a3 100644
17--- a/Makefile.inc
18+++ b/Makefile.inc
19@@ -85,14 +85,22 @@ TEST_CC_OPTION = $(shell \
20 echo "$(2)"; \
21 fi)
22
23-STACKPROT := $(call TEST_CC_OPTION,-fstack-protector-strong,-fstack-protector)
24-
25-OPTFLAGS = -O2 -g -pipe -Wall -Wextra -Wformat=2 -Werror=implicit-int \
26- -Werror=implicit-function-declaration -Werror=format-security \
27- -Wno-sign-compare -Wno-unused-parameter -Wno-clobbered \
28- -Werror=cast-qual -Werror=discarded-qualifiers \
29- -Wp,-D_FORTIFY_SOURCE=2 $(STACKPROT) \
30- --param=ssp-buffer-size=4
31+ifndef RPM_OPT_FLAGS
32+ STACKPROT := $(call TEST_CC_OPTION,-fstack-protector-strong,-fstack-protector)
33+ OPTFLAGS = -O2 -g -pipe -Wall -Werror=format-security \
34+ -Wp,-D_FORTIFY_SOURCE=2 -fexceptions \
35+ $(STACKPROT) --param=ssp-buffer-size=4 \
36+ -grecord-gcc-switches
37+ ifeq ($(shell test -f /usr/lib/rpm/redhat/redhat-hardened-cc1 && echo 1),1)
38+ OPTFLAGS += -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1
39+ endif
40+else
41+ OPTFLAGS = $(RPM_OPT_FLAGS)
42+endif
43+OPTFLAGS += -Wextra -Wstrict-prototypes -Wformat=2 -Werror=implicit-int \
44+ -Werror=implicit-function-declaration -Wno-sign-compare \
45+ -Wno-unused-parameter -Werror=cast-qual \
46+ -Werror=discarded-qualifiers
47
48 CFLAGS := $(OPTFLAGS) -DBIN_DIR=\"$(bindir)\" -DLIB_STRING=\"${LIB}\" -DRUN_DIR=\"${RUN}\" \
49 -MMD -MP $(CFLAGS)
50--
512.7.4
52