summaryrefslogtreecommitdiffstats
path: root/src/lib-sql/Makefile.am
blob: 89c3d2dcdda039649f1b9f85bf947c975d3ec223 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
noinst_LTLIBRARIES = libsql.la libdriver_test.la

SQL_DRIVER_PLUGINS =

# automake seems to force making this unconditional..
NOPLUGIN_LDFLAGS =

if SQL_PLUGINS
if BUILD_MYSQL
MYSQL_LIB = libdriver_mysql.la
SQL_DRIVER_PLUGINS += mysql
endif
if BUILD_PGSQL
PGSQL_LIB = libdriver_pgsql.la
SQL_DRIVER_PLUGINS += pgsql
endif
if BUILD_SQLITE
SQLITE_LIB = libdriver_sqlite.la
SQL_DRIVER_PLUGINS += sqlite
endif
if BUILD_CASSANDRA
CASSANDRA_LIB = libdriver_cassandra.la
SQL_DRIVER_PLUGINS += cassandra
endif

sql_module_LTLIBRARIES = \
	$(MYSQL_LIB) \
	$(PGSQL_LIB) \
	$(SQLITE_LIB) \
	$(CASSANDRA_LIB)

sql_moduledir = $(moduledir)
endif

sql_drivers = @sql_drivers@

AM_CPPFLAGS = \
	-I$(top_srcdir)/src/lib \
	-I$(top_srcdir)/src/lib-settings \
	$(SQL_CFLAGS)

dist_sources = \
	sql-api.c \
	sql-db-cache.c

if ! SQL_PLUGINS
driver_sources = \
	driver-mysql.c \
	driver-pgsql.c \
	driver-sqlite.c \
	driver-cassandra.c
endif

libsql_la_SOURCES = \
	$(dist_sources) \
	$(driver_sources) \
	driver-sqlpool.c
libsql_la_LIBADD = $(SQL_LIBS)

nodist_libsql_la_SOURCES = sql-drivers-register.c

deplibs = \
	../lib-dovecot/libdovecot.la

if SQL_PLUGINS
libdriver_mysql_la_LDFLAGS = -module -avoid-version
libdriver_mysql_la_LIBADD = $(MYSQL_LIBS)
libdriver_mysql_la_CPPFLAGS = $(AM_CPPFLAGS) $(MYSQL_CFLAGS)
libdriver_mysql_la_SOURCES = driver-mysql.c

libdriver_pgsql_la_LDFLAGS = -module -avoid-version
libdriver_pgsql_la_LIBADD = $(PGSQL_LIBS)
libdriver_pgsql_la_CPPFLAGS = $(AM_CPPFLAGS) $(PGSQL_CFLAGS)
libdriver_pgsql_la_SOURCES = driver-pgsql.c

libdriver_sqlite_la_LDFLAGS = -module -avoid-version
libdriver_sqlite_la_LIBADD = $(SQLITE_LIBS)
libdriver_sqlite_la_CPPFLAGS = $(AM_CPPFLAGS) $(SQLITE_CFLAGS)
libdriver_sqlite_la_SOURCES = driver-sqlite.c

libdriver_cassandra_la_LDFLAGS = -module -avoid-version
libdriver_cassandra_la_LIBADD = $(CASSANDRA_LIBS)
libdriver_cassandra_la_CPPFLAGS = $(AM_CPPFLAGS) $(CASSANDRA_CFLAGS)
libdriver_cassandra_la_SOURCES = driver-cassandra.c
else
endif

libdriver_test_la_LDFLAGS = -avoid-version
libdriver_test_la_CPPFLAGS = $(AM_CPPFLAGS) \
	-I$(top_srcdir)/src/lib-test
libdriver_test_la_SOURCES = driver-test.c

noinst_HEADERS = driver-test.h

pkglib_LTLIBRARIES = libdovecot-sql.la
libdovecot_sql_la_SOURCES = 
libdovecot_sql_la_LIBADD = libsql.la $(deplibs)
libdovecot_sql_la_DEPENDENCIES = libsql.la
libdovecot_sql_la_LDFLAGS = -export-dynamic

headers = \
	sql-api.h \
	sql-api-private.h \
	sql-db-cache.h

pkginc_libdir=$(pkgincludedir)
pkginc_lib_HEADERS = $(headers)

sql-drivers-register.c: Makefile
	rm -f $@
	echo '/* this file automatically generated by Makefile */' >$@
	echo '#include "lib.h"' >>$@
	echo '#include "sql-api.h"' >>$@
if ! SQL_PLUGINS
	for i in $(sql_drivers) null; do \
	  if [ "$${i}" != "null" ]; then \
	        echo "extern struct sql_db driver_$${i}_db;" >>$@ ; \
	  fi; \
	done
endif
	echo 'void sql_drivers_register_all(void) {' >>$@
if ! SQL_PLUGINS
	for i in $(sql_drivers) null; do \
	  if [ "$${i}" != "null" ]; then \
	        echo "sql_driver_register(&driver_$${i}_db);" >>$@ ; \
	  fi; \
	done
endif
	echo '}' >>$@

if SQL_PLUGINS
install-exec-local:
	for d in auth dict; do \
	  $(mkdir_p) $(DESTDIR)$(moduledir)/$$d; \
	  for driver in $(SQL_DRIVER_PLUGINS); do \
	    rm -f $(DESTDIR)$(moduledir)/$$d/libdriver_$$driver.so; \
	    $(LN_S) ../libdriver_$$driver.so $(DESTDIR)$(moduledir)/$$d; \
	  done; \
	done
endif


distclean-generic:
	rm -f Makefile sql-drivers-register.c