8 from wafsamba
import samba_dist
, samba_utils
, samba_bundled
9 from waflib
import Errors
, Options
, Logs
, Context
14 opt
.add_option('--without-ldb-lmdb',
15 help='disable new LMDB backend for LDB',
16 action
='store_true', dest
='without_ldb_lmdb', default
=False)
19 # where does the default LIBDIR end up? in conf.env somewhere?
21 conf
.env
.ldb_modules_install_dir
= conf
.SUBST_ENV_VAR('LDBMODULESDIR')
22 conf
.CONFIG_PATH('LDB_MODULESDIR', conf
.env
.ldb_modules_install_dir
)
24 if not conf
.CHECK_CODE('return !(sizeof(size_t) >= 8)',
25 "HAVE_64_BIT_SIZE_T_FOR_LMDB",
27 msg
='Checking for a 64-bit host to '
29 Logs
.warn("--without-ldb-lmdb implied as this "
32 if not Options
.options
.without_ad_dc
and \
33 conf
.CONFIG_GET('ENABLE_SELFTEST'):
34 Logs
.warn("NOTE: Some AD DC parts of selftest will fail")
36 conf
.env
.REQUIRE_LMDB
= False
37 elif Options
.options
.without_ldb_lmdb
:
38 if not Options
.options
.without_ad_dc
and \
39 conf
.CONFIG_GET('ENABLE_SELFTEST'):
40 raise Errors
.WafError('--without-ldb-lmdb conflicts '
41 'with --enable-selftest while '
44 conf
.env
.REQUIRE_LMDB
= False
46 conf
.env
.REQUIRE_LMDB
= True
48 # if lmdb support is enabled then we require lmdb
49 # is present, build the mdb back end and enable lmdb support in
51 if conf
.env
.REQUIRE_LMDB
:
52 if not conf
.CHECK_CFG(package
='lmdb',
53 args
='"lmdb >= 0.9.16" --cflags --libs',
54 msg
='Checking for lmdb >= 0.9.16',
56 if not conf
.CHECK_CODE('''
57 #if MDB_VERSION_MAJOR == 0 \
58 && MDB_VERSION_MINOR <= 9 \
59 && MDB_VERSION_PATCH < 16
63 'HAVE_GOOD_LMDB_VERSION',
65 msg
='Checking for lmdb >= 0.9.16 via header check'):
67 if not Options
.options
.without_ad_dc
:
68 raise Errors
.WafError('Samba AD DC and --enable-selftest '
70 'lmdb 0.9.16 or later')
72 raise Errors
.WafError('ldb build (unless --without-ldb-lmdb) '
74 'lmdb 0.9.16 or later')
76 if conf
.CHECK_FUNCS_IN('mdb_env_create', 'lmdb', headers
='lmdb.h'):
77 conf
.DEFINE('HAVE_LMDB', '1')
78 conf
.env
.HAVE_LMDB
= True
80 conf
.env
.ldb_is_public_library \
81 = not samba_bundled
.LIB_MUST_BE_PRIVATE(conf
, 'ldb')
84 bld
.env
.LDB_PACKAGE_VERSION
= LDB_VERSION
86 # we're not currently linking against the ldap libs, but ldb.pc.in
88 bld
.env
.LDAP_LIBS
= ''
90 LDB_MAP_SRC
= bld
.SUBDIR('ldb_map',
91 'ldb_map.c ldb_map_inbound.c ldb_map_outbound.c')
93 COMMON_SRC
= bld
.SUBDIR('common',
94 '''ldb_modules.c ldb_ldif.c ldb_parse.c ldb_msg.c ldb_utf8.c
95 ldb_debug.c ldb_dn.c ldb_match.c ldb_options.c ldb_pack.c
96 ldb_attributes.c attrib_handlers.c ldb_controls.c qsort.c''')
98 bld
.SAMBA_MODULE('ldb_ldap', 'ldb_ldap/ldb_ldap.c',
99 init_function
='ldb_ldap_init',
100 module_init_name
='ldb_init_module',
101 deps
='talloc lber ldap ldb',
102 enabled
=bld
.env
.ENABLE_LDAP_BACKEND
,
103 internal_module
=False,
106 if bld
.PYTHON_BUILD_IS_ENABLED():
107 name
= bld
.pyembed_libname('pyldb-util')
108 bld
.SAMBA_LIBRARY(name
,
110 source
='pyldb_util.c',
111 private_library
=True,
113 enabled
=bld
.PYTHON_BUILD_IS_ENABLED())
115 bld
.SAMBA_PYTHON('pyldb', 'pyldb.c',
116 deps
='replace ldb ' + name
,
118 cflags
='-DPACKAGE_VERSION=\"%s\"' % LDB_VERSION
)
120 bld
.SAMBA_SCRIPT('_ldb_text.py',
121 pattern
='_ldb_text.py',
124 bld
.INSTALL_FILES('${PYTHONARCHDIR}', '_ldb_text.py')
127 modules_dir
= bld
.EXPAND_VARIABLES('${LDB_MODULESDIR}')
129 # when we run from the source directory, we want to use
130 # the current modules, not the installed ones
131 modules_dir
= os
.path
.join(os
.getcwd(), 'bin/modules/ldb')
133 abi_match
= '!ldb_*module_ops !ldb_*backend_ops ldb_*'
135 ldb_headers
= ('include/ldb.h include/ldb_errors.h '
136 'include/ldb_module.h include/ldb_handlers.h')
138 bld
.SAMBA_LIBRARY('ldb',
139 COMMON_SRC
+ ' ' + LDB_MAP_SRC
,
140 deps
='tevent LIBLDB_MAIN replace',
142 public_headers
=ldb_headers
,
143 public_headers_install
=True,
146 private_library
=False,
147 manpages
='man/ldb.3',
149 abi_match
= abi_match
)
151 # generate a include/ldb_version.h
152 def generate_ldb_version_h(t
):
153 '''generate a vscript file for our public libraries'''
155 tgt
= t
.outputs
[0].bldpath(t
.env
)
157 v
= t
.env
.LDB_VERSION
.split('.')
159 f
= open(tgt
, mode
='w')
161 f
.write('#define LDB_VERSION "%s"\n' % t
.env
.LDB_VERSION
)
162 f
.write('#define LDB_VERSION_MAJOR %d\n' % int(v
[0]))
163 f
.write('#define LDB_VERSION_MINOR %d\n' % int(v
[1]))
164 f
.write('#define LDB_VERSION_RELEASE %d\n' % int(v
[2]))
168 t
= bld
.SAMBA_GENERATOR('ldb_version.h',
169 rule
=generate_ldb_version_h
,
170 dep_vars
=['LDB_VERSION'],
171 target
='include/ldb_version.h',
172 public_headers
='include/ldb_version.h',
173 public_headers_install
=bld
.env
.ldb_is_public_library
)
174 t
.env
.LDB_VERSION
= LDB_VERSION
176 bld
.SAMBA_MODULE('ldb_asq',
178 init_function
='ldb_asq_init',
179 module_init_name
='ldb_init_module',
180 internal_module
=False,
184 bld
.SAMBA_MODULE('ldb_server_sort',
186 init_function
='ldb_server_sort_init',
187 internal_module
=False,
188 module_init_name
='ldb_init_module',
192 bld
.SAMBA_MODULE('ldb_paged_searches',
193 'modules/paged_searches.c',
194 init_function
='ldb_paged_searches_init',
195 internal_module
=False,
196 module_init_name
='ldb_init_module',
200 bld
.SAMBA_MODULE('ldb_rdn_name',
201 'modules/rdn_name.c',
202 init_function
='ldb_rdn_name_init',
203 internal_module
=False,
204 module_init_name
='ldb_init_module',
208 bld
.SAMBA_MODULE('ldb_sample',
209 'tests/sample_module.c',
210 init_function
='ldb_sample_init',
211 internal_module
=False,
212 module_init_name
='ldb_init_module',
216 bld
.SAMBA_MODULE('ldb_skel',
218 init_function
='ldb_skel_init',
219 internal_module
=False,
220 module_init_name
='ldb_init_module',
224 bld
.SAMBA_MODULE('ldb_sqlite3',
225 'sqlite3/ldb_sqlite3.c',
226 init_function
='ldb_sqlite3_init',
227 internal_module
=False,
228 module_init_name
='ldb_init_module',
233 bld
.SAMBA_MODULE('ldb_tdb',
234 bld
.SUBDIR('ldb_tdb',
235 '''ldb_tdb_init.c'''),
236 init_function
='ldb_tdb_init',
237 module_init_name
='ldb_init_module',
238 internal_module
=False,
239 deps
='ldb ldb_tdb_int ldb_key_value',
242 bld
.SAMBA_LIBRARY('ldb_tdb_int',
243 bld
.SUBDIR('ldb_tdb',
244 '''ldb_tdb_wrap.c ldb_tdb.c'''),
245 private_library
=True,
246 deps
='ldb tdb ldb_key_value ldb_tdb_err_map')
248 bld
.SAMBA_LIBRARY('ldb_tdb_err_map',
249 bld
.SUBDIR('ldb_tdb',
250 '''ldb_tdb_err_map.c '''),
251 private_library
=True,
254 bld
.SAMBA_LIBRARY('ldb_key_value',
255 bld
.SUBDIR('ldb_key_value',
256 '''ldb_kv.c ldb_kv_search.c ldb_kv_index.c
258 private_library
=True,
259 deps
='tdb ldb ldb_tdb_err_map')
261 if bld
.CONFIG_SET('HAVE_LMDB'):
262 bld
.SAMBA_MODULE('ldb_mdb',
263 bld
.SUBDIR('ldb_mdb',
264 '''ldb_mdb_init.c'''),
265 init_function
='ldb_mdb_init',
266 module_init_name
='ldb_init_module',
267 internal_module
=False,
268 deps
='ldb ldb_key_value ldb_mdb_int',
271 bld
.SAMBA_LIBRARY('ldb_mdb_int',
272 bld
.SUBDIR('ldb_mdb',
274 private_library
=True,
275 deps
='ldb lmdb ldb_key_value')
276 lmdb_deps
= ' ldb_mdb_int'
281 bld
.SAMBA_MODULE('ldb_ldb',
282 bld
.SUBDIR('ldb_ldb',
284 init_function
='ldb_ldb_init',
285 module_init_name
='ldb_init_module',
286 internal_module
=False,
287 deps
='ldb ldb_tdb_int ldb_key_value' + lmdb_deps
,
290 # have a separate subsystem for common/ldb.c, so it can rebuild
291 # for install with a different -DLDB_MODULESDIR=
292 bld
.SAMBA_SUBSYSTEM('LIBLDB_MAIN',
296 cflags
=['-DLDB_MODULESDIR=\"%s\"' % modules_dir
])
298 LDB_TOOLS
='ldbadd ldbsearch ldbdel ldbmodify ldbedit ldbrename'
299 for t
in LDB_TOOLS
.split():
300 bld
.SAMBA_BINARY(t
, 'tools/%s.c' % t
, deps
='ldb-cmdline ldb',
301 manpages
='man/%s.1' % t
)
303 # ldbtest doesn't get installed
304 bld
.SAMBA_BINARY('ldbtest', 'tools/ldbtest.c', deps
='ldb-cmdline ldb',
307 if bld
.CONFIG_SET('HAVE_LMDB'):
311 # ldbdump doesn't get installed
312 bld
.SAMBA_BINARY('ldbdump',
314 deps
='ldb-cmdline ldb' + lmdb_deps
,
317 bld
.SAMBA_LIBRARY('ldb-cmdline',
318 source
='tools/ldbutil.c tools/cmdline.c',
320 private_library
=True)
322 bld
.SAMBA_BINARY('ldb_tdb_mod_op_test',
323 source
='tests/ldb_mod_op_test.c',
324 cflags
='-DTEST_BE=\"tdb\"',
328 bld
.SAMBA_BINARY('ldb_tdb_guid_mod_op_test',
329 source
='tests/ldb_mod_op_test.c',
330 cflags
='-DTEST_BE=\"tdb\" -DGUID_IDX=1',
334 bld
.SAMBA_BINARY('ldb_tdb_kv_ops_test',
335 source
='tests/ldb_kv_ops_test.c',
336 cflags
='-DTEST_BE=\"tdb\"',
340 bld
.SAMBA_BINARY('ldb_tdb_test',
341 source
='tests/ldb_tdb_test.c',
345 bld
.SAMBA_BINARY('ldb_msg_test',
346 source
='tests/ldb_msg.c',
350 bld
.SAMBA_BINARY('test_ldb_qsort',
351 source
='tests/test_ldb_qsort.c',
355 bld
.SAMBA_BINARY('test_ldb_dn',
356 source
='tests/test_ldb_dn.c',
360 bld
.SAMBA_BINARY('ldb_match_test',
361 source
='tests/ldb_match_test.c',
365 bld
.SAMBA_BINARY('test_ldb_comparison_fold',
366 source
='tests/test_ldb_comparison_fold.c',
367 deps
='cmocka ldb ldbwrap',
370 bld
.SAMBA_BINARY('ldb_key_value_test',
371 source
='tests/ldb_key_value_test.c',
372 deps
='cmocka ldb ldb_tdb_err_map',
375 bld
.SAMBA_BINARY('ldb_parse_test',
376 source
='tests/ldb_parse_test.c',
377 deps
='cmocka ldb ldb_tdb_err_map',
380 bld
.SAMBA_BINARY('ldb_filter_attrs_test',
381 source
='tests/ldb_filter_attrs_test.c',
382 deps
='cmocka ldb ldb_tdb_err_map',
385 bld
.SAMBA_BINARY('ldb_filter_attrs_in_place_test',
386 source
='tests/ldb_filter_attrs_in_place_test.c',
387 deps
='cmocka ldb ldb_tdb_err_map',
390 bld
.SAMBA_BINARY('ldb_key_value_sub_txn_tdb_test',
391 bld
.SUBDIR('ldb_key_value',
395 'tests/ldb_key_value_sub_txn_test.c',
396 cflags
='-DTEST_BE=\"tdb\"',
397 deps
='cmocka ldb ldb_tdb_err_map',
400 # If both libldap and liblber are available, test ldb_ldap
401 # code for a regression of bz#14413 -- even if we don't build
402 # it ourselves and simply using the system version
403 if bld
.env
.LIB_LDAP
and bld
.env
.LIB_LBER
:
404 bld
.SAMBA_BINARY('lldb_ldap_test',
405 source
='tests/lldb_ldap.c',
406 deps
='cmocka talloc lber ldap ldb',
409 if bld
.CONFIG_SET('HAVE_LMDB'):
410 bld
.SAMBA_BINARY('ldb_mdb_mod_op_test',
411 source
='tests/ldb_mod_op_test.c',
412 cflags
='-DTEST_BE=\"mdb\" -DGUID_IDX=1 '
414 deps
='cmocka ldb lmdb',
417 bld
.SAMBA_BINARY('ldb_lmdb_test',
418 source
='tests/ldb_lmdb_test.c',
422 bld
.SAMBA_BINARY('ldb_lmdb_size_test',
423 source
='tests/ldb_lmdb_size_test.c',
427 bld
.SAMBA_BINARY('ldb_mdb_kv_ops_test',
428 source
='tests/ldb_kv_ops_test.c',
429 cflags
='-DTEST_BE=\"mdb\" -DTEST_LMDB=1',
433 bld
.SAMBA_BINARY('ldb_lmdb_free_list_test',
434 source
='tests/ldb_lmdb_free_list_test.c',
435 cflags
='-DTEST_BE=\"mdb\" -DTEST_LMDB=1',
439 # We rely on the versions of the ldb_key_value functions included
440 # in ldb_key_value_sub_txn_test.c taking priority over the versions
441 # in the ldb_key_value shared library.
442 # If this turns out to not be the case, the dependencies will
443 # need to be unrolled, and all the source files included and the
444 # ldb_tdb module initialization code will need to be called
446 bld
.SAMBA_BINARY('ldb_key_value_sub_txn_mdb_test',
447 bld
.SUBDIR('ldb_key_value',
451 'tests/ldb_key_value_sub_txn_test.c',
452 cflags
='-DTEST_BE=\"mdb\"',
453 deps
='cmocka ldb ldb_tdb_err_map',
456 bld
.SAMBA_BINARY('ldb_no_lmdb_test',
457 source
='tests/ldb_no_lmdb_test.c',