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 sys
.platform
!= "openbsd4" and sys
.platform
!= "openbsd5":
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
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',
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 target
='include/ldb_version.h',
152 public_headers
='include/ldb_version.h',
153 public_headers_install
=not private_library
)
154 t
.env
.LDB_VERSION
= VERSION
155 bld
.add_manual_dependency(bld
.path
.find_or_declare('include/ldb_version.h'), VERSION
)
159 bld
.SAMBA_PYTHON('pyldb', 'pyldb.c',
160 deps
='ldb pyldb-util',
162 cflags
='-DPACKAGE_VERSION=\"%s\"' % VERSION
)
164 bld
.SAMBA_MODULE('ldb_paged_results',
165 'modules/paged_results.c',
166 init_function
='ldb_paged_results_init',
167 module_init_name
='ldb_init_module',
168 internal_module
=False,
172 bld
.SAMBA_MODULE('ldb_asq',
174 init_function
='ldb_asq_init',
175 module_init_name
='ldb_init_module',
176 internal_module
=False,
180 bld
.SAMBA_MODULE('ldb_server_sort',
182 init_function
='ldb_server_sort_init',
183 internal_module
=False,
184 module_init_name
='ldb_init_module',
188 bld
.SAMBA_MODULE('ldb_paged_searches',
189 'modules/paged_searches.c',
190 init_function
='ldb_paged_searches_init',
191 internal_module
=False,
192 module_init_name
='ldb_init_module',
196 bld
.SAMBA_MODULE('ldb_rdn_name',
197 'modules/rdn_name.c',
198 init_function
='ldb_rdn_name_init',
199 internal_module
=False,
200 module_init_name
='ldb_init_module',
204 bld
.SAMBA_MODULE('ldb_sample',
205 'tests/sample_module.c',
206 init_function
='ldb_sample_init',
207 internal_module
=False,
208 module_init_name
='ldb_init_module',
212 bld
.SAMBA_MODULE('ldb_skel',
214 init_function
='ldb_skel_init',
215 internal_module
=False,
216 module_init_name
='ldb_init_module',
220 bld
.SAMBA_MODULE('ldb_sqlite3',
221 'sqlite3/ldb_sqlite3.c',
222 init_function
='ldb_sqlite3_init',
223 internal_module
=False,
224 module_init_name
='ldb_init_module',
229 bld
.SAMBA_MODULE('ldb_tdb',
230 bld
.SUBDIR('ldb_tdb',
231 '''ldb_tdb.c ldb_pack.c ldb_search.c ldb_index.c
232 ldb_cache.c ldb_tdb_wrap.c'''),
233 init_function
='ldb_tdb_init',
234 module_init_name
='ldb_init_module',
235 internal_module
=False,
239 # have a separate subsystem for common/ldb.c, so it can rebuild
240 # for install with a different -DLDB_MODULESDIR=
241 bld
.SAMBA_SUBSYSTEM('LIBLDB_MAIN',
245 cflags
=['-DLDB_MODULESDIR=\"%s\"' % modules_dir
])
247 LDB_TOOLS
='ldbadd ldbsearch ldbdel ldbmodify ldbedit ldbrename'
248 for t
in LDB_TOOLS
.split():
249 bld
.SAMBA_BINARY(t
, 'tools/%s.c' % t
, deps
='ldb-cmdline ldb',
250 manpages
='man/%s.1' % t
)
252 # ldbtest doesn't get installed
253 bld
.SAMBA_BINARY('ldbtest', 'tools/ldbtest.c', deps
='ldb-cmdline ldb',
256 bld
.SAMBA_LIBRARY('ldb-cmdline',
257 source
='tools/ldbutil.c tools/cmdline.c',
259 private_library
=True)
263 '''run ldb testsuite'''
264 import Utils
, samba_utils
, shutil
265 test_prefix
= "%s/st" % (Utils
.g_module
.blddir
)
266 shutil
.rmtree(test_prefix
, ignore_errors
=True)
267 os
.makedirs(test_prefix
)
268 os
.environ
['TEST_DATA_PREFIX'] = test_prefix
269 cmd
= 'tests/test-tdb.sh %s' % Utils
.g_module
.blddir
270 ret
= samba_utils
.RUN_COMMAND(cmd
)
271 print("testsuite returned %d" % ret
)
272 # FIXME: Run python testsuite
276 '''makes a tarball for distribution'''
279 def reconfigure(ctx
):
280 '''reconfigure if config scripts have changed'''
282 samba_utils
.reconfigure(ctx
)