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 LDB_MAP_SRC = bld.SUBDIR('ldb_map',
76 'ldb_map.c ldb_map_inbound.c ldb_map_outbound.c')
78 COMMON_SRC = bld.SUBDIR('common',
79 '''ldb_modules.c ldb_ldif.c ldb_parse.c ldb_msg.c ldb_utf8.c
80 ldb_debug.c ldb_dn.c ldb_match.c ldb_options.c
81 ldb_attributes.c attrib_handlers.c ldb_controls.c qsort.c''')
83 bld.SAMBA_MODULE('ldb_ldap', 'ldb_ldap/ldb_ldap.c',
84 init_function='ldb_ldap_init',
85 module_init_name='ldb_init_module',
86 deps='talloc lber ldap ldb',
87 enabled=bld.env.ENABLE_LDAP_BACKEND,
88 internal_module=False,
91 # we're not currently linking against the ldap libs, but ldb.pc.in
93 bld.env.LDAP_LIBS = ''
95 if not 'PACKAGE_VERSION' in bld.env:
96 bld.env.PACKAGE_VERSION = VERSION
97 bld.env.PKGCONFIGDIR = '${LIBDIR}/pkgconfig'
99 if not bld.CONFIG_SET('USING_SYSTEM_PYLDB_UTIL'):
100 bld.SAMBA_LIBRARY('pyldb-util',
102 source='pyldb_util.c',
103 public_headers='pyldb.h',
105 pc_files='pyldb-util.pc',
108 if not bld.CONFIG_SET('USING_SYSTEM_LDB'):
109 if Options.is_install:
110 modules_dir = bld.EXPAND_VARIABLES('${LDB_MODULESDIR}')
112 # when we run from the source directory, we want to use
113 # the current modules, not the installed ones
114 modules_dir = os.path.join(os.getcwd(), 'bin/modules/ldb')
116 abi_file = 'ABI/ldb-%s.sigs' % VERSION
117 abi_match = '!ldb_*module_ops !ldb_*backend_ops ldb_*'
119 bld.SAMBA_LIBRARY('ldb',
120 COMMON_SRC + ' ' + LDB_MAP_SRC,
121 deps='tevent LIBLDB_MAIN',
123 public_headers='include/ldb.h include/ldb_errors.h '\
124 'include/ldb_module.h include/ldb_handlers.h',
127 manpages='man/ldb.3',
129 abi_match = abi_match)
132 bld.SAMBA_PYTHON('pyldb', 'pyldb.c',
133 deps='ldb pyldb-util',
135 cflags='-DPACKAGE_VERSION=\"%s\"' % VERSION)
137 bld.SAMBA_MODULE('ldb_paged_results',
138 'modules/paged_results.c',
139 init_function='ldb_paged_results_init',
140 module_init_name='ldb_init_module',
144 bld.SAMBA_MODULE('ldb_asq',
146 init_function='ldb_asq_init',
147 module_init_name='ldb_init_module',
151 bld.SAMBA_MODULE('ldb_server_sort',
153 init_function='ldb_server_sort_init',
154 module_init_name='ldb_init_module',
158 bld.SAMBA_MODULE('ldb_paged_searches',
159 'modules/paged_searches.c',
160 init_function='ldb_paged_searches_init',
161 module_init_name='ldb_init_module',
165 bld.SAMBA_MODULE('ldb_rdn_name',
166 'modules/rdn_name.c',
167 init_function='ldb_rdn_name_init',
168 module_init_name='ldb_init_module',
172 bld.SAMBA_MODULE('ldb_sample',
173 'tests/sample_module.c',
174 init_function='ldb_sample_init',
175 module_init_name='ldb_init_module',
179 bld.SAMBA_MODULE('ldb_skel',
181 init_function='ldb_skel_init',
182 module_init_name='ldb_init_module',
186 bld.SAMBA_MODULE('ldb_sqlite3',
187 'sqlite3/ldb_sqlite3.c',
188 init_function='ldb_sqlite3_init',
189 module_init_name='ldb_init_module',
194 bld.SAMBA_MODULE('ldb_tdb',
195 bld.SUBDIR('ldb_tdb',
196 '''ldb_tdb.c ldb_pack.c ldb_search.c ldb_index.c
197 ldb_cache.c ldb_tdb_wrap.c'''),
198 init_function='ldb_tdb_init',
199 module_init_name='ldb_init_module',
203 # have a separate subsystem for common/ldb.c, so it can rebuild
204 # for install with a different -DLDB_MODULESDIR=
205 bld.SAMBA_SUBSYSTEM('LIBLDB_MAIN',
209 cflags='-DLDB_MODULESDIR=\"%s\"' % modules_dir)
211 bld.SAMBA_LIBRARY('ldb-cmdline',
212 source='tools/ldbutil.c tools/cmdline.c',
214 private_library=True)
216 LDB_TOOLS='ldbadd ldbsearch ldbdel ldbmodify ldbedit ldbrename'
217 for t in LDB_TOOLS.split():
218 bld.SAMBA_BINARY(t, 'tools/%s.c' % t, deps='ldb-cmdline ldb',
219 manpages='man/%s.1' % t)
221 # ldbtest doesn't get installed
222 bld.SAMBA_BINARY('ldbtest', 'tools/ldbtest.c', deps='ldb-cmdline ldb',
227 '''run ldb testsuite'''
228 import Utils, samba_utils
229 cmd = 'tests/test-tdb.sh'
230 ret = samba_utils.RUN_COMMAND(cmd)
231 print("testsuite returned %d" % ret)
235 '''makes a tarball for distribution'''
238 def reconfigure(ctx):
239 '''reconfigure if config scripts have changed'''
241 samba_utils.reconfigure(ctx)