AC_SUBST([NETWORK_libs])
+AC_ARG_WITH([valgrind],
+ [AS_HELP_STRING([--with-valgrind],
+ [Add instrumentation to help valgrind to understand our allocator])],
+ [],
+ [with_valgrind=no])
+
+if test x$with_valgrind != xno; then
+ PKG_CHECK_MODULES([VALGRIND], [valgrind >= 3.6])
+ AC_DEFINE([WITH_VALGRIND], [1], [Define to add Valgrind instrumentation])
+fi
+
#### Set up final flags
LIBDBUS_LIBS="$THREAD_LIBS $NETWORK_libs"
AC_SUBST([LIBDBUS_LIBS])
-I$(top_builddir) \
-I$(top_srcdir) \
$(SYSTEMD_CFLAGS) \
+ $(VALGRIND_CFLAGS) \
-DDBUS_COMPILATION \
-DDBUS_MACHINE_UUID_FILE=\""$(localstatedir)/lib/dbus/machine-id"\" \
-DDBUS_SYSTEM_CONFIG_FILE=\""$(configdir)/system.conf"\" \
dbus-string-private.h \
$(DBUS_SHARED_arch_sources) \
dbus-sysdeps.c \
- dbus-sysdeps.h
+ dbus-sysdeps.h \
+ dbus-valgrind-internal.h
### source code that is generic utility functionality used
### by the bus daemon or test apps, but is NOT included
--- /dev/null
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
+/* dbus-valgrind-internal.h - valgrind glue
+ *
+ * Copyright © 2011 Nokia Corporation
+ *
+ * Licensed under the Academic Free License version 2.1
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#ifndef DBUS_VALGRIND_INTERNAL_H
+#define DBUS_VALGRIND_INTERNAL_H
+
+#include "config.h"
+#include "dbus-internals.h"
+
+#ifdef WITH_VALGRIND
+# include <memcheck.h>
+# include <valgrind.h>
+#else
+# define VALGRIND_CREATE_MEMPOOL(_1, _2, _3) /* nothing */
+# define VALGRIND_DESTROY_MEMPOOL(_1) /* nothing */
+# define VALGRIND_MEMPOOL_ALLOC(_1, _2, _3) /* nothing */
+# define VALGRIND_MEMPOOL_FREE(_1, _2) /* nothing */
+# define VALGRIND_MAKE_MEM_UNDEFINED(_1, _2) (0)
+
+# define VALGRIND_PRINTF(...) (0)
+# define VALGRIND_PRINTF_BACKTRACE(...) (0)
+
+# define RUNNING_ON_VALGRIND 0
+#endif /* WITH_VALGRIND */
+
+#endif /* header guard */