# -*- Makefile -*-
lib_LTLIBRARIES += libbongomsgapi.la

libbongomsgapi_la_SOURCES =			\
	src/libs/msgapi/cookie.c		\
	src/libs/msgapi/msgaddr.c		\
	src/libs/msgapi/msgapi.c		\
	src/libs/msgapi/msgapip.h		\
	src/libs/msgapi/msgauth.c		\
	src/libs/msgapi/msgcollector.c		\
	src/libs/msgapi/msgdate.c		\
	src/libs/msgapi/msghttp.c		\
	src/libs/msgapi/plugin-api.h		\
	src/libs/msgapi/sqldb.c			\
	src/libs/msgapi/msghttp.h

libbongomsgapi_la_CPPFLAGS = $(AM_CPPFLAGS) \
	$(LIBCURL_CPPFLAGS) \
	$(LIBICAL_CFLAGS) \
	$(SQLITE_CFLAGS)

libbongomsgapi_la_LIBADD =					   \
	libbongocal.la						   \
	libbongoconnio.la					   \
	libbongoutil.la						   \
	libbongo-json.la						   \
	libbongomemmgr.la					   \
	libbongonmap.la						   \
	libbongoxpl.la						   \
	$(LIBCURL_LIBS)						   \
	$(SQLITE_LIBS)                                             \
	$(LIBICAL_LIBS)                                            \
        $(DL_LIBS)						   

# auth backends
authdir = $(libdir)/bongo-auth/
auth_std_libadd = \
	$(top_builddir)/import/log4c/log4c/libbongolog4c.la \
	libbongomemmgr.la \
	$(PTHREAD_LIBS) \
	$(ALL_LIBS)

auth_LTLIBRARIES = libauthsqlite3.la

libauthsqlite3_la_SOURCES =			\
	src/libs/msgapi/auth-backends/sqlite.h	\
	src/libs/msgapi/auth-backends/sqlite.c

libauthsqlite3_la_CPPFLAGS = $(AM_CPPFLAGS) $(SQLITE_CFLAGS)

libauthsqlite3_la_LIBADD =				\
	$(SQLITE_LIBS) \
	$(auth_std_libadd)

if HAVE_LDAP
auth_LTLIBRARIES += libauthldap.la
endif

libauthldap_la_SOURCES = src/libs/msgapi/auth-backends/ldap.c
libauthldap_la_CPPFLAGS = $(AM_CPPFLAGS)
libauthldap_la_LIBADD = $(LDAP_LIBS)

if HAVE_ODBC
auth_LTLIBRARIES += libauthodbc.la
endif

libauthodbc_la_SOURCES = src/libs/msgapi/auth-backends/odbc.c
libauthodbc_la_CPPFLAGS = $(AM_CPPFLAGS)
libauthodbc_la_LIBADD = $(ODBC_LIBS)

src/libs/msgapi/all: libbongomsgapi.la $(auth_LTLIBRARIES)
src/libs/msgapi/clean: clean
src/libs/msgapi/install:
	@cd $(top_builddir) && $(MAKE) $(MFLAGS) lib_LTLIBRARIES=libbongomsgapi.la install-libLTLIBRARIES
