summaryrefslogtreecommitdiffstats
path: root/src/lib-dict-backend/Makefile.am
blob: 80c505012a9275fe252aa6c2ace6f18d3555cdad (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
noinst_LTLIBRARIES = libdict_backend.la

module_dictdir = $(moduledir)/dict
dict_drivers = @dict_drivers@

AM_CPPFLAGS = \
	-I$(top_srcdir)/src/lib \
	-I$(top_srcdir)/src/lib-test \
	-I$(top_srcdir)/src/lib-dict \
	-I$(top_srcdir)/src/lib-ldap \
	-I$(top_srcdir)/src/lib-sql \
	-I$(top_srcdir)/src/lib-settings \
	$(SQL_CFLAGS)

NOPLUGIN_LDFLAGS =

ldap_sources = \
	dict-ldap.c \
	dict-ldap-settings.c

libdict_backend_la_SOURCES = \
	dict-cdb.c \
	dict-sql.c \
	dict-sql-settings.c \
	$(ldap_sources)
libdict_backend_la_LIBADD =

nodist_libdict_backend_la_SOURCES = \
	dict-drivers-register.c

noinst_HEADERS = \
	dict-ldap-settings.h \
	dict-sql.h \
	dict-sql-private.h \
	dict-sql-settings.h

if LDAP_PLUGIN
LIBDICT_LDAP = libdict_ldap.la
libdict_ldap_la_DEPENDENCIES = $(LIBDOVECOT_LDAP) $(LIBDOVECOT_DEPS)
libdict_ldap_la_LDFLAGS = -module -avoid-version
libdict_ldap_la_LIBADD = $(LIBDOVECOT_LDAP) $(LIBDOVECOT)
libdict_ldap_la_CPPFLAGS = $(AM_CPPFLAGS) -DPLUGIN_BUILD
libdict_ldap_la_SOURCES = $(ldap_sources)
else
if HAVE_LDAP
libdict_backend_la_LIBADD += $(LIBDOVECOT_LDAP)
dict_drivers += ldap
endif
endif

module_dict_LTLIBRARIES = \
	$(LIBDICT_LDAP)

EXTRA_DIST = dict.conf

dict-drivers-register.c: Makefile $(top_builddir)/config.h
	rm -f $@
	echo '/* this file automatically generated by Makefile */' >$@
	echo '#include "lib.h"' >>$@
	echo '#include "dict.h"' >>$@
	echo '#include "ldap-client.h"' >>$@
	echo '#include "dict-sql.h"' >>$@
	for i in $(dict_drivers) null; do \
	  if [ "$${i}" != "null" ]; then \
	        echo "extern struct dict dict_driver_$${i};" >>$@ ; \
	  fi; \
	done
	echo 'void dict_drivers_register_all(void) {' >>$@
	echo 'dict_drivers_register_builtin();' >>$@
	echo 'dict_sql_register();' >>$@
	for i in $(dict_drivers) null; do \
	  if [ "$${i}" != "null" ]; then \
	        echo "dict_driver_register(&dict_driver_$${i});" >>$@ ; \
	  fi; \
	done
	echo '}' >>$@
	echo 'void dict_drivers_unregister_all(void) {' >>$@
	echo '#ifdef BUILTIN_LDAP' >>$@
	echo 'ldap_clients_cleanup();' >>$@
	echo '#endif' >>$@
	echo 'dict_drivers_unregister_builtin();' >>$@
	echo 'dict_sql_unregister();' >>$@
	for i in $(dict_drivers) null; do \
	  if [ "$${i}" != "null" ]; then \
	        echo "dict_driver_unregister(&dict_driver_$${i});" >>$@ ; \
	  fi; \
	done
	echo '}' >>$@

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

test_programs = \
	test-dict-sql

noinst_PROGRAMS = $(test_programs)

test_dict_sql_CFLAGS = $(AM_CPPFLAGS) -DDICT_SRC_DIR=\"$(top_srcdir)/src/lib-dict-backend\"
test_dict_sql_SOURCES = \
	test-dict-sql.c
test_dict_sql_LDADD = \
	$(noinst_LTLIBRARIES) \
	$(DICT_LIBS) \
	../lib-sql/libdriver_test.la \
	../lib-sql/libsql.la \
	../lib-dovecot/libdovecot.la
test_dict_sql_DEPENDENCIES = \
	$(noinst_LTLIBRARIES) \
	../lib-sql/libdriver_test.la \
	../lib-sql/libsql.la \
	../lib-dovecot/libdovecot.la

check-local:
	for bin in $(test_programs) $(check_PROGRAMS); do \
	  if ! $(RUN_TEST) ./$$bin; then exit 1; fi; \
	done