
lib_LTLIBRARIES =libgncguile.la libgw-gnc.la 

libgncguile_la_SOURCES = \
  gw-gnc.c \
  gnucash.c \
  tip-of-the-day.c
libgncguile_la_LIBADD = ${GLIB_LIBS}
libgncguile_la_LDFLAGS = -module -L. L.libs

docdir = ${GNC_DOC_INSTALL_DIR}
doc_DATA = gw-gnc.html

configdir = ${GNC_CONFIGDIR}
config_DATA = config

libgw_gnc_la_SOURCES = gw-gnc.c
libgw_gnc_la_LIBADD = ${G_WRAP_LINK_ARGS} ${GLIB_LIBS}
libgw_gnc_la_LDFLAGS = -module -L. L.libs

gwmoddir = ${GNC_GWRAP_LIBDIR}
gwmod_DATA = gw-gnc-spec.scm gw-gnc.scm

noinst_HEADERS = \
  gw-gnc.h \
  gnucash.h \
  i18n.h \
  tip-of-the-day.h

EXTRA_DIST = \
  .cvsignore \
  config \
  design.txt \
  gnucash.c.in \
  i18n.h.in \
  ${gwmod_DATA}

CFLAGS = @CFLAGS@ \
  -I.. \
  -I../engine \
  -I../app-utils \
  -I../gnome \
  -I../gnome-utils \
  -I../app-utils \
  -I../app-file \
  -I../register/ledger-core \
  -I../register/register-core \
  ${GUILE_INCS} \
  ${G_WRAP_COMPILE_ARGS} \
  ${GLIB_CFLAGS} \
  ${GTKHTML_CFLAGS} \
  ${GNOME_PRINT_CFLAGS} \
  ${GNOME_INCLUDEDIR}


noinst_DATA = .scm-links

.scm-links: 
	rm -f gnucash g-wrapped
	ln -sf . gnucash 
	ln -sf . g-wrapped 
	touch .scm-links
CLEANFILES = .scm-links gnucash g-wrapped

gw-gnc.scm gw-gnc.h gw-gnc.c gw-gnc.html: gw-gnc-spec.scm .scm-links
	FLAVOR=gnome guile -c \
          "(set! %load-path (cons \"${G_WRAP_MODULE_DIR}\" %load-path)) \
           (set! %load-path (cons \"../engine\" %load-path)) \
           (primitive-load \"./gw-gnc-spec.scm\") \
           (gw:generate-module \"gw-gnc\")"
BUILT_SOURCES = gw-gnc.scm gw-gnc.h gw-gnc.c
CLEANFILES += gw-gnc.scm gw-gnc.h gw-gnc.c 

## We borrow guile's convention and use @-...-@ as the substitution
## brackets here, instead of the usual @...@.  This prevents autoconf
## from substituting the values directly into the left-hand sides of
## the sed substitutions.
gnucash.c: gnucash.c.in i18n.h
	rm -f $@.tmp
	sed < $@.in > $@.tmp \
            -e 's:@-GNC_SHAREDIR-@:${GNC_SHAREDIR}:g' \
            -e 's:@-G_WRAP_MODULE_DIR-@:${G_WRAP_MODULE_DIR}:g'
	mv $@.tmp $@
BUILT_SOURCES += gnucash.c
# Make it go away on a make clean, not just a make distclean.
CLEANFILES += gnucash.c

i18n.h: i18n.h.in
	rm -f $@.tmp
	sed < $@.in > $@.tmp \
            -e 's:@-PACKAGE-@:${PACKAGE}:g' \
            -e 's:@-LOCALE_DIR-@:${LOCALE_DIR}:g'
	mv $@.tmp $@
# This has to be in BUILT_SOURCES because other files depend on it,
# but it's never a target itself.
BUILT_SOURCES += i18n.h

# We have to do this because otherwise automake insists on putting
# these files into the dist tarfile.  If there's a a better way,
# by all means, let us know...
dist-hook:
	rm ${distdir}/gw-gnc.c
	rm ${distdir}/gw-gnc.h
	rm ${distdir}/gnucash.c
	rm ${distdir}/i18n.h
