[PATCH util-macros] XORG_ENABLE_DEBUG: a configure option to enable code debugging

Gaetan Nadon memsize at videotron.ca
Tue Apr 20 17:32:46 PDT 2010


Provides a common configure option for all x.org modules.
Script friendly for turning on debug in several modules.
Integrates easily into existing modules debug code.
For both source code and makefiles
Configurable on/off default setting.

Signed-off-by: Gaetan Nadon <memsize at videotron.ca>
---
 xorg-macros.m4.in |   32 ++++++++++++++++++++++++++++++++
 1 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/xorg-macros.m4.in b/xorg-macros.m4.in
index 66c8e98..112db89 100644
--- a/xorg-macros.m4.in
+++ b/xorg-macros.m4.in
@@ -1029,3 +1029,35 @@ test -e \"\$\$OUTFILE\" || echo \"\$\$OUTSTR\" > \"\$\$OUTFILE\"; \
 CONTENT=\`cat \$\$OUTFILE\` && test \"\$\$CONTENT\" = \"\$\$OUTSTR\" || echo \$\$OUTSTR > \$\$OUTFILE;"
 AC_SUBST([GIT_MODULE_VERSION_CMD])
 ]) # XORG_GIT_MODULE_VERSION
+
+# XORG_ENABLE_DEBUG (enable_debug=no)
+# -----------------------------------
+# Minimum version: 1.8.0
+#
+# This macro defines a C preprocessor macro and a makefile conditional
+# to compile code for debugging purpose. (Not related to compiler options)
+#
+# Interface to module:
+# HAVE_DEBUG:	  used in makefiles to conditionally build targets
+#		  used in source code to conditionally debug code
+# --enable-debug: 'yes' user instructs the module to compile debug code
+#		 'no' user instructs the module not to compile debug code
+# parm1:	specify the default value, yes or no.
+#
+AC_DEFUN([XORG_ENABLE_DEBUG],[
+default=$1
+if test "x$default" = x ; then
+  default="no"
+fi
+AC_ARG_ENABLE([debug],
+	AS_HELP_STRING([--enable-debug],
+	   [Enable debugging code (default: no)]),
+	   [enable_debug=$enableval], [enable_debug=$default])
+
+if test x$enable_debug = xyes; then
+    AC_DEFINE([HAVE_DEBUG], [1], [Enable debugging code])
+fi
+AM_CONDITIONAL([HAVE_DEBUG], [test x$enable_debug = xyes])
+AC_MSG_CHECKING([whether to enable debug code])
+AC_MSG_RESULT([$enable_debug])
+]) # XORG_ENABLE_DEBUG
-- 
1.6.0.4

There are 4 modules with --enable-debug configure option but many more modules (44) do
have something like #define DEBUG with a wide variety of names. One has to dig in the code
to figure out how each module does it.

This macro will give the opportunity for modules to have a common configure option where
debug can be turned on without having to read all the code and to change it.

It was tempting to use DEBUG as the #define name, but there were already conflicts.
I checked HAVE_DEBUG was not already used so it's easy to wrap whatever #define is there
without changing much code.




More information about the xorg-devel mailing list