[Ocfs2-tools-devel] [PATCH 2/4] configure.in: Detect debugging CFLAGS in configure

Mark Fasheh mark.fasheh at oracle.com
Thu Feb 21 16:08:31 PST 2008


From: Joel Becker <joel.becker at oracle.com>

Rather than switch on OCFS2_DEBUG in every Makefile, set the default
optimization or debugging CFLAGS in configure.in.  This allows the
CFLAGS environment variable to override configure's choice - the correct
behavior.

Signed-off-by: Joel Becker <joel.becker at oracle.com>
Signed-off-by: Mark Fasheh <mark.fasheh at oracle.com>
---
 configure.in |   37 ++++++++++++++++++++++++++++---------
 1 files changed, 28 insertions(+), 9 deletions(-)

diff --git a/configure.in b/configure.in
index 04e4fa5..d3bf6bc 100644
--- a/configure.in
+++ b/configure.in
@@ -37,9 +37,37 @@ case "$host" in
     ;;
 esac
 
+#
+# If CFLAGS is non-empty, leave the debugging and optimization symobls
+# to the caller.  Otherwise, set them according to --enable-debug.
+#
+OCFS2_DEBUG=
+AC_MSG_CHECKING(for debugging)
+if test "x$CFLAGS" = "x"; then
+  AC_ARG_ENABLE(debug, [  --enable-debug=[yes/no]         Turn on debugging [default=no]],,enable_debug=no)
+  if test "x$enable_debug" = "xyes"; then
+    OCFS2_DEBUG=yes
+    CFLAGS="-g"
+  else
+    CFLAGS="-O2"
+  fi
+  AC_MSG_RESULT($enable_debug)
+else
+  AC_MSG_RESULT([skipped, CFLAGS is set])
+fi
+AC_SUBST(OCFS2_DEBUG)
+
 AC_PROG_CC
 AC_PROG_CPP
 
+#
+# If OCFS2_DEBUG was set, we know CFLAGS must be "-g".  If we're using
+# GNU C, get extra debugging symbols.
+#
+if test "x$GCC" = "xyes" -a "x$OCFS2_DEBUG" = "xyes"; then
+  CFLAGS="-ggdb"
+fi
+
 AC_PROG_INSTALL
 AC_PROG_LN_S
 AC_PROG_RANLIB
@@ -66,15 +94,6 @@ AC_SUBST(root_bindir)
 AC_SUBST(root_sbindir)
 AC_SUBST(root_sysconfdir)
 
-AC_MSG_CHECKING(for debugging)
-AC_ARG_ENABLE(debug, [  --enable-debug=[yes/no]         Turn on debugging [default=no]],,enable_debug=no)
-OCFS2_DEBUG=
-if test "x$enable_debug" = "xyes"; then
-  OCFS2_DEBUG=yes
-fi
-AC_SUBST(OCFS2_DEBUG)
-AC_MSG_RESULT($enable_debug)
-
 COM_ERR_LIBS=
 PKG_CHECK_MODULES(COM_ERR, com_err,, [
   AC_CHECK_LIB(com_err, com_err, COM_ERR_LIBS=-lcom_err)
-- 
1.5.3.6




More information about the Ocfs2-tools-devel mailing list