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
38 if Options
.options
.without_ad_dc
:
39 conf
.env
.REQUIRE_LMDB
= False
41 if Options
.options
.without_ldb_lmdb
:
42 if not Options
.options
.without_ad_dc
and \
43 conf
.CONFIG_GET('ENABLE_SELFTEST'):
44 raise Errors
.WafError('--without-ldb-lmdb conflicts '
45 'with --enable-selftest while '
48 conf
.env
.REQUIRE_LMDB
= False
50 conf
.env
.REQUIRE_LMDB
= True
52 # if lmdb support is enabled then we require lmdb
53 # is present, build the mdb back end and enable lmdb support in
55 if conf
.env
.REQUIRE_LMDB
:
56 if not conf
.CHECK_CFG(package
='lmdb',
57 args
='"lmdb >= 0.9.16" --cflags --libs',
58 msg
='Checking for lmdb >= 0.9.16',
60 if not conf
.CHECK_CODE('''
61 #if MDB_VERSION_MAJOR == 0 \
62 && MDB_VERSION_MINOR <= 9 \
63 && MDB_VERSION_PATCH < 16
67 'HAVE_GOOD_LMDB_VERSION',
69 msg
='Checking for lmdb >= 0.9.16 via header check'):
71 if not Options
.options
.without_ad_dc
:
72 raise Errors
.WafError('Samba AD DC and --enable-selftest '
74 'lmdb 0.9.16 or later')
76 raise Errors
.WafError('ldb build (unless --without-ldb-lmdb) '
78 'lmdb 0.9.16 or later')
80 if conf
.CHECK_FUNCS_IN('mdb_env_create', 'lmdb', headers
='lmdb.h'):
81 conf
.DEFINE('HAVE_LMDB', '1')
82 conf
.env
.HAVE_LMDB
= True
84 conf
.env
.ldb_is_public_library \
85 = not samba_bundled
.LIB_MUST_BE_PRIVATE(conf
, 'ldb')
88 bld
.env
.LDB_PACKAGE_VERSION
= LDB_VERSION
90 # we're not currently linking against the ldap libs, but ldb.pc.in
92 bld
.env
.LDAP_LIBS
= ''
94 LDB_MAP_SRC
= bld
.SUBDIR('ldb_map',
95 'ldb_map.c ldb_map_inbound.c ldb_map_outbound.c')
97 COMMON_SRC
= bld
.SUBDIR('common',
98 '''ldb_modules.c ldb_ldif.c ldb_parse.c ldb_msg.c ldb_utf8.c
99 ldb_debug.c ldb_dn.c ldb_match.c ldb_options.c ldb_pack.c
100 ldb_attributes.c attrib_handlers.c ldb_controls.c qsort.c''')
102 bld
.SAMBA_MODULE('ldb_ldap', 'ldb_ldap/ldb_ldap.c',
103 init_function
='ldb_ldap_init',
104 module_init_name
='ldb_init_module',
105 deps
='talloc lber ldap ldb',
106 enabled
=bld
.env
.ENABLE_LDAP_BACKEND
,
107 internal_module
=False,
110 if bld
.PYTHON_BUILD_IS_ENABLED():
111 name
= bld
.pyembed_libname('pyldb-util')
112 bld
.SAMBA_LIBRARY(name
,
114 source
='pyldb_util.c',
115 private_library
=True,
117 enabled
=bld
.PYTHON_BUILD_IS_ENABLED())
119 bld
.SAMBA_PYTHON('pyldb', 'pyldb.c',
120 deps
='replace ldb ' + name
,
122 cflags
='-DPACKAGE_VERSION=\"%s\"' % LDB_VERSION
)
124 bld
.SAMBA_SCRIPT('_ldb_text.py',
125 pattern
='_ldb_text.py',
128 bld
.INSTALL_FILES('${PYTHONARCHDIR}', '_ldb_text.py')
131 modules_dir
= bld
.EXPAND_VARIABLES('${LDB_MODULESDIR}')
133 # when we run from the source directory, we want to use
134 # the current modules, not the installed ones
135 modules_dir
= os
.path
.join(os
.getcwd(), 'bin/modules/ldb')
137 abi_match
= '!ldb_*module_ops !ldb_*backend_ops ldb_*'
139 ldb_headers
= ('include/ldb.h include/ldb_errors.h '
140 'include/ldb_module.h include/ldb_handlers.h')
142 bld
.SAMBA_LIBRARY('ldb',
143 COMMON_SRC
+ ' ' + LDB_MAP_SRC
,
144 deps
='tevent LIBLDB_MAIN replace',
146 public_headers
=ldb_headers
,
147 public_headers_install
=True,
150 private_library
=False,
151 manpages
='man/ldb.3',
153 abi_match
= abi_match
)
155 # generate a include/ldb_version.h
156 def generate_ldb_version_h(t
):
157 '''generate a vscript file for our public libraries'''
159 tgt
= t
.outputs
[0].bldpath(t
.env
)
161 v
= t
.env
.LDB_VERSION
.split('.')
163 f
= open(tgt
, mode
='w')
165 f
.write('#define LDB_VERSION "%s"\n' % t
.env
.LDB_VERSION
)
166 f
.write('#define LDB_VERSION_MAJOR %d\n' % int(v
[0]))
167 f
.write('#define LDB_VERSION_MINOR %d\n' % int(v
[1]))
168 f
.write('#define LDB_VERSION_RELEASE %d\n' % int(v
[2]))
172 t
= bld
.SAMBA_GENERATOR('ldb_version.h',
173 rule
=generate_ldb_version_h
,
174 dep_vars
=['LDB_VERSION'],
175 target
='include/ldb_version.h',
176 public_headers
='include/ldb_version.h',
177 public_headers_install
=not bld
.env
.ldb_is_public_library
)
178 t
.env
.LDB_VERSION
= LDB_VERSION
180 bld
.SAMBA_MODULE('ldb_asq',
182 init_function
='ldb_asq_init',
183 module_init_name
='ldb_init_module',
184 internal_module
=False,
188 bld
.SAMBA_MODULE('ldb_server_sort',
190 init_function
='ldb_server_sort_init',
191 internal_module
=False,
192 module_init_name
='ldb_init_module',
196 bld
.SAMBA_MODULE('ldb_paged_searches',
197 'modules/paged_searches.c',
198 init_function
='ldb_paged_searches_init',
199 internal_module
=False,
200 module_init_name
='ldb_init_module',
204 bld
.SAMBA_MODULE('ldb_rdn_name',
205 'modules/rdn_name.c',
206 init_function
='ldb_rdn_name_init',
207 internal_module
=False,
208 module_init_name
='ldb_init_module',
212 bld
.SAMBA_MODULE('ldb_sample',
213 'tests/sample_module.c',
214 init_function
='ldb_sample_init',
215 internal_module
=False,
216 module_init_name
='ldb_init_module',
220 bld
.SAMBA_MODULE('ldb_skel',
222 init_function
='ldb_skel_init',
223 internal_module
=False,
224 module_init_name
='ldb_init_module',
228 bld
.SAMBA_MODULE('ldb_sqlite3',
229 'sqlite3/ldb_sqlite3.c',
230 init_function
='ldb_sqlite3_init',
231 internal_module
=False,
232 module_init_name
='ldb_init_module',
237 bld
.SAMBA_MODULE('ldb_tdb',
238 bld
.SUBDIR('ldb_tdb',
239 '''ldb_tdb_init.c'''),
240 init_function
='ldb_tdb_init',
241 module_init_name
='ldb_init_module',
242 internal_module
=False,
243 deps
='ldb ldb_tdb_int ldb_key_value',
246 bld
.SAMBA_LIBRARY('ldb_tdb_int',
247 bld
.SUBDIR('ldb_tdb',
248 '''ldb_tdb_wrap.c ldb_tdb.c'''),
249 private_library
=True,
250 deps
='ldb tdb ldb_key_value ldb_tdb_err_map')
252 bld
.SAMBA_LIBRARY('ldb_tdb_err_map',
253 bld
.SUBDIR('ldb_tdb',
254 '''ldb_tdb_err_map.c '''),
255 private_library
=True,
258 bld
.SAMBA_LIBRARY('ldb_key_value',
259 bld
.SUBDIR('ldb_key_value',
260 '''ldb_kv.c ldb_kv_search.c ldb_kv_index.c
262 private_library
=True,
263 deps
='tdb ldb ldb_tdb_err_map')
265 if bld
.CONFIG_SET('HAVE_LMDB'):
266 bld
.SAMBA_MODULE('ldb_mdb',
267 bld
.SUBDIR('ldb_mdb',
268 '''ldb_mdb_init.c'''),
269 init_function
='ldb_mdb_init',
270 module_init_name
='ldb_init_module',
271 internal_module
=False,
272 deps
='ldb ldb_key_value ldb_mdb_int',
275 bld
.SAMBA_LIBRARY('ldb_mdb_int',
276 bld
.SUBDIR('ldb_mdb',
278 private_library
=True,
279 deps
='ldb lmdb ldb_key_value')
280 lmdb_deps
= ' ldb_mdb_int'
285 bld
.SAMBA_MODULE('ldb_ldb',
286 bld
.SUBDIR('ldb_ldb',
288 init_function
='ldb_ldb_init',
289 module_init_name
='ldb_init_module',
290 internal_module
=False,
291 deps
='ldb ldb_tdb_int ldb_key_value' + lmdb_deps
,
294 # have a separate subsystem for common/ldb.c, so it can rebuild
295 # for install with a different -DLDB_MODULESDIR=
296 bld
.SAMBA_SUBSYSTEM('LIBLDB_MAIN',
300 cflags
=['-DLDB_MODULESDIR=\"%s\"' % modules_dir
])
302 LDB_TOOLS
='ldbadd ldbsearch ldbdel ldbmodify ldbedit ldbrename'
303 for t
in LDB_TOOLS
.split():
304 bld
.SAMBA_BINARY(t
, 'tools/%s.c' % t
, deps
='ldb-cmdline ldb',
305 manpages
='man/%s.1' % t
)
307 # ldbtest doesn't get installed
308 bld
.SAMBA_BINARY('ldbtest', 'tools/ldbtest.c', deps
='ldb-cmdline ldb',
311 if bld
.CONFIG_SET('HAVE_LMDB'):
315 # ldbdump doesn't get installed
316 bld
.SAMBA_BINARY('ldbdump',
318 deps
='ldb-cmdline ldb' + lmdb_deps
,
321 bld
.SAMBA_LIBRARY('ldb-cmdline',
322 source
='tools/ldbutil.c tools/cmdline.c',
324 private_library
=True)
326 bld
.SAMBA_BINARY('ldb_tdb_mod_op_test',
327 source
='tests/ldb_mod_op_test.c',
328 cflags
='-DTEST_BE=\"tdb\"',
332 bld
.SAMBA_BINARY('ldb_tdb_guid_mod_op_test',
333 source
='tests/ldb_mod_op_test.c',
334 cflags
='-DTEST_BE=\"tdb\" -DGUID_IDX=1',
338 bld
.SAMBA_BINARY('ldb_tdb_kv_ops_test',
339 source
='tests/ldb_kv_ops_test.c',
340 cflags
='-DTEST_BE=\"tdb\"',
344 bld
.SAMBA_BINARY('ldb_tdb_test',
345 source
='tests/ldb_tdb_test.c',
349 bld
.SAMBA_BINARY('ldb_msg_test',
350 source
='tests/ldb_msg.c',
354 bld
.SAMBA_BINARY('test_ldb_qsort',
355 source
='tests/test_ldb_qsort.c',
359 bld
.SAMBA_BINARY('test_ldb_dn',
360 source
='tests/test_ldb_dn.c',
364 bld
.SAMBA_BINARY('ldb_match_test',
365 source
='tests/ldb_match_test.c',
369 bld
.SAMBA_BINARY('test_ldb_comparison_fold',
370 source
='tests/test_ldb_comparison_fold.c',
371 deps
='cmocka ldb ldbwrap',
374 bld
.SAMBA_BINARY('ldb_key_value_test',
375 source
='tests/ldb_key_value_test.c',
376 deps
='cmocka ldb ldb_tdb_err_map',
379 bld
.SAMBA_BINARY('ldb_parse_test',
380 source
='tests/ldb_parse_test.c',
381 deps
='cmocka ldb ldb_tdb_err_map',
384 bld
.SAMBA_BINARY('ldb_filter_attrs_test',
385 source
='tests/ldb_filter_attrs_test.c',
386 deps
='cmocka ldb ldb_tdb_err_map',
389 bld
.SAMBA_BINARY('ldb_filter_attrs_in_place_test',
390 source
='tests/ldb_filter_attrs_in_place_test.c',
391 deps
='cmocka ldb ldb_tdb_err_map',
394 bld
.SAMBA_BINARY('ldb_key_value_sub_txn_tdb_test',
395 bld
.SUBDIR('ldb_key_value',
399 'tests/ldb_key_value_sub_txn_test.c',
400 cflags
='-DTEST_BE=\"tdb\"',
401 deps
='cmocka ldb ldb_tdb_err_map',
404 # If both libldap and liblber are available, test ldb_ldap
405 # code for a regression of bz#14413 -- even if we don't build
406 # it ourselves and simply using the system version
407 if bld
.env
.LIB_LDAP
and bld
.env
.LIB_LBER
:
408 bld
.SAMBA_BINARY('lldb_ldap_test',
409 source
='tests/lldb_ldap.c',
410 deps
='cmocka talloc lber ldap ldb',
413 if bld
.CONFIG_SET('HAVE_LMDB'):
414 bld
.SAMBA_BINARY('ldb_mdb_mod_op_test',
415 source
='tests/ldb_mod_op_test.c',
416 cflags
='-DTEST_BE=\"mdb\" -DGUID_IDX=1 '
418 deps
='cmocka ldb lmdb',
421 bld
.SAMBA_BINARY('ldb_lmdb_test',
422 source
='tests/ldb_lmdb_test.c',
426 bld
.SAMBA_BINARY('ldb_lmdb_size_test',
427 source
='tests/ldb_lmdb_size_test.c',
431 bld
.SAMBA_BINARY('ldb_mdb_kv_ops_test',
432 source
='tests/ldb_kv_ops_test.c',
433 cflags
='-DTEST_BE=\"mdb\" -DTEST_LMDB=1',
437 bld
.SAMBA_BINARY('ldb_lmdb_free_list_test',
438 source
='tests/ldb_lmdb_free_list_test.c',
439 cflags
='-DTEST_BE=\"mdb\" -DTEST_LMDB=1',
443 # We rely on the versions of the ldb_key_value functions included
444 # in ldb_key_value_sub_txn_test.c taking priority over the versions
445 # in the ldb_key_value shared library.
446 # If this turns out to not be the case, the dependencies will
447 # need to be unrolled, and all the source files included and the
448 # ldb_tdb module initialization code will need to be called
450 bld
.SAMBA_BINARY('ldb_key_value_sub_txn_mdb_test',
451 bld
.SUBDIR('ldb_key_value',
455 'tests/ldb_key_value_sub_txn_test.c',
456 cflags
='-DTEST_BE=\"mdb\"',
457 deps
='cmocka ldb ldb_tdb_err_map',
460 bld
.SAMBA_BINARY('ldb_no_lmdb_test',
461 source
='tests/ldb_no_lmdb_test.c',