AC_INIT(src/ct_main.c) AM_INIT_AUTOMAKE(callgrind,0.9.8) AC_PROG_CC AC_PROG_CXX AC_PROG_INSTALL # set default PREFIX to existing valgrind installation AC_MSG_CHECKING([for valgrind installation]) vg_exec=`which valgrind` if test "x$vg_exec" = "x"; then AC_MSG_RESULT([not found in PATH]) AC_MSG_ERROR([Needs Valgrind >= Snapshot-20030725 (2.0.x,2.1.0 is fine)]) fi vg_binpath=`dirname $vg_exec` ac_default_prefix=`dirname $vg_binpath` AC_MSG_RESULT([in ${ac_default_prefix}]) # Even if a user defined a prefix other than the Valgrind installation # directory of this system, we need to find valgrind.h AC_SUBST(VG_INCDIR) VG_INCDIR="$ac_default_prefix/include/valgrind" AC_SUBST(VG_BINDIR) VG_BINDIR="$ac_default_prefix/bin" if test "x$prefix" = "xNONE"; then prefix=$ac_default_prefix ac_configure_args="$ac_configure_args --prefix=$prefix" fi # And delete superflous '/' to make compares easier prefix=`echo "$prefix" | sed 's,//*,/,g' | sed -e 's,/$,,'` exec_prefix=`echo "$exec_prefix" | sed 's,//*,/,g' | sed -e 's,/$,,'` # to be set to skin interface header file (internal or valgrind installed) AC_SUBST(CT_INCDIR) # check if there is a vg_skin.h installed AC_MSG_CHECKING([if vg_skin.h is available]) CFLAGS="-I $VG_INCDIR" AC_TRY_COMPILE(, [ #include "vg_skin.h" int main() { return 0 ; } ], [ # No need for additional directory CT_INCDIR="" AC_MSG_RESULT([Yes]) ], [ AC_MSG_ERROR([No. Needs header files from Valgrind >= Snapshot-20030725 (2.0.x,2.1.0 is fine). Perhaps there is a missing valgrind-dev package in your distribution?]) ]) # Check for Valgrind version AC_SUBST(CT_OPTIONS) AC_MSG_CHECKING([for valgrind version]) vg_version=`valgrind --version` case "${vg_version}" in valgrind-2.0.*) AC_MSG_RESULT([${vg_version} (stable)]) CT_OPTIONS="--skin=callgrind" ;; valgrind-2.1.*) AC_MSG_RESULT([${vg_version} (unstable)]) AC_DEFINE(VG_UNSTABLE,1,[Unstable Valgrind]) vg_unstable="yes" CT_OPTIONS="--tool=callgrind" ;; *) AC_MSG_RESULT([${vg_version}]) CT_OPTIONS="--tool=callgrind" ;; esac # check if we support skin version of installed valgrind # # Note that versions used in VG releases 2.y.x, with y odd, # are *not* reliable, so we define UNSTABLE to distinguish # unstable VG releases from stable ones reusing versions. AC_MSG_CHECKING([if skin version is supported]) CFLAGS="-I $VG_INCDIR" if test "x$vg_unstable" = "x"; then AC_TRY_RUN([ #include "vg_skin.h" int main() { return (VG_CORE_INTERFACE_MAJOR_VERSION > 5) ? 1:0; } ], [ AC_MSG_RESULT([Yes]) ], [ AC_MSG_ERROR([The installed stable Valgrind is too new for this package. Please update this package!]) ], [ AC_MSG_RESULT([Assuming yes (cross-compiling)]) ]) else AC_TRY_RUN([ #include "vg_skin.h" int main() { return (VG_CORE_INTERFACE_MAJOR_VERSION > 6) ? 1:0; } ], [ AC_MSG_RESULT([Yes]) ], [ AC_MSG_ERROR([The installed unstable Valgrind is too new for this package. Please update this package!]) ], [ AC_MSG_RESULT([Assuming yes (cross-compiling)]) ]) fi # copied from configure.in of valgrind distribution # does this compiler support -mpreferred-stack-boundary=2 ? AC_MSG_CHECKING([if gcc accepts -mpreferred-stack-boundary]) CFLAGS="-mpreferred-stack-boundary=2" AC_TRY_COMPILE(, [ int main () { return 0 ; } ], [ PREFERRED_STACK_BOUNDARY="-mpreferred-stack-boundary=2" AC_MSG_RESULT([$PREFERRED_STACK_BOUNDARY]) ], [ PREFERRED_STACK_BOUNDARY="" AC_MSG_RESULT([no]) ]) AC_SUBST(PREFERRED_STACK_BOUNDARY) AC_OUTPUT( Makefile \ src/Makefile \ docs/Makefile \ man/Makefile \ tests/Makefile \ callgrind \ callgrind_control \ callgrind_annotate)