s4/torture: additional tests for kernel-oplocks
[Samba.git] / lib / ldb / wscript
blobdd68d66c1393f77ca4e9e87a770bad81eb901c4c
1 #!/usr/bin/env python
3 APPNAME = 'ldb'
4 VERSION = '1.1.29'
6 blddir = 'bin'
8 import sys, os
10 # find the buildtools directory
11 srcdir = '.'
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 buildtools:buildtools third_party/waf:third_party/waf''')
24 def set_options(opt):
25 opt.BUILTIN_DEFAULT('replace')
26 opt.PRIVATE_EXTENSION_DEFAULT('ldb', noextension='ldb')
27 opt.RECURSE('lib/tdb')
28 opt.RECURSE('lib/tevent')
29 opt.RECURSE('lib/replace')
30 opt.tool_options('python') # options for disabling pyc or pyo compilation
32 def configure(conf):
33 conf.RECURSE('lib/tdb')
34 conf.RECURSE('lib/tevent')
36 if conf.CHECK_FOR_THIRD_PARTY():
37 conf.RECURSE('third_party/popt')
38 else:
39 if not conf.CHECK_POPT():
40 raise Utils.WafError('popt development packages have not been found.\nIf third_party is installed, check that it is in the proper place.')
41 else:
42 conf.define('USING_SYSTEM_POPT', 1)
44 conf.RECURSE('lib/replace')
45 conf.find_program('python', var='PYTHON')
46 conf.find_program('xsltproc', var='XSLTPROC')
47 conf.check_tool('python')
48 conf.check_python_version((2,4,2))
49 conf.SAMBA_CHECK_PYTHON_HEADERS(mandatory=True)
51 # where does the default LIBDIR end up? in conf.env somewhere?
53 conf.CONFIG_PATH('LDB_MODULESDIR', conf.SUBST_ENV_VAR('MODULESDIR') + '/ldb')
55 conf.env.standalone_ldb = conf.IN_LAUNCH_DIR()
57 if not conf.env.standalone_ldb:
59 # ldb >= 1.2.0 (as well as 1.1.30 and 1.1.31) are
60 # incompatible with Samba < 4.7
62 # See https://bugzilla.samba.org/show_bug.cgi?id=12859
64 maxversion = "1.1.99"
65 version_blacklist = ["1.1.30", "1.1.31"]
67 if conf.CHECK_BUNDLED_SYSTEM_PKG('pyldb-util',
68 minversion=VERSION,
69 maxversion=maxversion,
70 version_blacklist=version_blacklist,
71 onlyif='talloc tdb tevent',
72 implied_deps='replace talloc tdb tevent ldb'):
73 conf.define('USING_SYSTEM_PYLDB_UTIL', 1)
74 if conf.CHECK_BUNDLED_SYSTEM_PKG('ldb',
75 minversion=VERSION,
76 maxversion=maxversion,
77 version_blacklist=version_blacklist,
78 onlyif='talloc tdb tevent pyldb-util',
79 implied_deps='replace talloc tdb tevent'):
80 conf.define('USING_SYSTEM_LDB', 1)
82 if conf.env.standalone_ldb:
83 conf.CHECK_XSLTPROC_MANPAGES()
85 # we need this for the ldap backend
86 if conf.CHECK_FUNCS_IN('ber_flush ldap_open ldap_initialize', 'lber ldap', headers='lber.h ldap.h'):
87 conf.env.ENABLE_LDAP_BACKEND = True
89 # we don't want any libraries or modules to rely on runtime
90 # resolution of symbols
91 if not sys.platform.startswith("openbsd"):
92 conf.ADD_LDFLAGS('-Wl,-no-undefined', testflags=True)
94 conf.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags=True)
96 conf.SAMBA_CONFIG_H()
98 conf.SAMBA_CHECK_UNDEFINED_SYMBOL_FLAGS()
100 def build(bld):
101 bld.RECURSE('lib/tevent')
103 if bld.CHECK_FOR_THIRD_PARTY():
104 bld.RECURSE('third_party/popt')
106 bld.RECURSE('lib/replace')
107 bld.RECURSE('lib/tdb')
109 if bld.env.standalone_ldb:
110 private_library = False
111 else:
112 private_library = True
114 LDB_MAP_SRC = bld.SUBDIR('ldb_map',
115 'ldb_map.c ldb_map_inbound.c ldb_map_outbound.c')
117 COMMON_SRC = bld.SUBDIR('common',
118 '''ldb_modules.c ldb_ldif.c ldb_parse.c ldb_msg.c ldb_utf8.c
119 ldb_debug.c ldb_dn.c ldb_match.c ldb_options.c ldb_pack.c
120 ldb_attributes.c attrib_handlers.c ldb_controls.c qsort.c''')
122 bld.SAMBA_MODULE('ldb_ldap', 'ldb_ldap/ldb_ldap.c',
123 init_function='ldb_ldap_init',
124 module_init_name='ldb_init_module',
125 deps='talloc lber ldap ldb',
126 enabled=bld.env.ENABLE_LDAP_BACKEND,
127 internal_module=False,
128 subsystem='ldb')
130 # we're not currently linking against the ldap libs, but ldb.pc.in
131 # has @LDAP_LIBS@
132 bld.env.LDAP_LIBS = ''
134 if not 'PACKAGE_VERSION' in bld.env:
135 bld.env.PACKAGE_VERSION = VERSION
136 bld.env.PKGCONFIGDIR = '${LIBDIR}/pkgconfig'
138 if not bld.env.disable_python:
139 if not bld.CONFIG_SET('USING_SYSTEM_PYLDB_UTIL'):
140 for env in bld.gen_python_environments(['PKGCONFIGDIR']):
141 name = bld.pyembed_libname('pyldb-util')
142 bld.SAMBA_LIBRARY(name,
143 deps='ldb',
144 source='pyldb_util.c',
145 public_headers=('' if private_library else 'pyldb.h'),
146 public_headers_install=not private_library,
147 vnum=VERSION,
148 private_library=private_library,
149 pc_files='pyldb-util.pc',
150 pyembed=True,
151 abi_directory='ABI',
152 abi_match='pyldb_*')
154 if not bld.CONFIG_SET('USING_SYSTEM_LDB'):
155 bld.SAMBA_PYTHON('pyldb', 'pyldb.c',
156 deps='ldb ' + name,
157 realname='ldb.so',
158 cflags='-DPACKAGE_VERSION=\"%s\"' % VERSION)
160 for env in bld.gen_python_environments(['PKGCONFIGDIR']):
161 bld.SAMBA_SCRIPT('_ldb_text.py',
162 pattern='_ldb_text.py',
163 installdir='python')
165 bld.INSTALL_FILES('${PYTHONARCHDIR}', '_ldb_text.py')
167 if not bld.CONFIG_SET('USING_SYSTEM_LDB'):
168 if bld.is_install:
169 modules_dir = bld.EXPAND_VARIABLES('${LDB_MODULESDIR}')
170 else:
171 # when we run from the source directory, we want to use
172 # the current modules, not the installed ones
173 modules_dir = os.path.join(os.getcwd(), 'bin/modules/ldb')
175 abi_match = '!ldb_*module_ops !ldb_*backend_ops ldb_*'
177 ldb_headers = ('include/ldb.h include/ldb_errors.h '
178 'include/ldb_module.h include/ldb_handlers.h')
180 bld.SAMBA_LIBRARY('ldb',
181 COMMON_SRC + ' ' + LDB_MAP_SRC,
182 deps='tevent LIBLDB_MAIN replace',
183 includes='include',
184 public_headers=('' if private_library else ldb_headers),
185 public_headers_install=not private_library,
186 pc_files='ldb.pc',
187 vnum=VERSION,
188 private_library=private_library,
189 manpages='man/ldb.3',
190 abi_directory='ABI',
191 abi_match = abi_match)
193 # generate a include/ldb_version.h
194 t = bld.SAMBA_GENERATOR('ldb_version.h',
195 rule='echo "#define LDB_VERSION \\"${LDB_VERSION}\\"" > ${TGT}',
196 dep_vars=['LDB_VERSION'],
197 target='include/ldb_version.h',
198 public_headers='include/ldb_version.h',
199 public_headers_install=not private_library)
200 t.env.LDB_VERSION = VERSION
203 bld.SAMBA_MODULE('ldb_paged_results',
204 'modules/paged_results.c',
205 init_function='ldb_paged_results_init',
206 module_init_name='ldb_init_module',
207 internal_module=False,
208 deps='ldb',
209 subsystem='ldb')
211 bld.SAMBA_MODULE('ldb_asq',
212 'modules/asq.c',
213 init_function='ldb_asq_init',
214 module_init_name='ldb_init_module',
215 internal_module=False,
216 deps='ldb',
217 subsystem='ldb')
219 bld.SAMBA_MODULE('ldb_server_sort',
220 'modules/sort.c',
221 init_function='ldb_server_sort_init',
222 internal_module=False,
223 module_init_name='ldb_init_module',
224 deps='ldb',
225 subsystem='ldb')
227 bld.SAMBA_MODULE('ldb_paged_searches',
228 'modules/paged_searches.c',
229 init_function='ldb_paged_searches_init',
230 internal_module=False,
231 module_init_name='ldb_init_module',
232 deps='ldb',
233 subsystem='ldb')
235 bld.SAMBA_MODULE('ldb_rdn_name',
236 'modules/rdn_name.c',
237 init_function='ldb_rdn_name_init',
238 internal_module=False,
239 module_init_name='ldb_init_module',
240 deps='ldb',
241 subsystem='ldb')
243 bld.SAMBA_MODULE('ldb_sample',
244 'tests/sample_module.c',
245 init_function='ldb_sample_init',
246 internal_module=False,
247 module_init_name='ldb_init_module',
248 deps='ldb',
249 subsystem='ldb')
251 bld.SAMBA_MODULE('ldb_skel',
252 'modules/skel.c',
253 init_function='ldb_skel_init',
254 internal_module=False,
255 module_init_name='ldb_init_module',
256 deps='ldb',
257 subsystem='ldb')
259 bld.SAMBA_MODULE('ldb_sqlite3',
260 'sqlite3/ldb_sqlite3.c',
261 init_function='ldb_sqlite3_init',
262 internal_module=False,
263 module_init_name='ldb_init_module',
264 enabled=False,
265 deps='ldb',
266 subsystem='ldb')
268 bld.SAMBA_MODULE('ldb_tdb',
269 bld.SUBDIR('ldb_tdb',
270 '''ldb_tdb.c ldb_search.c ldb_index.c
271 ldb_cache.c ldb_tdb_wrap.c'''),
272 init_function='ldb_tdb_init',
273 module_init_name='ldb_init_module',
274 internal_module=False,
275 deps='tdb ldb',
276 subsystem='ldb')
278 # have a separate subsystem for common/ldb.c, so it can rebuild
279 # for install with a different -DLDB_MODULESDIR=
280 bld.SAMBA_SUBSYSTEM('LIBLDB_MAIN',
281 'common/ldb.c',
282 deps='tevent tdb',
283 includes='include',
284 cflags=['-DLDB_MODULESDIR=\"%s\"' % modules_dir])
286 LDB_TOOLS='ldbadd ldbsearch ldbdel ldbmodify ldbedit ldbrename'
287 for t in LDB_TOOLS.split():
288 bld.SAMBA_BINARY(t, 'tools/%s.c' % t, deps='ldb-cmdline ldb',
289 manpages='man/%s.1' % t)
291 # ldbtest doesn't get installed
292 bld.SAMBA_BINARY('ldbtest', 'tools/ldbtest.c', deps='ldb-cmdline ldb',
293 install=False)
295 # ldbdump doesn't get installed
296 bld.SAMBA_BINARY('ldbdump', 'tools/ldbdump.c', deps='ldb-cmdline ldb',
297 install=False)
299 bld.SAMBA_LIBRARY('ldb-cmdline',
300 source='tools/ldbutil.c tools/cmdline.c',
301 deps='ldb dl popt',
302 private_library=True)
305 def test(ctx):
306 '''run ldb testsuite'''
307 import Utils, samba_utils, shutil
308 test_prefix = "%s/st" % (Utils.g_module.blddir)
309 shutil.rmtree(test_prefix, ignore_errors=True)
310 os.makedirs(test_prefix)
311 os.environ['TEST_DATA_PREFIX'] = test_prefix
312 cmd = 'tests/test-tdb.sh %s' % Utils.g_module.blddir
313 ret = samba_utils.RUN_COMMAND(cmd)
314 print("testsuite returned %d" % ret)
316 tmp_dir = os.path.join(test_prefix, 'tmp')
317 if not os.path.exists(tmp_dir):
318 os.mkdir(tmp_dir)
319 pyret = samba_utils.RUN_PYTHON_TESTS(
320 ['tests/python/api.py'],
321 extra_env={'SELFTEST_PREFIX': test_prefix})
322 print("Python testsuite returned %d" % pyret)
323 sys.exit(ret or pyret)
325 def dist():
326 '''makes a tarball for distribution'''
327 samba_dist.dist()
329 def reconfigure(ctx):
330 '''reconfigure if config scripts have changed'''
331 import samba_utils
332 samba_utils.reconfigure(ctx)