10 # find the buildtools directory
12 while not os
.path
.exists(srcdir
+'/buildtools') and len(srcdir
.split('/')) < 5:
13 srcdir
= srcdir
+ '/..'
14 sys
.path
.insert(0, srcdir
+ '/buildtools/wafsamba')
16 import wafsamba
, samba_dist
, Utils
18 samba_dist
.DIST_DIRS('''lib/ldb:. lib/replace:lib/replace lib/talloc:lib/talloc
19 lib/tdb:lib/tdb lib/tdb:lib/tdb lib/tevent:lib/tevent
20 third_party/popt:third_party/popt
21 third_party/cmocka:third_party/cmocka
22 buildtools:buildtools third_party/waf:third_party/waf''')
26 opt
.BUILTIN_DEFAULT('replace')
27 opt
.PRIVATE_EXTENSION_DEFAULT('ldb', noextension
='ldb')
28 opt
.RECURSE('lib/tdb')
29 opt
.RECURSE('lib/tevent')
30 opt
.RECURSE('lib/replace')
31 opt
.tool_options('python') # options for disabling pyc or pyo compilation
34 conf
.RECURSE('lib/tdb')
35 conf
.RECURSE('lib/tevent')
37 if conf
.CHECK_FOR_THIRD_PARTY():
38 conf
.RECURSE('third_party/popt')
39 conf
.RECURSE('third_party/cmocka')
41 if not conf
.CHECK_POPT():
42 raise Utils
.WafError('popt development packages have not been found.\nIf third_party is installed, check that it is in the proper place.')
44 conf
.define('USING_SYSTEM_POPT', 1)
46 if not conf
.CHECK_CMOCKA():
47 raise Utils
.WafError('cmocka development package have not been found.\nIf third_party is installed, check that it is in the proper place.')
49 conf
.define('USING_SYSTEM_CMOCKA', 1)
51 conf
.RECURSE('lib/replace')
52 conf
.find_program('python', var
='PYTHON')
53 conf
.find_program('xsltproc', var
='XSLTPROC')
54 conf
.check_tool('python')
55 conf
.check_python_version((2,4,2))
56 conf
.SAMBA_CHECK_PYTHON_HEADERS(mandatory
=not conf
.env
.disable_python
)
58 # where does the default LIBDIR end up? in conf.env somewhere?
60 conf
.CONFIG_PATH('LDB_MODULESDIR', conf
.SUBST_ENV_VAR('MODULESDIR') + '/ldb')
62 conf
.env
.standalone_ldb
= conf
.IN_LAUNCH_DIR()
64 if not conf
.env
.standalone_ldb
:
65 if conf
.env
.disable_python
:
66 if conf
.CHECK_BUNDLED_SYSTEM_PKG('ldb', minversion
=VERSION
,
67 onlyif
='talloc tdb tevent',
68 implied_deps
='replace talloc tdb tevent'):
69 conf
.define('USING_SYSTEM_LDB', 1)
71 using_system_pyldb_util
= True
72 if not conf
.CHECK_BUNDLED_SYSTEM_PKG('pyldb-util', minversion
=VERSION
,
73 onlyif
='talloc tdb tevent',
74 implied_deps
='replace talloc tdb tevent ldb'):
75 using_system_pyldb_util
= False
77 # We need to get a pyldb-util for all the python versions
79 if conf
.env
['EXTRA_PYTHON']:
80 name
= 'pyldb-util' + conf
.all_envs
['extrapython']['PYTHON_SO_ABI_FLAG']
81 if not conf
.CHECK_BUNDLED_SYSTEM_PKG(name
, minversion
=VERSION
,
82 onlyif
='talloc tdb tevent',
83 implied_deps
='replace talloc tdb tevent ldb'):
84 using_system_pyldb_util
= False
86 if using_system_pyldb_util
:
87 conf
.define('USING_SYSTEM_PYLDB_UTIL', 1)
89 if conf
.CHECK_BUNDLED_SYSTEM_PKG('ldb', minversion
=VERSION
,
90 onlyif
='talloc tdb tevent pyldb-util',
91 implied_deps
='replace talloc tdb tevent'):
92 conf
.define('USING_SYSTEM_LDB', 1)
94 if conf
.CONFIG_SET('USING_SYSTEM_LDB'):
95 v
= VERSION
.split('.')
96 conf
.DEFINE('EXPECTED_SYSTEM_LDB_VERSION_MAJOR', int(v
[0]))
97 conf
.DEFINE('EXPECTED_SYSTEM_LDB_VERSION_MINOR', int(v
[1]))
98 conf
.DEFINE('EXPECTED_SYSTEM_LDB_VERSION_RELEASE', int(v
[2]))
100 if conf
.env
.standalone_ldb
:
101 conf
.CHECK_XSLTPROC_MANPAGES()
103 # we need this for the ldap backend
104 if conf
.CHECK_FUNCS_IN('ber_flush ldap_open ldap_initialize', 'lber ldap', headers
='lber.h ldap.h'):
105 conf
.env
.ENABLE_LDAP_BACKEND
= True
107 # we don't want any libraries or modules to rely on runtime
108 # resolution of symbols
109 if not sys
.platform
.startswith("openbsd"):
110 conf
.ADD_LDFLAGS('-Wl,-no-undefined', testflags
=True)
112 conf
.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags
=True)
114 conf
.SAMBA_CONFIG_H()
116 conf
.SAMBA_CHECK_UNDEFINED_SYMBOL_FLAGS()
119 bld
.RECURSE('lib/tevent')
121 if bld
.CHECK_FOR_THIRD_PARTY():
122 bld
.RECURSE('third_party/popt')
123 bld
.RECURSE('third_party/cmocka')
125 bld
.RECURSE('lib/replace')
126 bld
.RECURSE('lib/tdb')
128 if bld
.env
.standalone_ldb
:
129 private_library
= False
131 private_library
= True
133 LDB_MAP_SRC
= bld
.SUBDIR('ldb_map',
134 'ldb_map.c ldb_map_inbound.c ldb_map_outbound.c')
136 COMMON_SRC
= bld
.SUBDIR('common',
137 '''ldb_modules.c ldb_ldif.c ldb_parse.c ldb_msg.c ldb_utf8.c
138 ldb_debug.c ldb_dn.c ldb_match.c ldb_options.c ldb_pack.c
139 ldb_attributes.c attrib_handlers.c ldb_controls.c qsort.c''')
141 bld
.SAMBA_MODULE('ldb_ldap', 'ldb_ldap/ldb_ldap.c',
142 init_function
='ldb_ldap_init',
143 module_init_name
='ldb_init_module',
144 deps
='talloc lber ldap ldb',
145 enabled
=bld
.env
.ENABLE_LDAP_BACKEND
,
146 internal_module
=False,
149 if bld
.PYTHON_BUILD_IS_ENABLED():
150 if not bld
.CONFIG_SET('USING_SYSTEM_PYLDB_UTIL'):
151 for env
in bld
.gen_python_environments(['PKGCONFIGDIR']):
152 # we're not currently linking against the ldap libs, but ldb.pc.in
154 bld
.env
.LDAP_LIBS
= ''
156 if not 'PACKAGE_VERSION' in bld
.env
:
157 bld
.env
.PACKAGE_VERSION
= VERSION
158 bld
.env
.PKGCONFIGDIR
= '${LIBDIR}/pkgconfig'
160 name
= bld
.pyembed_libname('pyldb-util')
161 bld
.SAMBA_LIBRARY(name
,
163 source
='pyldb_util.c',
164 public_headers
=('' if private_library
else 'pyldb.h'),
165 public_headers_install
=not private_library
,
167 private_library
=private_library
,
168 pc_files
='pyldb-util.pc',
170 enabled
=bld
.PYTHON_BUILD_IS_ENABLED(),
174 if not bld
.CONFIG_SET('USING_SYSTEM_LDB'):
175 bld
.SAMBA_PYTHON('pyldb', 'pyldb.c',
178 cflags
='-DPACKAGE_VERSION=\"%s\"' % VERSION
)
180 # Do only install this file as part of the Samba build if we do not
181 # use the system libldb!
182 if not bld
.CONFIG_SET('USING_SYSTEM_PYLDB_UTIL'):
183 for env
in bld
.gen_python_environments(['PKGCONFIGDIR']):
184 bld
.SAMBA_SCRIPT('_ldb_text.py',
185 pattern
='_ldb_text.py',
188 bld
.INSTALL_FILES('${PYTHONARCHDIR}', '_ldb_text.py')
190 if not bld
.CONFIG_SET('USING_SYSTEM_LDB'):
192 modules_dir
= bld
.EXPAND_VARIABLES('${LDB_MODULESDIR}')
194 # when we run from the source directory, we want to use
195 # the current modules, not the installed ones
196 modules_dir
= os
.path
.join(os
.getcwd(), 'bin/modules/ldb')
198 abi_match
= '!ldb_*module_ops !ldb_*backend_ops ldb_*'
200 ldb_headers
= ('include/ldb.h include/ldb_errors.h '
201 'include/ldb_module.h include/ldb_handlers.h')
203 bld
.SAMBA_LIBRARY('ldb',
204 COMMON_SRC
+ ' ' + LDB_MAP_SRC
,
205 deps
='tevent LIBLDB_MAIN replace',
207 public_headers
=('' if private_library
else ldb_headers
),
208 public_headers_install
=not private_library
,
211 private_library
=private_library
,
212 manpages
='man/ldb.3',
214 abi_match
= abi_match
)
216 # generate a include/ldb_version.h
217 def generate_ldb_version_h(t
):
218 '''generate a vscript file for our public libraries'''
220 tgt
= t
.outputs
[0].bldpath(t
.env
)
222 v
= t
.env
.LDB_VERSION
.split('.')
224 f
= open(tgt
, mode
='w')
226 f
.write('#define LDB_VERSION "%s"\n' % t
.env
.LDB_VERSION
)
227 f
.write('#define LDB_VERSION_MAJOR %d\n' % int(v
[0]))
228 f
.write('#define LDB_VERSION_MINOR %d\n' % int(v
[1]))
229 f
.write('#define LDB_VERSION_RELEASE %d\n' % int(v
[2]))
233 t
= bld
.SAMBA_GENERATOR('ldb_version.h',
234 rule
=generate_ldb_version_h
,
235 dep_vars
=['LDB_VERSION'],
236 target
='include/ldb_version.h',
237 public_headers
='include/ldb_version.h',
238 public_headers_install
=not private_library
)
239 t
.env
.LDB_VERSION
= VERSION
242 bld
.SAMBA_MODULE('ldb_paged_results',
243 'modules/paged_results.c',
244 init_function
='ldb_paged_results_init',
245 module_init_name
='ldb_init_module',
246 internal_module
=False,
250 bld
.SAMBA_MODULE('ldb_asq',
252 init_function
='ldb_asq_init',
253 module_init_name
='ldb_init_module',
254 internal_module
=False,
258 bld
.SAMBA_MODULE('ldb_server_sort',
260 init_function
='ldb_server_sort_init',
261 internal_module
=False,
262 module_init_name
='ldb_init_module',
266 bld
.SAMBA_MODULE('ldb_paged_searches',
267 'modules/paged_searches.c',
268 init_function
='ldb_paged_searches_init',
269 internal_module
=False,
270 module_init_name
='ldb_init_module',
274 bld
.SAMBA_MODULE('ldb_rdn_name',
275 'modules/rdn_name.c',
276 init_function
='ldb_rdn_name_init',
277 internal_module
=False,
278 module_init_name
='ldb_init_module',
282 bld
.SAMBA_MODULE('ldb_sample',
283 'tests/sample_module.c',
284 init_function
='ldb_sample_init',
285 internal_module
=False,
286 module_init_name
='ldb_init_module',
290 bld
.SAMBA_MODULE('ldb_skel',
292 init_function
='ldb_skel_init',
293 internal_module
=False,
294 module_init_name
='ldb_init_module',
298 bld
.SAMBA_MODULE('ldb_sqlite3',
299 'sqlite3/ldb_sqlite3.c',
300 init_function
='ldb_sqlite3_init',
301 internal_module
=False,
302 module_init_name
='ldb_init_module',
307 bld
.SAMBA_MODULE('ldb_tdb',
308 bld
.SUBDIR('ldb_tdb',
309 '''ldb_tdb.c ldb_search.c ldb_index.c
310 ldb_cache.c ldb_tdb_wrap.c'''),
311 init_function
='ldb_tdb_init',
312 module_init_name
='ldb_init_module',
313 internal_module
=False,
317 # have a separate subsystem for common/ldb.c, so it can rebuild
318 # for install with a different -DLDB_MODULESDIR=
319 bld
.SAMBA_SUBSYSTEM('LIBLDB_MAIN',
323 cflags
=['-DLDB_MODULESDIR=\"%s\"' % modules_dir
])
325 LDB_TOOLS
='ldbadd ldbsearch ldbdel ldbmodify ldbedit ldbrename'
326 for t
in LDB_TOOLS
.split():
327 bld
.SAMBA_BINARY(t
, 'tools/%s.c' % t
, deps
='ldb-cmdline ldb',
328 manpages
='man/%s.1' % t
)
330 # ldbtest doesn't get installed
331 bld
.SAMBA_BINARY('ldbtest', 'tools/ldbtest.c', deps
='ldb-cmdline ldb',
334 # ldbdump doesn't get installed
335 bld
.SAMBA_BINARY('ldbdump', 'tools/ldbdump.c', deps
='ldb-cmdline ldb',
338 bld
.SAMBA_LIBRARY('ldb-cmdline',
339 source
='tools/ldbutil.c tools/cmdline.c',
341 private_library
=True)
343 bld
.SAMBA_BINARY('ldb_tdb_mod_op_test',
344 source
='tests/ldb_mod_op_test.c',
345 cflags
='-DTEST_BE=\"tdb\"',
349 bld
.SAMBA_BINARY('ldb_msg_test',
350 source
='tests/ldb_msg.c',
355 '''run ldb testsuite'''
356 import Utils
, samba_utils
, shutil
357 env
= samba_utils
.LOAD_ENVIRONMENT()
360 test_prefix
= "%s/st" % (Utils
.g_module
.blddir
)
361 shutil
.rmtree(test_prefix
, ignore_errors
=True)
362 os
.makedirs(test_prefix
)
363 os
.environ
['TEST_DATA_PREFIX'] = test_prefix
364 os
.environ
['LDB_MODULES_PATH'] = Utils
.g_module
.blddir
+ "/modules/ldb"
365 samba_utils
.ADD_LD_LIBRARY_PATH('bin/shared')
366 samba_utils
.ADD_LD_LIBRARY_PATH('bin/shared/private')
368 cmd
= 'tests/test-tdb.sh %s' % Utils
.g_module
.blddir
369 ret
= samba_utils
.RUN_COMMAND(cmd
)
370 print("testsuite returned %d" % ret
)
372 tmp_dir
= os
.path
.join(test_prefix
, 'tmp')
373 if not os
.path
.exists(tmp_dir
):
375 pyret
= samba_utils
.RUN_PYTHON_TESTS(
376 ['tests/python/api.py'],
377 extra_env
={'SELFTEST_PREFIX': test_prefix
})
378 print("Python testsuite returned %d" % pyret
)
381 for test_exe
in ['ldb_tdb_mod_op_test',
383 cmd
= os
.path
.join(Utils
.g_module
.blddir
, test_exe
)
384 cmocka_ret
= cmocka_ret
or samba_utils
.RUN_COMMAND(cmd
)
386 sys
.exit(ret
or pyret
or cmocka_ret
)
389 '''makes a tarball for distribution'''
392 def reconfigure(ctx
):
393 '''reconfigure if config scripts have changed'''
395 samba_utils
.reconfigure(ctx
)