#!/bin/sh

PATH="/usr/local/bin:${PATH}"
export PATH

GUILE_WARN_DEPRECATED="no"
export GUILE_WARN_DEPRECATED

GNC_MODULE_PATH="/usr/local/lib/gnucash:${GNC_MODULE_PATH}"

EXTRA_PATH="${EXTRA_PATH}:/usr/local/share/gnucash/guile-modules"
EXTRA_PATH="${EXTRA_PATH}:/usr/local/share/gnucash/scm"
GUILE_LOAD_PATH="${EXTRA_PATH}:${GUILE_LOAD_PATH}"

EXTRA_LIBS="${GNC_MODULE_PATH}"
EXTRA_LIBS="${EXTRA_LIBS}:/usr/local/lib"
EXTRA_LIBS="${EXTRA_LIBS}:/usr/local/lib/gnucash"

LD_LIBRARY_PATH="${EXTRA_LIBS}:${LD_LIBRARY_PATH}"
TOP_SRC_DIR="/usr/obj/ports/gnucash-2.2.9p0/gnucash-2.2.9/src/bin/../.."

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 "$@"
