#!/bin/sh

# Usage: gnucash-build-env

# Usage: gnucash-build-env any-cmd [ args ... ]
# runs any-cmd in gnucash's build environment.

# As with all the other gnucash overrides scripts, expects PATH to be
# set appropriately.

top_srcdir="@-GNC_SRCDIR-@"
top_builddir="@-GNC_BUILDDIR-@"

if test "${GNC_CONFIG_PATH}"x = x
then
  GNC_CONFIG_PATH="(\"${top_srcdir}/src/scm\")"
  export GNC_CONFIG_PATH
fi

if test "${GNC_SHARE_PATH}"x = x
then
  GNC_SHARE_PATH="(\"${top_srcdir}/src/scm\" \"${top_srcdir}/src/quotes\")"
  export GNC_SHARE_PATH
fi

if test "${GNC_DOC_PATH}"x = x
then
  GNC_DOC_PATH="(\"${top_srcdir}/src/scm\")"
  export GNC_DOC_PATH
fi

set +x
eval `${top_srcdir}/src/gnc-test-env.pl \
  --gnc-module-dir ${top_builddir}/src/engine \
  --gnc-module-dir ${top_builddir}/src/backend/xml \
  --gnc-module-dir ${top_builddir}/src/network-utils \
  --gnc-module-dir ${top_builddir}/src/calculation \
  --gnc-module-dir ${top_builddir}/src/tax/us \
  --gnc-module-dir ${top_builddir}/src/app-utils \
  --gnc-module-dir ${top_builddir}/src/gnome-utils \
  --gnc-module-dir ${top_builddir}/src/gnome-search \
  --gnc-module-dir ${top_builddir}/src/report/report-system \
  --gnc-module-dir ${top_builddir}/src/report/standard-reports \
  --gnc-module-dir ${top_builddir}/src/report/utility-reports \
  --gnc-module-dir ${top_builddir}/src/report/locale-specific/us \
  --gnc-module-dir ${top_builddir}/src/report/report-gnome \
  --gnc-module-dir ${top_builddir}/src/report/stylesheets \
  --gnc-module-dir ${top_builddir}/src/register/register-core \
  --gnc-module-dir ${top_builddir}/src/register/register-gnome \
  --gnc-module-dir ${top_builddir}/src/register/ledger-core \
  --gnc-module-dir ${top_builddir}/src/import-export \
  --gnc-module-dir ${top_builddir}/src/import-export/qif-import \
  --gnc-module-dir ${top_builddir}/src/import-export/ofx \
  --gnc-module-dir ${top_builddir}/src/import-export/hbci \
  --gnc-module-dir ${top_builddir}/src/import-export/log-replay \
  --gnc-module-dir ${top_builddir}/src/business/business-core \
  --gnc-module-dir ${top_builddir}/src/business/business-core/file \
  --gnc-module-dir ${top_builddir}/src/business/business-utils \
  --gnc-module-dir ${top_builddir}/src/business/dialog-tax-table \
  --gnc-module-dir ${top_builddir}/src/business/business-ledger \
  --gnc-module-dir ${top_builddir}/src/business/business-gnome \
  --guile-load-dir ${top_builddir}/src/core-utils \
  --guile-load-dir ${top_builddir}/src/gnc-module \
  --guile-load-dir ${top_builddir}/src/engine \
  --guile-load-dir ${top_builddir}/src/scm \
  --guile-load-dir ${top_builddir}/src/tax/us \
  --guile-load-dir ${top_builddir}/src/app-utils \
  --guile-load-dir ${top_builddir}/src/gnome-utils \
  --guile-load-dir ${top_builddir}/src/report/report-system \
  --guile-load-dir ${top_builddir}/src/report/standard-reports \
  --guile-load-dir ${top_builddir}/src/report/utility-reports \
  --guile-load-dir ${top_builddir}/src/report/locale-specific/us \
  --guile-load-dir ${top_builddir}/src/report/report-gnome \
  --guile-load-dir ${top_builddir}/src/report/stylesheets \
  --guile-load-dir ${top_builddir}/src/import-export/qif-import \
  --guile-load-dir ${top_builddir}/src/business/business-gnome \
  --guile-load-dir ${top_builddir}/src/business/business-reports \
  --library-dir    ${top_builddir}/src/test-core \
  --library-dir    ${top_builddir}/src/libqof/qof \
  --library-dir    ${top_builddir}/src/core-utils \
  --library-dir    ${top_builddir}/src/calculation \
  --library-dir    ${top_builddir}/src/app-utils \
  --library-dir    ${top_builddir}/src/gnome-utils \
  --library-dir    ${top_builddir}/src/html \
  --library-dir    ${top_builddir}/src/engine \
  --library-dir    ${top_builddir}/src/backend/xml \
  --library-dir    ${top_builddir}/src/backend/sql  \
  --library-dir    ${top_builddir}/src/gnc-module \
  --library-dir    ${top_builddir}/src/gnome \
  --library-dir    ${top_builddir}/src/gnome-search \
  --library-dir    ${top_builddir}/src/import-export \
  --library-dir    ${top_builddir}/src/register/register-gnome \
  --library-dir    ${top_builddir}/src/register/register-core \
  --library-dir    ${top_builddir}/src/register/ledger-core \
  --library-dir    ${top_builddir}/src/business/business-ledger \
  --library-dir    ${top_builddir}/src/report/report-system \
  --library-dir    ${top_builddir}/src/report/report-gnome
  `
LD_LIBRARY_PATH="${DYLD_LIBRARY_PATH}"

exec "$@"
