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 lib/popt:lib/popt
20 buildtools:buildtools''')
24 opt
.BUILTIN_DEFAULT('replace')
25 opt
.PRIVATE_EXTENSION_DEFAULT('ldb', noextension
='ldb')
26 opt
.RECURSE('lib/tdb')
27 opt
.RECURSE('lib/tevent')
28 opt
.RECURSE('lib/replace')
29 opt
.tool_options('python') # options for disabling pyc or pyo compilation
32 conf
.RECURSE('lib/tdb')
33 conf
.RECURSE('lib/tevent')
34 conf
.RECURSE('lib/popt')
35 conf
.RECURSE('lib/replace')
36 conf
.find_program('python', var
='PYTHON')
37 conf
.find_program('xsltproc', var
='XSLTPROC')
38 conf
.check_tool('python')
39 conf
.check_python_version((2,4,2))
40 conf
.SAMBA_CHECK_PYTHON_HEADERS(mandatory
=True)
42 # where does the default LIBDIR end up? in conf.env somewhere?
44 conf
.CONFIG_PATH('LDB_MODULESDIR', conf
.SUBST_ENV_VAR('MODULESDIR') + '/ldb')
46 conf
.env
.standalone_ldb
= conf
.IN_LAUNCH_DIR()
48 if not conf
.env
.standalone_ldb
:
49 if conf
.CHECK_BUNDLED_SYSTEM_PKG('ldb', minversion
=VERSION
,
50 onlyif
='talloc tdb tevent',
51 implied_deps
='replace talloc tdb tevent'):
52 conf
.define('USING_SYSTEM_LDB', 1)
53 if conf
.CHECK_BUNDLED_SYSTEM_PKG('pyldb-util', minversion
=VERSION
,
54 onlyif
='talloc tdb tevent ldb',
55 implied_deps
='replace talloc tdb tevent ldb'):
56 conf
.define('USING_SYSTEM_PYLDB_UTIL', 1)
58 if conf
.env
.standalone_ldb
:
59 conf
.CHECK_XSLTPROC_MANPAGES()
61 # we need this for the ldap backend
62 if conf
.CHECK_FUNCS_IN('ber_flush ldap_open ldap_initialize', 'lber ldap', headers
='lber.h ldap.h'):
63 conf
.env
.ENABLE_LDAP_BACKEND
= True
65 # we don't want any libraries or modules to rely on runtime
66 # resolution of symbols
67 if not sys
.platform
.startswith("openbsd"):
68 conf
.ADD_LDFLAGS('-Wl,-no-undefined', testflags
=True)
70 conf
.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags
=True)
74 conf
.SAMBA_CHECK_UNDEFINED_SYMBOL_FLAGS()
77 bld
.RECURSE('lib/tevent')
78 bld
.RECURSE('lib/popt')
79 bld
.RECURSE('lib/replace')
80 bld
.RECURSE('lib/tdb')
82 if bld
.env
.standalone_ldb
:
83 private_library
= False
85 private_library
= True
87 LDB_MAP_SRC
= bld
.SUBDIR('ldb_map',
88 'ldb_map.c ldb_map_inbound.c ldb_map_outbound.c')
90 COMMON_SRC
= bld
.SUBDIR('common',
91 '''ldb_modules.c ldb_ldif.c ldb_parse.c ldb_msg.c ldb_utf8.c
92 ldb_debug.c ldb_dn.c ldb_match.c ldb_options.c ldb_pack.c
93 ldb_attributes.c attrib_handlers.c ldb_controls.c qsort.c''')
95 bld
.SAMBA_MODULE('ldb_ldap', 'ldb_ldap/ldb_ldap.c',
96 init_function
='ldb_ldap_init',
97 module_init_name
='ldb_init_module',
98 deps
='talloc lber ldap ldb',
99 enabled
=bld
.env
.ENABLE_LDAP_BACKEND
,
100 internal_module
=False,
103 # we're not currently linking against the ldap libs, but ldb.pc.in
105 bld
.env
.LDAP_LIBS
= ''
107 if not 'PACKAGE_VERSION' in bld
.env
:
108 bld
.env
.PACKAGE_VERSION
= VERSION
109 bld
.env
.PKGCONFIGDIR
= '${LIBDIR}/pkgconfig'
111 if not bld
.CONFIG_SET('USING_SYSTEM_PYLDB_UTIL'):
112 bld
.SAMBA_LIBRARY('pyldb-util',
114 source
='pyldb_util.c',
115 public_headers
='pyldb.h',
116 public_headers_install
=not private_library
,
118 private_library
=private_library
,
119 pc_files
='pyldb-util.pc',
124 if not bld
.CONFIG_SET('USING_SYSTEM_LDB'):
125 if Options
.is_install
:
126 modules_dir
= bld
.EXPAND_VARIABLES('${LDB_MODULESDIR}')
128 # when we run from the source directory, we want to use
129 # the current modules, not the installed ones
130 modules_dir
= os
.path
.join(os
.getcwd(), 'bin/modules/ldb')
132 abi_match
= '!ldb_*module_ops !ldb_*backend_ops ldb_*'
134 bld
.SAMBA_LIBRARY('ldb',
135 COMMON_SRC
+ ' ' + LDB_MAP_SRC
,
136 deps
='tevent LIBLDB_MAIN replace',
138 public_headers
='include/ldb.h include/ldb_errors.h '\
139 'include/ldb_module.h include/ldb_handlers.h',
140 public_headers_install
=not private_library
,
143 private_library
=private_library
,
145 manpages
='man/ldb.3',
147 abi_match
= abi_match
)
149 # generate a include/ldb_version.h
150 t
= bld
.SAMBA_GENERATOR('ldb_version.h',
151 rule
='echo "#define LDB_VERSION \\"${LDB_VERSION}\\"" > ${TGT}',
152 target
='include/ldb_version.h',
153 public_headers
='include/ldb_version.h',
154 public_headers_install
=not private_library
)
155 t
.env
.LDB_VERSION
= VERSION
156 bld
.add_manual_dependency(bld
.path
.find_or_declare('include/ldb_version.h'), VERSION
)
160 bld
.SAMBA_PYTHON('pyldb', 'pyldb.c',
161 deps
='ldb pyldb-util',
163 cflags
='-DPACKAGE_VERSION=\"%s\"' % VERSION
)
165 bld
.SAMBA_MODULE('ldb_paged_results',
166 'modules/paged_results.c',
167 init_function
='ldb_paged_results_init',
168 module_init_name
='ldb_init_module',
169 internal_module
=False,
173 bld
.SAMBA_MODULE('ldb_asq',
175 init_function
='ldb_asq_init',
176 module_init_name
='ldb_init_module',
177 internal_module
=False,
181 bld
.SAMBA_MODULE('ldb_server_sort',
183 init_function
='ldb_server_sort_init',
184 internal_module
=False,
185 module_init_name
='ldb_init_module',
189 bld
.SAMBA_MODULE('ldb_paged_searches',
190 'modules/paged_searches.c',
191 init_function
='ldb_paged_searches_init',
192 internal_module
=False,
193 module_init_name
='ldb_init_module',
197 bld
.SAMBA_MODULE('ldb_rdn_name',
198 'modules/rdn_name.c',
199 init_function
='ldb_rdn_name_init',
200 internal_module
=False,
201 module_init_name
='ldb_init_module',
205 bld
.SAMBA_MODULE('ldb_sample',
206 'tests/sample_module.c',
207 init_function
='ldb_sample_init',
208 internal_module
=False,
210 module_init_name
='ldb_init_module',
214 bld
.SAMBA_MODULE('ldb_skel',
216 init_function
='ldb_skel_init',
217 internal_module
=False,
218 module_init_name
='ldb_init_module',
222 bld
.SAMBA_MODULE('ldb_sqlite3',
223 'sqlite3/ldb_sqlite3.c',
224 init_function
='ldb_sqlite3_init',
225 internal_module
=False,
226 module_init_name
='ldb_init_module',
231 bld
.SAMBA_MODULE('ldb_tdb',
232 bld
.SUBDIR('ldb_tdb',
233 '''ldb_tdb.c ldb_search.c ldb_index.c
234 ldb_cache.c ldb_tdb_wrap.c'''),
235 init_function
='ldb_tdb_init',
236 module_init_name
='ldb_init_module',
237 internal_module
=False,
241 # have a separate subsystem for common/ldb.c, so it can rebuild
242 # for install with a different -DLDB_MODULESDIR=
243 bld
.SAMBA_SUBSYSTEM('LIBLDB_MAIN',
248 cflags
=['-DLDB_MODULESDIR=\"%s\"' % modules_dir
])
250 LDB_TOOLS
='ldbadd ldbsearch ldbdel ldbmodify ldbedit ldbrename'
251 for t
in LDB_TOOLS
.split():
252 bld
.SAMBA_BINARY(t
, 'tools/%s.c' % t
, deps
='ldb-cmdline ldb',
253 manpages
='man/%s.1' % t
)
255 # ldbtest doesn't get installed
256 bld
.SAMBA_BINARY('ldbtest', 'tools/ldbtest.c', deps
='ldb-cmdline ldb',
259 # ldbdump doesn't get installed
260 bld
.SAMBA_BINARY('ldbdump', 'tools/ldbdump.c', deps
='ldb-cmdline ldb',
263 bld
.SAMBA_LIBRARY('ldb-cmdline',
264 source
='tools/ldbutil.c tools/cmdline.c',
266 private_library
=True)
270 '''run ldb testsuite'''
271 import Utils
, samba_utils
, shutil
272 test_prefix
= "%s/st" % (Utils
.g_module
.blddir
)
273 shutil
.rmtree(test_prefix
, ignore_errors
=True)
274 os
.makedirs(test_prefix
)
275 os
.environ
['TEST_DATA_PREFIX'] = test_prefix
276 cmd
= 'tests/test-tdb.sh %s' % Utils
.g_module
.blddir
277 ret
= samba_utils
.RUN_COMMAND(cmd
)
278 print("testsuite returned %d" % ret
)
279 # FIXME: Run python testsuite
283 '''makes a tarball for distribution'''
286 def reconfigure(ctx
):
287 '''reconfigure if config scripts have changed'''
289 samba_utils
.reconfigure(ctx
)