s3:net registry import: add option --precheck
[Samba.git] / lib / ldb / wscript
blob94a9682df900f23d5a4db4164f6f5f8139bcd188
1 #!/usr/bin/env python
3 APPNAME = 'ldb'
4 VERSION = '1.1.6'
6 blddir = 'bin'
8 import sys, os
10 # find the buildtools directory
11 srcdir = '.'
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:lib/tdb lib/ccan:lib/ccan lib/tevent:lib/tevent lib/popt:lib/popt
20 buildtools:buildtools''')
23 def set_options(opt):
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
31 def configure(conf):
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 # This make #include <ccan/...> work.
43 conf.ADD_EXTRA_INCLUDES('''#lib''')
45 # where does the default LIBDIR end up? in conf.env somewhere?
47 conf.CONFIG_PATH('LDB_MODULESDIR', conf.SUBST_ENV_VAR('MODULESDIR') + '/ldb')
49 conf.env.standalone_ldb = conf.IN_LAUNCH_DIR()
51 if not conf.env.standalone_ldb:
52 if conf.CHECK_BUNDLED_SYSTEM_PKG('ldb', minversion=VERSION,
53 onlyif='talloc tdb tevent',
54 implied_deps='replace talloc tdb tevent'):
55 conf.define('USING_SYSTEM_LDB', 1)
56 if conf.CHECK_BUNDLED_SYSTEM_PKG('pyldb-util', minversion=VERSION,
57 onlyif='talloc tdb tevent ldb',
58 implied_deps='replace talloc tdb tevent ldb'):
59 conf.define('USING_SYSTEM_PYLDB_UTIL', 1)
61 if conf.env.standalone_ldb:
62 conf.CHECK_XSLTPROC_MANPAGES()
64 # we need this for the ldap backend
65 if conf.CHECK_FUNCS_IN('ber_flush ldap_open ldap_initialize', 'lber ldap', headers='lber.h ldap.h'):
66 conf.env.ENABLE_LDAP_BACKEND = True
68 # we don't want any libraries or modules to rely on runtime
69 # resolution of symbols
70 if sys.platform != "openbsd4" and sys.platform != "openbsd5":
71 conf.ADD_LDFLAGS('-Wl,-no-undefined', testflags=True)
73 conf.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags=True)
75 conf.SAMBA_CONFIG_H()
77 conf.SAMBA_CHECK_UNDEFINED_SYMBOL_FLAGS()
79 def build(bld):
80 bld.RECURSE('lib/tevent')
81 bld.RECURSE('lib/popt')
82 bld.RECURSE('lib/replace')
83 bld.RECURSE('lib/tdb')
85 if bld.env.standalone_ldb:
86 private_library = False
87 else:
88 private_library = True
90 LDB_MAP_SRC = bld.SUBDIR('ldb_map',
91 'ldb_map.c ldb_map_inbound.c ldb_map_outbound.c')
93 COMMON_SRC = bld.SUBDIR('common',
94 '''ldb_modules.c ldb_ldif.c ldb_parse.c ldb_msg.c ldb_utf8.c
95 ldb_debug.c ldb_dn.c ldb_match.c ldb_options.c
96 ldb_attributes.c attrib_handlers.c ldb_controls.c qsort.c''')
98 bld.SAMBA_MODULE('ldb_ldap', 'ldb_ldap/ldb_ldap.c',
99 init_function='ldb_ldap_init',
100 module_init_name='ldb_init_module',
101 deps='talloc lber ldap ldb',
102 enabled=bld.env.ENABLE_LDAP_BACKEND,
103 internal_module=False,
104 subsystem='ldb')
106 # we're not currently linking against the ldap libs, but ldb.pc.in
107 # has @LDAP_LIBS@
108 bld.env.LDAP_LIBS = ''
110 if not 'PACKAGE_VERSION' in bld.env:
111 bld.env.PACKAGE_VERSION = VERSION
112 bld.env.PKGCONFIGDIR = '${LIBDIR}/pkgconfig'
114 if not bld.CONFIG_SET('USING_SYSTEM_PYLDB_UTIL'):
115 bld.SAMBA_LIBRARY('pyldb-util',
116 deps='ldb',
117 source='pyldb_util.c',
118 public_headers='pyldb.h',
119 public_headers_install=not private_library,
120 vnum=VERSION,
121 private_library=private_library,
122 pc_files='pyldb-util.pc',
123 pyembed=True,
124 abi_directory='ABI',
125 abi_match='pyldb_*')
127 if not bld.CONFIG_SET('USING_SYSTEM_LDB'):
128 if Options.is_install:
129 modules_dir = bld.EXPAND_VARIABLES('${LDB_MODULESDIR}')
130 else:
131 # when we run from the source directory, we want to use
132 # the current modules, not the installed ones
133 modules_dir = os.path.join(os.getcwd(), 'bin/modules/ldb')
135 abi_match = '!ldb_*module_ops !ldb_*backend_ops ldb_*'
137 bld.SAMBA_LIBRARY('ldb',
138 COMMON_SRC + ' ' + LDB_MAP_SRC,
139 deps='tevent LIBLDB_MAIN',
140 includes='include',
141 public_headers='include/ldb.h include/ldb_errors.h '\
142 'include/ldb_module.h include/ldb_handlers.h',
143 public_headers_install=not private_library,
144 pc_files='ldb.pc',
145 vnum=VERSION,
146 private_library=private_library,
147 manpages='man/ldb.3',
148 abi_directory='ABI',
149 abi_match = abi_match)
151 # generate a include/ldb_version.h
152 t = bld.SAMBA_GENERATOR('ldb_version.h',
153 rule='echo "#define LDB_VERSION \\"${LDB_VERSION}\\"" > ${TGT}',
154 target='include/ldb_version.h',
155 public_headers='include/ldb_version.h',
156 public_headers_install=not private_library)
157 t.env.LDB_VERSION = VERSION
158 bld.add_manual_dependency(bld.path.find_or_declare('include/ldb_version.h'), VERSION)
162 bld.SAMBA_PYTHON('pyldb', 'pyldb.c',
163 deps='ldb pyldb-util',
164 realname='ldb.so',
165 cflags='-DPACKAGE_VERSION=\"%s\"' % VERSION)
167 bld.SAMBA_MODULE('ldb_paged_results',
168 'modules/paged_results.c',
169 init_function='ldb_paged_results_init',
170 module_init_name='ldb_init_module',
171 internal_module=False,
172 deps='ldb',
173 subsystem='ldb')
175 bld.SAMBA_MODULE('ldb_asq',
176 'modules/asq.c',
177 init_function='ldb_asq_init',
178 module_init_name='ldb_init_module',
179 internal_module=False,
180 deps='ldb',
181 subsystem='ldb')
183 bld.SAMBA_MODULE('ldb_server_sort',
184 'modules/sort.c',
185 init_function='ldb_server_sort_init',
186 internal_module=False,
187 module_init_name='ldb_init_module',
188 deps='ldb',
189 subsystem='ldb')
191 bld.SAMBA_MODULE('ldb_paged_searches',
192 'modules/paged_searches.c',
193 init_function='ldb_paged_searches_init',
194 internal_module=False,
195 module_init_name='ldb_init_module',
196 deps='ldb',
197 subsystem='ldb')
199 bld.SAMBA_MODULE('ldb_rdn_name',
200 'modules/rdn_name.c',
201 init_function='ldb_rdn_name_init',
202 internal_module=False,
203 module_init_name='ldb_init_module',
204 deps='ldb',
205 subsystem='ldb')
207 bld.SAMBA_MODULE('ldb_sample',
208 'tests/sample_module.c',
209 init_function='ldb_sample_init',
210 internal_module=False,
211 module_init_name='ldb_init_module',
212 deps='ldb',
213 subsystem='ldb')
215 bld.SAMBA_MODULE('ldb_skel',
216 'modules/skel.c',
217 init_function='ldb_skel_init',
218 internal_module=False,
219 module_init_name='ldb_init_module',
220 deps='ldb',
221 subsystem='ldb')
223 bld.SAMBA_MODULE('ldb_sqlite3',
224 'sqlite3/ldb_sqlite3.c',
225 init_function='ldb_sqlite3_init',
226 internal_module=False,
227 module_init_name='ldb_init_module',
228 enabled=False,
229 deps='ldb',
230 subsystem='ldb')
232 bld.SAMBA_MODULE('ldb_tdb',
233 bld.SUBDIR('ldb_tdb',
234 '''ldb_tdb.c ldb_pack.c ldb_search.c ldb_index.c
235 ldb_cache.c ldb_tdb_wrap.c'''),
236 init_function='ldb_tdb_init',
237 module_init_name='ldb_init_module',
238 internal_module=False,
239 deps='tdb ldb',
240 subsystem='ldb')
242 # have a separate subsystem for common/ldb.c, so it can rebuild
243 # for install with a different -DLDB_MODULESDIR=
244 bld.SAMBA_SUBSYSTEM('LIBLDB_MAIN',
245 'common/ldb.c',
246 deps='tevent tdb',
247 includes='include',
248 cflags=['-DLDB_MODULESDIR=\"%s\"' % modules_dir])
250 LDB_TOOLS='ldbadd ldbsearch ldbdel ldbmodify ldbedit ldbrename'
251 for t in LDB_TOOLS.split():
252 bld.SAMBA_BINARY(t, 'tools/%s.c' % t, deps='ldb-cmdline ldb',
253 manpages='man/%s.1' % t)
255 # ldbtest doesn't get installed
256 bld.SAMBA_BINARY('ldbtest', 'tools/ldbtest.c', deps='ldb-cmdline ldb',
257 install=False)
259 bld.SAMBA_LIBRARY('ldb-cmdline',
260 source='tools/ldbutil.c tools/cmdline.c',
261 deps='ldb dl popt',
262 private_library=True)
265 def test(ctx):
266 '''run ldb testsuite'''
267 import Utils, samba_utils, shutil
268 test_prefix = "%s/st" % (Utils.g_module.blddir)
269 shutil.rmtree(test_prefix, ignore_errors=True)
270 os.makedirs(test_prefix)
271 os.environ['TEST_DATA_PREFIX'] = test_prefix
272 cmd = 'tests/test-tdb.sh %s' % Utils.g_module.blddir
273 ret = samba_utils.RUN_COMMAND(cmd)
274 print("testsuite returned %d" % ret)
275 # FIXME: Run python testsuite
276 sys.exit(ret)
278 def dist():
279 '''makes a tarball for distribution'''
280 samba_dist.dist()
282 def reconfigure(ctx):
283 '''reconfigure if config scripts have changed'''
284 import samba_utils
285 samba_utils.reconfigure(ctx)