I\'ve been looking for this for a while: I\'m currently converting a medium-size program to autotools, coming from an Eclipse-based method (with makefiles)
I\'m alwa
Another example to configure CFLAGS
/CXXFLAGS
without editing Makefile.in
or Makefile.am
. Add this code to your configure.in
or configure.ac
file:
test -z "$SED" && SED=sed
AC_ARG_ENABLE([debug],
[AS_HELP_STRING([--enable-debug],
[whether to include debug symbols (default is no)])],
[enable_debug=$enableval],
[enable_debug=no]
)
if test "x$enable_debug" = xyes; then
dnl Remove all optimization flags from CFLAGS
changequote({,})
CFLAGS=`echo "$CFLAGS" | $SED -e 's/-O[0-9s]*//g'`
CXXFLAGS=`echo "$CXXFLAGS" | $SED -e 's/-O[0-9s]*//g'`
CFLAGS=`echo "$CFLAGS" | $SED -e 's/-g[0-9]*//g'`
CXXFLAGS=`echo "$CXXFLAGS" | $SED -e 's/-g[0-9]*//g'`
changequote([,])
CFLAGS="$CFLAGS -g -O0"
CXXFLAGS="$CXXFLAGS -g -O0"
fi
echo "CFLAGS=$CFLAGS"
Test it:
$ ./configure --enable-debug | grep CFLAGS