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, Options
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''')
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 if conf.CHECK_BUNDLED_SYSTEM_PKG('ldb', minversion=VERSION,
59 onlyif='talloc tdb tevent',
60 implied_deps='replace talloc tdb tevent'):
61 conf.define('USING_SYSTEM_LDB', 1)
62 if conf.CHECK_BUNDLED_SYSTEM_PKG('pyldb-util', minversion=VERSION,
63 onlyif='talloc tdb tevent ldb',
64 implied_deps='replace talloc tdb tevent ldb'):
65 conf.define('USING_SYSTEM_PYLDB_UTIL', 1)
67 if conf.env.standalone_ldb:
68 conf.CHECK_XSLTPROC_MANPAGES()
70 # we need this for the ldap backend
71 if conf.CHECK_FUNCS_IN('ber_flush ldap_open ldap_initialize', 'lber ldap', headers='lber.h ldap.h'):
72 conf.env.ENABLE_LDAP_BACKEND = True
74 # we don't want any libraries or modules to rely on runtime
75 # resolution of symbols
76 if not sys.platform.startswith("openbsd"):
77 conf.ADD_LDFLAGS('-Wl,-no-undefined', testflags=True)
79 conf.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags=True)
83 conf.SAMBA_CHECK_UNDEFINED_SYMBOL_FLAGS()
86 bld.RECURSE('lib/tevent')
88 if os.path.exists('third_party'):
89 bld.RECURSE('third_party/popt')
91 bld.RECURSE('lib/replace')
92 bld.RECURSE('lib/tdb')
94 if bld.env.standalone_ldb:
95 private_library = False
97 private_library = True
99 LDB_MAP_SRC = bld.SUBDIR('ldb_map',
100 'ldb_map.c ldb_map_inbound.c ldb_map_outbound.c')
102 COMMON_SRC = bld.SUBDIR('common',
103 '''ldb_modules.c ldb_ldif.c ldb_parse.c ldb_msg.c ldb_utf8.c
104 ldb_debug.c ldb_dn.c ldb_match.c ldb_options.c ldb_pack.c
105 ldb_attributes.c attrib_handlers.c ldb_controls.c qsort.c''')
107 bld.SAMBA_MODULE('ldb_ldap', 'ldb_ldap/ldb_ldap.c',
108 init_function='ldb_ldap_init',
109 module_init_name='ldb_init_module',
110 deps='talloc lber ldap ldb',
111 enabled=bld.env.ENABLE_LDAP_BACKEND,
112 internal_module=False,
115 # we're not currently linking against the ldap libs, but ldb.pc.in
117 bld.env.LDAP_LIBS = ''
119 if not 'PACKAGE_VERSION' in bld.env:
120 bld.env.PACKAGE_VERSION = VERSION
121 bld.env.PKGCONFIGDIR = '${LIBDIR}/pkgconfig'
123 if not bld.CONFIG_SET('USING_SYSTEM_PYLDB_UTIL'):
124 bld.SAMBA_LIBRARY('pyldb-util',
126 source='pyldb_util.c',
127 public_headers='pyldb.h',
128 public_headers_install=not private_library,
130 private_library=private_library,
131 pc_files='pyldb-util.pc',
136 if not bld.CONFIG_SET('USING_SYSTEM_LDB'):
137 if Options.is_install:
138 modules_dir = bld.EXPAND_VARIABLES('${LDB_MODULESDIR}')
140 # when we run from the source directory, we want to use
141 # the current modules, not the installed ones
142 modules_dir = os.path.join(os.getcwd(), 'bin/modules/ldb')
144 abi_match = '!ldb_*module_ops !ldb_*backend_ops ldb_*'
146 bld.SAMBA_LIBRARY('ldb',
147 COMMON_SRC + ' ' + LDB_MAP_SRC,
148 deps='tevent LIBLDB_MAIN replace',
150 public_headers='include/ldb.h include/ldb_errors.h '\
151 'include/ldb_module.h include/ldb_handlers.h',
152 public_headers_install=not private_library,
155 private_library=private_library,
157 manpages='man/ldb.3',
159 abi_match = abi_match)
161 # generate a include/ldb_version.h
162 t = bld.SAMBA_GENERATOR('ldb_version.h',
163 rule='echo "#define LDB_VERSION \\"${LDB_VERSION}\\"" > ${TGT}',
164 target='include/ldb_version.h',
165 public_headers='include/ldb_version.h',
166 public_headers_install=not private_library)
167 t.env.LDB_VERSION = VERSION
168 bld.add_manual_dependency(bld.path.find_or_declare('include/ldb_version.h'), VERSION)
172 bld.SAMBA_PYTHON('pyldb', 'pyldb.c',
173 deps='ldb pyldb-util',
175 cflags='-DPACKAGE_VERSION=\"%s\"' % VERSION)
177 bld.SAMBA_MODULE('ldb_paged_results',
178 'modules/paged_results.c',
179 init_function='ldb_paged_results_init',
180 module_init_name='ldb_init_module',
181 internal_module=False,
185 bld.SAMBA_MODULE('ldb_asq',
187 init_function='ldb_asq_init',
188 module_init_name='ldb_init_module',
189 internal_module=False,
193 bld.SAMBA_MODULE('ldb_server_sort',
195 init_function='ldb_server_sort_init',
196 internal_module=False,
197 module_init_name='ldb_init_module',
201 bld.SAMBA_MODULE('ldb_paged_searches',
202 'modules/paged_searches.c',
203 init_function='ldb_paged_searches_init',
204 internal_module=False,
205 module_init_name='ldb_init_module',
209 bld.SAMBA_MODULE('ldb_rdn_name',
210 'modules/rdn_name.c',
211 init_function='ldb_rdn_name_init',
212 internal_module=False,
213 module_init_name='ldb_init_module',
217 bld.SAMBA_MODULE('ldb_sample',
218 'tests/sample_module.c',
219 init_function='ldb_sample_init',
220 internal_module=False,
222 module_init_name='ldb_init_module',
226 bld.SAMBA_MODULE('ldb_skel',
228 init_function='ldb_skel_init',
229 internal_module=False,
230 module_init_name='ldb_init_module',
234 bld.SAMBA_MODULE('ldb_sqlite3',
235 'sqlite3/ldb_sqlite3.c',
236 init_function='ldb_sqlite3_init',
237 internal_module=False,
238 module_init_name='ldb_init_module',
243 bld.SAMBA_MODULE('ldb_tdb',
244 bld.SUBDIR('ldb_tdb',
245 '''ldb_tdb.c ldb_search.c ldb_index.c
246 ldb_cache.c ldb_tdb_wrap.c'''),
247 init_function='ldb_tdb_init',
248 module_init_name='ldb_init_module',
249 internal_module=False,
253 # have a separate subsystem for common/ldb.c, so it can rebuild
254 # for install with a different -DLDB_MODULESDIR=
255 bld.SAMBA_SUBSYSTEM('LIBLDB_MAIN',
260 cflags=['-DLDB_MODULESDIR=\"%s\"' % modules_dir])
262 LDB_TOOLS='ldbadd ldbsearch ldbdel ldbmodify ldbedit ldbrename'
263 for t in LDB_TOOLS.split():
264 bld.SAMBA_BINARY(t, 'tools/%s.c' % t, deps='ldb-cmdline ldb',
265 manpages='man/%s.1' % t)
267 # ldbtest doesn't get installed
268 bld.SAMBA_BINARY('ldbtest', 'tools/ldbtest.c', deps='ldb-cmdline ldb',
271 # ldbdump doesn't get installed
272 bld.SAMBA_BINARY('ldbdump', 'tools/ldbdump.c', deps='ldb-cmdline ldb',
275 bld.SAMBA_LIBRARY('ldb-cmdline',
276 source='tools/ldbutil.c tools/cmdline.c',
278 private_library=True)
282 '''run ldb testsuite'''
283 import Utils, samba_utils, shutil
284 test_prefix = "%s/st" % (Utils.g_module.blddir)
285 shutil.rmtree(test_prefix, ignore_errors=True)
286 os.makedirs(test_prefix)
287 os.environ['TEST_DATA_PREFIX'] = test_prefix
288 cmd = 'tests/test-tdb.sh %s' % Utils.g_module.blddir
289 ret = samba_utils.RUN_COMMAND(cmd)
290 print("testsuite returned %d" % ret)
291 # FIXME: Run python testsuite
295 '''makes a tarball for distribution'''
298 def reconfigure(ctx):
299 '''reconfigure if config scripts have changed'''
301 samba_utils.reconfigure(ctx)