SUBDIRS = . test

pkglib_LTLIBRARIES = libgncmod-backend-postgres.la 

libgncmod_backend_postgres_la_LDFLAGS = -module 

libgncmod_backend_postgres_la_LIBADD  =  -lpq  \
  ${top_srcdir}/src/engine/libgncmod-engine.la \
  ${GLIB_LIBS}

libgncmod_backend_postgres_la_SOURCES = \
  PostgresBackend.c \
  account.c \
  builder.c \
  checkpoint.c \
  escape.c \
  events.c \
  gncquery.c \
  gncmod-backend-postgres.c \
  kvp-sql.c \
  price.c \
  txn.c \
  txnmass.c \
  upgrade.c

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

EXTRA_DIST = \
  .cvsignore \
  README \
  base-objects.m4 \
  check-objects.m4 \
  design.txt \
  functions.sql \
  kvp-objects.m4 \
  table.m4 \
  table-audit.sql \
  table-create.sql \
  table-drop.sql \
  table-version.sql \
  demo.c 

AM_CFLAGS = -I.. -I../.. -I../../engine -I../../gnc-module ${GLIB_CFLAGS}

# Some of the required C files are built with the m4 pre-processor
# As a result, we need to manually specify dependencies, clean targets.

PostgresBackend.o: base-autogen.c table-audit.c table-create.c table-version.c table-drop.c functions.c
PostgresBackend.lo: base-autogen.c table-audit.c table-create.c table-version.c table-drop.c functions.c

checkpoint.o: check-autogen.c
checkpoint.lo: check-autogen.c

kvp-sql.o: kvp-autogen.c
kvp-sql.lo: kvp-autogen.c

base-autogen.c:	table.m4 base-objects.m4
	m4 base-objects.m4 > base-autogen.c

check-autogen.c: table.m4 check-objects.m4
	m4 check-objects.m4 > check-autogen.c

kvp-autogen.c:	table.m4 kvp-objects.m4
	m4 kvp-objects.m4 > kvp-autogen.c

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

table-audit.c:	table-audit.sql
	echo \" > table-audit.c
	echo "-- DO NOT EDIT THIS FILE. IT IS AUTOGENERATED." >> table-audit.c
	cat table-audit.sql >> table-audit.c
	echo \" >> table-audit.c

table-create.c:	table-create.sql
	echo \" > table-create.c
	echo "-- DO NOT EDIT THIS FILE. IT IS AUTOGENERATED." >> table-create.c
	cat table-create.sql >> table-create.c
	echo \" >> table-create.c

table-drop.c:	table-drop.sql
	echo \" > table-drop.c
	echo "-- DO NOT EDIT THIS FILE. IT IS AUTOGENERATED." >> table-drop.c
	cat table-drop.sql >> table-drop.c
	echo \" >> table-drop.c

table-version.c: table-version.sql
	echo \" > table-version.c
	echo "-- DO NOT EDIT THIS FILE. IT IS AUTOGENERATED." >> table-version.c
	cat table-version.sql >> table-version.c
	echo \" >> table-version.c

CLEANFILES = base-autogen.c check-autogen.c kvp-autogen.c \
             table-drop.c table-create.c table-version.c functions.c
