From 2dc812f720191f68b35cbaed7cdc7e8995da3c41 Mon Sep 17 00:00:00 2001 From: Shiqing Fan Date: Wed, 4 Jun 2008 11:46:50 +0000 Subject: [PATCH] Clean configure.m4 of memchecker/valgrind. If Valgrind is requested but wrong version is supplied, print error messages and stop. Save the CPPFLAGS in opal_memchecker_valgrind_CPPFLAGS, which could be used in Makefile.am. Many thanks to Jeff. This commit was SVN r18573. --- opal/mca/memchecker/configure.m4 | 18 ++++-- opal/mca/memchecker/valgrind/configure.m4 | 72 ++++++++--------------- 2 files changed, 37 insertions(+), 53 deletions(-) diff --git a/opal/mca/memchecker/configure.m4 b/opal/mca/memchecker/configure.m4 index ae72b252b6..7d1e441000 100644 --- a/opal/mca/memchecker/configure.m4 +++ b/opal/mca/memchecker/configure.m4 @@ -2,6 +2,7 @@ dnl -*- shell-script -*- dnl dnl Copyright (c) 2004-2006 High Performance Computing Center Stuttgart, dnl University of Stuttgart. All rights reserved. +dnl Copyright (c) 2008 Cisco Systems, Inc. All rights reserved. dnl $COPYRIGHT$ dnl dnl Additional copyrights may follow @@ -13,18 +14,25 @@ dnl we only want one :) m4_define(MCA_memchecker_CONFIGURE_MODE, STOP_AT_FIRST) AC_DEFUN([MCA_memchecker_CONFIG],[ + ompi_show_subsubtitle "Pre-configuring the framework memchecker" - - AC_MSG_CHECKING([if the memchecker mca should be enabled]) + AC_MSG_CHECKING([if --enable-memchecker was specified]) AC_ARG_ENABLE(memchecker, AC_HELP_STRING([--enable-memchecker], - [Enable memory and buffer checks (default: disabled)])) + [Enable memory and buffer checks. Note that disabling will *also* add "memchecker" to the --enable-mca-no-build list (default: disabled)])) if test "$enable_memchecker" = "yes"; then AC_MSG_RESULT([yes]) WANT_MEMCHECKER=1 else - AC_MSG_RESULT([no]) + AC_MSG_RESULT([no (adding "memchecker" to --enable-mca-no-build list)]) WANT_MEMCHECKER=0 + + # Setting this environment variable causes + # MCA_COMONENT_BUILD_CHECK (in ompi_mca.m4, invoked by + # MCA_CONFIGURE_FRAMEWORK, below) to rule that the component + # should not be built. It is effectively the same as adding + # "memchecker" to the --enable-mca-no-build list. + DISABLE_memchecker=1 fi AC_DEFINE_UNQUOTED([OMPI_WANT_MEMCHECKER], [$WANT_MEMCHECKER], @@ -32,8 +40,6 @@ AC_DEFUN([MCA_memchecker_CONFIG],[ AM_CONDITIONAL([OMPI_WANT_MEMCHECKER], [test "$WANT_MEMCHECKER" = "1"]) - memchecker_base_found=0 - # first, compile all the components MCA_CONFIGURE_FRAMEWORK($1, $2, 1) diff --git a/opal/mca/memchecker/valgrind/configure.m4 b/opal/mca/memchecker/valgrind/configure.m4 index 461eb797a5..9ab02490ca 100644 --- a/opal/mca/memchecker/valgrind/configure.m4 +++ b/opal/mca/memchecker/valgrind/configure.m4 @@ -2,6 +2,7 @@ # # Copyright (c) 2004-2008 High Performance Computing Center Stuttgart, # University of Stuttgart. All rights reserved. +# Copyright (c) 2008 Cisco Systems, Inc. All rights reserved. # $COPYRIGHT$ # # Additional copyrights may follow @@ -24,53 +25,30 @@ AC_DEFUN([MCA_memchecker_valgrind_CONFIG],[ [AC_HELP_STRING([--with-valgrind(=DIR)], [Directory where the valgrind software is installed])]) - if test "$WANT_MEMCHECKER" = "1" ; then + ompi_check_memchecker_valgrind_save_CPPFLAGS="$CPPFLAGS" + ompi_check_memchecker_valgrind_happy=no - AC_MSG_CHECKING([for the valgrind include directory]) - if test -n "$with_valgrind" -a -d "$with_valgrind/include" ; then - CPPFLAGS="$CPPFLAGS -I$with_valgrind/include" - AC_MSG_RESULT([$with_valgrind/include]) - - AC_CHECK_HEADER([valgrind/valgrind.h], - [AC_CHECK_HEADER([valgrind/memcheck.h], - [happy=yes])]) + AS_IF([test "$with_valgrind" != "no"], + [AS_IF([test ! -z "$with_valgrind" -a "$with_valgrind" != "yes"], + [CPPFLAGS="$CPPFLAGS -I$with_valgrind/include" + opal_memchecker_valgrind_CPPFLAGS="-I$with_valgrind/include"]) + AC_CHECK_HEADERS([valgrind/valgrind.h], + [AC_MSG_CHECKING([for VALGRIND_CHECK_MEM_IS_ADDRESSABLE]) + AC_COMPILE_IFELSE(AC_LANG_PROGRAM([[ +#include "valgrind/memcheck.h" +]], + [[char buffer = 0xff; + VALGRIND_CHECK_MEM_IS_ADDRESSABLE(&buffer, sizeof(buffer));]]), + [AC_MSG_RESULT([yes]) + ompi_check_memchecker_valgrind_happy=yes], + [AC_MSG_RESULT([no])] + [AC_MSG_ERROR([Need Valgrind version 3.2.0 or later. Can not build component.])]) + ], + [AC_MSG_WARN([valgrind.h not found]) + AC_MSG_WARN([Cannot compile this component])])]) - if test "x$happy" != "xyes" ; then - AC_MSG_WARN([*** Could not find valgrind header files, as valgrind support was requested]) - AC_MSG_WARN([*** Cannot compile this component]) - memchecker_valgrind_happy=0 - want_component=0 - should_build=2 - else - AC_MSG_CHECKING([for VALGRIND_CHECK_MEM_IS_ADDRESSABLE inside valgrind/memcheck.h]) - - AC_TRY_COMPILE([#include "valgrind/memcheck.h"], - [ - char buffer = 0xff; - VALGRIND_CHECK_MEM_IS_ADDRESSABLE(&buffer, sizeof(buffer)); - ], valgrind_version_new=yes, valgrind_version_new=no) - AC_MSG_RESULT($valgrind_version_new) - - if test "x$valgrind_version_new" != "xyes" ; then - AC_MSG_WARN([*** Need at least Valgrind v3.2.0, please specify using --with-valgrind]) - AC_MSG_WARN([*** Cannot compile this component]) - memchecker_valgrind_happy=0 - want_component=0 - should_build=2 - fi - fi - else - AC_MSG_RESULT([not found]) - AC_MSG_WARN([*** Cannot compile this component]) - memchecker_valgrind_happy=0 - want_component=0 - should_build=2 - fi - else - happy=0 # none_needed - happy_value=0 # none_needed - memchecker_valgrind_happy=0 # This should suffice to get rid of the component - should_build=2 - want_component=0 - fi + CPPFLAGS="$ompi_check_memchecker_valgrind_save_CPPFLAGS" + + AS_IF([test "$ompi_check_valgrind_happy" = "yes"], + [$1], [$2]) ])dnl