]> arthur.barton.de Git - netatalk.git/blob - macros/cnid-backend.m4
Overhaul CNID dbd backend, make it default, txn only... See #2724774
[netatalk.git] / macros / cnid-backend.m4
1 AC_DEFUN([AC_NETATALK_CNID], [
2
3     dnl Don't use BDB unless it's needed
4     bdb_required=no
5     compiled_backends=""
6
7     dnl Determine whether or not to use BDB Concurrent Data Store
8     AC_MSG_CHECKING([whether or not to use BDB Concurrent Data Store])
9     AC_ARG_WITH(cnid-cdb-backend,
10         [  --with-cnid-cdb-backend      build CNID with Concurrent BDB Data Store],[
11             if test x"$withval" = x"no"; then
12                 use_cdb_backend=no
13         else
14             use_cdb_backend=yes
15         fi
16     ],[use_cdb_backend=no]
17     )
18
19     if test $use_cdb_backend = yes; then
20         AC_MSG_RESULT([yes])
21         AC_DEFINE(CNID_BACKEND_CDB, 1, [Define if CNID Concurrent BDB backend should be compiled.])         
22         DEFAULT_CNID_SCHEME=cdb
23         bdb_required=yes
24         compiled_backends="$compiled_backends cdb"
25     else
26         AC_MSG_RESULT([no])
27     fi
28     AM_CONDITIONAL(USE_CDB_BACKEND, test x"$use_cdb_backend" = x"yes")
29
30     dnl Determine whether or not to use Database Daemon CNID backend
31     AC_MSG_CHECKING([whether or not to use Database Daemon CNID backend])
32     AC_ARG_WITH(cnid-dbd-backend,
33     [  --with-cnid-dbd-backend       build CNID with Database Daemon Data Store],
34     [   if test x"$withval" = x"no"; then
35             AC_MSG_RESULT([no])
36             use_dbd_backend=no
37         else
38             use_dbd_backend=yes
39             AC_MSG_RESULT([yes])
40         fi
41     ],[
42         use_dbd_backend=yes
43         AC_MSG_RESULT([yes])
44     ])
45
46     if test $use_dbd_backend = yes; then
47         compiled_backends="$compiled_backends dbd"
48         AC_DEFINE(CNID_BACKEND_DBD, 1, [Define if CNID Database Daemon backend should be compiled.])
49         if test x"$DEFAULT_CNID_SCHEME" = x; then
50             DEFAULT_CNID_SCHEME=dbd
51         fi
52         bdb_required=yes
53     fi
54     AM_CONDITIONAL(BUILD_DBD_DAEMON, test x"$use_dbd_backend" = x"yes")
55
56     dnl Determine whether or not to use BDB transactional data store
57     AC_MSG_CHECKING([whether or not to use BDB transactional DB store])
58     AC_ARG_WITH(cnid-db3-backend,
59     [  --with-cnid-db3-backend  build CNID with transactional BDB Data Store],
60         [
61             if test x"$withval" = x"no"; then
62             use_db3_backend=no
63         else
64             use_db3_backend=yes
65         fi
66     ],[
67         use_db3_backend=no
68     ])
69
70     if test x"$use_db3_backend" = x"yes"; then
71         AC_MSG_RESULT([yes])
72         AC_DEFINE(CNID_BACKEND_DB3, 1, [Define if CNID transactional BDB backend should be compiled.])
73         if test x"$DEFAULT_CNID_SCHEME" = x; then
74             DEFAULT_CNID_SCHEME=db3
75         fi
76         compiled_backends="$compiled_backends db3"
77         bdb_required=yes
78     else
79         AC_MSG_RESULT([no])
80     fi
81     AM_CONDITIONAL(USE_DB3_BACKEND, test x"$use_db3_backend" = x"yes")
82
83     dnl Determine whether or not to use LAST DID scheme
84     AC_MSG_CHECKING([whether or not to use LAST DID scheme])
85     AC_ARG_WITH(cnid-last-backend,
86         [  --with-cnid-last-backend     build LAST CNID scheme],
87         [
88         if test x"$withval" = x"no"; then
89             use_last_backend=no
90         else
91             use_last_backend=yes
92         fi
93     ],[
94         use_last_backend=yes
95     ])
96
97     if test $use_last_backend = yes; then
98         AC_MSG_RESULT([yes])
99         AC_DEFINE(CNID_BACKEND_LAST, 1, [Define if CNID LAST scheme backend should be compiled.])
100         if test x"$DEFAULT_CNID_SCHEME" = x; then
101             DEFAULT_CNID_SCHEME=last
102         fi
103         compiled_backends="$compiled_backends last"
104     else
105         AC_MSG_RESULT([no])
106     fi
107
108     dnl Determine whether or not to use HASH DID scheme
109     AC_MSG_CHECKING([whether or not to use HASH DID scheme])
110     AC_ARG_WITH(cnid-hash-backend,
111         [  --with-cnid-hash-backend     build HASH CNID scheme],
112         [
113         if test x"$withval" = x"no"; then
114             use_hash_backend=no
115         else
116             use_hash_backend=yes
117         fi
118     ],[
119         use_hash_backend=no
120     ])
121
122     if test $use_hash_backend = yes; then
123         AC_MSG_RESULT([yes])
124         AC_DEFINE(CNID_BACKEND_HASH, 1, [Define if CNID HASH scheme backend should be compiled.])
125         if test x"$DEFAULT_CNID_SCHEME" = x; then
126             DEFAULT_CNID_SCHEME=hash
127         fi
128         compiled_backends="$compiled_backends hash"
129     else
130         AC_MSG_RESULT([no])
131     fi
132
133     dnl Determine whether or not to use TDB DID scheme
134     AC_MSG_CHECKING([whether or not to use TDB DID scheme])
135     AC_ARG_WITH(cnid-tdb-backend,
136         [  --with-cnid-tdb-backend      build DID CNID scheme],
137     [
138         if test x"$withval" = x"no"; then
139             use_tdb_backend=no
140         else
141             use_tdb_backend=yes
142         fi
143     ],[
144         use_tdb_backend=no
145     ])
146
147     if test $use_tdb_backend = yes; then
148         AC_MSG_RESULT([yes])
149         AC_DEFINE(CNID_BACKEND_TDB, 1, [Define if CNID TDB scheme backend should be compiled.])
150         if test x"$DEFAULT_TDB_SCHEME" = x; then
151             DEFAULT_CNID_SCHEME=tdb
152         fi
153         compiled_backends="$compiled_backends tdb"
154     else
155         AC_MSG_RESULT([no])
156     fi
157
158     dnl Determine whether or not to use MTAB DID scheme
159     AC_MSG_CHECKING([whether or not to use MTAB DID scheme])
160     AC_ARG_WITH(cnid-mtab-backend,
161         [  --with-cnid-mtab-backend     build MTAB CNID scheme],
162     [
163         if test x"$withval" = x"no"; then
164             use_mtab_backend=no
165         else
166             use_mtab_backend=yes
167         fi
168     ],[
169         use_mtab_backend=no
170     ])
171
172     if test $use_mtab_backend = yes; then
173         AC_MSG_RESULT([yes])
174         AC_DEFINE(CNID_BACKEND_MTAB, 1, [Define if CNID MTAB scheme backend should be compiled.])
175         if test x"$DEFAULT_CNID_SCHEME" = x; then
176             DEFAULT_CNID_SCHEME=mtab
177         fi
178         compiled_backends="$compiled_backends mtab"
179     else                
180         AC_MSG_RESULT([no])
181     fi
182
183     dnl Set default DID scheme
184     AC_MSG_CHECKING([default DID scheme])
185     AC_ARG_WITH(cnid-default-backend,
186         [  --with-cnid-default-backend=val      set default DID scheme],
187     [
188         if test x"$withval" = x; then
189             AC_MSG_RESULT([ignored])
190         else
191             DEFAULT_CNID_SCHEME=$withval
192             AC_MSG_RESULT($DEFAULT_CNID_SCHEME)
193         fi
194     ],[
195         AC_MSG_RESULT($DEFAULT_CNID_SCHEME)
196     ])
197
198     if test x"$DEFAULT_CNID_SCHEME" = x; then
199         AC_MSG_ERROR([No DID schemes compiled in ])
200     fi
201
202     AC_MSG_CHECKING([whether default CNID scheme has been activated])
203     found_scheme=no
204     for scheme in $compiled_backends ; do
205         if test x"$scheme" = x"$DEFAULT_CNID_SCHEME"; then      
206             found_scheme=yes
207         fi
208     done
209     if test x"$found_scheme" = x"no"; then
210         AC_MSG_RESULT([no])
211         AC_MSG_ERROR([Specified default CNID scheme $DEFAULT_CNID_SCHEME was not selected for compilation])
212     else
213         AC_MSG_RESULT([yes])
214     fi
215
216     AC_DEFINE_UNQUOTED(DEFAULT_CNID_SCHEME, "$DEFAULT_CNID_SCHEME", [Default CNID scheme to be used])
217     AC_SUBST(DEFAULT_CNID_SCHEME)
218     AC_SUBST(compiled_backends)
219
220     if test "x$bdb_required" = "xyes"; then
221         ifelse([$1], , :, [$1])
222     else
223         ifelse([$2], , :, [$2])     
224     fi
225 ])