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('''source4/lib/ldb:. lib/replace:lib/replace lib/talloc:lib/talloc
19 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')
31 conf
.RECURSE('lib/tdb')
32 conf
.RECURSE('lib/tevent')
33 conf
.RECURSE('lib/popt')
34 conf
.RECURSE('lib/replace')
36 # where does the default LIBDIR end up? in conf.env somewhere?
38 conf
.CONFIG_PATH('LDB_MODULESDIR', conf
.SUBST_ENV_VAR('MODULESDIR') + '/ldb')
40 conf
.env
.standalone_ldb
= conf
.IN_LAUNCH_DIR()
42 if not conf
.env
.standalone_ldb
:
43 if conf
.CHECK_BUNDLED_SYSTEM('ldb', minversion
=VERSION
,
44 onlyif
='talloc tdb tevent',
45 implied_deps
='replace talloc tdb tevent'):
46 conf
.define('USING_SYSTEM_LDB', 1)
47 if conf
.CHECK_BUNDLED_SYSTEM('pyldb-util', minversion
=VERSION
,
48 onlyif
='talloc tdb tevent ldb',
49 implied_deps
='replace talloc tdb tevent ldb'):
50 conf
.define('USING_SYSTEM_PYLDB_UTIL', 1)
52 if conf
.env
.standalone_ldb
:
53 conf
.CHECK_XSLTPROC_MANPAGES()
55 # we need this for the ldap backend
56 if conf
.CHECK_FUNCS_IN('ber_flush ldap_open ldap_initialize', 'lber ldap', headers
='lber.h ldap.h'):
57 conf
.env
.ENABLE_LDAP_BACKEND
= True
59 conf
.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags
=True)
61 # we don't want any libraries or modules to rely on runtime
62 # resolution of symbols
63 if sys
.platform
!= "openbsd4":
64 conf
.ADD_LDFLAGS('-Wl,-no-undefined', testflags
=True)
69 bld
.RECURSE('lib/tdb')
70 bld
.RECURSE('lib/tevent')
71 bld
.RECURSE('lib/popt')
72 bld
.RECURSE('lib/replace')
74 if bld
.env
.standalone_ldb
:
75 private_library
= False
77 pyldb_pc_files
='pyldb-util.pc'
79 private_library
= True
83 LDB_MAP_SRC
= bld
.SUBDIR('ldb_map',
84 'ldb_map.c ldb_map_inbound.c ldb_map_outbound.c')
86 COMMON_SRC
= bld
.SUBDIR('common',
87 '''ldb_modules.c ldb_ldif.c ldb_parse.c ldb_msg.c ldb_utf8.c
88 ldb_debug.c ldb_dn.c ldb_match.c ldb_options.c
89 ldb_attributes.c attrib_handlers.c ldb_controls.c qsort.c''')
91 bld
.SAMBA_MODULE('ldb_ldap', 'ldb_ldap/ldb_ldap.c',
92 init_function
='ldb_ldap_init',
93 module_init_name
='ldb_init_module',
94 deps
='talloc lber ldap ldb',
95 enabled
=bld
.env
.ENABLE_LDAP_BACKEND
,
96 internal_module
=False,
99 # we're not currently linking against the ldap libs, but ldb.pc.in
101 bld
.env
.LDAP_LIBS
= ''
103 if not 'PACKAGE_VERSION' in bld
.env
:
104 bld
.env
.PACKAGE_VERSION
= VERSION
105 bld
.env
.PKGCONFIGDIR
= '${LIBDIR}/pkgconfig'
107 if not bld
.CONFIG_SET('USING_SYSTEM_PYLDB_UTIL'):
108 bld
.SAMBA_LIBRARY('pyldb-util',
109 deps
='ldb pytalloc-util',
110 source
='pyldb_util.c',
111 public_headers
='pyldb.h',
112 public_headers_install
=not private_library
,
114 private_library
=private_library
,
115 pc_files
=pyldb_pc_files
,
118 if not bld
.CONFIG_SET('USING_SYSTEM_LDB'):
119 if Options
.is_install
:
120 modules_dir
= bld
.EXPAND_VARIABLES('${LDB_MODULESDIR}')
122 # when we run from the source directory, we want to use
123 # the current modules, not the installed ones
124 modules_dir
= os
.path
.join(os
.getcwd(), 'bin/modules/ldb')
126 abi_match
= '!ldb_*module_ops !ldb_*backend_ops ldb_*'
128 bld
.SAMBA_LIBRARY('ldb',
129 COMMON_SRC
+ ' ' + LDB_MAP_SRC
,
130 deps
='tevent LIBLDB_MAIN',
132 public_headers
='include/ldb.h include/ldb_errors.h '\
133 'include/ldb_module.h include/ldb_handlers.h',
134 public_headers_install
=not private_library
,
135 pc_files
=ldb_pc_files
,
137 private_library
=private_library
,
138 manpages
='man/ldb.3',
139 abi_directory
= 'ABI',
140 abi_match
= abi_match
)
142 # generate a include/ldb_version.h
143 t
= bld
.SAMBA_GENERATOR('ldb_version.h',
144 rule
='echo "#define LDB_VERSION \\"${LDB_VERSION}\\"" > ${TGT}',
145 target
='include/ldb_version.h',
146 public_headers
='include/ldb_version.h',
147 public_headers_install
=not private_library
)
148 t
.env
.LDB_VERSION
= VERSION
149 bld
.add_manual_dependency(bld
.path
.find_or_declare('include/ldb_version.h'), VERSION
)
153 bld
.SAMBA_PYTHON('pyldb', 'pyldb.c',
154 deps
='ldb pyldb-util',
156 cflags
='-DPACKAGE_VERSION=\"%s\"' % VERSION
)
158 bld
.SAMBA_MODULE('ldb_paged_results',
159 'modules/paged_results.c',
160 init_function
='ldb_paged_results_init',
161 module_init_name
='ldb_init_module',
162 internal_module
=False,
166 bld
.SAMBA_MODULE('ldb_asq',
168 init_function
='ldb_asq_init',
169 module_init_name
='ldb_init_module',
170 internal_module
=False,
174 bld
.SAMBA_MODULE('ldb_server_sort',
176 init_function
='ldb_server_sort_init',
177 internal_module
=False,
178 module_init_name
='ldb_init_module',
182 bld
.SAMBA_MODULE('ldb_paged_searches',
183 'modules/paged_searches.c',
184 init_function
='ldb_paged_searches_init',
185 internal_module
=False,
186 module_init_name
='ldb_init_module',
190 bld
.SAMBA_MODULE('ldb_rdn_name',
191 'modules/rdn_name.c',
192 init_function
='ldb_rdn_name_init',
193 internal_module
=False,
194 module_init_name
='ldb_init_module',
198 bld
.SAMBA_MODULE('ldb_sample',
199 'tests/sample_module.c',
200 init_function
='ldb_sample_init',
201 internal_module
=False,
202 module_init_name
='ldb_init_module',
206 bld
.SAMBA_MODULE('ldb_skel',
208 init_function
='ldb_skel_init',
209 internal_module
=False,
210 module_init_name
='ldb_init_module',
214 bld
.SAMBA_MODULE('ldb_sqlite3',
215 'sqlite3/ldb_sqlite3.c',
216 init_function
='ldb_sqlite3_init',
217 internal_module
=False,
218 module_init_name
='ldb_init_module',
223 bld
.SAMBA_MODULE('ldb_tdb',
224 bld
.SUBDIR('ldb_tdb',
225 '''ldb_tdb.c ldb_pack.c ldb_search.c ldb_index.c
226 ldb_cache.c ldb_tdb_wrap.c'''),
227 init_function
='ldb_tdb_init',
228 module_init_name
='ldb_init_module',
229 internal_module
=False,
233 # have a separate subsystem for common/ldb.c, so it can rebuild
234 # for install with a different -DLDB_MODULESDIR=
235 bld
.SAMBA_SUBSYSTEM('LIBLDB_MAIN',
239 cflags
=['-DLDB_MODULESDIR=\"%s\"' % modules_dir
])
241 LDB_TOOLS
='ldbadd ldbsearch ldbdel ldbmodify ldbedit ldbrename'
242 for t
in LDB_TOOLS
.split():
243 bld
.SAMBA_BINARY(t
, 'tools/%s.c' % t
, deps
='ldb-cmdline ldb',
244 manpages
='man/%s.1' % t
)
246 # ldbtest doesn't get installed
247 bld
.SAMBA_BINARY('ldbtest', 'tools/ldbtest.c', deps
='ldb-cmdline ldb',
250 bld
.SAMBA_LIBRARY('ldb-cmdline',
251 source
='tools/ldbutil.c tools/cmdline.c',
253 private_library
=True)
257 '''run ldb testsuite'''
258 import Utils
, samba_utils
, shutil
259 test_prefix
= "%s/st" % (Utils
.g_module
.blddir
)
260 shutil
.rmtree(test_prefix
, ignore_errors
=True)
261 os
.makedirs(test_prefix
)
262 os
.environ
['TEST_DATA_PREFIX'] = test_prefix
263 cmd
= 'tests/test-tdb.sh'
264 ret
= samba_utils
.RUN_COMMAND(cmd
)
265 print("testsuite returned %d" % ret
)
266 # FIXME: Run python testsuite
270 '''makes a tarball for distribution'''
273 def reconfigure(ctx
):
274 '''reconfigure if config scripts have changed'''
276 samba_utils
.reconfigure(ctx
)