Google

Back to the Main Page.

peti_with_dmalloc

Download the M4 Source.

Synopsis

PETI_WITH_DMALLOC

Version

1.2 (2001/07/26)     Installed_Packages @ ac-archive-0.5.39

Author

Peter Simons <simons@computer.org>

Description

The dmalloc library is an useful tool to debug memory problems in your programs, but you don't really want to compile dmalloc-support into every binary you produce, because dmalloc brings performance loss.

The PETI_WITH_DMALLOC macro defines a user switch '--with-dmalloc' which can be used likes this:

      ./configure --with-dmalloc[=BASE-PATH]

If no BASE-PATH has been provided, "/usr/local" will be used as default.

The BASE-PATH is the place where autoconf expects to find the include- and link library files of dmalloc, specifically in:

      $(BASE-PATH)/include
      $(BASE-PATH)/lib

If dmalloc-support has been enabled, the pre-processor defines "DEBUG_DMALLOC" and "DMALLOC_FUNC_CHECK" will added to CPPFLAGS as well as the apropriate "-I" statement.

Use the first define in your source codes to determine whether you have dmalloc support enabled or not. Usually something like this will suffice:

      #ifdef DEBUG_DMALLOC
      #  include <dmalloc.h>
      #endif

You will find dmalloc at <http://www.dmalloc.com/>.

M4 Source Code
AC_DEFUN([PETI_WITH_DMALLOC], [
AC_MSG_CHECKING(whether to use dmalloc library)
AC_ARG_WITH(dmalloc,
[  --with-dmalloc[=ARG]     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))
])