#!/bin/sh

PATH="@-BIN_DIR-@:${PATH}"
export PATH

GUILE_WARN_DEPRECATED="no"
export GUILE_WARN_DEPRECATED

GNC_MODULE_PATH="@-GNC_PKGLIB_INSTALLDIR-@:${GNC_MODULE_PATH}"

EXTRA_PATH="${EXTRA_PATH}:@-GNC_GUILE_MODULE_DIR-@"
EXTRA_PATH="${EXTRA_PATH}:@-GNC_SCM_INSTALL_DIR-@"
GUILE_LOAD_PATH="${EXTRA_PATH}:${GUILE_LOAD_PATH}"

EXTRA_LIBS="${GNC_MODULE_PATH}"
EXTRA_LIBS="${EXTRA_LIBS}:@-GNC_LIB_INSTALLDIR-@"
EXTRA_LIBS="${EXTRA_LIBS}:@-GNC_PKGLIB_INSTALLDIR-@"

LD_LIBRARY_PATH="${EXTRA_LIBS}:${LD_LIBRARY_PATH}"
TOP_SRC_DIR="@-TOP_SRC_DIR-@"

export GNC_MODULE_PATH
export GUILE_LOAD_PATH
export LD_LIBRARY_PATH

#
# Other potentially useful options, particularly for valgrind-2.x:
# --tool=memcheck --trace-children=yes
#
exec valgrind -v \
    --suppressions=${TOP_SRC_DIR}/src/valgrind-gnucash.supp  \
    --error-limit=no \
    --tool=callgrind \
    --instr-atstart=no \
    --collect-atstart=no \
    gnucash-bin "$@"
