From Fedora Project Wiki

How to remove unwanted compiler flags from $RPM_OPT_FLAGS

Stop (medium size).png This document is a draft.

Some packages like blender (see Bug #199418) don't be able to compile properly, if all compiler options in $RPM_OPT_FLAGS will be specified. Becouse we want to use as much as compiler options in $RPM_OPT_FLAGS as possible, we need a method to remove selected compiler options from $RPM_OPT_FLAGS.

Advances

An advance to have such a method is the usage of arch specific compiler options specified in the $RPM_OPT_FLAGS without to run in trouble on using compiler options which will couse issues with a specific package.

Therfor I have create the following shell script:

rmopts.sh

#
#
rmopts() {
for i in $@ ; do
RPM_OPT_FLAGS=$(echo $RPM_OPT_FLAGS | sed -e "s/\S*$i\S*//")
done
}

In the following I demonstrate how to remove all compiler options in $RPM_OPT_FLAGS which match to the regular expression 'protector':

Sample for using rmopts

Sourcex:	rmopts.sh

%description
This package demonstrate the usage of rpmopts.sh script

%build
source %{SOURCEx}
rmopts 'protector'

echo $RPM_OPT_FLAGS

%changelog

The letter 'x' in Sourcex may be substitute by any number.