In order to instrument your automake project with Purify, you would need to perform following modifications to your project files:
- add SUPPORT_PURIFY m4 macro to the project files
- modify configure.ac
- modify $rootdir/Makefile.am
- add Purify-specific bootstrap script
Add m4 macro to test Purify installation
Under $rootdir create macros directory and add support_purify.m4 file:
AC_DEFUN([SUPPORT_PURIFY],
[
dnl Name: support-purify.m4
dnl
dnl Description: Definition of SUPPORT_PURIFY m4 macro.
dnl
dnl
AC_ARG_ENABLE(purify-linker,
[AC_HELP_STRING([--enable-purify-linker],
[Augment the linker with purify.])],
[enable_purify_linker=$withval],
[enable_purify_linker=no])
if test "x$enable_purify_linker" = xyes ; then
echo "Option enabled --enable-purify-linker=yes"
AC_DEFINE([USE_PURIFY_LINKER],[],[Link-time support for Purify.])
use_purify_linker=yes
else
use_purify_linker=no
fi
dnl ====================================================
dnl Specify location of PURIFY
AC_MSG_CHECKING(for purify)
AC_ARG_WITH(purify,
[ --with-purify=PATH Specify the prefix where purify is installed],
,
test "$purify_PREFIX" && with_purify="$purify_PREFIX")
test "$with_purify" &&
test ! "$with_purify" = no &&
purify_PREFIX="$with_purify"
AC_MSG_RESULT($purify_PREFIX)
AC_SUBST(purify_BIN)
echo "purify_BIN is $purify_BIN"
dnl ====================================================
dnl Specify options for Purify
AC_ARG_WITH(purify-options,
[ --with-purify-options=ARG manually set PURIFY options to ARG],
PURIFY_OPTIONS=$with_purify_options,
PURIFY_OPTIONS="-follow-child-processes=yes -windows=no -cache-dir=${HOME}/tmp -always-use-cache-dir=yes -view-file=${HOME}/tmp/%v-%p.pv -messages=batch")
AC_SUBST(PURIFY_OPTIONS)
dnl ====================================================
dnl Augment linker
if test "x$enable_purify_linker" = xyes ; then
echo "augment the linker"
AUX_LINKER="${purify_BIN} ${PURIFY_OPTIONS}"
echo "AUX_LINKER = $AUX_LINKER"
fi
AC_SUBST(AUX_LINKER)
CCLD="$AUX_LINKER $CXX"
CXXLD="$AUX_LINKER $CXX"
AC_SUBST(CXXLD)
AC_SUBST(CCCLD)
echo "In macro SUPPORT PURIFY: CXX = $CXX"
echo "In macro SUPPORT PURIFY: CXXLD = $CXXLD"
dnl ====================================================
dnl End of Purify macro definition
]
)
Modify configure.ac
m4_include([macros/support_purify.m4])
SUPPORT_PURIFY
Modify $topdir/Makefile.am
Add 'bootstrap-dev-purify' and 'macros/support_purify.m4' to your EXTRA_DIST target.
Purify-specific bootstrap script
Modify your bootstrap script to enable Purify instrumentation:
autogen.sh
configure --prefix=$INSTALLDIR --enable-purify-linker=yes
make
Conclusion
Now you can run 'bootstrap-dev-purify' script to let automake test Purify on your system and if successful, instrument your project with Purify-enabled object code.