auto import from //depot/cupcake/@135843
diff --git a/m4/dmalloc.m4 b/m4/dmalloc.m4
new file mode 100644
index 0000000..f724670
--- /dev/null
+++ b/m4/dmalloc.m4
@@ -0,0 +1,22 @@
+## ----------------------------------- ##
+## Check if --with-dmalloc was given.  ##
+## From Franc,ois Pinard               ##
+## ----------------------------------- ##
+
+# serial 1
+
+AC_DEFUN([AM_WITH_DMALLOC],
+[AC_MSG_CHECKING([if malloc debugging is wanted])
+AC_ARG_WITH(dmalloc,
+[  --with-dmalloc          use dmalloc, as in
+                          http://www.dmalloc.com/dmalloc.tar.gz],
+[if test "$withval" = yes; then
+  AC_MSG_RESULT(yes)
+  AC_DEFINE(WITH_DMALLOC,1,
+            [Define if using the dmalloc debugging malloc package])
+  LIBS="$LIBS -ldmalloc"
+  LDFLAGS="$LDFLAGS -g"
+else
+  AC_MSG_RESULT(no)
+fi], [AC_MSG_RESULT(no)])
+])