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
This commit is contained in:
Karl Wette 2014-10-05 14:31:24 +02:00 committed by Karl Wette
commit 18a9c095f8

View file

@ -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}"