Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame^] | 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 |
| 2 | From: Benjamin Marzinski <bmarzins@redhat.com> |
| 3 | Date: Wed, 19 Apr 2017 06:10:01 -0500 |
| 4 | Subject: [PATCH] RH: use rpm optflags if present |
| 5 | |
| 6 | Use the passed in optflags when compiling as an RPM, and keep the |
| 7 | default flags as close as possible to the current fedora flags, while |
| 8 | still being generic. |
| 9 | |
| 10 | Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com> |
| 11 | --- |
| 12 | Makefile.inc | 24 ++++++++++++++++-------- |
| 13 | 1 file changed, 16 insertions(+), 8 deletions(-) |
| 14 | |
| 15 | diff --git a/Makefile.inc b/Makefile.inc |
| 16 | index 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 | -- |
| 51 | 2.7.4 |
| 52 | |