ldb: version 1.1.21
[Samba.git] / lib / ldb / wscript
blob0e8193222778cbb4700bb4cc1e8f0a2f6dcae4b1
1 #!/usr/bin/env python
3 APPNAME = 'ldb'
4 VERSION = '1.1.21'
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, Utils
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
20 third_party/popt:third_party/popt
21 buildtools:buildtools third_party/waf:third_party/waf''')
24 def set_options(opt):
25 opt.BUILTIN_DEFAULT('replace')
26 opt.PRIVATE_EXTENSION_DEFAULT('ldb', noextension='ldb')
27 opt.RECURSE('lib/tdb')
28 opt.RECURSE('lib/tevent')
29 opt.RECURSE('lib/replace')
30 opt.tool_options('python') # options for disabling pyc or pyo compilation
32 def configure(conf):
33 conf.RECURSE('lib/tdb')
34 conf.RECURSE('lib/tevent')
36 if conf.CHECK_FOR_THIRD_PARTY():
37 conf.RECURSE('third_party/popt')
38 else:
39 if not conf.CHECK_POPT():
40 raise Utils.WafError('popt development packages have not been found.\nIf third_party is installed, check that it is in the proper place.')
41 else:
42 conf.define('USING_SYSTEM_POPT', 1)
44 conf.RECURSE('lib/replace')
45 conf.find_program('python', var='PYTHON')
46 conf.find_program('xsltproc', var='XSLTPROC')
47 conf.check_tool('python')
48 conf.check_python_version((2,4,2))
49 conf.SAMBA_CHECK_PYTHON_HEADERS(mandatory=True)
51 # where does the default LIBDIR end up? in conf.env somewhere?
53 conf.CONFIG_PATH('LDB_MODULESDIR', conf.SUBST_ENV_VAR('MODULESDIR') + '/ldb')
55 conf.env.standalone_ldb = conf.IN_LAUNCH_DIR()
57 if not conf.env.standalone_ldb:
58 if conf.CHECK_BUNDLED_SYSTEM_PKG('pyldb-util', minversion=VERSION,
59 onlyif='talloc tdb tevent ldb',
60 implied_deps='replace talloc tdb tevent ldb'):
61 conf.define('USING_SYSTEM_PYLDB_UTIL', 1)
62 if conf.CHECK_BUNDLED_SYSTEM_PKG('ldb', minversion=VERSION,
63 onlyif='talloc tdb tevent',
64 implied_deps='replace talloc tdb tevent'):
65 conf.define('USING_SYSTEM_LDB', 1)
67 if conf.env.standalone_ldb:
68 conf.CHECK_XSLTPROC_MANPAGES()
70 # we need this for the ldap backend
71 if conf.CHECK_FUNCS_IN('ber_flush ldap_open ldap_initialize', 'lber ldap', headers='lber.h ldap.h'):
72 conf.env.ENABLE_LDAP_BACKEND = True
74 # we don't want any libraries or modules to rely on runtime
75 # resolution of symbols
76 if not sys.platform.startswith("openbsd"):
77 conf.ADD_LDFLAGS('-Wl,-no-undefined', testflags=True)
79 conf.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags=True)
81 conf.SAMBA_CONFIG_H()
83 conf.SAMBA_CHECK_UNDEFINED_SYMBOL_FLAGS()
85 def build(bld):
86 bld.RECURSE('lib/tevent')
88 if bld.CHECK_FOR_THIRD_PARTY():
89 bld.RECURSE('third_party/popt')
91 bld.RECURSE('lib/replace')
92 bld.RECURSE('lib/tdb')
94 if bld.env.standalone_ldb:
95 private_library = False
96 else:
97 private_library = True
99 LDB_MAP_SRC = bld.SUBDIR('ldb_map',
100 'ldb_map.c ldb_map_inbound.c ldb_map_outbound.c')
102 COMMON_SRC = bld.SUBDIR('common',
103 '''ldb_modules.c ldb_ldif.c ldb_parse.c ldb_msg.c ldb_utf8.c
104 ldb_debug.c ldb_dn.c ldb_match.c ldb_options.c ldb_pack.c
105 ldb_attributes.c attrib_handlers.c ldb_controls.c qsort.c''')
107 bld.SAMBA_MODULE('ldb_ldap', 'ldb_ldap/ldb_ldap.c',
108 init_function='ldb_ldap_init',
109 module_init_name='ldb_init_module',
110 deps='talloc lber ldap ldb',
111 enabled=bld.env.ENABLE_LDAP_BACKEND,
112 internal_module=False,
113 subsystem='ldb')
115 # we're not currently linking against the ldap libs, but ldb.pc.in
116 # has @LDAP_LIBS@
117 bld.env.LDAP_LIBS = ''
119 if not 'PACKAGE_VERSION' in bld.env:
120 bld.env.PACKAGE_VERSION = VERSION
121 bld.env.PKGCONFIGDIR = '${LIBDIR}/pkgconfig'
123 if not bld.CONFIG_SET('USING_SYSTEM_PYLDB_UTIL'):
124 bld.SAMBA_LIBRARY('pyldb-util',
125 deps='ldb',
126 source='pyldb_util.c',
127 public_headers='pyldb.h',
128 public_headers_install=not private_library,
129 vnum=VERSION,
130 private_library=private_library,
131 pc_files='pyldb-util.pc',
132 pyembed=True,
133 abi_directory='ABI',
134 abi_match='pyldb_*')
136 if not bld.CONFIG_SET('USING_SYSTEM_LDB'):
137 if Options.is_install:
138 modules_dir = bld.EXPAND_VARIABLES('${LDB_MODULESDIR}')
139 else:
140 # when we run from the source directory, we want to use
141 # the current modules, not the installed ones
142 modules_dir = os.path.join(os.getcwd(), 'bin/modules/ldb')
144 abi_match = '!ldb_*module_ops !ldb_*backend_ops ldb_*'
146 bld.SAMBA_LIBRARY('ldb',
147 COMMON_SRC + ' ' + LDB_MAP_SRC,
148 deps='tevent LIBLDB_MAIN replace',
149 includes='include',
150 public_headers='include/ldb.h include/ldb_errors.h '\
151 'include/ldb_module.h include/ldb_handlers.h',
152 public_headers_install=not private_library,
153 pc_files='ldb.pc',
154 vnum=VERSION,
155 private_library=private_library,
156 manpages='man/ldb.3',
157 abi_directory='ABI',
158 abi_match = abi_match)
160 # generate a include/ldb_version.h
161 t = bld.SAMBA_GENERATOR('ldb_version.h',
162 rule='echo "#define LDB_VERSION \\"${LDB_VERSION}\\"" > ${TGT}',
163 dep_vars=['LDB_VERSION'],
164 target='include/ldb_version.h',
165 public_headers='include/ldb_version.h',
166 public_headers_install=not private_library)
167 t.env.LDB_VERSION = VERSION
170 bld.SAMBA_PYTHON('pyldb', 'pyldb.c',
171 deps='ldb pyldb-util',
172 realname='ldb.so',
173 cflags='-DPACKAGE_VERSION=\"%s\"' % VERSION)
175 bld.SAMBA_MODULE('ldb_paged_results',
176 'modules/paged_results.c',
177 init_function='ldb_paged_results_init',
178 module_init_name='ldb_init_module',
179 internal_module=False,
180 deps='ldb',
181 subsystem='ldb')
183 bld.SAMBA_MODULE('ldb_asq',
184 'modules/asq.c',
185 init_function='ldb_asq_init',
186 module_init_name='ldb_init_module',
187 internal_module=False,
188 deps='ldb',
189 subsystem='ldb')
191 bld.SAMBA_MODULE('ldb_server_sort',
192 'modules/sort.c',
193 init_function='ldb_server_sort_init',
194 internal_module=False,
195 module_init_name='ldb_init_module',
196 deps='ldb',
197 subsystem='ldb')
199 bld.SAMBA_MODULE('ldb_paged_searches',
200 'modules/paged_searches.c',
201 init_function='ldb_paged_searches_init',
202 internal_module=False,
203 module_init_name='ldb_init_module',
204 deps='ldb',
205 subsystem='ldb')
207 bld.SAMBA_MODULE('ldb_rdn_name',
208 'modules/rdn_name.c',
209 init_function='ldb_rdn_name_init',
210 internal_module=False,
211 module_init_name='ldb_init_module',
212 deps='ldb',
213 subsystem='ldb')
215 bld.SAMBA_MODULE('ldb_sample',
216 'tests/sample_module.c',
217 init_function='ldb_sample_init',
218 internal_module=False,
219 module_init_name='ldb_init_module',
220 deps='ldb',
221 subsystem='ldb')
223 bld.SAMBA_MODULE('ldb_skel',
224 'modules/skel.c',
225 init_function='ldb_skel_init',
226 internal_module=False,
227 module_init_name='ldb_init_module',
228 deps='ldb',
229 subsystem='ldb')
231 bld.SAMBA_MODULE('ldb_sqlite3',
232 'sqlite3/ldb_sqlite3.c',
233 init_function='ldb_sqlite3_init',
234 internal_module=False,
235 module_init_name='ldb_init_module',
236 enabled=False,
237 deps='ldb',
238 subsystem='ldb')
240 bld.SAMBA_MODULE('ldb_tdb',
241 bld.SUBDIR('ldb_tdb',
242 '''ldb_tdb.c ldb_search.c ldb_index.c
243 ldb_cache.c ldb_tdb_wrap.c'''),
244 init_function='ldb_tdb_init',
245 module_init_name='ldb_init_module',
246 internal_module=False,
247 deps='tdb ldb',
248 subsystem='ldb')
250 # have a separate subsystem for common/ldb.c, so it can rebuild
251 # for install with a different -DLDB_MODULESDIR=
252 bld.SAMBA_SUBSYSTEM('LIBLDB_MAIN',
253 'common/ldb.c',
254 deps='tevent tdb',
255 includes='include',
256 cflags=['-DLDB_MODULESDIR=\"%s\"' % modules_dir])
258 LDB_TOOLS='ldbadd ldbsearch ldbdel ldbmodify ldbedit ldbrename'
259 for t in LDB_TOOLS.split():
260 bld.SAMBA_BINARY(t, 'tools/%s.c' % t, deps='ldb-cmdline ldb',
261 manpages='man/%s.1' % t)
263 # ldbtest doesn't get installed
264 bld.SAMBA_BINARY('ldbtest', 'tools/ldbtest.c', deps='ldb-cmdline ldb',
265 install=False)
267 # ldbdump doesn't get installed
268 bld.SAMBA_BINARY('ldbdump', 'tools/ldbdump.c', deps='ldb-cmdline ldb',
269 install=False)
271 bld.SAMBA_LIBRARY('ldb-cmdline',
272 source='tools/ldbutil.c tools/cmdline.c',
273 deps='ldb dl popt',
274 private_library=True)
277 def test(ctx):
278 '''run ldb testsuite'''
279 import Utils, samba_utils, shutil
280 test_prefix = "%s/st" % (Utils.g_module.blddir)
281 shutil.rmtree(test_prefix, ignore_errors=True)
282 os.makedirs(test_prefix)
283 os.environ['TEST_DATA_PREFIX'] = test_prefix
284 cmd = 'tests/test-tdb.sh %s' % Utils.g_module.blddir
285 ret = samba_utils.RUN_COMMAND(cmd)
286 print("testsuite returned %d" % ret)
287 # FIXME: Run python testsuite
288 sys.exit(ret)
290 def dist():
291 '''makes a tarball for distribution'''
292 samba_dist.dist()
294 def reconfigure(ctx):
295 '''reconfigure if config scripts have changed'''
296 import samba_utils
297 samba_utils.reconfigure(ctx)