--- trunk/c++/src/build-system/configure.ac 2012/12/21 15:12:14 56664 +++ trunk/c++/src/build-system/configure.ac 2012/12/27 15:43:29 56694 @@ -623,6 +623,13 @@ * ) AC_SUBST(PROJECTS, "\$(top_srcdir)/$with_projects") ;; esac +# Check for custom optimization flags before potentially going with defaults. +skip_fast_flags=no +if test -z "${DEF_FAST_FLAGS}${FAST_CXXFLAGS}"; then + case " $CFLAGS $CXXFLAGS" in + *\ -O* | *\ -xO* ) skip_fast_flags=yes ;; + esac +fi #### Always define this AC_DEFINE(NCBI_CXX_TOOLKIT, 1, [This is the NCBI C++ Toolkit.]) @@ -1431,7 +1438,7 @@ wsrx="[[$wschars]]" #### Flags to enable (potentially unsafe) extra optimization. -if test -z "$DEF_FAST_FLAGS" -o -z "$FAST_CXXFLAGS" ; then +if test "$skip_fast_flags" = no -a -z "$DEF_FAST_FLAGS" ; then case "$compiler:$compiler_version" in GCC:2* | GCC:344 ) # GCC 2.9x sometimes experiences internal errors at high optimization; @@ -1502,8 +1509,6 @@ DEF_FAST_FLAGS="-O" ;; esac -else - DEF_FAST_FLAGS="-O" fi : ${FAST_CFLAGS="$DEF_FAST_FLAGS"} @@ -2608,9 +2613,15 @@ CXXFLAGS="$CXXFLAGS -O" ; fi if echo " $LDFLAGS " | grep -v "$optrx" >/dev/null ; then LDFLAGS="$LDFLAGS -O" ; fi - FAST_CFLAGS="$NOPT_CFLAGS $FAST_CFLAGS" - FAST_CXXFLAGS="$NOPT_CXXFLAGS $FAST_CXXFLAGS" - FAST_LDFLAGS="$NOPT_LDFLAGS $FAST_LDFLAGS" + if test "$skip_fast_flags" = yes ; then + FAST_CFLAGS="$CFLAGS" + FAST_CXXFLAGS="$CXXFLAGS" + FAST_LDFLAGS="$LDFLAGS" + else + FAST_CFLAGS="$NOPT_CFLAGS $FAST_CFLAGS" + FAST_CXXFLAGS="$NOPT_CXXFLAGS $FAST_CXXFLAGS" + FAST_LDFLAGS="$NOPT_LDFLAGS $FAST_LDFLAGS" + fi fi changequote([, ])dnl fi