test "${enable_debug}" != "yes" && enable_debug="no"
AH_TEMPLATE(NDEBUG,
[Define to 1 if debug code should NOT be compiled])
-AS_IF([test "x${enable_debug}" = "xno"], [AC_DEFINE(NDEBUG)])
+AS_IF([test "x${enable_debug}" = "xno"], [
+ AC_DEFINE(NDEBUG)
+], [
+ AC_CHECK_HEADERS([valgrind/valgrind.h])
+])
dnl
dnl Allow runing as root (usefull for people runing on embedded platforms)
# include <dl.h>
# endif
#endif
+#ifdef HAVE_VALGRIND_VALGRIND_H
+# include <valgrind/valgrind.h>
+#endif
/*****************************************************************************
* Local prototypes
FreeLibrary( handle );
#elif defined(HAVE_DL_DLOPEN)
-# ifdef NDEBUG
- dlclose( handle );
-# else
- (void)handle;
+# ifdef HAVE_VALGRIND_VALGRIND_H
+ if( RUNNING_ON_VALGRIND > 0 )
+ return; /* do not dlclose() so that we get proper stack traces */
# endif
+ dlclose( handle );
#elif defined(HAVE_DL_SHL_LOAD)
shl_unload( handle );