From 18a9c095f82a6046ab2b4a4e1ce4af13150ca1d6 Mon Sep 17 00:00:00 2001 From: Karl Wette Date: Sun, 5 Oct 2014 14:31:24 +0200 Subject: [PATCH] Octave: disable optimization of tests for faster compiles/less memory usage - Filter out all but -g... and -W... flags from OCTAVE_CXXFLAGS - Use AX_CHECK_COMPILE_FLAG() to check if -O0 is supported, if so add to end of OCTAVE_CXXFLAGS to ensure optimization is disabled - Also run mkoctfile under "env -" to protect it from environment - Also use more standard-compliant sed expressions --- configure.ac | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/configure.ac b/configure.ac index 78c276029..22d66d1ef 100644 --- a/configure.ac +++ b/configure.ac @@ -937,25 +937,43 @@ fi if test -n "$OCTAVE"; then AC_MSG_CHECKING([for Octave preprocessor flags]) OCTAVE_CPPFLAGS= - for n in CPPFLAGS INCFLAGS; do - OCTAVE_CPPFLAGS="${OCTAVE_CPPFLAGS} "`unset CPPFLAGS; ${mkoctfile} -p $n` + for var in CPPFLAGS INCFLAGS ALL_CXXFLAGS; do + for flag in `env - ${mkoctfile} -p ${var}`; do + case ${flag} in + -D*|-I*) OCTAVE_CPPFLAGS="${OCTAVE_CPPFLAGS} ${flag}";; + *) ;; + esac + done done AC_MSG_RESULT([$OCTAVE_CPPFLAGS]) AC_MSG_CHECKING([for Octave compiler flags]) OCTAVE_CXXFLAGS= - for n in ALL_CXXFLAGS; do - OCTAVE_CXXFLAGS="${OCTAVE_CXXFLAGS} "`unset CXXFLAGS; ${mkoctfile} -p $n` + for var in ALL_CXXFLAGS; do + for flag in `env - ${mkoctfile} -p ${var}`; do + case ${flag} in + -g*|-W*) OCTAVE_CXXFLAGS="${OCTAVE_CXXFLAGS} ${flag}";; + *) ;; + esac + done done + save_CXXFLAGS="${CXXFLAGS}" + CXXFLAGS="-Werror -O0" + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],[]) + ],[ + OCTAVE_CXXFLAGS="${OCTAVE_CXXFLAGS} -O0" + ]) + CXXFLAGS="${save_CXXFLAGS}" AC_MSG_RESULT([$OCTAVE_CXXFLAGS]) AC_MSG_CHECKING([for Octave linker flags]) OCTAVE_LDFLAGS= - for n in RDYNAMIC_FLAG LFLAGS RLD_FLAG OCTAVE_LIBS LIBS; do - OCTAVE_LDFLAGS="${OCTAVE_LDFLAGS} "`${mkoctfile} -p $n` + for var in RDYNAMIC_FLAG LFLAGS RLD_FLAG OCTAVE_LIBS LIBS; do + OCTAVE_LDFLAGS="${OCTAVE_LDFLAGS} "`env - ${mkoctfile} -p ${var}` done AC_MSG_RESULT([$OCTAVE_LDFLAGS]) for octave_opt in --silent --norc --no-history --no-window-system; do AC_MSG_CHECKING([if Octave option '${octave_opt}' is supported]) - octave_out=`${OCTAVE} ${octave_opt} /dev/null 2>&1 | sed -n '1{/unrecognized/p}'` + octave_out=`${OCTAVE} ${octave_opt} /dev/null 2>&1 | sed -n '1p' | sed -n '/unrecognized/p'` AS_IF([test "x${octave_out}" = x],[ AC_MSG_RESULT([yes]) OCTAVE="${OCTAVE} ${octave_opt}"