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 buildtools:buildtools third_party/waf:third_party/waf''')
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
33 conf.RECURSE('lib/tdb')
34 conf.RECURSE('lib/tevent')
36 if conf.CHECK_FOR_THIRD_PARTY():
37 conf.RECURSE('third_party/popt')
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.')
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:
58 using_system_pyldb_util = True
59 if not conf.CHECK_BUNDLED_SYSTEM_PKG('pyldb-util', minversion=VERSION,
60 onlyif='talloc tdb tevent',
61 implied_deps='replace talloc tdb tevent ldb'):
62 using_system_pyldb_util = False
64 # We need to get a pyldb-util for all the python versions
66 if conf.env['EXTRA_PYTHON']:
67 name = 'pyldb-util' + conf.all_envs['extrapython']['PYTHON_SO_ABI_FLAG']
68 if not conf.CHECK_BUNDLED_SYSTEM_PKG(name, minversion=VERSION,
69 onlyif='talloc tdb tevent',
70 implied_deps='replace talloc tdb tevent ldb'):
71 using_system_pyldb_util = False
73 if using_system_pyldb_util:
74 conf.define('USING_SYSTEM_PYLDB_UTIL', 1)
75 if conf.CHECK_BUNDLED_SYSTEM_PKG('ldb', minversion=VERSION,
76 onlyif='talloc tdb tevent pyldb-util',
77 implied_deps='replace talloc tdb tevent'):
78 conf.define('USING_SYSTEM_LDB', 1)
80 if conf.env.standalone_ldb:
81 conf.CHECK_XSLTPROC_MANPAGES()
83 # we need this for the ldap backend
84 if conf.CHECK_FUNCS_IN('ber_flush ldap_open ldap_initialize', 'lber ldap', headers='lber.h ldap.h'):
85 conf.env.ENABLE_LDAP_BACKEND = True
87 # we don't want any libraries or modules to rely on runtime
88 # resolution of symbols
89 if not sys.platform.startswith("openbsd"):
90 conf.ADD_LDFLAGS('-Wl,-no-undefined', testflags=True)
92 conf.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags=True)
96 conf.SAMBA_CHECK_UNDEFINED_SYMBOL_FLAGS()
99 bld.RECURSE('lib/tevent')
101 if bld.CHECK_FOR_THIRD_PARTY():
102 bld.RECURSE('third_party/popt')
104 bld.RECURSE('lib/replace')
105 bld.RECURSE('lib/tdb')
107 if bld.env.standalone_ldb:
108 private_library = False
110 private_library = True
112 LDB_MAP_SRC = bld.SUBDIR('ldb_map',
113 'ldb_map.c ldb_map_inbound.c ldb_map_outbound.c')
115 COMMON_SRC = bld.SUBDIR('common',
116 '''ldb_modules.c ldb_ldif.c ldb_parse.c ldb_msg.c ldb_utf8.c
117 ldb_debug.c ldb_dn.c ldb_match.c ldb_options.c ldb_pack.c
118 ldb_attributes.c attrib_handlers.c ldb_controls.c qsort.c''')
120 bld.SAMBA_MODULE('ldb_ldap', 'ldb_ldap/ldb_ldap.c',
121 init_function='ldb_ldap_init',
122 module_init_name='ldb_init_module',
123 deps='talloc lber ldap ldb',
124 enabled=bld.env.ENABLE_LDAP_BACKEND,
125 internal_module=False,
128 if not bld.env.disable_python:
129 if not bld.CONFIG_SET('USING_SYSTEM_PYLDB_UTIL'):
130 for env in bld.gen_python_environments(['PKGCONFIGDIR']):
131 # we're not currently linking against the ldap libs, but ldb.pc.in
133 bld.env.LDAP_LIBS = ''
135 if not 'PACKAGE_VERSION' in bld.env:
136 bld.env.PACKAGE_VERSION = VERSION
137 bld.env.PKGCONFIGDIR = '${LIBDIR}/pkgconfig'
139 name = bld.pyembed_libname('pyldb-util')
140 bld.SAMBA_LIBRARY(name,
142 source='pyldb_util.c',
143 public_headers=('' if private_library else 'pyldb.h'),
144 public_headers_install=not private_library,
146 private_library=private_library,
147 pc_files='pyldb-util.pc',
152 if not bld.CONFIG_SET('USING_SYSTEM_LDB'):
153 bld.SAMBA_PYTHON('pyldb', 'pyldb.c',
156 cflags='-DPACKAGE_VERSION=\"%s\"' % VERSION)
158 for env in bld.gen_python_environments(['PKGCONFIGDIR']):
159 bld.SAMBA_SCRIPT('_ldb_text.py',
160 pattern='_ldb_text.py',
163 bld.INSTALL_FILES('${PYTHONARCHDIR}', '_ldb_text.py')
165 if not bld.CONFIG_SET('USING_SYSTEM_LDB'):
167 modules_dir = bld.EXPAND_VARIABLES('${LDB_MODULESDIR}')
169 # when we run from the source directory, we want to use
170 # the current modules, not the installed ones
171 modules_dir = os.path.join(os.getcwd(), 'bin/modules/ldb')
173 abi_match = '!ldb_*module_ops !ldb_*backend_ops ldb_*'
175 ldb_headers = ('include/ldb.h include/ldb_errors.h '
176 'include/ldb_module.h include/ldb_handlers.h')
178 bld.SAMBA_LIBRARY('ldb',
179 COMMON_SRC + ' ' + LDB_MAP_SRC,
180 deps='tevent LIBLDB_MAIN replace',
182 public_headers=('' if private_library else ldb_headers),
183 public_headers_install=not private_library,
186 private_library=private_library,
187 manpages='man/ldb.3',
189 abi_match = abi_match)
191 # generate a include/ldb_version.h
192 t = bld.SAMBA_GENERATOR('ldb_version.h',
193 rule='echo "#define LDB_VERSION \\"${LDB_VERSION}\\"" > ${TGT}',
194 dep_vars=['LDB_VERSION'],
195 target='include/ldb_version.h',
196 public_headers='include/ldb_version.h',
197 public_headers_install=not private_library)
198 t.env.LDB_VERSION = VERSION
201 bld.SAMBA_MODULE('ldb_paged_results',
202 'modules/paged_results.c',
203 init_function='ldb_paged_results_init',
204 module_init_name='ldb_init_module',
205 internal_module=False,
209 bld.SAMBA_MODULE('ldb_asq',
211 init_function='ldb_asq_init',
212 module_init_name='ldb_init_module',
213 internal_module=False,
217 bld.SAMBA_MODULE('ldb_server_sort',
219 init_function='ldb_server_sort_init',
220 internal_module=False,
221 module_init_name='ldb_init_module',
225 bld.SAMBA_MODULE('ldb_paged_searches',
226 'modules/paged_searches.c',
227 init_function='ldb_paged_searches_init',
228 internal_module=False,
229 module_init_name='ldb_init_module',
233 bld.SAMBA_MODULE('ldb_rdn_name',
234 'modules/rdn_name.c',
235 init_function='ldb_rdn_name_init',
236 internal_module=False,
237 module_init_name='ldb_init_module',
241 bld.SAMBA_MODULE('ldb_sample',
242 'tests/sample_module.c',
243 init_function='ldb_sample_init',
244 internal_module=False,
245 module_init_name='ldb_init_module',
249 bld.SAMBA_MODULE('ldb_skel',
251 init_function='ldb_skel_init',
252 internal_module=False,
253 module_init_name='ldb_init_module',
257 bld.SAMBA_MODULE('ldb_sqlite3',
258 'sqlite3/ldb_sqlite3.c',
259 init_function='ldb_sqlite3_init',
260 internal_module=False,
261 module_init_name='ldb_init_module',
266 bld.SAMBA_MODULE('ldb_tdb',
267 bld.SUBDIR('ldb_tdb',
268 '''ldb_tdb.c ldb_search.c ldb_index.c
269 ldb_cache.c ldb_tdb_wrap.c'''),
270 init_function='ldb_tdb_init',
271 module_init_name='ldb_init_module',
272 internal_module=False,
276 # have a separate subsystem for common/ldb.c, so it can rebuild
277 # for install with a different -DLDB_MODULESDIR=
278 bld.SAMBA_SUBSYSTEM('LIBLDB_MAIN',
282 cflags=['-DLDB_MODULESDIR=\"%s\"' % modules_dir])
284 LDB_TOOLS='ldbadd ldbsearch ldbdel ldbmodify ldbedit ldbrename'
285 for t in LDB_TOOLS.split():
286 bld.SAMBA_BINARY(t, 'tools/%s.c' % t, deps='ldb-cmdline ldb',
287 manpages='man/%s.1' % t)
289 # ldbtest doesn't get installed
290 bld.SAMBA_BINARY('ldbtest', 'tools/ldbtest.c', deps='ldb-cmdline ldb',
293 # ldbdump doesn't get installed
294 bld.SAMBA_BINARY('ldbdump', 'tools/ldbdump.c', deps='ldb-cmdline ldb',
297 bld.SAMBA_LIBRARY('ldb-cmdline',
298 source='tools/ldbutil.c tools/cmdline.c',
300 private_library=True)
304 '''run ldb testsuite'''
305 import Utils, samba_utils, shutil
306 test_prefix = "%s/st" % (Utils.g_module.blddir)
307 shutil.rmtree(test_prefix, ignore_errors=True)
308 os.makedirs(test_prefix)
309 os.environ['TEST_DATA_PREFIX'] = test_prefix
310 cmd = 'tests/test-tdb.sh %s' % Utils.g_module.blddir
311 ret = samba_utils.RUN_COMMAND(cmd)
312 print("testsuite returned %d" % ret)
314 tmp_dir = os.path.join(test_prefix, 'tmp')
315 if not os.path.exists(tmp_dir):
317 pyret = samba_utils.RUN_PYTHON_TESTS(
318 ['tests/python/api.py'],
319 extra_env={'SELFTEST_PREFIX': test_prefix})
320 print("Python testsuite returned %d" % pyret)
321 sys.exit(ret or pyret)
324 '''makes a tarball for distribution'''
327 def reconfigure(ctx):
328 '''reconfigure if config scripts have changed'''
330 samba_utils.reconfigure(ctx)