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
:
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
65 version_blacklist
= ["1.1.30", "1.1.31"]
67 if conf
.CHECK_BUNDLED_SYSTEM_PKG('pyldb-util',
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',
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)
98 conf
.SAMBA_CHECK_UNDEFINED_SYMBOL_FLAGS()
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
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,
130 # we're not currently linking against the ldap libs, but ldb.pc.in
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
,
144 source
='pyldb_util.c',
145 public_headers
=('' if private_library
else 'pyldb.h'),
146 public_headers_install
=not private_library
,
148 private_library
=private_library
,
149 pc_files
='pyldb-util.pc',
154 if not bld
.CONFIG_SET('USING_SYSTEM_LDB'):
155 bld
.SAMBA_PYTHON('pyldb', 'pyldb.c',
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',
165 bld
.INSTALL_FILES('${PYTHONARCHDIR}', '_ldb_text.py')
167 if not bld
.CONFIG_SET('USING_SYSTEM_LDB'):
169 modules_dir
= bld
.EXPAND_VARIABLES('${LDB_MODULESDIR}')
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',
184 public_headers
=('' if private_library
else ldb_headers
),
185 public_headers_install
=not private_library
,
188 private_library
=private_library
,
189 manpages
='man/ldb.3',
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,
211 bld
.SAMBA_MODULE('ldb_asq',
213 init_function
='ldb_asq_init',
214 module_init_name
='ldb_init_module',
215 internal_module
=False,
219 bld
.SAMBA_MODULE('ldb_server_sort',
221 init_function
='ldb_server_sort_init',
222 internal_module
=False,
223 module_init_name
='ldb_init_module',
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',
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',
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',
251 bld
.SAMBA_MODULE('ldb_skel',
253 init_function
='ldb_skel_init',
254 internal_module
=False,
255 module_init_name
='ldb_init_module',
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',
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,
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',
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',
295 # ldbdump doesn't get installed
296 bld
.SAMBA_BINARY('ldbdump', 'tools/ldbdump.c', deps
='ldb-cmdline ldb',
299 bld
.SAMBA_LIBRARY('ldb-cmdline',
300 source
='tools/ldbutil.c tools/cmdline.c',
302 private_library
=True)
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
):
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
)
326 '''makes a tarball for distribution'''
329 def reconfigure(ctx
):
330 '''reconfigure if config scripts have changed'''
332 samba_utils
.reconfigure(ctx
)