Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 1 | From 436f7594485e35523269e662c4b5dc3a2c10ff9b Mon Sep 17 00:00:00 2001 |
| 2 | From: Changqing Li <changqing.li@windriver.com> |
| 3 | Date: Mon, 26 Nov 2018 09:19:17 +0800 |
| 4 | Subject: [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 Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 7 | |
| 8 | Use the passed in optflags when compiling as an RPM, and keep the |
| 9 | default flags as close as possible to the current fedora flags, while |
| 10 | still being generic. |
| 11 | |
| 12 | Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com> |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 13 | |
| 14 | Upstream-Status: Pending |
| 15 | |
| 16 | update this patch to new version |
| 17 | |
| 18 | Signed-off-by: Changqing Li <changqing.li@windriver.com> |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 19 | --- |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 20 | Makefile.inc | 25 ++++++++++++++++--------- |
| 21 | 1 file changed, 16 insertions(+), 9 deletions(-) |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 22 | |
| 23 | diff --git a/Makefile.inc b/Makefile.inc |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 24 | index b86cba6..295afb9 100644 |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 25 | --- a/Makefile.inc |
| 26 | +++ b/Makefile.inc |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 27 | @@ -85,15 +85,22 @@ TEST_CC_OPTION = $(shell \ |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 28 | echo "$(2)"; \ |
| 29 | fi) |
| 30 | |
| 31 | -STACKPROT := $(call TEST_CC_OPTION,-fstack-protector-strong,-fstack-protector) |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 32 | -ERROR_DISCARDED_QUALIFIERS := $(call TEST_CC_OPTION,-Werror=discarded-qualifiers,) |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 33 | - |
| 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 Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 37 | - -Werror=cast-qual $(ERROR_DISCARDED_QUALIFIERS) \ |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 38 | - -Wp,-D_FORTIFY_SOURCE=2 $(STACKPROT) \ |
| 39 | - --param=ssp-buffer-size=4 |
| 40 | +ifndef RPM_OPT_FLAGS |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 41 | + 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 Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 49 | +else |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 50 | + OPTFLAGS = $(RPM_OPT_FLAGS) |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 51 | +endif |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 52 | +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 Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 56 | |
| 57 | CFLAGS := $(OPTFLAGS) -DBIN_DIR=\"$(bindir)\" -DLIB_STRING=\"${LIB}\" -DRUN_DIR=\"${RUN}\" \ |
| 58 | -MMD -MP $(CFLAGS) |
| 59 | -- |
| 60 | 2.7.4 |
| 61 | |