SUBDIRS = . test

lib_LTLIBRARIES = libgnc-backend-postgres.la 

libgnc_backend_postgres_la_LDFLAGS = -module 

libgnc_backend_postgres_la_LIBADD  =  ${PGSQL_LIBS} -lpq  \
  ${top_builddir}/src/engine/libgncmod-engine.la \
  ${QOF_LIBS} \
  ${GLIB_LIBS}

libgnc_backend_postgres_la_SOURCES = \
  PostgresBackend.c \
  account.c \
  book.c \
  builder.c \
  checkpoint.c \
  escape.c \
  events.c \
  gncquery.c \
  kvp-sql.c \
  price.c \
  txn.c \
  txnmass.c \
  upgrade.c \
  putil.c

## Distributed autogenerated and #included files
EXTRA_libgnc_backend_postgres_la_SOURCES = \
  base-autogen.c \
  check-autogen.c \
  kvp-autogen.c \
  table-audit.c \
  table-drop.c \
  table-create.c \
  table-version.c \
  functions.c

noinst_HEADERS = \
  PostgresBackend.h \
  account.h \
  base-autogen.h \
  book.h \
  builder.h \
  checkpoint.h \
  check-autogen.h \
  escape.h \
  events.h \
  gncquery.h \
  kvp-autogen.h \
  kvp-sql.h \
  price.h \
  putil.h \
  txn.h \
  txnmass.h \
  upgrade.h \
  newtables.h

EXTRA_DIST = \
  .cvsignore \
  README \
  design.txt \
  functions.sql \
  table.m4 \
  table-audit.sql \
  table-create.sql \
  table-drop.sql \
  table-version.sql \
  demo.c  \
  $(M4_SRC)

BUILT_SOURCES = \
	base-autogen.c \
	base-autogen.h \
	check-autogen.c \
	check-autogen.h \
	kvp-autogen.c \
	kvp-autogen.h \
	table-audit.c \
	table-drop.c \
	table-create.c \
	table-version.c \
	functions.c

M4_SRC = \
	base-objects.m4 \
	base-objects-header.m4 \
	check-objects.m4 \
	check-objects-header.m4 \
	kvp-objects.m4 \
	kvp-objects-header.m4

SUFFIXES = .sql

AM_CFLAGS = \
	-I.. -I${srcdir}/.. \
	-I../.. -I${srcdir}/../.. \
	-I../../engine -I${srcdir}/../../engine \
	${PGSQL_CFLAGS} \
	${QOF_CFLAGS} \
	${GLIB_CFLAGS}

$(M4_SRC): table.m4

%-autogen.c: %-objects.m4  table.m4
	m4 -I ${srcdir} $< > $@

%-autogen.h: %-objects-header.m4 table.m4
	m4 -I ${srcdir} $< > $@

.sql.c:
	echo "\"-- DO NOT EDIT THIS FILE. IT IS AUTOGENERATED.\"" > $@
	cat $< >> $@
