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/tdb2:lib/tdb2 lib/tdb_compat:lib/tdb_compat lib/ccan:lib/ccan 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_compat')
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_compat')
33 conf
.RECURSE('lib/tevent')
34 conf
.RECURSE('lib/popt')
35 conf
.RECURSE('lib/replace')
36 conf
.RECURSE('lib/tdb_compat')
37 conf
.find_program('python', var
='PYTHON')
38 conf
.find_program('xsltproc', var
='XSLTPROC')
39 conf
.check_tool('python')
40 conf
.check_python_version((2,4,2))
41 conf
.SAMBA_CHECK_PYTHON_HEADERS(mandatory
=True)
43 # This make #include <ccan/...> work.
44 conf
.ADD_EXTRA_INCLUDES('''#lib''')
46 # where does the default LIBDIR end up? in conf.env somewhere?
48 conf
.CONFIG_PATH('LDB_MODULESDIR', conf
.SUBST_ENV_VAR('MODULESDIR') + '/ldb')
50 conf
.env
.standalone_ldb
= conf
.IN_LAUNCH_DIR()
52 if not conf
.env
.standalone_ldb
:
53 if conf
.CHECK_BUNDLED_SYSTEM_PKG('ldb', minversion
=VERSION
,
54 onlyif
='talloc tdb tevent',
55 implied_deps
='replace talloc tdb tevent'):
56 conf
.define('USING_SYSTEM_LDB', 1)
57 if conf
.CHECK_BUNDLED_SYSTEM_PKG('pyldb-util', minversion
=VERSION
,
58 onlyif
='talloc tdb tevent ldb',
59 implied_deps
='replace talloc tdb tevent ldb'):
60 conf
.define('USING_SYSTEM_PYLDB_UTIL', 1)
62 if conf
.env
.standalone_ldb
:
63 conf
.CHECK_XSLTPROC_MANPAGES()
65 # we need this for the ldap backend
66 if conf
.CHECK_FUNCS_IN('ber_flush ldap_open ldap_initialize', 'lber ldap', headers
='lber.h ldap.h'):
67 conf
.env
.ENABLE_LDAP_BACKEND
= True
69 # we don't want any libraries or modules to rely on runtime
70 # resolution of symbols
71 if sys
.platform
!= "openbsd4":
72 conf
.ADD_LDFLAGS('-Wl,-no-undefined', testflags
=True)
74 conf
.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags
=True)
78 conf
.SAMBA_CHECK_UNDEFINED_SYMBOL_FLAGS()
81 bld
.RECURSE('lib/tdb_compat')
82 bld
.RECURSE('lib/tevent')
83 bld
.RECURSE('lib/popt')
84 bld
.RECURSE('lib/replace')
85 bld
.RECURSE('lib/tdb_compat')
87 if bld
.env
.standalone_ldb
:
88 private_library
= False
90 private_library
= True
92 LDB_MAP_SRC
= bld
.SUBDIR('ldb_map',
93 'ldb_map.c ldb_map_inbound.c ldb_map_outbound.c')
95 COMMON_SRC
= bld
.SUBDIR('common',
96 '''ldb_modules.c ldb_ldif.c ldb_parse.c ldb_msg.c ldb_utf8.c
97 ldb_debug.c ldb_dn.c ldb_match.c ldb_options.c
98 ldb_attributes.c attrib_handlers.c ldb_controls.c qsort.c''')
100 bld
.SAMBA_MODULE('ldb_ldap', 'ldb_ldap/ldb_ldap.c',
101 init_function
='ldb_ldap_init',
102 module_init_name
='ldb_init_module',
103 deps
='talloc lber ldap ldb',
104 enabled
=bld
.env
.ENABLE_LDAP_BACKEND
,
105 internal_module
=False,
108 # we're not currently linking against the ldap libs, but ldb.pc.in
110 bld
.env
.LDAP_LIBS
= ''
112 if not 'PACKAGE_VERSION' in bld
.env
:
113 bld
.env
.PACKAGE_VERSION
= VERSION
114 bld
.env
.PKGCONFIGDIR
= '${LIBDIR}/pkgconfig'
116 if not bld
.CONFIG_SET('USING_SYSTEM_PYLDB_UTIL'):
117 bld
.SAMBA_LIBRARY('pyldb-util',
119 source
='pyldb_util.c',
120 public_headers
='pyldb.h',
121 public_headers_install
=not private_library
,
123 private_library
=private_library
,
124 pc_files
='pyldb-util.pc',
129 if not bld
.CONFIG_SET('USING_SYSTEM_LDB'):
130 if Options
.is_install
:
131 modules_dir
= bld
.EXPAND_VARIABLES('${LDB_MODULESDIR}')
133 # when we run from the source directory, we want to use
134 # the current modules, not the installed ones
135 modules_dir
= os
.path
.join(os
.getcwd(), 'bin/modules/ldb')
137 abi_match
= '!ldb_*module_ops !ldb_*backend_ops ldb_*'
139 bld
.SAMBA_LIBRARY('ldb',
140 COMMON_SRC
+ ' ' + LDB_MAP_SRC
,
141 deps
='tevent LIBLDB_MAIN',
143 public_headers
='include/ldb.h include/ldb_errors.h '\
144 'include/ldb_module.h include/ldb_handlers.h',
145 public_headers_install
=not private_library
,
148 private_library
=private_library
,
149 manpages
='man/ldb.3',
151 abi_match
= abi_match
)
153 # generate a include/ldb_version.h
154 t
= bld
.SAMBA_GENERATOR('ldb_version.h',
155 rule
='echo "#define LDB_VERSION \\"${LDB_VERSION}\\"" > ${TGT}',
156 target
='include/ldb_version.h',
157 public_headers
='include/ldb_version.h',
158 public_headers_install
=not private_library
)
159 t
.env
.LDB_VERSION
= VERSION
160 bld
.add_manual_dependency(bld
.path
.find_or_declare('include/ldb_version.h'), VERSION
)
164 bld
.SAMBA_PYTHON('pyldb', 'pyldb.c',
165 deps
='ldb pyldb-util',
167 cflags
='-DPACKAGE_VERSION=\"%s\"' % VERSION
)
169 bld
.SAMBA_MODULE('ldb_paged_results',
170 'modules/paged_results.c',
171 init_function
='ldb_paged_results_init',
172 module_init_name
='ldb_init_module',
173 internal_module
=False,
177 bld
.SAMBA_MODULE('ldb_asq',
179 init_function
='ldb_asq_init',
180 module_init_name
='ldb_init_module',
181 internal_module
=False,
185 bld
.SAMBA_MODULE('ldb_server_sort',
187 init_function
='ldb_server_sort_init',
188 internal_module
=False,
189 module_init_name
='ldb_init_module',
193 bld
.SAMBA_MODULE('ldb_paged_searches',
194 'modules/paged_searches.c',
195 init_function
='ldb_paged_searches_init',
196 internal_module
=False,
197 module_init_name
='ldb_init_module',
201 bld
.SAMBA_MODULE('ldb_rdn_name',
202 'modules/rdn_name.c',
203 init_function
='ldb_rdn_name_init',
204 internal_module
=False,
205 module_init_name
='ldb_init_module',
209 bld
.SAMBA_MODULE('ldb_sample',
210 'tests/sample_module.c',
211 init_function
='ldb_sample_init',
212 internal_module
=False,
213 module_init_name
='ldb_init_module',
217 bld
.SAMBA_MODULE('ldb_skel',
219 init_function
='ldb_skel_init',
220 internal_module
=False,
221 module_init_name
='ldb_init_module',
225 bld
.SAMBA_MODULE('ldb_sqlite3',
226 'sqlite3/ldb_sqlite3.c',
227 init_function
='ldb_sqlite3_init',
228 internal_module
=False,
229 module_init_name
='ldb_init_module',
234 bld
.SAMBA_MODULE('ldb_tdb',
235 bld
.SUBDIR('ldb_tdb',
236 '''ldb_tdb.c ldb_pack.c ldb_search.c ldb_index.c
237 ldb_cache.c ldb_tdb_wrap.c'''),
238 init_function
='ldb_tdb_init',
239 module_init_name
='ldb_init_module',
240 internal_module
=False,
241 deps
='tdb_compat ldb',
244 # have a separate subsystem for common/ldb.c, so it can rebuild
245 # for install with a different -DLDB_MODULESDIR=
246 bld
.SAMBA_SUBSYSTEM('LIBLDB_MAIN',
248 deps
='tevent tdb_compat',
250 cflags
=['-DLDB_MODULESDIR=\"%s\"' % modules_dir
])
252 LDB_TOOLS
='ldbadd ldbsearch ldbdel ldbmodify ldbedit ldbrename'
253 for t
in LDB_TOOLS
.split():
254 bld
.SAMBA_BINARY(t
, 'tools/%s.c' % t
, deps
='ldb-cmdline ldb',
255 manpages
='man/%s.1' % t
)
257 # ldbtest doesn't get installed
258 bld
.SAMBA_BINARY('ldbtest', 'tools/ldbtest.c', deps
='ldb-cmdline ldb',
261 bld
.SAMBA_LIBRARY('ldb-cmdline',
262 source
='tools/ldbutil.c tools/cmdline.c',
264 private_library
=True)
268 '''run ldb testsuite'''
269 import Utils
, samba_utils
, shutil
270 test_prefix
= "%s/st" % (Utils
.g_module
.blddir
)
271 shutil
.rmtree(test_prefix
, ignore_errors
=True)
272 os
.makedirs(test_prefix
)
273 os
.environ
['TEST_DATA_PREFIX'] = test_prefix
274 cmd
= 'tests/test-tdb.sh'
275 ret
= samba_utils
.RUN_COMMAND(cmd
)
276 print("testsuite returned %d" % ret
)
277 # FIXME: Run python testsuite
281 '''makes a tarball for distribution'''
284 def reconfigure(ctx
):
285 '''reconfigure if config scripts have changed'''
287 samba_utils
.reconfigure(ctx
)