param: add extra default parameter to get_parametrics_by_service
[Samba.git] / lib / ldb / wscript
blob5621b38e347c7a8bcfdb375b911796300b973ad0
1 #!/usr/bin/env python
3 APPNAME = 'ldb'
4 VERSION = '1.1.17'
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/tdb:lib/tdb 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 # where does the default LIBDIR end up? in conf.env somewhere?
44 conf.CONFIG_PATH('LDB_MODULESDIR', conf.SUBST_ENV_VAR('MODULESDIR') + '/ldb')
46 conf.env.standalone_ldb = conf.IN_LAUNCH_DIR()
48 if not conf.env.standalone_ldb:
49 if conf.CHECK_BUNDLED_SYSTEM_PKG('ldb', minversion=VERSION,
50 onlyif='talloc tdb tevent',
51 implied_deps='replace talloc tdb tevent'):
52 conf.define('USING_SYSTEM_LDB', 1)
53 if conf.CHECK_BUNDLED_SYSTEM_PKG('pyldb-util', minversion=VERSION,
54 onlyif='talloc tdb tevent ldb',
55 implied_deps='replace talloc tdb tevent ldb'):
56 conf.define('USING_SYSTEM_PYLDB_UTIL', 1)
58 if conf.env.standalone_ldb:
59 conf.CHECK_XSLTPROC_MANPAGES()
61 # we need this for the ldap backend
62 if conf.CHECK_FUNCS_IN('ber_flush ldap_open ldap_initialize', 'lber ldap', headers='lber.h ldap.h'):
63 conf.env.ENABLE_LDAP_BACKEND = True
65 # we don't want any libraries or modules to rely on runtime
66 # resolution of symbols
67 if not sys.platform.startswith("openbsd"):
68 conf.ADD_LDFLAGS('-Wl,-no-undefined', testflags=True)
70 conf.DEFINE('HAVE_CONFIG_H', 1, add_to_cflags=True)
72 conf.SAMBA_CONFIG_H()
74 conf.SAMBA_CHECK_UNDEFINED_SYMBOL_FLAGS()
76 def build(bld):
77 bld.RECURSE('lib/tevent')
78 bld.RECURSE('lib/popt')
79 bld.RECURSE('lib/replace')
80 bld.RECURSE('lib/tdb')
82 if bld.env.standalone_ldb:
83 private_library = False
84 else:
85 private_library = True
87 LDB_MAP_SRC = bld.SUBDIR('ldb_map',
88 'ldb_map.c ldb_map_inbound.c ldb_map_outbound.c')
90 COMMON_SRC = bld.SUBDIR('common',
91 '''ldb_modules.c ldb_ldif.c ldb_parse.c ldb_msg.c ldb_utf8.c
92 ldb_debug.c ldb_dn.c ldb_match.c ldb_options.c ldb_pack.c
93 ldb_attributes.c attrib_handlers.c ldb_controls.c qsort.c''')
95 bld.SAMBA_MODULE('ldb_ldap', 'ldb_ldap/ldb_ldap.c',
96 init_function='ldb_ldap_init',
97 module_init_name='ldb_init_module',
98 deps='talloc lber ldap ldb',
99 enabled=bld.env.ENABLE_LDAP_BACKEND,
100 internal_module=False,
101 subsystem='ldb')
103 # we're not currently linking against the ldap libs, but ldb.pc.in
104 # has @LDAP_LIBS@
105 bld.env.LDAP_LIBS = ''
107 if not 'PACKAGE_VERSION' in bld.env:
108 bld.env.PACKAGE_VERSION = VERSION
109 bld.env.PKGCONFIGDIR = '${LIBDIR}/pkgconfig'
111 if not bld.CONFIG_SET('USING_SYSTEM_PYLDB_UTIL'):
112 bld.SAMBA_LIBRARY('pyldb-util',
113 deps='ldb',
114 source='pyldb_util.c',
115 public_headers='pyldb.h',
116 public_headers_install=not private_library,
117 vnum=VERSION,
118 private_library=private_library,
119 pc_files='pyldb-util.pc',
120 pyembed=True,
121 abi_directory='ABI',
122 abi_match='pyldb_*')
124 if not bld.CONFIG_SET('USING_SYSTEM_LDB'):
125 if Options.is_install:
126 modules_dir = bld.EXPAND_VARIABLES('${LDB_MODULESDIR}')
127 else:
128 # when we run from the source directory, we want to use
129 # the current modules, not the installed ones
130 modules_dir = os.path.join(os.getcwd(), 'bin/modules/ldb')
132 abi_match = '!ldb_*module_ops !ldb_*backend_ops ldb_*'
134 bld.SAMBA_LIBRARY('ldb',
135 COMMON_SRC + ' ' + LDB_MAP_SRC,
136 deps='tevent LIBLDB_MAIN replace',
137 includes='include',
138 public_headers='include/ldb.h include/ldb_errors.h '\
139 'include/ldb_module.h include/ldb_handlers.h',
140 public_headers_install=not private_library,
141 pc_files='ldb.pc',
142 vnum=VERSION,
143 private_library=private_library,
144 allow_warnings=True,
145 manpages='man/ldb.3',
146 abi_directory='ABI',
147 abi_match = abi_match)
149 # generate a include/ldb_version.h
150 t = bld.SAMBA_GENERATOR('ldb_version.h',
151 rule='echo "#define LDB_VERSION \\"${LDB_VERSION}\\"" > ${TGT}',
152 target='include/ldb_version.h',
153 public_headers='include/ldb_version.h',
154 public_headers_install=not private_library)
155 t.env.LDB_VERSION = VERSION
156 bld.add_manual_dependency(bld.path.find_or_declare('include/ldb_version.h'), VERSION)
160 bld.SAMBA_PYTHON('pyldb', 'pyldb.c',
161 deps='ldb pyldb-util',
162 realname='ldb.so',
163 cflags='-DPACKAGE_VERSION=\"%s\"' % VERSION)
165 bld.SAMBA_MODULE('ldb_paged_results',
166 'modules/paged_results.c',
167 init_function='ldb_paged_results_init',
168 module_init_name='ldb_init_module',
169 internal_module=False,
170 deps='ldb',
171 subsystem='ldb')
173 bld.SAMBA_MODULE('ldb_asq',
174 'modules/asq.c',
175 init_function='ldb_asq_init',
176 module_init_name='ldb_init_module',
177 internal_module=False,
178 deps='ldb',
179 subsystem='ldb')
181 bld.SAMBA_MODULE('ldb_server_sort',
182 'modules/sort.c',
183 init_function='ldb_server_sort_init',
184 internal_module=False,
185 module_init_name='ldb_init_module',
186 deps='ldb',
187 subsystem='ldb')
189 bld.SAMBA_MODULE('ldb_paged_searches',
190 'modules/paged_searches.c',
191 init_function='ldb_paged_searches_init',
192 internal_module=False,
193 module_init_name='ldb_init_module',
194 deps='ldb',
195 subsystem='ldb')
197 bld.SAMBA_MODULE('ldb_rdn_name',
198 'modules/rdn_name.c',
199 init_function='ldb_rdn_name_init',
200 internal_module=False,
201 module_init_name='ldb_init_module',
202 deps='ldb',
203 subsystem='ldb')
205 bld.SAMBA_MODULE('ldb_sample',
206 'tests/sample_module.c',
207 init_function='ldb_sample_init',
208 internal_module=False,
209 allow_warnings=True,
210 module_init_name='ldb_init_module',
211 deps='ldb',
212 subsystem='ldb')
214 bld.SAMBA_MODULE('ldb_skel',
215 'modules/skel.c',
216 init_function='ldb_skel_init',
217 internal_module=False,
218 module_init_name='ldb_init_module',
219 deps='ldb',
220 subsystem='ldb')
222 bld.SAMBA_MODULE('ldb_sqlite3',
223 'sqlite3/ldb_sqlite3.c',
224 init_function='ldb_sqlite3_init',
225 internal_module=False,
226 module_init_name='ldb_init_module',
227 enabled=False,
228 deps='ldb',
229 subsystem='ldb')
231 bld.SAMBA_MODULE('ldb_tdb',
232 bld.SUBDIR('ldb_tdb',
233 '''ldb_tdb.c ldb_search.c ldb_index.c
234 ldb_cache.c ldb_tdb_wrap.c'''),
235 init_function='ldb_tdb_init',
236 module_init_name='ldb_init_module',
237 internal_module=False,
238 deps='tdb ldb',
239 subsystem='ldb')
241 # have a separate subsystem for common/ldb.c, so it can rebuild
242 # for install with a different -DLDB_MODULESDIR=
243 bld.SAMBA_SUBSYSTEM('LIBLDB_MAIN',
244 'common/ldb.c',
245 deps='tevent tdb',
246 includes='include',
247 allow_warnings=True,
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 # ldbdump doesn't get installed
260 bld.SAMBA_BINARY('ldbdump', 'tools/ldbdump.c', deps='ldb-cmdline ldb',
261 install=False)
263 bld.SAMBA_LIBRARY('ldb-cmdline',
264 source='tools/ldbutil.c tools/cmdline.c',
265 deps='ldb dl popt',
266 private_library=True)
269 def test(ctx):
270 '''run ldb testsuite'''
271 import Utils, samba_utils, shutil
272 test_prefix = "%s/st" % (Utils.g_module.blddir)
273 shutil.rmtree(test_prefix, ignore_errors=True)
274 os.makedirs(test_prefix)
275 os.environ['TEST_DATA_PREFIX'] = test_prefix
276 cmd = 'tests/test-tdb.sh %s' % Utils.g_module.blddir
277 ret = samba_utils.RUN_COMMAND(cmd)
278 print("testsuite returned %d" % ret)
279 # FIXME: Run python testsuite
280 sys.exit(ret)
282 def dist():
283 '''makes a tarball for distribution'''
284 samba_dist.dist()
286 def reconfigure(ctx):
287 '''reconfigure if config scripts have changed'''
288 import samba_utils
289 samba_utils.reconfigure(ctx)