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('LDB_VERSION', VERSION, quote=True)
61 conf.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags=True)
63 # we don't want any libraries or modules to rely on runtime
64 # resolution of symbols
65 conf.ADD_LDFLAGS('-Wl,-no-undefined', testflags=True)
70 bld.RECURSE('lib/tdb')
71 bld.RECURSE('lib/tevent')
72 bld.RECURSE('lib/popt')
73 bld.RECURSE('lib/replace')
75 if bld.env.standalone_ldb:
76 private_library = False
79 private_library = True
82 LDB_MAP_SRC = bld.SUBDIR('ldb_map',
83 'ldb_map.c ldb_map_inbound.c ldb_map_outbound.c')
85 COMMON_SRC = bld.SUBDIR('common',
86 '''ldb_modules.c ldb_ldif.c ldb_parse.c ldb_msg.c ldb_utf8.c
87 ldb_debug.c ldb_dn.c ldb_match.c ldb_options.c
88 ldb_attributes.c attrib_handlers.c ldb_controls.c qsort.c''')
90 bld.SAMBA_MODULE('ldb_ldap', 'ldb_ldap/ldb_ldap.c',
91 init_function='ldb_ldap_init',
92 module_init_name='ldb_init_module',
93 deps='talloc lber ldap ldb',
94 enabled=bld.env.ENABLE_LDAP_BACKEND,
95 internal_module=False,
98 # we're not currently linking against the ldap libs, but ldb.pc.in
100 bld.env.LDAP_LIBS = ''
102 if not 'PACKAGE_VERSION' in bld.env:
103 bld.env.PACKAGE_VERSION = VERSION
104 bld.env.PKGCONFIGDIR = '${LIBDIR}/pkgconfig'
106 if not bld.CONFIG_SET('USING_SYSTEM_PYLDB_UTIL'):
107 bld.SAMBA_LIBRARY('pyldb-util',
109 source='pyldb_util.c',
110 public_headers='pyldb.h',
112 private_library=private_library,
113 pc_files='pyldb-util.pc',
116 if not bld.CONFIG_SET('USING_SYSTEM_LDB'):
117 if Options.is_install:
118 modules_dir = bld.EXPAND_VARIABLES('${LDB_MODULESDIR}')
120 # when we run from the source directory, we want to use
121 # the current modules, not the installed ones
122 modules_dir = os.path.join(os.getcwd(), 'bin/modules/ldb')
124 abi_match = '!ldb_*module_ops !ldb_*backend_ops ldb_*'
126 bld.SAMBA_LIBRARY('ldb',
127 COMMON_SRC + ' ' + LDB_MAP_SRC,
128 deps='tevent LIBLDB_MAIN',
130 public_headers='include/ldb.h include/ldb_errors.h '\
131 'include/ldb_module.h include/ldb_handlers.h',
134 private_library=private_library,
135 manpages='man/ldb.3',
136 abi_directory = 'ABI',
137 abi_match = abi_match)
140 bld.SAMBA_PYTHON('pyldb', 'pyldb.c',
141 deps='ldb pyldb-util',
143 cflags='-DPACKAGE_VERSION=\"%s\"' % VERSION)
145 bld.SAMBA_MODULE('ldb_paged_results',
146 'modules/paged_results.c',
147 init_function='ldb_paged_results_init',
148 module_init_name='ldb_init_module',
152 bld.SAMBA_MODULE('ldb_asq',
154 init_function='ldb_asq_init',
155 module_init_name='ldb_init_module',
159 bld.SAMBA_MODULE('ldb_server_sort',
161 init_function='ldb_server_sort_init',
162 module_init_name='ldb_init_module',
166 bld.SAMBA_MODULE('ldb_paged_searches',
167 'modules/paged_searches.c',
168 init_function='ldb_paged_searches_init',
169 module_init_name='ldb_init_module',
173 bld.SAMBA_MODULE('ldb_rdn_name',
174 'modules/rdn_name.c',
175 init_function='ldb_rdn_name_init',
176 module_init_name='ldb_init_module',
180 bld.SAMBA_MODULE('ldb_sample',
181 'tests/sample_module.c',
182 init_function='ldb_sample_init',
183 module_init_name='ldb_init_module',
187 bld.SAMBA_MODULE('ldb_skel',
189 init_function='ldb_skel_init',
190 module_init_name='ldb_init_module',
194 bld.SAMBA_MODULE('ldb_sqlite3',
195 'sqlite3/ldb_sqlite3.c',
196 init_function='ldb_sqlite3_init',
197 module_init_name='ldb_init_module',
202 bld.SAMBA_MODULE('ldb_tdb',
203 bld.SUBDIR('ldb_tdb',
204 '''ldb_tdb.c ldb_pack.c ldb_search.c ldb_index.c
205 ldb_cache.c ldb_tdb_wrap.c'''),
206 init_function='ldb_tdb_init',
207 module_init_name='ldb_init_module',
211 # have a separate subsystem for common/ldb.c, so it can rebuild
212 # for install with a different -DLDB_MODULESDIR=
213 bld.SAMBA_SUBSYSTEM('LIBLDB_MAIN',
217 cflags=['-DLDB_MODULESDIR=\"%s\"' % modules_dir])
219 LDB_TOOLS='ldbadd ldbsearch ldbdel ldbmodify ldbedit ldbrename'
220 for t in LDB_TOOLS.split():
221 bld.SAMBA_BINARY(t, 'tools/%s.c' % t, deps='ldb-cmdline ldb',
222 manpages='man/%s.1' % t)
224 # ldbtest doesn't get installed
225 bld.SAMBA_BINARY('ldbtest', 'tools/ldbtest.c', deps='ldb-cmdline ldb',
228 bld.SAMBA_LIBRARY('ldb-cmdline',
229 source='tools/ldbutil.c tools/cmdline.c',
231 private_library=True)
235 '''run ldb testsuite'''
236 import Utils, samba_utils
237 cmd = 'tests/test-tdb.sh'
238 ret = samba_utils.RUN_COMMAND(cmd)
239 print("testsuite returned %d" % ret)
240 # FIXME: Run python testsuite
244 '''makes a tarball for distribution'''
247 def reconfigure(ctx):
248 '''reconfigure if config scripts have changed'''
250 samba_utils.reconfigure(ctx)