#!/bin/sh

# Usage: gnucash-env any-cmd [ args ... ]
# runs any-cmd in an environment appropriate for gnucash.
# we'll also add a gnucash-build-env later for running from the install tree.

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}"
DYLD_LIBRARY_PATH="${EXTRA_LIBS}:${DYLD_LIBRARY_PATH}"

export GNC_MODULE_PATH
export GUILE_LOAD_PATH
export LD_LIBRARY_PATH
export DYLD_LIBRARY_PATH

exec "$@"
