diff --git a/configure.ac b/configure.ac index 86136bb0f1b..73ad0b5446f 100644 --- a/configure.ac +++ b/configure.ac @@ -198,21 +198,36 @@ saved_user_CPPFLAGS="$CPPFLAGS" ## ## Regex: ## -## -Werror Literal -Werror -## \( Start optional capturing group -## = Literal equals sign -## [^[:space:]-] Non-space characters -## \+ 1 or more of the above -## \) End optional capturing group -## \? 0 or 1 capturing group matches +## -Werror Literal -Werror +## \( Start optional capturing group +## = Literal equals sign +## [^[:space:]] Non-space characters +## \+ 1 or more of the above +## \) End optional capturing group +## \? 0 or 1 capturing group matches ## -WERROR_SED= "sed -e 's/-Werror\(=[^[:space:]]\+\)\?//g'" - -CFLAGS="`echo $CFLAGS | $WERROR_SED`" -CXXFLAGS="`echo $CXXFLAGS | $WERROR_SED`" -FCFLAGS="`echo $FCFLAGS | $WERROR_SED`" -JAVACFLAGS="`echo $JAVACFLAGS | $WERROR_SED`" -CPPFLAGS="`echo $CPPFLAGS | $WERROR_SED`" +## Note that the outer pair of '[]' ends up getting removed +WERROR_SED='s/-Werror\(=[[^[:space:]]]\+\)\?//g' +CFLAGS_SED="`echo $CFLAGS | sed -e $WERROR_SED`" +if test $? -eq 0; then + CFLAGS="$CFLAGS_SED" +fi +CXXFLAGS_SED="`echo $CXXFLAGS | sed -e $WERROR_SED`" +if test $? -eq 0; then + CXXFLAGS="$CXXFLAGS_SED" +fi +FCFLAGS_SED="`echo $FCFLAGS | sed -e $WERROR_SED`" +if test $? -eq 0; then + FCFLAGS="$FCFLAGS_SED" +fi +JAVACFLAGS_SED="`echo $JAVACFLAGS | sed -e $WERROR_SED`" +if test $? -eq 0; then + JAVACFLAGS="$JAVACFLAGS_SED" +fi +CPPFLAGS_SED="`echo $CPPFLAGS | sed -e $WERROR_SED`" +if test $? -eq 0; then + CPPFLAGS="$CPPFLAGS_SED" +fi ## Support F9X variable to define Fortran compiler if FC variable is ## not used. This should be deprecated in the future.