modification of CFLAGS

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

I'd like to write a macro, called LX_DEBUG. This checks if the user gives "--enable-debug" and then depending on the compiler, modify CFLAGS.

However, I see that the autoconf macros already modify CFLAGS. Is there a way that I can obtain what the user originally entered *within* my macro after AC_PROG_CC? If the user provided CFLAGS, I wish to use that and make no modifications. Otherwise, if GNU CC is used, I wish to set it to "-O0 -g".

Currently, autotools sets it to "-O2 -g". I can't seem to figure out where the original settings are given.

If the user doesn't provide --enable-debug, I don't want to change anything.

My macro currently looks like:
AC_DEFUN([LX_DEBUG],
  [AC_ARG_ENABLE(debug)
   AM_CONDITIONAL([HAVE_DEBUG], [test x$enable_debug = xyes])
   if test x$enable_debug = xyes; then
      AC_DEFINE([DEBUG], [1], [Enable Debugging])
      AC_MSG_CHECKING([supported compiler debug options])
      if test x$ac_cv_c_compiler_gnu = xyes; then
         AC_MSG_RESULT([GCC])
         AC_MSG_CHECKING([gcc cflags])
# Unfortunately here, CFLAGS is always set, even if the user didn't set them
         if test "x$CFLAGS" = "x"; then
            CFLAGS="-O0 -g"
         fi
         AC_MSG_RESULT([$CFLAGS])
      else
         AC_MSG_RESULT([Unknown])
      fi
   fi
])



_______________________________________________
Autoconf mailing list
Autoconf@xxxxxxx
http://lists.gnu.org/mailman/listinfo/autoconf

[Index of Archives]     [GCC Help]     [Kernel Discussion]     [RPM Discussion]     [Red Hat Development]     [Yosemite News]     [Linux USB]     [Samba]

  Powered by Linux