[Macro Index Page] | [Download M4 Source] |
PETI_WITH_DMALLOC
The Debug Malloc Library is an useful tool to debug memory problems in your programs, but you don't want to compile dmalloc-support into every binary you produce, because of the performance loss.
This macro adds a user command-line flag --with-dmalloc
to
the configure script, which can be specified like this:
./configure --with-dmalloc[=PREFIX]
When activated, the macro will add the flags
-IPREFIX/include
to $CPPFLAGS
and
-LPREFIX/lib
to $LDFLAGS
. (If the
PREFIX has been omitted /usr/local will be used as
default.) Also, the flags -DDEBUG_DMALLOC
and
-DDMALLOC_FUNC_CHECK
will added to $CPPFLAGS
.
Thus, you can use the following code in your header files to activate or deactivate dmalloc support:
#ifdef DEBUG_DMALLOC # include <dmalloc.h> #endif
1.9 (last modified: 2003-01-15)
AC_DEFUN([PETI_WITH_DMALLOC], [ AC_MSG_CHECKING(whether to use the dmalloc library) AC_ARG_WITH(dmalloc, [ --with-dmalloc[=PREFIX] Compile with dmalloc library], if test "$withval" = "" -o "$withval" = "yes"; then ac_cv_dmalloc="/usr/local" else ac_cv_dmalloc="$withval" fi AC_MSG_RESULT(yes) CPPFLAGS="$CPPFLAGS -DDEBUG_DMALLOC -DDMALLOC_FUNC_CHECK -I$ac_cv_dmalloc/include" LDFLAGS="$LDFLAGS -L$ac_cv_dmalloc/lib" LIBS="$LIBS -ldmalloc" ,AC_MSG_RESULT(no)) ])