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
,
144 manpages
='man/ldb.3',
146 abi_match
= abi_match
)
148 # generate a include/ldb_version.h
149 t
= bld
.SAMBA_GENERATOR('ldb_version.h',
150 rule
='echo "#define LDB_VERSION \\"${LDB_VERSION}\\"" > ${TGT}',
151 dep_vars
=['LDB_VERSION'],
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
158 bld
.SAMBA_PYTHON('pyldb', 'pyldb.c',
159 deps
='ldb pyldb-util',
161 cflags
='-DPACKAGE_VERSION=\"%s\"' % VERSION
)
163 bld
.SAMBA_MODULE('ldb_paged_results',
164 'modules/paged_results.c',
165 init_function
='ldb_paged_results_init',
166 module_init_name
='ldb_init_module',
167 internal_module
=False,
171 bld
.SAMBA_MODULE('ldb_asq',
173 init_function
='ldb_asq_init',
174 module_init_name
='ldb_init_module',
175 internal_module
=False,
179 bld
.SAMBA_MODULE('ldb_server_sort',
181 init_function
='ldb_server_sort_init',
182 internal_module
=False,
183 module_init_name
='ldb_init_module',
187 bld
.SAMBA_MODULE('ldb_paged_searches',
188 'modules/paged_searches.c',
189 init_function
='ldb_paged_searches_init',
190 internal_module
=False,
191 module_init_name
='ldb_init_module',
195 bld
.SAMBA_MODULE('ldb_rdn_name',
196 'modules/rdn_name.c',
197 init_function
='ldb_rdn_name_init',
198 internal_module
=False,
199 module_init_name
='ldb_init_module',
203 bld
.SAMBA_MODULE('ldb_sample',
204 'tests/sample_module.c',
205 init_function
='ldb_sample_init',
206 internal_module
=False,
207 module_init_name
='ldb_init_module',
211 bld
.SAMBA_MODULE('ldb_skel',
213 init_function
='ldb_skel_init',
214 internal_module
=False,
215 module_init_name
='ldb_init_module',
219 bld
.SAMBA_MODULE('ldb_sqlite3',
220 'sqlite3/ldb_sqlite3.c',
221 init_function
='ldb_sqlite3_init',
222 internal_module
=False,
223 module_init_name
='ldb_init_module',
228 bld
.SAMBA_MODULE('ldb_tdb',
229 bld
.SUBDIR('ldb_tdb',
230 '''ldb_tdb.c ldb_search.c ldb_index.c
231 ldb_cache.c ldb_tdb_wrap.c'''),
232 init_function
='ldb_tdb_init',
233 module_init_name
='ldb_init_module',
234 internal_module
=False,
238 # have a separate subsystem for common/ldb.c, so it can rebuild
239 # for install with a different -DLDB_MODULESDIR=
240 bld
.SAMBA_SUBSYSTEM('LIBLDB_MAIN',
244 cflags
=['-DLDB_MODULESDIR=\"%s\"' % modules_dir
])
246 LDB_TOOLS
='ldbadd ldbsearch ldbdel ldbmodify ldbedit ldbrename'
247 for t
in LDB_TOOLS
.split():
248 bld
.SAMBA_BINARY(t
, 'tools/%s.c' % t
, deps
='ldb-cmdline ldb',
249 manpages
='man/%s.1' % t
)
251 # ldbtest doesn't get installed
252 bld
.SAMBA_BINARY('ldbtest', 'tools/ldbtest.c', deps
='ldb-cmdline ldb',
255 # ldbdump doesn't get installed
256 bld
.SAMBA_BINARY('ldbdump', 'tools/ldbdump.c', deps
='ldb-cmdline ldb',
259 bld
.SAMBA_LIBRARY('ldb-cmdline',
260 source
='tools/ldbutil.c tools/cmdline.c',
262 private_library
=True)
266 '''run ldb testsuite'''
267 import Utils
, samba_utils
, shutil
268 test_prefix
= "%s/st" % (Utils
.g_module
.blddir
)
269 shutil
.rmtree(test_prefix
, ignore_errors
=True)
270 os
.makedirs(test_prefix
)
271 os
.environ
['TEST_DATA_PREFIX'] = test_prefix
272 cmd
= 'tests/test-tdb.sh %s' % Utils
.g_module
.blddir
273 ret
= samba_utils
.RUN_COMMAND(cmd
)
274 print("testsuite returned %d" % ret
)
275 # FIXME: Run python testsuite
279 '''makes a tarball for distribution'''
282 def reconfigure(ctx
):
283 '''reconfigure if config scripts have changed'''
285 samba_utils
.reconfigure(ctx
)